Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Add trigger value adjustment code to the SDL_GameControllerGetAxis co…

…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 21bf91537f4462a458b20334d59f43c3bdec6066
Showing with 11 additions and 1 deletion.
  1. +11 −1 src/joystick/SDL_gamecontroller.c
@@ -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 )
{

0 comments on commit 21bf915

Please sign in to comment.