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

View File

@ -323,7 +323,7 @@ Uint8 SDL_EventState(Uint32 type, int state)
return stateBefore; 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); const SDL_DisplayMode *currentMode = SDL_GetCurrentDisplayMode(displayID);

View File

@ -3831,7 +3831,6 @@ void PlayAutomationEvent(AutomationEvent event)
// Check if a key has been pressed once // Check if a key has been pressed once
bool IsKeyPressed(int key) bool IsKeyPressed(int key)
{ {
bool pressed = false; bool pressed = false;
if ((key > 0) && (key < MAX_KEYBOARD_KEYS)) if ((key > 0) && (key < MAX_KEYBOARD_KEYS))
@ -3973,8 +3972,10 @@ bool IsGamepadButtonPressed(int gamepad, int button)
{ {
bool pressed = false; bool pressed = false;
if ((gamepad < MAX_GAMEPADS) && CORE.Input.Gamepad.ready[gamepad] && (button < MAX_GAMEPAD_BUTTONS) && 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 ((CORE.Input.Gamepad.previousButtonState[gamepad][button] == 0) && (CORE.Input.Gamepad.currentButtonState[gamepad][button] == 1)) pressed = true;
}
return pressed; return pressed;
} }
@ -3984,8 +3985,10 @@ bool IsGamepadButtonDown(int gamepad, int button)
{ {
bool down = false; bool down = false;
if ((gamepad < MAX_GAMEPADS) && CORE.Input.Gamepad.ready[gamepad] && (button < MAX_GAMEPAD_BUTTONS) && if ((gamepad < MAX_GAMEPADS) && CORE.Input.Gamepad.ready[gamepad] && (button < MAX_GAMEPAD_BUTTONS))
(CORE.Input.Gamepad.currentButtonState[gamepad][button] == 1)) down = true; {
if (CORE.Input.Gamepad.currentButtonState[gamepad][button] == 1) down = true;
}
return down; return down;
} }
@ -3995,8 +3998,10 @@ bool IsGamepadButtonReleased(int gamepad, int button)
{ {
bool released = false; bool released = false;
if ((gamepad < MAX_GAMEPADS) && CORE.Input.Gamepad.ready[gamepad] && (button < MAX_GAMEPAD_BUTTONS) && 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 ((CORE.Input.Gamepad.previousButtonState[gamepad][button] == 1) && (CORE.Input.Gamepad.currentButtonState[gamepad][button] == 0)) released = true;
}
return released; return released;
} }
@ -4006,8 +4011,10 @@ bool IsGamepadButtonUp(int gamepad, int button)
{ {
bool up = false; bool up = false;
if ((gamepad < MAX_GAMEPADS) && CORE.Input.Gamepad.ready[gamepad] && (button < MAX_GAMEPAD_BUTTONS) && if ((gamepad < MAX_GAMEPADS) && CORE.Input.Gamepad.ready[gamepad] && (button < MAX_GAMEPAD_BUTTONS))
(CORE.Input.Gamepad.currentButtonState[gamepad][button] == 0)) up = true; {
if (CORE.Input.Gamepad.currentButtonState[gamepad][button] == 0) up = true;
}
return up; return up;
} }
@ -4053,10 +4060,13 @@ bool IsMouseButtonPressed(int button)
{ {
bool pressed = false; bool pressed = false;
if ((button >= 0) && (button <= MOUSE_BUTTON_BACK))
{
if ((CORE.Input.Mouse.currentButtonState[button] == 1) && (CORE.Input.Mouse.previousButtonState[button] == 0)) pressed = true; if ((CORE.Input.Mouse.currentButtonState[button] == 1) && (CORE.Input.Mouse.previousButtonState[button] == 0)) pressed = true;
// Map touches to mouse buttons checking // Map touches to mouse buttons checking
if ((CORE.Input.Touch.currentTouchState[button] == 1) && (CORE.Input.Touch.previousTouchState[button] == 0)) pressed = true; if ((CORE.Input.Touch.currentTouchState[button] == 1) && (CORE.Input.Touch.previousTouchState[button] == 0)) pressed = true;
}
return pressed; return pressed;
} }
@ -4066,10 +4076,13 @@ bool IsMouseButtonDown(int button)
{ {
bool down = false; bool down = false;
if ((button >= 0) && (button <= MOUSE_BUTTON_BACK))
{
if (CORE.Input.Mouse.currentButtonState[button] == 1) down = true; if (CORE.Input.Mouse.currentButtonState[button] == 1) down = true;
// NOTE: Touches are considered like mouse buttons // NOTE: Touches are considered like mouse buttons
if (CORE.Input.Touch.currentTouchState[button] == 1) down = true; if (CORE.Input.Touch.currentTouchState[button] == 1) down = true;
}
return down; return down;
} }
@ -4079,10 +4092,13 @@ bool IsMouseButtonReleased(int button)
{ {
bool released = false; bool released = false;
if ((button >= 0) && (button <= MOUSE_BUTTON_BACK))
{
if ((CORE.Input.Mouse.currentButtonState[button] == 0) && (CORE.Input.Mouse.previousButtonState[button] == 1)) released = true; if ((CORE.Input.Mouse.currentButtonState[button] == 0) && (CORE.Input.Mouse.previousButtonState[button] == 1)) released = true;
// Map touches to mouse buttons checking // Map touches to mouse buttons checking
if ((CORE.Input.Touch.currentTouchState[button] == 0) && (CORE.Input.Touch.previousTouchState[button] == 1)) released = true; if ((CORE.Input.Touch.currentTouchState[button] == 0) && (CORE.Input.Touch.previousTouchState[button] == 1)) released = true;
}
return released; return released;
} }
@ -4092,10 +4108,13 @@ bool IsMouseButtonUp(int button)
{ {
bool up = false; bool up = false;
if ((button >= 0) && (button <= MOUSE_BUTTON_BACK))
{
if (CORE.Input.Mouse.currentButtonState[button] == 0) up = true; if (CORE.Input.Mouse.currentButtonState[button] == 0) up = true;
// NOTE: Touches are considered like mouse buttons // NOTE: Touches are considered like mouse buttons
if (CORE.Input.Touch.currentTouchState[button] == 0) up = true; if (CORE.Input.Touch.currentTouchState[button] == 0) up = true;
}
return up; return up;
} }
@ -4104,6 +4123,7 @@ bool IsMouseButtonUp(int button)
int GetMouseX(void) int GetMouseX(void)
{ {
int mouseX = (int)((CORE.Input.Mouse.currentPosition.x + CORE.Input.Mouse.offset.x)*CORE.Input.Mouse.scale.x); int mouseX = (int)((CORE.Input.Mouse.currentPosition.x + CORE.Input.Mouse.offset.x)*CORE.Input.Mouse.scale.x);
return mouseX; return mouseX;
} }
@ -4111,6 +4131,7 @@ int GetMouseX(void)
int GetMouseY(void) int GetMouseY(void)
{ {
int mouseY = (int)((CORE.Input.Mouse.currentPosition.y + CORE.Input.Mouse.offset.y)*CORE.Input.Mouse.scale.y); int mouseY = (int)((CORE.Input.Mouse.currentPosition.y + CORE.Input.Mouse.offset.y)*CORE.Input.Mouse.scale.y);
return mouseY; return mouseY;
} }

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->rotation = QuaternionMultiply(worldTransform.rotation, root->rotation);
root->scale = Vector3Multiply(root->scale, worldTransform.scale); root->scale = Vector3Multiply(root->scale, worldTransform.scale);
root->translation = Vector3Multiply(root->translation, 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 // 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 x = 0;
int y = radius; 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) // 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); 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 // Program main entry point
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
int main(int argc, char* argv[]) int main(int argc, char *argv[])
{ {
if (argc > 1) ProcessCommandLine(argc, argv); if (argc > 1) ProcessCommandLine(argc, argv);