From 623bc5c156eb1f045c3cb62d936f8d29bde4ef0e Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Wed, 26 Feb 2020 19:19:43 -0800 Subject: [PATCH] Fix check for gamepad buttons. Fixes #788 --- .../com/limelight/binding/input/ControllerHandler.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 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 02828e54..dfcf2e1a 100644 --- a/app/src/main/java/com/limelight/binding/input/ControllerHandler.java +++ b/app/src/main/java/com/limelight/binding/input/ControllerHandler.java @@ -401,11 +401,14 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD // Note that we are explicitly NOT excluding the current device we're examining here, // since the other gamepad buttons may be on our current device and that's fine. - boolean[] keys = currentDev.hasKeys(KeyEvent.KEYCODE_BUTTON_SELECT, KeyEvent.KEYCODE_BUTTON_A); - if (keys[0]) { + if (currentDev.hasKeys(KeyEvent.KEYCODE_BUTTON_SELECT)[0]) { foundInternalSelect = true; } - if (keys[1]) { + + // We don't check KEYCODE_BUTTON_A here, since the Shield Android TV has a + // virtual mouse device that claims to have KEYCODE_BUTTON_A. Instead, we rely + // on the SOURCE_GAMEPAD flag to be set on gamepad devices. + if (hasGamepadButtons(currentDev)) { foundInternalGamepad = true; } }