diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-06-24 19:32:42 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-24 19:32:42 +0200 |
commit | ab932bb675f7966b94c46da76ca822ebbf24ddd2 (patch) | |
tree | 8f26bbf00073ff0857f90ba5d61de2c7766eb6e5 /platform | |
parent | efa4264633e842e3606aa3113ea26ab9b9f986ca (diff) | |
parent | 512f8ebb937e3b32a2f429763982d4328ad0ca50 (diff) |
Merge pull request #29948 from lawnjelly/androidkeyboard
Fix some keyboards not working with Android
Diffstat (limited to 'platform')
-rw-r--r-- | platform/android/java/src/org/godotengine/godot/input/GodotInputHandler.java | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/platform/android/java/src/org/godotengine/godot/input/GodotInputHandler.java b/platform/android/java/src/org/godotengine/godot/input/GodotInputHandler.java index d01f958123..a443a0ad90 100644 --- a/platform/android/java/src/org/godotengine/godot/input/GodotInputHandler.java +++ b/platform/android/java/src/org/godotengine/godot/input/GodotInputHandler.java @@ -65,6 +65,14 @@ public class GodotInputHandler implements InputDeviceListener { godotView.queueEvent(task); } + private boolean isKeyEvent_GameDevice(int source) { + // Note that keyboards are often (SOURCE_KEYBOARD | SOURCE_DPAD) + if (source == (InputDevice.SOURCE_KEYBOARD | InputDevice.SOURCE_DPAD)) + return false; + + return (source & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK || (source & InputDevice.SOURCE_DPAD) == InputDevice.SOURCE_DPAD || (source & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD; + } + public boolean onKeyUp(final int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { return true; @@ -75,7 +83,7 @@ public class GodotInputHandler implements InputDeviceListener { }; int source = event.getSource(); - if ((source & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK || (source & InputDevice.SOURCE_DPAD) == InputDevice.SOURCE_DPAD || (source & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD) { + if (isKeyEvent_GameDevice(source)) { final int button = getGodotButton(keyCode); final int device_id = findJoystickDevice(event.getDeviceId()); @@ -118,7 +126,7 @@ public class GodotInputHandler implements InputDeviceListener { int source = event.getSource(); //Log.e(TAG, String.format("Key down! source %d, device %d, joystick %d, %d, %d", event.getDeviceId(), source, (source & InputDevice.SOURCE_JOYSTICK), (source & InputDevice.SOURCE_DPAD), (source & InputDevice.SOURCE_GAMEPAD))); - if ((source & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK || (source & InputDevice.SOURCE_DPAD) == InputDevice.SOURCE_DPAD || (source & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD) { + if (isKeyEvent_GameDevice(source)) { if (event.getRepeatCount() > 0) // ignore key echo return true; |