mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2026-04-03 06:26:16 +00:00
Fix crash on controllers with RX and RY but no Z and RZ axes
This commit is contained in:
@@ -502,8 +502,14 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD
|
||||
// other sane controller that uses RX and RY for right stick and Z and RZ for triggers.
|
||||
context.rightStickXAxis = MotionEvent.AXIS_RX;
|
||||
context.rightStickYAxis = MotionEvent.AXIS_RY;
|
||||
context.leftTriggerAxis = MotionEvent.AXIS_Z;
|
||||
context.rightTriggerAxis = MotionEvent.AXIS_RZ;
|
||||
|
||||
// While it's likely that Z and RZ are triggers, we may have digital trigger buttons
|
||||
// instead. We must check that we actually have Z and RZ axes before assigning them.
|
||||
if (getMotionRangeForJoystickAxis(dev, MotionEvent.AXIS_Z) != null &&
|
||||
getMotionRangeForJoystickAxis(dev, MotionEvent.AXIS_RZ) != null) {
|
||||
context.leftTriggerAxis = MotionEvent.AXIS_Z;
|
||||
context.rightTriggerAxis = MotionEvent.AXIS_RZ;
|
||||
}
|
||||
}
|
||||
|
||||
// Triggers always idle negative on axes that are centered at zero
|
||||
|
||||
Reference in New Issue
Block a user