mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-17 00:29:50 -04:00
Fix(gui event processor): remove double clicks, handle all res when tracking still finger, instant clicks (#5635)
This commit is contained in:
parent
856bace37c
commit
d23bdb9ffa
@ -29,6 +29,8 @@ public class InGUIEventProcessor implements TouchEventProcessor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean processTouchEvent(MotionEvent motionEvent) {
|
public boolean processTouchEvent(MotionEvent motionEvent) {
|
||||||
|
boolean singleTap = mSingleTapDetector.onTouchEvent(motionEvent);
|
||||||
|
|
||||||
switch (motionEvent.getActionMasked()) {
|
switch (motionEvent.getActionMasked()) {
|
||||||
case MotionEvent.ACTION_DOWN:
|
case MotionEvent.ACTION_DOWN:
|
||||||
mTracker.startTracking(motionEvent);
|
mTracker.startTracking(motionEvent);
|
||||||
@ -66,13 +68,17 @@ public class InGUIEventProcessor implements TouchEventProcessor {
|
|||||||
case MotionEvent.ACTION_UP:
|
case MotionEvent.ACTION_UP:
|
||||||
mScroller.resetScrollOvershoot();
|
mScroller.resetScrollOvershoot();
|
||||||
mTracker.cancelTracking();
|
mTracker.cancelTracking();
|
||||||
|
|
||||||
|
// Handle single tap on gestures
|
||||||
|
if((!LauncherPreferences.PREF_DISABLE_GESTURES || touchpadDisplayed()) && !mIsMouseDown && singleTap) {
|
||||||
|
CallbackBridge.putMouseEventWithCoords(LwjglGlfwKeycode.GLFW_MOUSE_BUTTON_LEFT, CallbackBridge.mouseX, CallbackBridge.mouseY);
|
||||||
|
}
|
||||||
|
|
||||||
if(mIsMouseDown) disableMouse();
|
if(mIsMouseDown) disableMouse();
|
||||||
resetGesture();
|
resetGesture();
|
||||||
}
|
}
|
||||||
|
|
||||||
if((!LauncherPreferences.PREF_DISABLE_GESTURES || touchpadDisplayed()) && mSingleTapDetector.onTouchEvent(motionEvent)) {
|
|
||||||
clickMouse();
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,14 +104,9 @@ public class InGUIEventProcessor implements TouchEventProcessor {
|
|||||||
mIsMouseDown = false;
|
mIsMouseDown = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clickMouse() {
|
|
||||||
CallbackBridge.sendMouseButton(LwjglGlfwKeycode.GLFW_MOUSE_BUTTON_LEFT, true);
|
|
||||||
CallbackBridge.sendMouseButton(LwjglGlfwKeycode.GLFW_MOUSE_BUTTON_LEFT, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setGestureStart(MotionEvent event) {
|
private void setGestureStart(MotionEvent event) {
|
||||||
mStartX = event.getX();
|
mStartX = event.getX() * mScaleFactor;
|
||||||
mStartY = event.getY();
|
mStartY = event.getY() * mScaleFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetGesture() {
|
private void resetGesture() {
|
||||||
|
@ -20,7 +20,7 @@ public class TapDetector {
|
|||||||
public final static int DETECTION_METHOD_UP = 0x2;
|
public final static int DETECTION_METHOD_UP = 0x2;
|
||||||
public final static int DETECTION_METHOD_BOTH = 0x3; //Unused for now
|
public final static int DETECTION_METHOD_BOTH = 0x3; //Unused for now
|
||||||
|
|
||||||
private final static int TAP_MIN_DELTA_MS = 10;
|
private final static int TAP_MIN_DELTA_MS = -1;
|
||||||
private final static int TAP_MAX_DELTA_MS = 300;
|
private final static int TAP_MAX_DELTA_MS = 300;
|
||||||
private final static int TAP_SLOP_SQUARE_PX = (int) Tools.dpToPx(2500);
|
private final static int TAP_SLOP_SQUARE_PX = (int) Tools.dpToPx(2500);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user