Handle paddle buttons on Xbox Elite controllers

This commit is contained in:
Cameron Gutman
2023-06-28 17:23:40 -05:00
parent 71c831b02d
commit 27701eda49
@@ -1950,9 +1950,26 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD
} }
context.rightTrigger = 0; context.rightTrigger = 0;
break; break;
default:
// 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: default:
return false; return false;
} }
}
// Check if we're emulating the select button // Check if we're emulating the select button
if ((context.emulatingButtonFlags & ControllerHandler.EMULATING_SELECT) != 0) if ((context.emulatingButtonFlags & ControllerHandler.EMULATING_SELECT) != 0)
@@ -2125,9 +2142,26 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD
} }
context.rightTrigger = (byte)0xFF; context.rightTrigger = (byte)0xFF;
break; break;
default:
// 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: default:
return false; return false;
} }
}
// Start+Back+LB+RB is the quit combo // Start+Back+LB+RB is the quit combo
if (context.inputMap == (ControllerPacket.BACK_FLAG | ControllerPacket.PLAY_FLAG | if (context.inputMap == (ControllerPacket.BACK_FLAG | ControllerPacket.PLAY_FLAG |