src/joystick/SDL_gamecontroller.c
changeset 7248 52d3427f8b5a
parent 7247 6a4570f12c20
child 7277 1290cd7f34af
equal deleted inserted replaced
7247:6a4570f12c20 7248:52d3427f8b5a
   958     if ( !gamecontroller )
   958     if ( !gamecontroller )
   959         return 0;
   959         return 0;
   960 
   960 
   961     if (gamecontroller->mapping.axes[axis] >= 0 )
   961     if (gamecontroller->mapping.axes[axis] >= 0 )
   962     {
   962     {
   963         return ( SDL_JoystickGetAxis( gamecontroller->joystick, gamecontroller->mapping.axes[axis]) );
   963         Sint16 value = ( SDL_JoystickGetAxis( gamecontroller->joystick, gamecontroller->mapping.axes[axis]) );
       
   964         switch (axis)
       
   965         {
       
   966             case SDL_CONTROLLER_AXIS_TRIGGERLEFT:
       
   967             case SDL_CONTROLLER_AXIS_TRIGGERRIGHT:
       
   968                 /* Shift it to be 0 - 32767. */
       
   969                 value = value / 2 + 16384;
       
   970             default:
       
   971                 break;
       
   972         }
       
   973         return value;
   964     }
   974     }
   965     else if (gamecontroller->mapping.buttonasaxis[axis] >= 0 )
   975     else if (gamecontroller->mapping.buttonasaxis[axis] >= 0 )
   966     {
   976     {
   967         Uint8 value;
   977         Uint8 value;
   968         value = SDL_JoystickGetButton( gamecontroller->joystick, gamecontroller->mapping.buttonasaxis[axis] );
   978         value = SDL_JoystickGetButton( gamecontroller->joystick, gamecontroller->mapping.buttonasaxis[axis] );