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 7248 52d3427f8b5a
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
--- a/src/joystick/SDL_gamecontroller.c	Thu May 30 10:42:52 2013 -0400
+++ b/src/joystick/SDL_gamecontroller.c	Thu May 30 22:14:24 2013 -0400
@@ -960,7 +960,17 @@
 
     if (gamecontroller->mapping.axes[axis] >= 0 )
     {
-        return ( SDL_JoystickGetAxis( gamecontroller->joystick, gamecontroller->mapping.axes[axis]) );
+        Sint16 value = ( SDL_JoystickGetAxis( gamecontroller->joystick, gamecontroller->mapping.axes[axis]) );
+        switch (axis)
+        {
+            case SDL_CONTROLLER_AXIS_TRIGGERLEFT:
+            case SDL_CONTROLLER_AXIS_TRIGGERRIGHT:
+                /* Shift it to be 0 - 32767. */
+                value = value / 2 + 16384;
+            default:
+                break;
+        }
+        return value;
     }
     else if (gamecontroller->mapping.buttonasaxis[axis] >= 0 )
     {