fix: set correct default axes for gamepads that are not connected

`glfwGetGamepadState` will set all gamepad state variables to 0.0 if required gamepad is not connected, but `RecordAutomationEvent()` inside rcore.c expects trigger axes to be -1.0f when gamepad is not connected. Since SDL and RGFW return -1.0f in such case, this change is aligning it with them
This commit is contained in:
Dino 2025-12-26 00:45:27 +01:00 committed by GitHub
parent 101502103a
commit c4531302ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1266,7 +1266,13 @@ void PollInputEvents(void)
// Get current gamepad state
// NOTE: There is no callback available, so we get it manually
GLFWgamepadstate state = { 0 };
glfwGetGamepadState(i, &state); // This remapps all gamepads so they have their buttons mapped like an xbox controller
int isGamepadConnected = glfwGetGamepadState(i, &state); // This remapps all gamepads so they have their buttons mapped like an xbox controller
if (!isGamepadConnected)
{
// setting axes to expected value instead of GLFW's 0.0f default when gamepad isnt connected
state.axes[GAMEPAD_AXIS_LEFT_TRIGGER] = -1.0f;
state.axes[GAMEPAD_AXIS_RIGHT_TRIGGER] = -1.0f;
}
const unsigned char *buttons = state.buttons;