mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-17 16:47:14 -04:00
the touchpad mouse tracking is good now !
This commit is contained in:
parent
7ed4607bc8
commit
283634cba2
@ -44,6 +44,9 @@ public class BaseMainActivity extends LoggableActivity {
|
|||||||
private final int fingerStillThreshold = 8;
|
private final int fingerStillThreshold = 8;
|
||||||
private int initialX, initialY;
|
private int initialX, initialY;
|
||||||
private int scrollInitialX, scrollInitialY;
|
private int scrollInitialX, scrollInitialY;
|
||||||
|
private float prevX, prevY;
|
||||||
|
private int currentPointerID;
|
||||||
|
|
||||||
private boolean mIsResuming = false;
|
private boolean mIsResuming = false;
|
||||||
private static final int MSG_LEFT_MOUSE_BUTTON_CHECK = 1028;
|
private static final int MSG_LEFT_MOUSE_BUTTON_CHECK = 1028;
|
||||||
private static final int MSG_DROP_ITEM_BUTTON_CHECK = 1029;
|
private static final int MSG_DROP_ITEM_BUTTON_CHECK = 1029;
|
||||||
@ -230,10 +233,7 @@ public class BaseMainActivity extends LoggableActivity {
|
|||||||
if (isAndroid8OrHigher()) {
|
if (isAndroid8OrHigher()) {
|
||||||
touchPad.setDefaultFocusHighlightEnabled(false);
|
touchPad.setDefaultFocusHighlightEnabled(false);
|
||||||
}
|
}
|
||||||
touchPad.setOnTouchListener(new OnTouchListener(){
|
touchPad.setOnTouchListener((v, event) -> {
|
||||||
private float prevX, prevY;
|
|
||||||
@Override
|
|
||||||
public boolean onTouch(View v, MotionEvent event) {
|
|
||||||
// MotionEvent reports input details from the touch screen
|
// MotionEvent reports input details from the touch screen
|
||||||
// and other input controls. In this case, you are only
|
// and other input controls. In this case, you are only
|
||||||
// interested in events where the touch position changed.
|
// interested in events where the touch position changed.
|
||||||
@ -247,32 +247,22 @@ public class BaseMainActivity extends LoggableActivity {
|
|||||||
|
|
||||||
float x = event.getX();
|
float x = event.getX();
|
||||||
float y = event.getY();
|
float y = event.getY();
|
||||||
if(event.getHistorySize() > 0) {
|
|
||||||
prevX = event.getHistoricalX(0);
|
|
||||||
prevY = event.getHistoricalY(0);
|
|
||||||
}else{
|
|
||||||
prevX = x;
|
|
||||||
prevY = y;
|
|
||||||
}
|
|
||||||
float mouseX = mousePointer.getTranslationX();
|
float mouseX = mousePointer.getTranslationX();
|
||||||
float mouseY = mousePointer.getTranslationY();
|
float mouseY = mousePointer.getTranslationY();
|
||||||
|
|
||||||
if (gestureDetector.onTouchEvent(event)) {
|
if (gestureDetector.onTouchEvent(event)) {
|
||||||
mouse_x = (int) (mouseX * scaleFactor);
|
mouse_x = (int) (mouseX * scaleFactor);
|
||||||
mouse_y = (int) (mouseY * scaleFactor);
|
mouse_y = (int) (mouseY * scaleFactor);
|
||||||
CallbackBridge.sendCursorPos((int) (mouseX * scaleFactor), (int) (mouseY *scaleFactor));
|
CallbackBridge.sendCursorPos(mouse_x, mouse_y);
|
||||||
CallbackBridge.sendMouseKeycode(rightOverride ? LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_RIGHT : LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_LEFT);
|
CallbackBridge.sendMouseKeycode(rightOverride ? LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_RIGHT : LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_LEFT);
|
||||||
if (!rightOverride) {
|
if (!rightOverride) CallbackBridge.mouseLeft = true;
|
||||||
CallbackBridge.mouseLeft = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case MotionEvent.ACTION_UP: // 1
|
case MotionEvent.ACTION_UP: // 1
|
||||||
case MotionEvent.ACTION_CANCEL: // 3
|
case MotionEvent.ACTION_CANCEL: // 3
|
||||||
if (!rightOverride) {
|
if (!rightOverride) CallbackBridge.mouseLeft = false;
|
||||||
CallbackBridge.mouseLeft = false;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MotionEvent.ACTION_POINTER_DOWN: // 5
|
case MotionEvent.ACTION_POINTER_DOWN: // 5
|
||||||
@ -280,7 +270,10 @@ public class BaseMainActivity extends LoggableActivity {
|
|||||||
scrollInitialY = CallbackBridge.mouseY;
|
scrollInitialY = CallbackBridge.mouseY;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MotionEvent.ACTION_POINTER_UP: // 6
|
case MotionEvent.ACTION_DOWN:
|
||||||
|
prevX = x;
|
||||||
|
prevY = y;
|
||||||
|
currentPointerID = event.getPointerId(0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MotionEvent.ACTION_MOVE: // 2
|
case MotionEvent.ACTION_MOVE: // 2
|
||||||
@ -290,19 +283,18 @@ public class BaseMainActivity extends LoggableActivity {
|
|||||||
scrollInitialX = CallbackBridge.mouseX;
|
scrollInitialX = CallbackBridge.mouseX;
|
||||||
scrollInitialY = CallbackBridge.mouseY;
|
scrollInitialY = CallbackBridge.mouseY;
|
||||||
} else {
|
} else {
|
||||||
mouseX = Math.max(0, Math.min(displayMetrics.widthPixels, mouseX + (x - prevX)*LauncherPreferences.PREF_MOUSESPEED));
|
if(currentPointerID == event.getPointerId(0)) {
|
||||||
mouseY = Math.max(0, Math.min(displayMetrics.heightPixels, mouseY + (y - prevY)*LauncherPreferences.PREF_MOUSESPEED));
|
mouseX = Math.max(0, Math.min(displayMetrics.widthPixels, mouseX + (x - prevX) * LauncherPreferences.PREF_MOUSESPEED));
|
||||||
|
mouseY = Math.max(0, Math.min(displayMetrics.heightPixels, mouseY + (y - prevY) * LauncherPreferences.PREF_MOUSESPEED));
|
||||||
mouse_x = (int) (mouseX * scaleFactor);
|
mouse_x = (int) (mouseX * scaleFactor);
|
||||||
mouse_y = (int) (mouseY * scaleFactor);
|
mouse_y = (int) (mouseY * scaleFactor);
|
||||||
placeMouseAt(mouseX, mouseY);
|
placeMouseAt(mouseX, mouseY);
|
||||||
CallbackBridge.sendCursorPos((int) (mouseX * scaleFactor), (int) (mouseY *scaleFactor));
|
CallbackBridge.sendCursorPos(mouse_x, mouse_y);
|
||||||
/*
|
}else currentPointerID = event.getPointerId(0);
|
||||||
if (!CallbackBridge.isGrabbing()) {
|
|
||||||
CallbackBridge.sendMouseKeycode(LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_LEFT, 0, isLeftMouseDown);
|
|
||||||
CallbackBridge.sendMouseKeycode(LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_RIGHT, 0, isRightMouseDown);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
prevX = x;
|
||||||
|
prevY = y;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -311,7 +303,6 @@ public class BaseMainActivity extends LoggableActivity {
|
|||||||
CallbackBridge.DEBUG_STRING.setLength(0);
|
CallbackBridge.DEBUG_STRING.setLength(0);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// System.loadLibrary("Regal");
|
// System.loadLibrary("Regal");
|
||||||
@ -320,8 +311,6 @@ public class BaseMainActivity extends LoggableActivity {
|
|||||||
glTouchListener = new OnTouchListener(){
|
glTouchListener = new OnTouchListener(){
|
||||||
private boolean isTouchInHotbar = false;
|
private boolean isTouchInHotbar = false;
|
||||||
private int hotbarX, hotbarY;
|
private int hotbarX, hotbarY;
|
||||||
private float prevX, prevY;
|
|
||||||
private int currentPointerID;
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouch(View p1, MotionEvent e) {
|
public boolean onTouch(View p1, MotionEvent e) {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user