Skip to content

Commit

Permalink
Merge pull request #814 from mariotaku/master
Browse files Browse the repository at this point in the history
Fixed trigger left/right range
  • Loading branch information
irtimmer authored Apr 21, 2021
2 parents 5baa2c9 + 9cec420 commit 7c8795f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
8 changes: 4 additions & 4 deletions src/input/sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,19 +186,19 @@ int sdlinput_handle_event(SDL_Event* event) {
gamepad->leftStickX = event->caxis.value;
break;
case SDL_CONTROLLER_AXIS_LEFTY:
gamepad->leftStickY = -event->caxis.value - 1;
gamepad->leftStickY = -SDL_max(event->caxis.value, (short)-32767);
break;
case SDL_CONTROLLER_AXIS_RIGHTX:
gamepad->rightStickX = event->caxis.value;
break;
case SDL_CONTROLLER_AXIS_RIGHTY:
gamepad->rightStickY = -event->caxis.value - 1;
gamepad->rightStickY = -SDL_max(event->caxis.value, (short)-32767);
break;
case SDL_CONTROLLER_AXIS_TRIGGERLEFT:
gamepad->leftTrigger = (event->caxis.value >> 8) + 127;
gamepad->leftTrigger = (unsigned char)(event->caxis.value * 255UL / 32767);
break;
case SDL_CONTROLLER_AXIS_TRIGGERRIGHT:
gamepad->rightTrigger = (event->caxis.value >> 8) + 127;
gamepad->rightTrigger = (unsigned char)(event->caxis.value * 255UL / 32767);
break;
default:
return SDL_NOTHING;
Expand Down

0 comments on commit 7c8795f

Please sign in to comment.