diff options
author | Tareq Anuar <mtareqazim@gmail.com> | 2024-06-11 10:26:57 +0800 |
---|---|---|
committer | Tareq Anuar <mtareqazim@gmail.com> | 2024-06-11 12:10:09 +0800 |
commit | d14bea4413a0c2945cad288d5361fa56c806b59c (patch) | |
tree | 55b9a1b6bad7f7ca19d20f38353188116be747e2 | |
parent | 5241d30bfa223ed45784e32d8143d20a98a8d862 (diff) | |
download | redot-engine-d14bea4413a0c2945cad288d5361fa56c806b59c.tar.gz |
Move the most specific motion event guard to the top of the function.
-rw-r--r-- | platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java b/platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java index 43ae71f8e1..83e76e49c9 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java +++ b/platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java @@ -228,16 +228,6 @@ public class GodotInputHandler implements InputManager.InputDeviceListener { public boolean onGenericMotionEvent(MotionEvent event) { lastSeenToolType = getEventToolType(event); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && gestureDetector.onGenericMotionEvent(event)) { - // The gesture detector has handled the event. - return true; - } - - if (godotGestureHandler.onMotionEvent(event)) { - // The gesture handler has handled the event. - return true; - } - if (event.isFromSource(InputDevice.SOURCE_JOYSTICK) && event.getActionMasked() == MotionEvent.ACTION_MOVE) { // Check if the device exists final int deviceId = event.getDeviceId(); @@ -273,11 +263,20 @@ public class GodotInputHandler implements InputManager.InputDeviceListener { } return true; } - } else { - return handleMouseEvent(event); + return false; } - return false; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && gestureDetector.onGenericMotionEvent(event)) { + // The gesture detector has handled the event. + return true; + } + + if (godotGestureHandler.onMotionEvent(event)) { + // The gesture handler has handled the event. + return true; + } + + return handleMouseEvent(event); } public void initInputDevices() { |