From 35fa8f5bccd6d64e7df07dbe17dd2d963573d104 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 4 May 2017 23:00:47 -0700 Subject: [PATCH] Fix keyboard arrow keys being sent as gamepad d-pad events --- app/src/main/java/com/limelight/Game.java | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/limelight/Game.java b/app/src/main/java/com/limelight/Game.java index 42e4a049..ca91137e 100644 --- a/app/src/main/java/com/limelight/Game.java +++ b/app/src/main/java/com/limelight/Game.java @@ -574,8 +574,14 @@ public class Game extends Activity implements SurfaceHolder.Callback, return super.onKeyDown(keyCode, event); } - // Try the controller handler first - boolean handled = controllerHandler.handleButtonDown(event); + boolean handled = false; + if (event.getDevice() == null || + event.getDevice().getKeyboardType() != InputDevice.KEYBOARD_TYPE_ALPHABETIC) { + // Always try the controller handler first, unless it's an alphanumeric keyboard device. + // Otherwise, controller handler will eat keyboard d-pad events. + handled = controllerHandler.handleButtonDown(event); + } + if (!handled) { // Try the keyboard handler short translated = keybTranslator.translate(event.getKeyCode()); @@ -607,8 +613,14 @@ public class Game extends Activity implements SurfaceHolder.Callback, return super.onKeyUp(keyCode, event); } - // Try the controller handler first - boolean handled = controllerHandler.handleButtonUp(event); + boolean handled = false; + if (event.getDevice() == null || + event.getDevice().getKeyboardType() != InputDevice.KEYBOARD_TYPE_ALPHABETIC) { + // Always try the controller handler first, unless it's an alphanumeric keyboard device. + // Otherwise, controller handler will eat keyboard d-pad events. + handled = controllerHandler.handleButtonUp(event); + } + if (!handled) { // Try the keyboard handler short translated = keybTranslator.translate(event.getKeyCode());