From 67760f0ed7b30bfc9131608520c624a73bc8d8ad Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Mon, 20 Apr 2020 18:58:18 -0400 Subject: [PATCH] joystick: Don't report duplicate recentering events for game controllers. --- src/joystick/SDL_gamecontroller.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/joystick/SDL_gamecontroller.c b/src/joystick/SDL_gamecontroller.c index 32eb9e2cb..f3f4b57c0 100644 --- a/src/joystick/SDL_gamecontroller.c +++ b/src/joystick/SDL_gamecontroller.c @@ -357,11 +357,15 @@ static void RecenterGameController(SDL_GameController *gamecontroller) SDL_GameControllerAxis axis; for (button = (SDL_GameControllerButton) 0; button < SDL_CONTROLLER_BUTTON_MAX; button++) { - SDL_PrivateGameControllerButton(gamecontroller, button, SDL_RELEASED); + if (SDL_GameControllerGetButton(gamecontroller, button)) { + SDL_PrivateGameControllerButton(gamecontroller, button, SDL_RELEASED); + } } for (axis = (SDL_GameControllerAxis) 0; axis < SDL_CONTROLLER_AXIS_MAX; axis++) { - SDL_PrivateGameControllerAxis(gamecontroller, axis, 0); + if (SDL_GameControllerGetAxis(gamecontroller, axis) != 0) { + SDL_PrivateGameControllerAxis(gamecontroller, axis, 0); + } } }