Add trigger value adjustment code to the SDL_GameControllerGetAxis code as well.
authorEdward Rudd <urkle@outoforder.cc>
Thu, 30 May 2013 22:14:24 -0400
changeset 724852d3427f8b5a
parent 7247 6a4570f12c20
child 7249 606c8fcfef2f
Add trigger value adjustment code to the SDL_GameControllerGetAxis code as well.

- fixes Trigger values when polling instead of using event driven
src/joystick/SDL_gamecontroller.c
     1.1 --- a/src/joystick/SDL_gamecontroller.c	Thu May 30 10:42:52 2013 -0400
     1.2 +++ b/src/joystick/SDL_gamecontroller.c	Thu May 30 22:14:24 2013 -0400
     1.3 @@ -960,7 +960,17 @@
     1.4  
     1.5      if (gamecontroller->mapping.axes[axis] >= 0 )
     1.6      {
     1.7 -        return ( SDL_JoystickGetAxis( gamecontroller->joystick, gamecontroller->mapping.axes[axis]) );
     1.8 +        Sint16 value = ( SDL_JoystickGetAxis( gamecontroller->joystick, gamecontroller->mapping.axes[axis]) );
     1.9 +        switch (axis)
    1.10 +        {
    1.11 +            case SDL_CONTROLLER_AXIS_TRIGGERLEFT:
    1.12 +            case SDL_CONTROLLER_AXIS_TRIGGERRIGHT:
    1.13 +                /* Shift it to be 0 - 32767. */
    1.14 +                value = value / 2 + 16384;
    1.15 +            default:
    1.16 +                break;
    1.17 +        }
    1.18 +        return value;
    1.19      }
    1.20      else if (gamecontroller->mapping.buttonasaxis[axis] >= 0 )
    1.21      {