Code gardening

This commit is contained in:
Ray 2026-08-04 21:16:08 +02:00
commit 7711de62fb
14 changed files with 40 additions and 45 deletions

2
src/external/rlsw.h vendored
View file

@ -774,7 +774,7 @@ SWAPI void swGetFramebufferAttachmentParameteriv(SWattachment attachment, SWatta
// Simple log system to avoid printf() calls if required // Simple log system to avoid printf() calls if required
// NOTE: Avoiding those calls, also avoids const strings memory usage // NOTE: Avoiding those calls, also avoids const strings memory usage
#define RLSW_SUPPORT_LOG_INFO #define RLSW_SUPPORT_LOG_INFO
#if defined(RLSW_SUPPORT_LOG_INFO) //&& defined(_DEBUG) // WARNING: LOG() output required for this tool #if defined(RLSW_SUPPORT_LOG_INFO)
#include <stdio.h> #include <stdio.h>
#define SW_LOG(...) printf(__VA_ARGS__) #define SW_LOG(...) printf(__VA_ARGS__)
#else #else

View file

@ -1613,11 +1613,11 @@ void PollInputEvents(void)
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// using RGFW callbacks instead of polling // Using RGFW callbacks instead of polling
RGFW_pollEvents(); RGFW_pollEvents();
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
mg_event gamepad_event; mg_event gamepad_event = { 0 };
while (mg_gamepads_check_event(&platform.minigamepad, &gamepad_event)) while (mg_gamepads_check_event(&platform.minigamepad, &gamepad_event))
{ {
int gamepadIndex = gamepad_event.gamepad->index; int gamepadIndex = gamepad_event.gamepad->index;

View file

@ -1652,7 +1652,7 @@ void PollInputEvents(void)
} break; } break;
#endif #endif
// Keyboard events // Check keyboard events
case SDL_KEYDOWN: case SDL_KEYDOWN:
{ {
#if defined(USING_VERSION_SDL3) #if defined(USING_VERSION_SDL3)
@ -1680,10 +1680,8 @@ void PollInputEvents(void)
if (CORE.Input.Keyboard.currentKeyState[CORE.Input.Keyboard.exitKey]) CORE.Window.shouldClose = true; if (CORE.Input.Keyboard.currentKeyState[CORE.Input.Keyboard.exitKey]) CORE.Window.shouldClose = true;
} break; } break;
case SDL_KEYUP: case SDL_KEYUP:
{ {
#if defined(USING_VERSION_SDL3) #if defined(USING_VERSION_SDL3)
KeyboardKey key = ConvertScancodeToKey(event.key.scancode); KeyboardKey key = ConvertScancodeToKey(event.key.scancode);
#else #else
@ -1691,7 +1689,6 @@ void PollInputEvents(void)
#endif #endif
if (key != KEY_NULL) CORE.Input.Keyboard.currentKeyState[key] = 0; if (key != KEY_NULL) CORE.Input.Keyboard.currentKeyState[key] = 0;
} break; } break;
case SDL_TEXTINPUT: case SDL_TEXTINPUT:
{ {
// NOTE: event.text.text data comes an UTF-8 text sequence but register codepoints (int) // NOTE: event.text.text data comes an UTF-8 text sequence but register codepoints (int)
@ -1700,7 +1697,6 @@ void PollInputEvents(void)
if (CORE.Input.Keyboard.charPressedQueueCount < MAX_CHAR_PRESSED_QUEUE) if (CORE.Input.Keyboard.charPressedQueueCount < MAX_CHAR_PRESSED_QUEUE)
{ {
// Add character (codepoint) to the queue // Add character (codepoint) to the queue
#if defined(USING_VERSION_SDL3) #if defined(USING_VERSION_SDL3)
size_t textLen = strlen(event.text.text); size_t textLen = strlen(event.text.text);
unsigned int codepoint = (unsigned int)SDL_StepUTF8(&event.text.text, &textLen); unsigned int codepoint = (unsigned int)SDL_StepUTF8(&event.text.text, &textLen);
@ -1769,6 +1765,7 @@ void PollInputEvents(void)
touchAction = 2; touchAction = 2;
} break; } break;
// Check Touch events
case SDL_FINGERDOWN: case SDL_FINGERDOWN:
{ {
UpdateTouchPointsSDL(event.tfinger); UpdateTouchPointsSDL(event.tfinger);
@ -1788,24 +1785,21 @@ void PollInputEvents(void)
realTouch = true; realTouch = true;
} break; } break;
// Check gamepad events // Check Gamepad events
case SDL_JOYDEVICEADDED: case SDL_JOYDEVICEADDED:
{ {
int jid = event.jdevice.which; // Joystick device index int jid = event.jdevice.which; // Joystick device index
// check if already added at InitPlatform // Check if already added at InitPlatform
for (int i = 0; i < MAX_GAMEPADS; i++) for (int i = 0; i < MAX_GAMEPADS; i++)
{ {
if (jid == platform.gamepadId[i]) if (jid == platform.gamepadId[i]) return;
{
return;
}
} }
int nextAvailableSlot = 0; int nextAvailableSlot = 0;
while (nextAvailableSlot < MAX_GAMEPADS && CORE.Input.Gamepad.ready[nextAvailableSlot]) while (nextAvailableSlot < MAX_GAMEPADS && CORE.Input.Gamepad.ready[nextAvailableSlot])
{ {
++nextAvailableSlot; nextAvailableSlot++;
} }
if ((nextAvailableSlot < MAX_GAMEPADS) && !CORE.Input.Gamepad.ready[nextAvailableSlot]) if ((nextAvailableSlot < MAX_GAMEPADS) && !CORE.Input.Gamepad.ready[nextAvailableSlot])

View file

@ -1118,7 +1118,7 @@ void PollInputEvents(void)
// NOTE: For DRM touchscreen devices, this mapping is disabled to avoid false touch detection // NOTE: For DRM touchscreen devices, this mapping is disabled to avoid false touch detection
// CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition; // CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition;
// Handle the mouse/touch/gestures events: // Handle the mouse/touch/gestures events
PollMouseEvents(); PollMouseEvents();
} }
@ -1938,6 +1938,7 @@ static void InitEvdevInput(void)
(strncmp("mouse", entity->d_name, strlen("mouse")) == 0)) // Search for devices named "mouse*" (strncmp("mouse", entity->d_name, strlen("mouse")) == 0)) // Search for devices named "mouse*"
{ {
snprintf(path, MAX_FILEPATH_LENGTH, "%s%s", DEFAULT_EVDEV_PATH, entity->d_name); snprintf(path, MAX_FILEPATH_LENGTH, "%s%s", DEFAULT_EVDEV_PATH, entity->d_name);
ConfigureEvdevDevice(path); // Configure the device if appropriate ConfigureEvdevDevice(path); // Configure the device if appropriate
} }
} }

View file

@ -477,7 +477,7 @@ void PollInputEvents(void)
if (kbhit()) if (kbhit())
{ {
int key = getch(); int key = getch();
if (key == 27) CORE.Window.shouldClose = true; // KEY_SCAPE if (key == 27) CORE.Window.shouldClose = true; // KEY_ESCAPE
} }
} }

View file

@ -1128,7 +1128,7 @@ void PollInputEvents(void)
// Register previous gamepad button states // Register previous gamepad button states
for (int k = 0; k < MAX_GAMEPAD_BUTTONS; k++) CORE.Input.Gamepad.previousButtonState[i][k] = CORE.Input.Gamepad.currentButtonState[i][k]; for (int k = 0; k < MAX_GAMEPAD_BUTTONS; k++) CORE.Input.Gamepad.previousButtonState[i][k] = CORE.Input.Gamepad.currentButtonState[i][k];
EmscriptenGamepadEvent gamepadState; EmscriptenGamepadEvent gamepadState = { 0 };
int result = emscripten_get_gamepad_status(i, &gamepadState); int result = emscripten_get_gamepad_status(i, &gamepadState);

View file

@ -353,7 +353,7 @@ void ProcessGestureEvent(GestureEvent event)
GESTURES.Drag.vector.y = GESTURES.Touch.moveDownPositionA.y - GESTURES.Touch.downDragPosition.y; GESTURES.Drag.vector.y = GESTURES.Touch.moveDownPositionA.y - GESTURES.Touch.downDragPosition.y;
} }
} }
else if (GESTURES.Touch.pointCount == 2) // Two touch points else if (GESTURES.Touch.pointCount == 2)
{ {
if (event.touchAction == TOUCH_ACTION_DOWN) if (event.touchAction == TOUCH_ACTION_DOWN)
{ {