Avoid duplicate joystick axis events
authorSam Lantinga <slouken@libsdl.org>
Fri, 22 Sep 2017 08:56:09 -0700
changeset 11520fe2afdc5616c
parent 11519 535b0c8ba4ce
child 11522 2b3a78025695
Avoid duplicate joystick axis events
src/joystick/SDL_joystick.c
     1.1 --- a/src/joystick/SDL_joystick.c	Fri Sep 22 08:51:45 2017 -0700
     1.2 +++ b/src/joystick/SDL_joystick.c	Fri Sep 22 08:56:09 2017 -0700
     1.3 @@ -672,6 +672,9 @@
     1.4          joystick->axes[axis].zero = value;
     1.5          joystick->axes[axis].has_initial_value = SDL_TRUE;
     1.6      }
     1.7 +    if (value == joystick->axes[axis].value) {
     1.8 +        return 0;
     1.9 +    }
    1.10      if (!joystick->axes[axis].sent_initial_value) {
    1.11          /* Make sure we don't send motion until there's real activity on this axis */
    1.12          const int MAX_ALLOWED_JITTER = SDL_JOYSTICK_AXIS_MAX / 80;  /* ShanWan PS3 controller needed 96 */