Repository: PojavLauncherTeam/PojavLauncher (language: java)

Issue:
[BUG] weird double click when operating too quickly
### Describe the bug

After I install the latest build of `v3_openjdk`, when I use the virtual mouse to operate quickly, some operations may be input as double-clicks, but I don't want to trigger a double-click.

For example: Now I am sorting items in my inventory. I hold a bunch of items in my hand, press and hold the touchpad, and move the cursor to the position I want. I quickly release my finger, and then click the screen to drop items.  Then quickly release it, and then press and hold the screen again to move the cursor to the next item.  But Pojav seemed to see me touching the screen twice in a short period of time and interpreted my operation as a double-click input to the game. As a result, my item was put down and then picked up again.

Now I have to wait a while after each time I drop the item to avoid it being considered a double click.  And this delay is very uncomfortable.

### The log file and images/videos

before update, with build <https://github.com/PojavLauncherTeam/PojavLauncher/actions/runs/9022894637>:

https://github.com/PojavLauncherTeam/PojavLauncher/assets/73000464/1fc6f8de-5560-4c4e-8f01-92e7be853722

after update, with build <https://github.com/PojavLauncherTeam/PojavLauncher/actions/runs/9142570207>:

https://github.com/PojavLauncherTeam/PojavLauncher/assets/73000464/98b15999-e48d-41b0-a352-baa569960607

### Steps To Reproduce

```markdown
Here are the steps that demonstrate the impact of this behavior, but not the only one

1. launch the game and join in the world, and take some item to your inventory 
2. open inventory
3. with virtual mouse, to pickup an item (just left-click the item)
4. move cursor to any empty slots
5. (do it quickly!) click on touchpad, or hold your finger to the touchpad, then release it.
6. (do it quickly!) hold your finger on the touchpad (because you want to move the cursor to the other items), and drag your finger on the touchpad
7. weird double-click happened, the items placed before back to your cursor now
```


### Expected Behavior

I want to place the item to the slot normally, instead of triggering a double click. In other words, I want to trigger the double-click when there is a real double-click, rather than triggering the double-click when the screen is touched again without releasing after the first click.

### Platform

```markdown
- Device model: Huawei DUB-AL00
- CPU architecture: aarch64
- Android version: 8.1
- PojavLauncher version: edelweiss-20240518-3443b04-v3_openjdk
```


### Anything else?

I'm also testing it with build <https://github.com/PojavLauncherTeam/PojavLauncher/actions/runs/9148192919>, because its name contains "control", but the buggy behaviour still appears.
At the same time, when I wrote this issue, the `v3_openjdk` branch seemed to have a new commit, but it seemed that it was only the "control" branch that was merged, so I believe this problem still exists in the latest build.

Finally, if we ignore the problem above, the double-click operation works just fine!  Can directly gather scattered similar items.


Discussion / hints:
> Maybe just add a Q button?

My bad didn't read it full. 
Hi there @Silvigarabis, first of all thank you for the detailed report, it made reproducing the issue very quick. I'm looking into it

Fix patch:
diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/mouse/TapDetector.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/mouse/TapDetector.java
index 52540643af..e47d6096b4 100644
--- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/mouse/TapDetector.java
+++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/mouse/TapDetector.java
@@ -22,7 +22,7 @@ public class TapDetector {
 
     private final static int TAP_MIN_DELTA_MS = 10;
     private final static int TAP_MAX_DELTA_MS = 300;
-    private final static int TAP_SLOP_SQUARE_PX = (int) Math.pow(Tools.dpToPx(100), 2);
+    private final static int TAP_SLOP_SQUARE_PX = (int) Tools.dpToPx(2500);
 
     private final int mTapNumberToDetect;
     private int mCurrentTapNumber = 0;
@@ -83,8 +83,14 @@ public boolean onTouchEvent(MotionEvent e){
         if(mCurrentTapNumber > 0){
             if  ((deltaTime < TAP_MIN_DELTA_MS || deltaTime > TAP_MAX_DELTA_MS) ||
                 ((deltaX*deltaX + deltaY*deltaY) > TAP_SLOP_SQUARE_PX)) {
-                // We invalidate previous taps, not this one though
-                mCurrentTapNumber = 0;
+                if (mDetectionMethod == DETECTION_METHOD_BOTH && (eventAction == ACTION_UP || eventAction == ACTION_POINTER_UP)) {
+                    // For the both method, the user is expected to start with a down action.
+                    resetTapDetectionState();
+                    return false;
+                } else {
+                    // We invalidate previous taps, not this one though
+                    mCurrentTapNumber = 0;
+                }
             }
         }
 


Test patch: