mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-16 16:16:04 -04:00
Fix hotbar taking mouse pass-through
This commit is contained in:
parent
58e2c2ff82
commit
d4e19bf6a8
@ -323,7 +323,6 @@ public class BaseMainActivity extends LoggableActivity {
|
|||||||
|
|
||||||
|
|
||||||
glTouchListener = new OnTouchListener(){
|
glTouchListener = new OnTouchListener(){
|
||||||
private boolean isTouchInHotbar = false;
|
|
||||||
private int lastHotbarKey = -1;
|
private int lastHotbarKey = -1;
|
||||||
/*
|
/*
|
||||||
* Tells if a double tap happened [MOUSE GRAB ONLY]. Doesn't tell where though.
|
* Tells if a double tap happened [MOUSE GRAB ONLY]. Doesn't tell where though.
|
||||||
@ -375,14 +374,9 @@ public class BaseMainActivity extends LoggableActivity {
|
|||||||
//shouldBeDown = true;
|
//shouldBeDown = true;
|
||||||
CallbackBridge.sendPrepareGrabInitialPos();
|
CallbackBridge.sendPrepareGrabInitialPos();
|
||||||
|
|
||||||
currentPointerID = e.getPointerId(0);
|
|
||||||
CallbackBridge.sendCursorPos(mouse_x, mouse_y);
|
|
||||||
prevX = e.getX();
|
|
||||||
prevY = e.getY();
|
|
||||||
|
|
||||||
int hudKeyHandled;
|
int hudKeyHandled = handleGuiBar((int)e.getX(), (int) e.getY());
|
||||||
hudKeyHandled = handleGuiBar((int)e.getX(), (int) e.getY());
|
boolean isTouchInHotbar = hudKeyHandled != -1;
|
||||||
isTouchInHotbar = hudKeyHandled != -1;
|
|
||||||
if (isTouchInHotbar) {
|
if (isTouchInHotbar) {
|
||||||
sendKeyPress(hudKeyHandled);
|
sendKeyPress(hudKeyHandled);
|
||||||
if(hasDoubleTapped && hudKeyHandled == lastHotbarKey){
|
if(hasDoubleTapped && hudKeyHandled == lastHotbarKey){
|
||||||
@ -396,12 +390,16 @@ public class BaseMainActivity extends LoggableActivity {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CallbackBridge.sendCursorPos(mouse_x, mouse_y);
|
||||||
|
prevX = e.getX();
|
||||||
|
prevY = e.getY();
|
||||||
|
|
||||||
if (CallbackBridge.isGrabbing()) {
|
if (CallbackBridge.isGrabbing()) {
|
||||||
|
currentPointerID = e.getPointerId(0);
|
||||||
// It cause hold left mouse while moving camera
|
// It cause hold left mouse while moving camera
|
||||||
initialX = mouse_x;
|
initialX = mouse_x;
|
||||||
initialY = mouse_y;
|
initialY = mouse_y;
|
||||||
if(!isTouchInHotbar) theHandler.sendEmptyMessageDelayed(BaseMainActivity.MSG_LEFT_MOUSE_BUTTON_CHECK, LauncherPreferences.PREF_LONGPRESS_TRIGGER);
|
theHandler.sendEmptyMessageDelayed(BaseMainActivity.MSG_LEFT_MOUSE_BUTTON_CHECK, LauncherPreferences.PREF_LONGPRESS_TRIGGER);
|
||||||
}
|
}
|
||||||
lastHotbarKey = hudKeyHandled;
|
lastHotbarKey = hudKeyHandled;
|
||||||
break;
|
break;
|
||||||
@ -411,6 +409,9 @@ public class BaseMainActivity extends LoggableActivity {
|
|||||||
shouldBeDown = false;
|
shouldBeDown = false;
|
||||||
currentPointerID = -1;
|
currentPointerID = -1;
|
||||||
|
|
||||||
|
hudKeyHandled = handleGuiBar((int)e.getX(), (int) e.getY());
|
||||||
|
isTouchInHotbar = hudKeyHandled != -1;
|
||||||
|
|
||||||
if (CallbackBridge.isGrabbing()) {
|
if (CallbackBridge.isGrabbing()) {
|
||||||
if (!isTouchInHotbar && !triggeredLeftMouseButton && Math.abs(initialX - mouse_x) < fingerStillThreshold && Math.abs(initialY - mouse_y) < fingerStillThreshold) {
|
if (!isTouchInHotbar && !triggeredLeftMouseButton && Math.abs(initialX - mouse_x) < fingerStillThreshold && Math.abs(initialY - mouse_y) < fingerStillThreshold) {
|
||||||
if (!LauncherPreferences.PREF_DISABLE_GESTURES) {
|
if (!LauncherPreferences.PREF_DISABLE_GESTURES) {
|
||||||
@ -463,18 +464,25 @@ public class BaseMainActivity extends LoggableActivity {
|
|||||||
CallbackBridge.sendCursorPos(mouse_x, mouse_y);
|
CallbackBridge.sendCursorPos(mouse_x, mouse_y);
|
||||||
prevX = e.getX();
|
prevX = e.getX();
|
||||||
prevY = e.getY();
|
prevY = e.getY();
|
||||||
} else if (!isTouchInHotbar) {
|
} else {
|
||||||
//Camera movement
|
//Camera movement
|
||||||
if (CallbackBridge.isGrabbing()) {
|
if (CallbackBridge.isGrabbing()) {
|
||||||
int pointerIndex = e.findPointerIndex(currentPointerID);
|
int pointerIndex = e.findPointerIndex(currentPointerID);
|
||||||
if (pointerIndex == -1 || lastPointerCount != e.getPointerCount() || !shouldBeDown) {
|
if (pointerIndex == -1 || lastPointerCount != e.getPointerCount() || !shouldBeDown) {
|
||||||
shouldBeDown = true;
|
shouldBeDown = true;
|
||||||
|
|
||||||
|
hudKeyHandled = handleGuiBar((int)e.getX(), (int) e.getY());
|
||||||
|
if(hudKeyHandled != -1) break; //No camera movement on hotbar
|
||||||
|
|
||||||
currentPointerID = e.getPointerId(0);
|
currentPointerID = e.getPointerId(0);
|
||||||
prevX = e.getX();
|
prevX = e.getX();
|
||||||
prevY = e.getY();
|
prevY = e.getY();
|
||||||
} else {
|
} else {
|
||||||
|
hudKeyHandled = handleGuiBar((int)e.getX(), (int) e.getY());
|
||||||
|
if(hudKeyHandled == -1){ //No camera on hotbar
|
||||||
mouse_x += (e.getX(pointerIndex) - prevX) * sensitivityFactor;
|
mouse_x += (e.getX(pointerIndex) - prevX) * sensitivityFactor;
|
||||||
mouse_y += (e.getY(pointerIndex) - prevY) * sensitivityFactor;
|
mouse_y += (e.getY(pointerIndex) - prevY) * sensitivityFactor;
|
||||||
|
}
|
||||||
|
|
||||||
prevX = e.getX(pointerIndex);
|
prevX = e.getX(pointerIndex);
|
||||||
prevY = e.getY(pointerIndex);
|
prevY = e.getY(pointerIndex);
|
||||||
@ -483,9 +491,10 @@ public class BaseMainActivity extends LoggableActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
lastPointerCount = e.getPointerCount();
|
lastPointerCount = e.getPointerCount();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user