Fix Y inverted

This commit is contained in:
khanhduytran0 2020-09-27 19:50:23 +07:00
parent e99c608434
commit c658d005c6
3 changed files with 22 additions and 20 deletions

View File

@ -403,14 +403,13 @@ public class MainActivity extends LoggableActivity implements OnTouchListener, O
{
// System.out.println("Pre touch, isTouchInHotbar=" + Boolean.toString(isTouchInHotbar) + ", action=" + MotionEvent.actionToString(e.getActionMasked()));
int x = ((int) e.getX()) / scaleFactor;
int y = (CallbackBridge.windowHeight - ((int) e.getY())) / scaleFactor;
int y = ((int) e.getY()) / scaleFactor;
int hudKeyHandled = handleGuiBar(x, y, e);
if (!CallbackBridge.isGrabbing() && gestureDetector.onTouchEvent(e)) {
if (hudKeyHandled != -1) {
sendKeyPress(hudKeyHandled);
} else {
CallbackBridge.putMouseEventWithCoords(rightOverride ? (byte) 1 : (byte) 0, (byte) 1, x, y, 0, System.nanoTime());
CallbackBridge.putMouseEventWithCoords(rightOverride ? (byte) 1 : (byte) 0, (byte) 0, x, y, 0, System.nanoTime());
CallbackBridge.putMouseEventWithCoords(rightOverride ? (byte) 1 : (byte) 0, x, y);
if (!rightOverride) {
CallbackBridge.mouseLeft = true;
}
@ -434,8 +433,7 @@ public class MainActivity extends LoggableActivity implements OnTouchListener, O
}
if (CallbackBridge.isGrabbing()) {
// bug hold left mouse!
CallbackBridge.putMouseEventWithCoords(rightOverride ? (byte) 1 : (byte) 0, (byte) 1, x, y, 0, System.nanoTime());
CallbackBridge.putMouseEventWithCoords(rightOverride ? (byte) 1 : (byte) 0, (byte) 1, x, y);
initialX = x;
initialY = y;
theHandler.sendEmptyMessageDelayed(MainActivity.MSG_LEFT_MOUSE_BUTTON_CHECK, LauncherPreferences.PREF_LONGPRESS_TRIGGER);
@ -450,7 +448,7 @@ public class MainActivity extends LoggableActivity implements OnTouchListener, O
CallbackBridge.mouseY = y;
// TODO uncomment after fix wrong trigger
// CallbackBridge.putMouseEventWithCoords(rightOverride ? (byte) 1 : (byte) 0, (byte) 0, x, y, 0, System.nanoTime());
// CallbackBridge.putMouseEventWithCoords(rightOverride ? (byte) 1 : (byte) 0, (byte) 0, x, y);
if (!rightOverride) {
CallbackBridge.mouseLeft = false;
}
@ -487,7 +485,6 @@ public class MainActivity extends LoggableActivity implements OnTouchListener, O
}
}
/*
int x = ((int) e.getX()) / scaleFactor;
int y = (minecraftGLView.getHeight() - ((int) e.getY())) / scaleFactor;
@ -538,7 +535,7 @@ public class MainActivity extends LoggableActivity implements OnTouchListener, O
CallbackBridge.sendCursorPos(x, CallbackBridge.windowHeight - y);
// TODO uncomment after fix wrong trigger
// CallbackBridge.putMouseEventWithCoords(rightOverride ? (byte) 1 : (byte) 0, (byte) 0, x, y, 0, System.nanoTime());
// CallbackBridge.putMouseEventWithCoords(rightOverride ? (byte) 1 : (byte) 0, (byte) 0, x, y);
if (!rightOverride) {
// CallbackBridge.mouseLeft = false;
}
@ -655,7 +652,7 @@ public class MainActivity extends LoggableActivity implements OnTouchListener, O
case MotionEvent.ACTION_POINTER_UP: // 6
CallbackBridge.sendCursorPos(x, y);
CallbackBridge.sendMouseKeycode(rightOverride ? LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_RIGHT : LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_LEFT, 0, true);
// CallbackBridge.putMouseEventWithCoords(!CallbackBridge.mouseLeft /* rightOverride */ ? (byte) 1 : (byte) 0, (byte) 0, x, y, 0, System.nanoTime());
// CallbackBridge.putMouseEventWithCoords(!CallbackBridge.mouseLeft /* rightOverride */ ? (byte) 1 : (byte) 0, (byte) 0, x, y);
/*
if (!triggeredLeftMouseButton && Math.abs(initialX - x) < fingerStillThreshold && Math.abs(initialY - y) < fingerStillThreshold) {
sendMouseButton(1, true);
@ -887,7 +884,7 @@ public class MainActivity extends LoggableActivity implements OnTouchListener, O
}
*/
CallbackBridge.putMouseEventWithCoords(LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_RIGHT, isDown ? 1 : 0, CallbackBridge.mouseX, CallbackBridge.mouseY, 0, 0l);
CallbackBridge.putMouseEventWithCoords(LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_RIGHT, isDown ? 1 : 0, CallbackBridge.mouseX, CallbackBridge.mouseY);
setRightOverride(isDown);
} break;

View File

@ -186,7 +186,7 @@ public final class Tools
// Should be compatible?
// overrideableArgList.add("-Dos.name=Android");
overrideableArgList.add("-Dos.name=Linux");
overrideableArgList.add("-Dos.version=" + Build.VERSION.SDK);
overrideableArgList.add("-Dos.version=" + Build.VERSION.RELEASE);
// javaArgList.add("-Dorg.lwjgl.libname=liblwjgl3.so");
// javaArgList.add("-Dorg.lwjgl.system.jemalloc.libname=libjemalloc.so");

View File

@ -20,7 +20,12 @@ public class CallbackBridge {
// volatile private static boolean isGrabbing = false;
public static void putMouseEventWithCoords(int button, int state, int x, int y, int dz, long nanos) {
public static void putMouseEventWithCoords(int button, int x, int y /* , int dz, long nanos */) {
putMouseEventWithCoords(button, 1, x, y);
putMouseEventWithCoords(button, 0, x, y);
}
public static void putMouseEventWithCoords(int button, int state, int x, int y /* , int dz, long nanos */) {
sendCursorPos(x, y);
sendMouseKeycode(button, 0, state == 1);
}