Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Add trigger value adjustment code to the SDL_GameControllerGetAxis co…
Browse files Browse the repository at this point in the history
…de as well.

- fixes Trigger values when polling instead of using event driven
  • Loading branch information
urkle committed May 31, 2013
1 parent 384e3f4 commit 21bf915
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/joystick/SDL_gamecontroller.c
Expand Up @@ -960,7 +960,17 @@ SDL_GameControllerGetAxis(SDL_GameController * gamecontroller, SDL_GameControlle

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 )
{
Expand Down

0 comments on commit 21bf915

Please sign in to comment.