Skip to content

Commit

Permalink
joystick: Don't report duplicate recentering events for game controll…
Browse files Browse the repository at this point in the history
…ers.
  • Loading branch information
icculus committed Apr 20, 2020
1 parent c5f2a1c commit 67760f0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/joystick/SDL_gamecontroller.c
Expand Up @@ -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);
}
}
}

Expand Down

0 comments on commit 67760f0

Please sign in to comment.