src/joystick/SDL_joystick.c
changeset 10477 dc4bec0fc176
parent 10226 cb13d22b7f09
child 10595 9da2701eeb4a
     1.1 --- a/src/joystick/SDL_joystick.c	Fri Oct 07 16:04:15 2016 -0700
     1.2 +++ b/src/joystick/SDL_joystick.c	Fri Oct 07 16:13:37 2016 -0700
     1.3 @@ -142,8 +142,8 @@
     1.4          joystick->name = NULL;
     1.5  
     1.6      if (joystick->naxes > 0) {
     1.7 -        joystick->axes = (Sint16 *) SDL_malloc
     1.8 -            (joystick->naxes * sizeof(Sint16));
     1.9 +        joystick->axes = (Sint16 *) SDL_malloc(joystick->naxes * sizeof(Sint16));
    1.10 +        joystick->axes_zero = (Sint16 *) SDL_malloc(joystick->naxes * sizeof(Sint16));
    1.11      }
    1.12      if (joystick->nhats > 0) {
    1.13          joystick->hats = (Uint8 *) SDL_malloc
    1.14 @@ -167,6 +167,7 @@
    1.15      }
    1.16      if (joystick->axes) {
    1.17          SDL_memset(joystick->axes, 0, joystick->naxes * sizeof(Sint16));
    1.18 +        SDL_memset(joystick->axes_zero, 0, joystick->naxes * sizeof(Sint16));
    1.19      }
    1.20      if (joystick->hats) {
    1.21          SDL_memset(joystick->hats, 0, joystick->nhats * sizeof(Uint8));
    1.22 @@ -579,8 +580,8 @@
    1.23       * events.
    1.24       */
    1.25      if (SDL_PrivateJoystickShouldIgnoreEvent()) {
    1.26 -        if ((value > 0 && value >= joystick->axes[axis]) ||
    1.27 -            (value < 0 && value <= joystick->axes[axis])) {
    1.28 +        if ((value > joystick->axes_zero[axis] && value >= joystick->axes[axis]) ||
    1.29 +            (value < joystick->axes_zero[axis] && value <= joystick->axes[axis])) {
    1.30              return 0;
    1.31          }
    1.32      }
    1.33 @@ -753,7 +754,7 @@
    1.34  
    1.35              /* Tell the app that everything is centered/unpressed...  */
    1.36              for (i = 0; i < joystick->naxes; i++) {
    1.37 -                SDL_PrivateJoystickAxis(joystick, i, 0);
    1.38 +                SDL_PrivateJoystickAxis(joystick, i, joystick->axes_zero[i]);
    1.39              }
    1.40  
    1.41              for (i = 0; i < joystick->nbuttons; i++) {