mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-28 17:14:50 +00:00
fix: set correct default axes for gamepads that are not connected (inside rcore_desktop_glfw.c) (#5444)
* 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 * updated comment in rcore_desktop_glfw.c
This commit is contained in:
@@ -1266,8 +1266,14 @@ 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 resting 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;
|
||||
|
||||
for (int k = 0; (buttons != NULL) && (k < MAX_GAMEPAD_BUTTONS); k++)
|
||||
|
||||
Reference in New Issue
Block a user