From 27701eda49ee72f9f5ef393dd6706e6b490db5ad Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Wed, 28 Jun 2023 17:23:40 -0500 Subject: [PATCH] Handle paddle buttons on Xbox Elite controllers --- .../binding/input/ControllerHandler.java | 38 ++++++++++++++++++- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/limelight/binding/input/ControllerHandler.java b/app/src/main/java/com/limelight/binding/input/ControllerHandler.java index ccfd5370..f3afcb6a 100644 --- a/app/src/main/java/com/limelight/binding/input/ControllerHandler.java +++ b/app/src/main/java/com/limelight/binding/input/ControllerHandler.java @@ -1951,7 +1951,24 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD context.rightTrigger = 0; break; default: - return false; + // Paddles aren't mapped in any of the Android key layout files, + // so we need to handle the evdev key codes directly. + switch (event.getScanCode()) { + case 0x2c4: // BTN_TRIGGER_HAPPY5 + context.inputMap &= ~ControllerPacket.PADDLE1_FLAG; + break; + case 0x2c5: // BTN_TRIGGER_HAPPY6 + context.inputMap &= ~ControllerPacket.PADDLE2_FLAG; + break; + case 0x2c6: // BTN_TRIGGER_HAPPY7 + context.inputMap &= ~ControllerPacket.PADDLE3_FLAG; + break; + case 0x2c7: // BTN_TRIGGER_HAPPY8 + context.inputMap &= ~ControllerPacket.PADDLE4_FLAG; + break; + default: + return false; + } } // Check if we're emulating the select button @@ -2126,7 +2143,24 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD context.rightTrigger = (byte)0xFF; break; default: - return false; + // Paddles aren't mapped in any of the Android key layout files, + // so we need to handle the evdev key codes directly. + switch (event.getScanCode()) { + case 0x2c4: // BTN_TRIGGER_HAPPY5 + context.inputMap |= ControllerPacket.PADDLE1_FLAG; + break; + case 0x2c5: // BTN_TRIGGER_HAPPY6 + context.inputMap |= ControllerPacket.PADDLE2_FLAG; + break; + case 0x2c6: // BTN_TRIGGER_HAPPY7 + context.inputMap |= ControllerPacket.PADDLE3_FLAG; + break; + case 0x2c7: // BTN_TRIGGER_HAPPY8 + context.inputMap |= ControllerPacket.PADDLE4_FLAG; + break; + default: + return false; + } } // Start+Back+LB+RB is the quit combo