4 Commits

Author SHA1 Message Date
Ray
de7fc12be0 REVIEWED: IsGamepadButton*() for consistency with key and mouse equivalents 2026-01-28 19:35:54 +01:00
Ray
8a2da96eed Reviewed formating and spacing 2026-01-28 19:34:55 +01:00
af37fa2a96 Refactoring based on Coding Style Conventions (#5517)
Co-authored-by: maiconpintoabreu <maicon@thinkpad02.exads.com>
2026-01-28 19:27:03 +01:00
d0a6892989 [rcore] IsMouseButton*(), random key codes return unexpected results (#5516)
* update

* update

* stuff

* update

* move headerfile to root

* delete .h

* update ignore

* fix IsMouseButtonDown\Pressed\Released\Up will get randomly returned to true when the button code is outside the range of mouse button

* remove unessary macro

* refactor IsMouseButton*() early returns
2026-01-28 19:26:07 +01:00
6 changed files with 59 additions and 38 deletions

View File

@ -100,7 +100,7 @@
#include <unistd.h> // Required for: usleep()
//#define GLFW_EXPOSE_NATIVE_COCOA // WARNING: Fails due to type redefinition
void *glfwGetCocoaWindow(GLFWwindow* handle);
void *glfwGetCocoaWindow(GLFWwindow *handle);
#include "GLFW/glfw3native.h" // Required for: glfwGetCocoaWindow()
#endif
@ -224,8 +224,8 @@ void ToggleFullscreen(void)
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI))
{
Vector2 scaleDpi = GetWindowScaleDPI();
CORE.Window.screen.width = (unsigned int)(CORE.Window.screen.width * scaleDpi.x);
CORE.Window.screen.height = (unsigned int)(CORE.Window.screen.height * scaleDpi.y);
CORE.Window.screen.width = (unsigned int)(CORE.Window.screen.width*scaleDpi.x);
CORE.Window.screen.height = (unsigned int)(CORE.Window.screen.height*scaleDpi.y);
}
#endif
@ -303,8 +303,8 @@ void ToggleBorderlessWindowed(void)
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI))
{
Vector2 scaleDpi = GetWindowScaleDPI();
CORE.Window.screen.width = (unsigned int)(CORE.Window.screen.width * scaleDpi.x);
CORE.Window.screen.height = (unsigned int)(CORE.Window.screen.height * scaleDpi.y);
CORE.Window.screen.width = (unsigned int)(CORE.Window.screen.width*scaleDpi.x);
CORE.Window.screen.height = (unsigned int)(CORE.Window.screen.height*scaleDpi.y);
}
#endif

View File

@ -323,7 +323,7 @@ Uint8 SDL_EventState(Uint32 type, int state)
return stateBefore;
}
void SDL_GetCurrentDisplayMode_Adapter(SDL_DisplayID displayID, SDL_DisplayMode* mode)
void SDL_GetCurrentDisplayMode_Adapter(SDL_DisplayID displayID, SDL_DisplayMode *mode)
{
const SDL_DisplayMode *currentMode = SDL_GetCurrentDisplayMode(displayID);

View File

@ -1936,7 +1936,7 @@ void TraceLog(int logType, const char *text, ...)
// Set custom trace log
void SetTraceLogCallback(TraceLogCallback callback)
{
{
traceLog = callback;
}
@ -2771,7 +2771,7 @@ FilePathList LoadDirectoryFilesEx(const char *basePath, const char *filter, bool
{
// SCAN 1: Count files
unsigned int fileCounter = GetDirectoryFileCountEx(basePath, filter, scanSubdirs);
// Memory allocation for dirFileCount
files.paths = (char **)RL_CALLOC(fileCounter, sizeof(char *));
for (unsigned int i = 0; i < fileCounter; i++) files.paths[i] = (char *)RL_CALLOC(MAX_FILEPATH_LENGTH, sizeof(char));
@ -3670,13 +3670,13 @@ bool ExportAutomationEventList(AutomationEventList list, const char *fileName)
int binarySize = 4 + sizeof(int) + sizeof(AutomationEvent)*list.count;
unsigned char *binBuffer = (unsigned char *)RL_CALLOC(binarySize, 1);
int offset = 0;
memcpy(binBuffer + offset, "rAE ", 4);
memcpy(binBuffer + offset, "rAE ", 4);
offset += 4;
memcpy(binBuffer + offset, &list.count, sizeof(int));
memcpy(binBuffer + offset, &list.count, sizeof(int));
offset += sizeof(int);
memcpy(binBuffer + offset, list.events, sizeof(AutomationEvent)*list.count);
offset += sizeof(AutomationEvent)*list.count;
success = SaveFileData(TextFormat("%s.rae",fileName), binBuffer, binarySize);
RL_FREE(binBuffer);
}
@ -3831,7 +3831,6 @@ void PlayAutomationEvent(AutomationEvent event)
// Check if a key has been pressed once
bool IsKeyPressed(int key)
{
bool pressed = false;
if ((key > 0) && (key < MAX_KEYBOARD_KEYS))
@ -3973,8 +3972,10 @@ bool IsGamepadButtonPressed(int gamepad, int button)
{
bool pressed = false;
if ((gamepad < MAX_GAMEPADS) && CORE.Input.Gamepad.ready[gamepad] && (button < MAX_GAMEPAD_BUTTONS) &&
(CORE.Input.Gamepad.previousButtonState[gamepad][button] == 0) && (CORE.Input.Gamepad.currentButtonState[gamepad][button] == 1)) pressed = true;
if ((gamepad < MAX_GAMEPADS) && CORE.Input.Gamepad.ready[gamepad] && (button < MAX_GAMEPAD_BUTTONS))
{
if ((CORE.Input.Gamepad.previousButtonState[gamepad][button] == 0) && (CORE.Input.Gamepad.currentButtonState[gamepad][button] == 1)) pressed = true;
}
return pressed;
}
@ -3984,8 +3985,10 @@ bool IsGamepadButtonDown(int gamepad, int button)
{
bool down = false;
if ((gamepad < MAX_GAMEPADS) && CORE.Input.Gamepad.ready[gamepad] && (button < MAX_GAMEPAD_BUTTONS) &&
(CORE.Input.Gamepad.currentButtonState[gamepad][button] == 1)) down = true;
if ((gamepad < MAX_GAMEPADS) && CORE.Input.Gamepad.ready[gamepad] && (button < MAX_GAMEPAD_BUTTONS))
{
if (CORE.Input.Gamepad.currentButtonState[gamepad][button] == 1) down = true;
}
return down;
}
@ -3995,8 +3998,10 @@ bool IsGamepadButtonReleased(int gamepad, int button)
{
bool released = false;
if ((gamepad < MAX_GAMEPADS) && CORE.Input.Gamepad.ready[gamepad] && (button < MAX_GAMEPAD_BUTTONS) &&
(CORE.Input.Gamepad.previousButtonState[gamepad][button] == 1) && (CORE.Input.Gamepad.currentButtonState[gamepad][button] == 0)) released = true;
if ((gamepad < MAX_GAMEPADS) && CORE.Input.Gamepad.ready[gamepad] && (button < MAX_GAMEPAD_BUTTONS))
{
if ((CORE.Input.Gamepad.previousButtonState[gamepad][button] == 1) && (CORE.Input.Gamepad.currentButtonState[gamepad][button] == 0)) released = true;
}
return released;
}
@ -4006,8 +4011,10 @@ bool IsGamepadButtonUp(int gamepad, int button)
{
bool up = false;
if ((gamepad < MAX_GAMEPADS) && CORE.Input.Gamepad.ready[gamepad] && (button < MAX_GAMEPAD_BUTTONS) &&
(CORE.Input.Gamepad.currentButtonState[gamepad][button] == 0)) up = true;
if ((gamepad < MAX_GAMEPADS) && CORE.Input.Gamepad.ready[gamepad] && (button < MAX_GAMEPAD_BUTTONS))
{
if (CORE.Input.Gamepad.currentButtonState[gamepad][button] == 0) up = true;
}
return up;
}
@ -4053,10 +4060,13 @@ bool IsMouseButtonPressed(int button)
{
bool pressed = false;
if ((CORE.Input.Mouse.currentButtonState[button] == 1) && (CORE.Input.Mouse.previousButtonState[button] == 0)) pressed = true;
if ((button >= 0) && (button <= MOUSE_BUTTON_BACK))
{
if ((CORE.Input.Mouse.currentButtonState[button] == 1) && (CORE.Input.Mouse.previousButtonState[button] == 0)) pressed = true;
// Map touches to mouse buttons checking
if ((CORE.Input.Touch.currentTouchState[button] == 1) && (CORE.Input.Touch.previousTouchState[button] == 0)) pressed = true;
// Map touches to mouse buttons checking
if ((CORE.Input.Touch.currentTouchState[button] == 1) && (CORE.Input.Touch.previousTouchState[button] == 0)) pressed = true;
}
return pressed;
}
@ -4066,10 +4076,13 @@ bool IsMouseButtonDown(int button)
{
bool down = false;
if (CORE.Input.Mouse.currentButtonState[button] == 1) down = true;
if ((button >= 0) && (button <= MOUSE_BUTTON_BACK))
{
if (CORE.Input.Mouse.currentButtonState[button] == 1) down = true;
// NOTE: Touches are considered like mouse buttons
if (CORE.Input.Touch.currentTouchState[button] == 1) down = true;
// NOTE: Touches are considered like mouse buttons
if (CORE.Input.Touch.currentTouchState[button] == 1) down = true;
}
return down;
}
@ -4079,10 +4092,13 @@ bool IsMouseButtonReleased(int button)
{
bool released = false;
if ((CORE.Input.Mouse.currentButtonState[button] == 0) && (CORE.Input.Mouse.previousButtonState[button] == 1)) released = true;
if ((button >= 0) && (button <= MOUSE_BUTTON_BACK))
{
if ((CORE.Input.Mouse.currentButtonState[button] == 0) && (CORE.Input.Mouse.previousButtonState[button] == 1)) released = true;
// Map touches to mouse buttons checking
if ((CORE.Input.Touch.currentTouchState[button] == 0) && (CORE.Input.Touch.previousTouchState[button] == 1)) released = true;
// Map touches to mouse buttons checking
if ((CORE.Input.Touch.currentTouchState[button] == 0) && (CORE.Input.Touch.previousTouchState[button] == 1)) released = true;
}
return released;
}
@ -4092,10 +4108,13 @@ bool IsMouseButtonUp(int button)
{
bool up = false;
if (CORE.Input.Mouse.currentButtonState[button] == 0) up = true;
if ((button >= 0) && (button <= MOUSE_BUTTON_BACK))
{
if (CORE.Input.Mouse.currentButtonState[button] == 0) up = true;
// NOTE: Touches are considered like mouse buttons
if (CORE.Input.Touch.currentTouchState[button] == 0) up = true;
// NOTE: Touches are considered like mouse buttons
if (CORE.Input.Touch.currentTouchState[button] == 0) up = true;
}
return up;
}
@ -4104,6 +4123,7 @@ bool IsMouseButtonUp(int button)
int GetMouseX(void)
{
int mouseX = (int)((CORE.Input.Mouse.currentPosition.x + CORE.Input.Mouse.offset.x)*CORE.Input.Mouse.scale.x);
return mouseX;
}
@ -4111,6 +4131,7 @@ int GetMouseX(void)
int GetMouseY(void)
{
int mouseY = (int)((CORE.Input.Mouse.currentPosition.y + CORE.Input.Mouse.offset.y)*CORE.Input.Mouse.scale.y);
return mouseY;
}
@ -4470,7 +4491,7 @@ static void RecordAutomationEvent(void)
if (currentEventList->count == currentEventList->capacity) return; // Security check
// Event type: INPUT_TOUCH_POSITION
// Event type: INPUT_TOUCH_POSITION
if (((int)CORE.Input.Touch.position[id].x != (int)CORE.Input.Touch.previousPosition[id].x) ||
((int)CORE.Input.Touch.position[id].y != (int)CORE.Input.Touch.previousPosition[id].y))
{
@ -4483,7 +4504,7 @@ static void RecordAutomationEvent(void)
TRACELOG(LOG_INFO, "AUTOMATION: Frame: %i | Event type: INPUT_TOUCH_POSITION | Event parameters: %i, %i, %i", currentEventList->events[currentEventList->count].frame, currentEventList->events[currentEventList->count].params[0], currentEventList->events[currentEventList->count].params[1], currentEventList->events[currentEventList->count].params[2]);
currentEventList->count++;
}
if (currentEventList->count == currentEventList->capacity) return; // Security check
}

View File

@ -6517,7 +6517,7 @@ static ModelAnimation *LoadModelAnimationsGLTF(const char *fileName, int *animCo
};
}
Transform* root = &animations[i].framePoses[j][0];
Transform *root = &animations[i].framePoses[j][0];
root->rotation = QuaternionMultiply(worldTransform.rotation, root->rotation);
root->scale = Vector3Multiply(root->scale, worldTransform.scale);
root->translation = Vector3Multiply(root->translation, worldTransform.scale);

View File

@ -3625,7 +3625,7 @@ void ImageDrawLineEx(Image *dst, Vector2 start, Vector2 end, int thick, Color co
}
// Draw circle within an image
void ImageDrawCircle(Image* dst, int centerX, int centerY, int radius, Color color)
void ImageDrawCircle(Image *dst, int centerX, int centerY, int radius, Color color)
{
int x = 0;
int y = radius;
@ -3649,7 +3649,7 @@ void ImageDrawCircle(Image* dst, int centerX, int centerY, int radius, Color col
}
// Draw circle within an image (Vector version)
void ImageDrawCircleV(Image* dst, Vector2 center, int radius, Color color)
void ImageDrawCircleV(Image *dst, Vector2 center, int radius, Color color)
{
ImageDrawCircle(dst, (int)center.x, (int)center.y, radius, color);
}

View File

@ -198,7 +198,7 @@ static void ExportParsedData(const char *fileName, int format); // Export parsed
//----------------------------------------------------------------------------------
// Program main entry point
//----------------------------------------------------------------------------------
int main(int argc, char* argv[])
int main(int argc, char *argv[])
{
if (argc > 1) ProcessCommandLine(argc, argv);