mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-10 13:16:04 -04:00
Clean[touch]: remove old commented touch processing code
This commit is contained in:
parent
91467ef78f
commit
93cf884d8b
@ -181,163 +181,6 @@ public class MinecraftGLSurface extends View implements GrabListener {
|
|||||||
return true; //mouse event handled successfully
|
return true; //mouse event handled successfully
|
||||||
}
|
}
|
||||||
|
|
||||||
// System.out.println("Pre touch, isTouchInHotbar=" + Boolean.toString(isTouchInHotbar) + ", action=" + MotionEvent.actionToString(e.getActionMasked()));
|
|
||||||
|
|
||||||
//Getting scaled position from the event
|
|
||||||
/* Tells if a double tap happened [MOUSE GRAB ONLY]. Doesn't tell where though. */
|
|
||||||
/*if(!CallbackBridge.isGrabbing()) {
|
|
||||||
CallbackBridge.mouseX = (e.getX() * mScaleFactor);
|
|
||||||
CallbackBridge.mouseY = (e.getY() * mScaleFactor);
|
|
||||||
//One android click = one MC click
|
|
||||||
if(mSingleTapDetector.onTouchEvent(e)){
|
|
||||||
CallbackBridge.putMouseEventWithCoords(LwjglGlfwKeycode.GLFW_MOUSE_BUTTON_LEFT, CallbackBridge.mouseX, CallbackBridge.mouseY);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check double tap state, used for the hotbar
|
|
||||||
boolean hasDoubleTapped = mDoubleTapDetector.onTouchEvent(e);
|
|
||||||
|
|
||||||
switch (e.getActionMasked()) {
|
|
||||||
case MotionEvent.ACTION_MOVE:
|
|
||||||
int pointerCount = e.getPointerCount();
|
|
||||||
|
|
||||||
// In-menu interactions
|
|
||||||
if(!CallbackBridge.isGrabbing()){
|
|
||||||
|
|
||||||
// Touch hover
|
|
||||||
if(pointerCount == 1){
|
|
||||||
CallbackBridge.sendCursorPos(CallbackBridge.mouseX, CallbackBridge.mouseY);
|
|
||||||
mPrevX = e.getX();
|
|
||||||
mPrevY = e.getY();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Scrolling feature
|
|
||||||
if(LauncherPreferences.PREF_DISABLE_GESTURES) break;
|
|
||||||
// The pointer count can never be 0, and it is not 1, therefore it is >= 2
|
|
||||||
int hScroll = ((int) (e.getX() - mScrollLastInitialX)) / FINGER_SCROLL_THRESHOLD;
|
|
||||||
int vScroll = ((int) (e.getY() - mScrollLastInitialY)) / FINGER_SCROLL_THRESHOLD;
|
|
||||||
|
|
||||||
if(vScroll != 0 || hScroll != 0){
|
|
||||||
CallbackBridge.sendScroll(hScroll, vScroll);
|
|
||||||
mScrollLastInitialX = e.getX();
|
|
||||||
mScrollLastInitialY = e.getY();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Camera movement
|
|
||||||
int pointerIndex = e.findPointerIndex(mCurrentPointerID);
|
|
||||||
int hudKeyHandled = handleGuiBar((int)e.getX(), (int) e.getY());
|
|
||||||
// Start movement, due to new pointer or loss of pointer
|
|
||||||
if (pointerIndex == -1 || mLastPointerCount != pointerCount || !mShouldBeDown) {
|
|
||||||
if(hudKeyHandled != -1) break; //No pointer attribution on hotbar
|
|
||||||
|
|
||||||
mShouldBeDown = true;
|
|
||||||
mCurrentPointerID = e.getPointerId(0);
|
|
||||||
mPrevX = e.getX();
|
|
||||||
mPrevY = e.getY();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// Continue movement as usual
|
|
||||||
if(hudKeyHandled == -1){ //No camera on hotbar
|
|
||||||
CallbackBridge.mouseX += (e.getX(pointerIndex) - mPrevX) * mSensitivityFactor;
|
|
||||||
CallbackBridge.mouseY += (e.getY(pointerIndex) - mPrevY) * mSensitivityFactor;
|
|
||||||
}
|
|
||||||
|
|
||||||
mPrevX = e.getX(pointerIndex);
|
|
||||||
mPrevY = e.getY(pointerIndex);
|
|
||||||
|
|
||||||
CallbackBridge.sendCursorPos(CallbackBridge.mouseX, CallbackBridge.mouseY);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MotionEvent.ACTION_DOWN: // 0
|
|
||||||
hudKeyHandled = handleGuiBar((int)e.getX(), (int) e.getY());
|
|
||||||
boolean isTouchInHotbar = hudKeyHandled != -1;
|
|
||||||
if (isTouchInHotbar) {
|
|
||||||
sendKeyPress(hudKeyHandled);
|
|
||||||
if(hasDoubleTapped && hudKeyHandled == mLastHotbarKey && !PREF_DISABLE_SWAP_HAND){
|
|
||||||
//Prevent double tapping Event on two different slots
|
|
||||||
sendKeyPress(LwjglGlfwKeycode.GLFW_KEY_F);
|
|
||||||
} else {
|
|
||||||
mHandler.sendEmptyMessageDelayed(MSG_DROP_ITEM_BUTTON_CHECK, 350);
|
|
||||||
}
|
|
||||||
|
|
||||||
CallbackBridge.sendCursorPos(CallbackBridge.mouseX, CallbackBridge.mouseY);
|
|
||||||
mLastHotbarKey = hudKeyHandled;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
CallbackBridge.sendCursorPos(CallbackBridge.mouseX, CallbackBridge.mouseY);
|
|
||||||
mPrevX = e.getX();
|
|
||||||
mPrevY = e.getY();
|
|
||||||
|
|
||||||
if (CallbackBridge.isGrabbing()) {
|
|
||||||
mCurrentPointerID = e.getPointerId(0);
|
|
||||||
// It cause hold left mouse while moving camera
|
|
||||||
mInitialX = CallbackBridge.mouseX;
|
|
||||||
mInitialY = CallbackBridge.mouseY;
|
|
||||||
mHandler.sendEmptyMessageDelayed(MSG_LEFT_MOUSE_BUTTON_CHECK, LauncherPreferences.PREF_LONGPRESS_TRIGGER);
|
|
||||||
}
|
|
||||||
mLastHotbarKey = hudKeyHandled;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MotionEvent.ACTION_UP: // 1
|
|
||||||
case MotionEvent.ACTION_CANCEL: // 3
|
|
||||||
mShouldBeDown = false;
|
|
||||||
mCurrentPointerID = -1;
|
|
||||||
|
|
||||||
hudKeyHandled = handleGuiBar((int)e.getX(), (int) e.getY());
|
|
||||||
isTouchInHotbar = hudKeyHandled != -1;
|
|
||||||
// We only treat in world events
|
|
||||||
if (!CallbackBridge.isGrabbing()) break;
|
|
||||||
|
|
||||||
// Stop the dropping of items
|
|
||||||
sendKeyPress(LwjglGlfwKeycode.GLFW_KEY_Q, 0, false);
|
|
||||||
mHandler.removeMessages(MSG_DROP_ITEM_BUTTON_CHECK);
|
|
||||||
|
|
||||||
// Remove the mouse left button
|
|
||||||
if(triggeredLeftMouseButton){
|
|
||||||
sendMouseButton(LwjglGlfwKeycode.GLFW_MOUSE_BUTTON_LEFT, false);
|
|
||||||
triggeredLeftMouseButton = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
mHandler.removeMessages(MSG_LEFT_MOUSE_BUTTON_CHECK);
|
|
||||||
|
|
||||||
// In case of a short click, just send a quick right click
|
|
||||||
if(!LauncherPreferences.PREF_DISABLE_GESTURES &&
|
|
||||||
MathUtils.dist(mInitialX, mInitialY, CallbackBridge.mouseX, CallbackBridge.mouseY) < FINGER_STILL_THRESHOLD){
|
|
||||||
sendMouseButton(LwjglGlfwKeycode.GLFW_MOUSE_BUTTON_RIGHT, true);
|
|
||||||
sendMouseButton(LwjglGlfwKeycode.GLFW_MOUSE_BUTTON_RIGHT, false);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MotionEvent.ACTION_POINTER_DOWN: // 5
|
|
||||||
//TODO Hey we could have some sort of middle click detection ?
|
|
||||||
|
|
||||||
mScrollLastInitialX = e.getX();
|
|
||||||
mScrollLastInitialY = e.getY();
|
|
||||||
//Checking if we are pressing the hotbar to select the item
|
|
||||||
hudKeyHandled = handleGuiBar((int)e.getX(e.getPointerCount()-1), (int) e.getY(e.getPointerCount()-1));
|
|
||||||
if(hudKeyHandled != -1){
|
|
||||||
sendKeyPress(hudKeyHandled);
|
|
||||||
if(hasDoubleTapped && hudKeyHandled == mLastHotbarKey){
|
|
||||||
//Prevent double tapping Event on two different slots
|
|
||||||
sendKeyPress(LwjglGlfwKeycode.GLFW_KEY_F);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mLastHotbarKey = hudKeyHandled;
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Actualise the pointer count
|
|
||||||
mLastPointerCount = e.getPointerCount();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
*/
|
|
||||||
boolean isGrabbing = CallbackBridge.isGrabbing();
|
boolean isGrabbing = CallbackBridge.isGrabbing();
|
||||||
if(mLastGrabState != isGrabbing) {
|
if(mLastGrabState != isGrabbing) {
|
||||||
pickEventProcessor(mLastGrabState).cancelPendingActions();
|
pickEventProcessor(mLastGrabState).cancelPendingActions();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user