Skip to content

Commit fa03246

Browse files
committed
REVIEWED: Code formatting to follow raylib conventions
1 parent 98662b6 commit fa03246

File tree

1 file changed

+50
-54
lines changed

1 file changed

+50
-54
lines changed

src/platforms/rcore_desktop_rgfw.c

Lines changed: 50 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -47,56 +47,55 @@
4747
**********************************************************************************************/
4848

4949
#ifdef GRAPHICS_API_OPENGL_ES2
50-
#define RGFW_OPENGL_ES2
50+
#define RGFW_OPENGL_ES2
5151
#endif
5252

5353
void ShowCursor(void);
5454
void CloseWindow(void);
5555

56-
#ifdef __linux__
57-
#define _INPUT_EVENT_CODES_H
56+
#if defined(__linux__)
57+
#define _INPUT_EVENT_CODES_H
5858
#endif
5959

6060
#if defined(__unix__) || defined(__linux__)
61-
#define _XTYPEDEF_FONT
61+
#define _XTYPEDEF_FONT
6262
#endif
6363

6464
#define RGFW_IMPLEMENTATION
6565

6666
#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_
7272
#endif
7373

74-
#ifdef __APPLE__
75-
#define Point NSPOINT
76-
#define Size NSSIZE
74+
#if defined(__APPLE__)
75+
#define Point NSPOINT
76+
#define Size NSSIZE
7777
#endif
7878

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);
8181
#endif
8282

8383
#include "../external/RGFW.h"
8484

85-
86-
8785
#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
9290
#endif
9391

94-
#ifdef __APPLE__
95-
#undef Point
96-
#undef Size
92+
#if defined(__APPLE__)
93+
#undef Point
94+
#undef Size
9795
#endif
9896

9997
#include <stdbool.h>
98+
#include <string.h> // Required for: strcmp()
10099

101100
//----------------------------------------------------------------------------------
102101
// Types and Structures Definition
@@ -110,7 +109,9 @@ typedef struct {
110109
//----------------------------------------------------------------------------------
111110
extern CoreData CORE; // Global CORE state context
112111

113-
static PlatformData platform = { NULL }; // Platform specific
112+
static PlatformData platform = { NULL }; // Platform specific
113+
114+
static bool RGFW_disableCursor = false;
114115

115116
static const unsigned short keyMappingRGFW[] = {
116117
[RGFW_KEY_NULL] = KEY_NULL,
@@ -250,7 +251,8 @@ void ToggleFullscreen(void)
250251
// Toggle borderless windowed mode
251252
void ToggleBorderlessWindowed(void)
252253
{
253-
if (platform.window != NULL) {
254+
if (platform.window != NULL)
255+
{
254256
RGFW_window_setBorder(platform.window, CORE.Window.flags & FLAG_WINDOW_UNDECORATED);
255257
}
256258
}
@@ -569,8 +571,7 @@ int GetCurrentMonitor(void)
569571

570572
for (int i = 0; i < 6; i++)
571573
{
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;
574575
}
575576

576577
return 0;
@@ -672,8 +673,6 @@ void HideCursor(void)
672673
CORE.Input.Mouse.cursorHidden = true;
673674
}
674675

675-
bool RGFW_disableCursor = false;
676-
677676
// Enables cursor (unlock cursor)
678677
void EnableCursor(void)
679678
{
@@ -690,6 +689,7 @@ void EnableCursor(void)
690689
void DisableCursor(void)
691690
{
692691
RGFW_disableCursor = true;
692+
693693
// Set cursor position in the middle
694694
SetMousePosition(CORE.Window.screen.width/2, CORE.Window.screen.height/2);
695695

@@ -727,7 +727,7 @@ void OpenURL(const char *url)
727727
if (strchr(url, '\'') != NULL) TRACELOG(LOG_WARNING, "SYSTEM: Provided URL could be potentially malicious, avoid [\'] character");
728728
else
729729
{
730-
// TODO:
730+
// TODO: Open URL implementation
731731
}
732732
}
733733

@@ -758,16 +758,12 @@ void SetMouseCursor(int cursor)
758758

759759
static KeyboardKey ConvertScancodeToKey(u32 keycode);
760760

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];
769765

770-
static const char* map[] = {
766+
static const char *map[] = {
771767
"asciitilde", "`",
772768
"grave", "~",
773769
"exclam", "!",
@@ -806,10 +802,10 @@ char RSGL_keystrToChar(const char* str) {
806802
"enter", "\n",
807803
};
808804

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+
}
813809

814810
return '\0';
815811
}
@@ -866,25 +862,25 @@ void PollInputEvents(void)
866862
}
867863

868864
// 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];
871866

872867
// Poll input events for current platform
873868
//-----------------------------------------------------------------------------
874869
CORE.Window.resizedLastFrame = false;
875870

871+
#define RGFW_HOLD_MOUSE (1L<<2)
876872

877-
#define RGFW_HOLD_MOUSE (1L<<2)
878-
#if defined(RGFW_X11) //|| defined(RGFW_MACOS)
873+
#if defined(RGFW_X11) //|| defined(RGFW_MACOS)
879874
if (platform.window->src.winArgs & RGFW_HOLD_MOUSE)
880875
{
881876
CORE.Input.Mouse.previousPosition = (Vector2){ 0.0f, 0.0f };
882877
CORE.Input.Mouse.currentPosition = (Vector2){ 0.0f, 0.0f };
883878
}
884-
else {
879+
else
880+
{
885881
CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition;
886882
}
887-
#endif
883+
#endif
888884

889885
while (RGFW_window_checkEvent(platform.window))
890886
{
@@ -901,7 +897,7 @@ void PollInputEvents(void)
901897
}
902898
}
903899

904-
RGFW_Event* event = &platform.window->event;
900+
RGFW_Event *event = &platform.window->event;
905901

906902
// All input events can be processed after polling
907903
switch (event->type)
@@ -1163,6 +1159,7 @@ void PollInputEvents(void)
11631159
int button = (axis == GAMEPAD_AXIS_LEFT_TRIGGER)? GAMEPAD_BUTTON_LEFT_TRIGGER_2 : GAMEPAD_BUTTON_RIGHT_TRIGGER_2;
11641160
int pressed = (value > 0.1f);
11651161
CORE.Input.Gamepad.currentButtonState[event->joystick][button] = pressed;
1162+
11661163
if (pressed) CORE.Input.Gamepad.lastButtonPressed = button;
11671164
else if (CORE.Input.Gamepad.lastButtonPressed == button) CORE.Input.Gamepad.lastButtonPressed = 0;
11681165
}
@@ -1254,8 +1251,7 @@ int InitPlatform(void)
12541251

12551252
platform.window = RGFW_createWindow(CORE.Window.title, RGFW_RECT(0, 0, CORE.Window.screen.width, CORE.Window.screen.height), flags);
12561253

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);
12591255

12601256
RGFW_window_makeCurrent(platform.window);
12611257

@@ -1320,12 +1316,12 @@ int InitPlatform(void)
13201316
CORE.Storage.basePath = GetWorkingDirectory();
13211317
//----------------------------------------------------------------------------
13221318

1323-
#ifdef RGFW_X11
1319+
#ifdef RGFW_X11
13241320
for (int i = 0; (i < 4) && (i < MAX_GAMEPADS); i++)
13251321
{
13261322
RGFW_registerJoystick(platform.window, i);
13271323
}
1328-
#endif
1324+
#endif
13291325

13301326
TRACELOG(LOG_INFO, "PLATFORM: CUSTOM: Initialized successfully");
13311327

0 commit comments

Comments
 (0)