47
47
**********************************************************************************************/
48
48
49
49
#ifdef GRAPHICS_API_OPENGL_ES2
50
- #define RGFW_OPENGL_ES2
50
+ #define RGFW_OPENGL_ES2
51
51
#endif
52
52
53
53
void ShowCursor (void );
54
54
void CloseWindow (void );
55
55
56
- #ifdef __linux__
57
- #define _INPUT_EVENT_CODES_H
56
+ #if defined( __linux__ )
57
+ #define _INPUT_EVENT_CODES_H
58
58
#endif
59
59
60
60
#if defined(__unix__ ) || defined(__linux__ )
61
- #define _XTYPEDEF_FONT
61
+ #define _XTYPEDEF_FONT
62
62
#endif
63
63
64
64
#define RGFW_IMPLEMENTATION
65
65
66
66
#if defined(__WIN32 ) || defined(__WIN64 )
67
- #define WIN32_LEAN_AND_MEAN
68
- #define Rectangle rectangle_win32
69
- #define CloseWindow CloseWindow_win32
70
- #define ShowCursor __imp_ShowCursor
71
- #define _APISETSTRING_
67
+ #define WIN32_LEAN_AND_MEAN
68
+ #define Rectangle rectangle_win32
69
+ #define CloseWindow CloseWindow_win32
70
+ #define ShowCursor __imp_ShowCursor
71
+ #define _APISETSTRING_
72
72
#endif
73
73
74
- #ifdef __APPLE__
75
- #define Point NSPOINT
76
- #define Size NSSIZE
74
+ #if defined( __APPLE__ )
75
+ #define Point NSPOINT
76
+ #define Size NSSIZE
77
77
#endif
78
78
79
- #ifdef _MSC_VER
80
- __declspec(dllimport ) int __stdcall MultiByteToWideChar (unsigned int CodePage , unsigned long dwFlags , const char * lpMultiByteStr , int cbMultiByte , wchar_t * lpWideCharStr , int cchWideChar );
79
+ #if defined( _MSC_VER )
80
+ __declspec(dllimport ) int __stdcall MultiByteToWideChar (unsigned int CodePage , unsigned long dwFlags , const char * lpMultiByteStr , int cbMultiByte , wchar_t * lpWideCharStr , int cchWideChar );
81
81
#endif
82
82
83
83
#include "../external/RGFW.h"
84
84
85
-
86
-
87
85
#if defined(__WIN32 ) || defined(__WIN64 )
88
- #undef DrawText
89
- #undef ShowCursor
90
- #undef CloseWindow
91
- #undef Rectangle
86
+ #undef DrawText
87
+ #undef ShowCursor
88
+ #undef CloseWindow
89
+ #undef Rectangle
92
90
#endif
93
91
94
- #ifdef __APPLE__
95
- #undef Point
96
- #undef Size
92
+ #if defined( __APPLE__ )
93
+ #undef Point
94
+ #undef Size
97
95
#endif
98
96
99
97
#include <stdbool.h>
98
+ #include <string.h> // Required for: strcmp()
100
99
101
100
//----------------------------------------------------------------------------------
102
101
// Types and Structures Definition
@@ -110,7 +109,9 @@ typedef struct {
110
109
//----------------------------------------------------------------------------------
111
110
extern CoreData CORE ; // Global CORE state context
112
111
113
- static PlatformData platform = { NULL }; // Platform specific
112
+ static PlatformData platform = { NULL }; // Platform specific
113
+
114
+ static bool RGFW_disableCursor = false;
114
115
115
116
static const unsigned short keyMappingRGFW [] = {
116
117
[RGFW_KEY_NULL ] = KEY_NULL ,
@@ -250,7 +251,8 @@ void ToggleFullscreen(void)
250
251
// Toggle borderless windowed mode
251
252
void ToggleBorderlessWindowed (void )
252
253
{
253
- if (platform .window != NULL ) {
254
+ if (platform .window != NULL )
255
+ {
254
256
RGFW_window_setBorder (platform .window , CORE .Window .flags & FLAG_WINDOW_UNDECORATED );
255
257
}
256
258
}
@@ -569,8 +571,7 @@ int GetCurrentMonitor(void)
569
571
570
572
for (int i = 0 ; i < 6 ; i ++ )
571
573
{
572
- if ((mons [i ].rect .x == mon .rect .x ) && (mons [i ].rect .y == mon .rect .y ))
573
- return i ;
574
+ if ((mons [i ].rect .x == mon .rect .x ) && (mons [i ].rect .y == mon .rect .y )) return i ;
574
575
}
575
576
576
577
return 0 ;
@@ -672,8 +673,6 @@ void HideCursor(void)
672
673
CORE .Input .Mouse .cursorHidden = true;
673
674
}
674
675
675
- bool RGFW_disableCursor = false;
676
-
677
676
// Enables cursor (unlock cursor)
678
677
void EnableCursor (void )
679
678
{
@@ -690,6 +689,7 @@ void EnableCursor(void)
690
689
void DisableCursor (void )
691
690
{
692
691
RGFW_disableCursor = true;
692
+
693
693
// Set cursor position in the middle
694
694
SetMousePosition (CORE .Window .screen .width /2 , CORE .Window .screen .height /2 );
695
695
@@ -727,7 +727,7 @@ void OpenURL(const char *url)
727
727
if (strchr (url , '\'' ) != NULL ) TRACELOG (LOG_WARNING , "SYSTEM: Provided URL could be potentially malicious, avoid [\'] character" );
728
728
else
729
729
{
730
- // TODO:
730
+ // TODO: Open URL implementation
731
731
}
732
732
}
733
733
@@ -758,16 +758,12 @@ void SetMouseCursor(int cursor)
758
758
759
759
static KeyboardKey ConvertScancodeToKey (u32 keycode );
760
760
761
- /*
762
- TODO, try to make this better (RSGL uses this method too :I )
763
- sourced from RSGL obviously -> ColleagueRiley
764
- */
765
- char RSGL_keystrToChar (const char * str ) {
766
- if (str [1 ] == 0 )
767
- return str [0 ];
768
-
761
+ // TODO: Review function to avoid duplicate with RSGL
762
+ char RSGL_keystrToChar (const char * str )
763
+ {
764
+ if (str [1 ] == 0 ) return str [0 ];
769
765
770
- static const char * map [] = {
766
+ static const char * map [] = {
771
767
"asciitilde" , "`" ,
772
768
"grave" , "~" ,
773
769
"exclam" , "!" ,
@@ -806,10 +802,10 @@ char RSGL_keystrToChar(const char* str) {
806
802
"enter" , "\n" ,
807
803
};
808
804
809
- u8 i = 0 ;
810
- for ( i = 0 ; i < ( sizeof ( map ) / sizeof ( char * )); i += 2 )
811
- if (strcmp (map [i ], str ) == 0 )
812
- return * map [ i + 1 ];
805
+ for ( unsigned char i = 0 ; i < ( sizeof ( map )/ sizeof ( char * )); i += 2 )
806
+ {
807
+ if (strcmp (map [i ], str ) == 0 ) return * map [ i + 1 ];
808
+ }
813
809
814
810
return '\0' ;
815
811
}
@@ -866,25 +862,25 @@ void PollInputEvents(void)
866
862
}
867
863
868
864
// Register previous mouse states
869
- for (int i = 0 ; i < MAX_MOUSE_BUTTONS ; i ++ )
870
- CORE .Input .Mouse .previousButtonState [i ] = CORE .Input .Mouse .currentButtonState [i ];
865
+ for (int i = 0 ; i < MAX_MOUSE_BUTTONS ; i ++ ) CORE .Input .Mouse .previousButtonState [i ] = CORE .Input .Mouse .currentButtonState [i ];
871
866
872
867
// Poll input events for current platform
873
868
//-----------------------------------------------------------------------------
874
869
CORE .Window .resizedLastFrame = false;
875
870
871
+ #define RGFW_HOLD_MOUSE (1L<<2)
876
872
877
- #define RGFW_HOLD_MOUSE (1L<<2)
878
- #if defined(RGFW_X11 ) //|| defined(RGFW_MACOS)
873
+ #if defined(RGFW_X11 ) //|| defined(RGFW_MACOS)
879
874
if (platform .window -> src .winArgs & RGFW_HOLD_MOUSE )
880
875
{
881
876
CORE .Input .Mouse .previousPosition = (Vector2 ){ 0.0f , 0.0f };
882
877
CORE .Input .Mouse .currentPosition = (Vector2 ){ 0.0f , 0.0f };
883
878
}
884
- else {
879
+ else
880
+ {
885
881
CORE .Input .Mouse .previousPosition = CORE .Input .Mouse .currentPosition ;
886
882
}
887
- #endif
883
+ #endif
888
884
889
885
while (RGFW_window_checkEvent (platform .window ))
890
886
{
@@ -901,7 +897,7 @@ void PollInputEvents(void)
901
897
}
902
898
}
903
899
904
- RGFW_Event * event = & platform .window -> event ;
900
+ RGFW_Event * event = & platform .window -> event ;
905
901
906
902
// All input events can be processed after polling
907
903
switch (event -> type )
@@ -1163,6 +1159,7 @@ void PollInputEvents(void)
1163
1159
int button = (axis == GAMEPAD_AXIS_LEFT_TRIGGER )? GAMEPAD_BUTTON_LEFT_TRIGGER_2 : GAMEPAD_BUTTON_RIGHT_TRIGGER_2 ;
1164
1160
int pressed = (value > 0.1f );
1165
1161
CORE .Input .Gamepad .currentButtonState [event -> joystick ][button ] = pressed ;
1162
+
1166
1163
if (pressed ) CORE .Input .Gamepad .lastButtonPressed = button ;
1167
1164
else if (CORE .Input .Gamepad .lastButtonPressed == button ) CORE .Input .Gamepad .lastButtonPressed = 0 ;
1168
1165
}
@@ -1254,8 +1251,7 @@ int InitPlatform(void)
1254
1251
1255
1252
platform .window = RGFW_createWindow (CORE .Window .title , RGFW_RECT (0 , 0 , CORE .Window .screen .width , CORE .Window .screen .height ), flags );
1256
1253
1257
- if (CORE .Window .flags & FLAG_VSYNC_HINT )
1258
- RGFW_window_swapInterval (platform .window , 1 );
1254
+ if (CORE .Window .flags & FLAG_VSYNC_HINT ) RGFW_window_swapInterval (platform .window , 1 );
1259
1255
1260
1256
RGFW_window_makeCurrent (platform .window );
1261
1257
@@ -1320,12 +1316,12 @@ int InitPlatform(void)
1320
1316
CORE .Storage .basePath = GetWorkingDirectory ();
1321
1317
//----------------------------------------------------------------------------
1322
1318
1323
- #ifdef RGFW_X11
1319
+ #ifdef RGFW_X11
1324
1320
for (int i = 0 ; (i < 4 ) && (i < MAX_GAMEPADS ); i ++ )
1325
1321
{
1326
1322
RGFW_registerJoystick (platform .window , i );
1327
1323
}
1328
- #endif
1324
+ #endif
1329
1325
1330
1326
TRACELOG (LOG_INFO , "PLATFORM: CUSTOM: Initialized successfully" );
1331
1327
0 commit comments