From 925690dc4618db5d7c29885b3274f062c9f816ee Mon Sep 17 00:00:00 2001 From: artdeell Date: Sat, 6 Apr 2024 08:30:30 -0400 Subject: [PATCH] Fix[input]: minor gesture handling an positioning issues --- .../mouse/InGameEventProcessor.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/mouse/InGameEventProcessor.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/mouse/InGameEventProcessor.java index e254fe1df3..daed7323b4 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/mouse/InGameEventProcessor.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/mouse/InGameEventProcessor.java @@ -41,6 +41,13 @@ public InGameEventProcessor(float scaleFactor, double sensitivity) { @Override public boolean processTouchEvent(MotionEvent motionEvent) { boolean hasDoubleTapped = mDoubleTapDetector.onTouchEvent(motionEvent); + boolean hasGuiBarHit = handleGuiBar(motionEvent); + // Handle this gesture separately, outside of the event masking to avoid inconsistencies + // with the double tap detector. + if(hasGuiBarHit && hasDoubleTapped && !LauncherPreferences.PREF_DISABLE_SWAP_HAND) { + CallbackBridge.sendKeyPress(LwjglGlfwKeycode.GLFW_KEY_F); + } + // Handle the rest of the in-game motion. switch (motionEvent.getActionMasked()) { case MotionEvent.ACTION_DOWN: mTracker.startTracking(motionEvent); @@ -49,17 +56,17 @@ public boolean processTouchEvent(MotionEvent motionEvent) { break; case MotionEvent.ACTION_MOVE: mTracker.trackEvent(motionEvent); + if(!LauncherPreferences.PREF_DISABLE_GESTURES) { + checkGestures(hasGuiBarHit); + } + // Only send new mouse positions if the event hasn't hit the inventory bar. + // Note that the events are sent to the tracker regardless, to prevent cursor + // jumps when leaving the inventory bar in one single touch gesture. + if(hasGuiBarHit) break; float[] motionVector = mTracker.getMotionVector(); CallbackBridge.mouseX += motionVector[0] * mSensitivity; CallbackBridge.mouseY += motionVector[1] * mSensitivity; CallbackBridge.sendCursorPos(CallbackBridge.mouseX, CallbackBridge.mouseY); - boolean hasGuiBarHit = handleGuiBar(motionEvent); - // Handle this gesture separately as it's a separate toggle in settings - if(hasGuiBarHit && hasDoubleTapped && !LauncherPreferences.PREF_DISABLE_SWAP_HAND) { - CallbackBridge.sendKeyPress(LwjglGlfwKeycode.GLFW_KEY_F); - } - if(LauncherPreferences.PREF_DISABLE_GESTURES) break; - checkGestures(hasGuiBarHit); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: