Move the most specific motion event guard to the top of the function.

This commit is contained in:
Tareq Anuar 2024-06-11 10:26:57 +08:00
parent 5241d30bfa
commit d14bea4413
No known key found for this signature in database
GPG Key ID: A3279F60D5EAB9EF

View File

@ -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() {