Skip to content

Commit

Permalink
Move the most specific motion event guard to the top of the function.
Browse files Browse the repository at this point in the history
  • Loading branch information
MTareqAzim committed Jun 11, 2024
1 parent 5241d30 commit d14bea4
Showing 1 changed file with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,16 +228,6 @@ public boolean onTouchEvent(final MotionEvent event) {
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();
Expand Down Expand Up @@ -273,11 +263,20 @@ public boolean onGenericMotionEvent(MotionEvent event) {
}
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() {
Expand Down

0 comments on commit d14bea4

Please sign in to comment.