File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -975,10 +975,22 @@ namespace joystick
975975 void Joystick::handleAxisEvent (const SDL_GamepadAxisEvent &evt)
976976 {
977977 auto axis = evt.axis ;
978+ auto value = evt.value ;
978979
979980 Assertion (axis < numAxes (), " SDL event contained invalid axis index!" );
980981
981- _axisValues[axis] = evt.value ;
982+ // Triggers range from 0..32767 so we need to scale the value for FSO
983+ // since it expects a full -32768..32767 range. Note that precision is
984+ // lost in the scaling so only scale if not min/max trigger value
985+ if ((axis == SDL_GAMEPAD_AXIS_LEFT_TRIGGER ) || (axis == SDL_GAMEPAD_AXIS_RIGHT_TRIGGER )) {
986+ if (value == 0 ) {
987+ value = -32768 ;
988+ } else if (value < 32767 ) {
989+ value = static_cast <decltype (value)>((value * 2 ) - 32768 );
990+ }
991+ }
992+
993+ _axisValues[axis] = value;
982994 }
983995
984996 void Joystick::handleButtonEvent (const SDL_JoyButtonEvent &evt)
You can’t perform that action at this time.
0 commit comments