Skip to content

Commit

Permalink
touchpad: Fixed crash when using touchpad and input controls at the s…
Browse files Browse the repository at this point in the history
…ame time.
  • Loading branch information
longjunyu2 committed Aug 22, 2024
1 parent 0c3e7c7 commit 0fe7b92
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app/src/main/java/com/winlator/widget/TouchpadView.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,17 @@ public boolean onTouchEvent(MotionEvent event) {
}
postDelayed(clickDelay, CLICK_DELAYED_TIME);
} else if (pointerId == 1) {
continueClick = System.currentTimeMillis() - fingers[0].touchTime > CLICK_DELAYED_TIME;
// When put a finger on InputControl, such as a button.
// The pointerId that TouchPadView got won't increase from 1, so map 1 as 0 here.
if (numFingers < 2) {
continueClick = true;
if (Math.hypot(fingers[1].x - lastTouchedPosX, fingers[1].y - lastTouchedPosY) * resolutionScale > EFFECTIVE_TOUCH_DISTANCE) {
lastTouchedPosX = fingers[1].x;
lastTouchedPosY = fingers[1].y;
}
postDelayed(clickDelay, CLICK_DELAYED_TIME);
} else
continueClick = System.currentTimeMillis() - fingers[0].touchTime > CLICK_DELAYED_TIME;
}
}
break;
Expand Down

0 comments on commit 0fe7b92

Please sign in to comment.