Fix issue with ipega controller not capturing keypresses on Samsung phones. (#386)

This commit is contained in:
joeyenfield 2017-05-16 02:07:54 +01:00 committed by Cameron Gutman
parent e7d96f0ac2
commit 043c9a978e

View File

@ -575,8 +575,13 @@ public class Game extends Activity implements SurfaceHolder.Callback,
} }
boolean handled = false; boolean handled = false;
if (event.getDevice() == null ||
event.getDevice().getKeyboardType() != InputDevice.KEYBOARD_TYPE_ALPHABETIC) { boolean detectedGamepad = event.getDevice() == null ? false :
((event.getDevice().getSources() & InputDevice.SOURCE_JOYSTICK) != 0 ||
(event.getDevice().getSources() & InputDevice.SOURCE_GAMEPAD) != 0);
if (detectedGamepad || (event.getDevice() == null ||
event.getDevice().getKeyboardType() != InputDevice.KEYBOARD_TYPE_ALPHABETIC
)) {
// Always try the controller handler first, unless it's an alphanumeric keyboard device. // Always try the controller handler first, unless it's an alphanumeric keyboard device.
// Otherwise, controller handler will eat keyboard d-pad events. // Otherwise, controller handler will eat keyboard d-pad events.
handled = controllerHandler.handleButtonDown(event); handled = controllerHandler.handleButtonDown(event);
@ -614,8 +619,12 @@ public class Game extends Activity implements SurfaceHolder.Callback,
} }
boolean handled = false; boolean handled = false;
if (event.getDevice() == null || boolean detectedGamepad = event.getDevice() == null ? false :
event.getDevice().getKeyboardType() != InputDevice.KEYBOARD_TYPE_ALPHABETIC) { ((event.getDevice().getSources() & InputDevice.SOURCE_JOYSTICK) != 0 ||
(event.getDevice().getSources() & InputDevice.SOURCE_GAMEPAD) != 0);
if (detectedGamepad || (event.getDevice() == null ||
event.getDevice().getKeyboardType() != InputDevice.KEYBOARD_TYPE_ALPHABETIC
)) {
// Always try the controller handler first, unless it's an alphanumeric keyboard device. // Always try the controller handler first, unless it's an alphanumeric keyboard device.
// Otherwise, controller handler will eat keyboard d-pad events. // Otherwise, controller handler will eat keyboard d-pad events.
handled = controllerHandler.handleButtonUp(event); handled = controllerHandler.handleButtonUp(event);