From 5ab5c9b76784697092fe3ac340d4024ff59ab8d7 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 22 Sep 2017 08:56:09 -0700 Subject: [PATCH] Avoid duplicate joystick axis events --- src/joystick/SDL_joystick.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index bfce1faf24b2d..0724db258adb0 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -672,6 +672,9 @@ SDL_PrivateJoystickAxis(SDL_Joystick * joystick, Uint8 axis, Sint16 value) joystick->axes[axis].zero = value; joystick->axes[axis].has_initial_value = SDL_TRUE; } + if (value == joystick->axes[axis].value) { + return 0; + } if (!joystick->axes[axis].sent_initial_value) { /* Make sure we don't send motion until there's real activity on this axis */ const int MAX_ALLOWED_JITTER = SDL_JOYSTICK_AXIS_MAX / 80; /* ShanWan PS3 controller needed 96 */