Back to grab check

This commit is contained in:
khanhduytran0 2020-09-27 17:53:22 +07:00
parent 1645902524
commit 41e6935914

View file

@ -433,10 +433,12 @@ public class MainActivity extends LoggableActivity implements OnTouchListener, O
CallbackBridge.mouseLeft = true; CallbackBridge.mouseLeft = true;
} }
// CallbackBridge.putMouseEventWithCoords(rightOverride ? (byte) 1 : (byte) 0, (byte) 1, x, y, 0, System.nanoTime()); if (CallbackBridge.isGrabbing()) {
initialX = x; // CallbackBridge.putMouseEventWithCoords(rightOverride ? (byte) 1 : (byte) 0, (byte) 1, x, y, 0, System.nanoTime());
initialY = y; initialX = x;
theHandler.sendEmptyMessageDelayed(MainActivity.MSG_LEFT_MOUSE_BUTTON_CHECK, LauncherPreferences.PREF_LONGPRESS_TRIGGER); initialY = y;
theHandler.sendEmptyMessageDelayed(MainActivity.MSG_LEFT_MOUSE_BUTTON_CHECK, LauncherPreferences.PREF_LONGPRESS_TRIGGER);
}
} }
break; break;
case MotionEvent.ACTION_UP: // 1 case MotionEvent.ACTION_UP: // 1
@ -452,24 +454,26 @@ public class MainActivity extends LoggableActivity implements OnTouchListener, O
CallbackBridge.mouseLeft = false; CallbackBridge.mouseLeft = false;
} }
} }
// System.out.println((String) ("[Math.abs(" + initialX + " - " + x + ") = " + Math.abs(initialX - x) + "] < " + fingerStillThreshold)); if (CallbackBridge.isGrabbing()) {
// System.out.println((String) ("[Math.abs(" + initialY + " - " + y + ") = " + Math.abs(initialY - y) + "] < " + fingerStillThreshold)); // System.out.println((String) ("[Math.abs(" + initialX + " - " + x + ") = " + Math.abs(initialX - x) + "] < " + fingerStillThreshold));
if (isTouchInHotbar && Math.abs(hotbarX - x) < fingerStillThreshold && Math.abs(hotbarY - y) < fingerStillThreshold) { // System.out.println((String) ("[Math.abs(" + initialY + " - " + y + ") = " + Math.abs(initialY - y) + "] < " + fingerStillThreshold));
sendKeyPress(hudKeyHandled, 0, false); if (isTouchInHotbar && Math.abs(hotbarX - x) < fingerStillThreshold && Math.abs(hotbarY - y) < fingerStillThreshold) {
} else if (!triggeredLeftMouseButton && Math.abs(initialX - x) < fingerStillThreshold && Math.abs(initialY - y) < fingerStillThreshold) { sendKeyPress(hudKeyHandled, 0, false);
sendMouseButton(1, true); } else if (!triggeredLeftMouseButton && Math.abs(initialX - x) < fingerStillThreshold && Math.abs(initialY - y) < fingerStillThreshold) {
sendMouseButton(1, false); sendMouseButton(1, true);
} sendMouseButton(1, false);
if (!isTouchInHotbar) { }
if (triggeredLeftMouseButton) { if (!isTouchInHotbar) {
sendMouseButton(0, false); if (triggeredLeftMouseButton) {
sendMouseButton(0, false);
}
triggeredLeftMouseButton = false;
theHandler.removeMessages(MainActivity.MSG_LEFT_MOUSE_BUTTON_CHECK);
} else {
sendKeyPress(LWJGLGLFWKeycode.GLFW_KEY_Q, 0, false);
theHandler.removeMessages(MSG_DROP_ITEM_BUTTON_CHECK);
} }
triggeredLeftMouseButton = false;
theHandler.removeMessages(MainActivity.MSG_LEFT_MOUSE_BUTTON_CHECK);
} else {
sendKeyPress(LWJGLGLFWKeycode.GLFW_KEY_Q, 0, false);
theHandler.removeMessages(MSG_DROP_ITEM_BUTTON_CHECK);
} }
break; break;