Support sub-pixel cursor precision

This commit is contained in:
SerpentSpirale 2021-10-23 09:05:24 +02:00
parent 37202f21cd
commit d183c991a0
4 changed files with 13 additions and 13 deletions

View File

@ -49,7 +49,7 @@ public class BaseMainActivity extends LoggableActivity {
public double sensitivityFactor;
private final int fingerStillThreshold = (int) Tools.dpToPx(9);
private float initialX, initialY;
private int scrollInitialX, scrollInitialY;
private float scrollInitialX, scrollInitialY;
private float prevX, prevY;
private int currentPointerID;
@ -62,8 +62,8 @@ public class BaseMainActivity extends LoggableActivity {
switch (msg.what) {
case MSG_LEFT_MOUSE_BUTTON_CHECK:
if(LauncherPreferences.PREF_DISABLE_GESTURES) break;
int x = CallbackBridge.mouseX;
int y = CallbackBridge.mouseY;
float x = CallbackBridge.mouseX;
float y = CallbackBridge.mouseY;
if (CallbackBridge.isGrabbing() &&
Math.abs(initialX - x) < fingerStillThreshold &&
Math.abs(initialY - y) < fingerStillThreshold) {

View File

@ -49,8 +49,8 @@ public class JavaGUILauncherActivity extends LoggableActivity implements View.On
public void handleMessage(Message msg) {
switch (msg.what) {
case MSG_LEFT_MOUSE_BUTTON_CHECK: {
int x = CallbackBridge.mouseX;
int y = CallbackBridge.mouseY;
float x = CallbackBridge.mouseX;
float y = CallbackBridge.mouseY;
if (CallbackBridge.isGrabbing() &&
Math.abs(initialX - x) < fingerStillThreshold &&
Math.abs(initialY - y) < fingerStillThreshold) {

View File

@ -15,7 +15,7 @@ public class CallbackBridge {
public static volatile int windowWidth, windowHeight;
public static volatile int physicalWidth, physicalHeight;
public static int mouseX, mouseY;
public static float mouseX, mouseY;
public static StringBuilder DEBUG_STRING = new StringBuilder();
// volatile private static boolean isGrabbing = false;
@ -37,7 +37,7 @@ public class CallbackBridge {
new Thread(new PusherRunnable(button,x,y)).run();
}
public static void putMouseEventWithCoords(int button, boolean isDown, int x, int y /* , int dz, long nanos */) {
public static void putMouseEventWithCoords(int button, boolean isDown, float x, float y /* , int dz, long nanos */) {
sendCursorPos(x, y);
sendMouseKeycode(button, CallbackBridge.getCurrentMods(), isDown);
}
@ -49,8 +49,8 @@ public class CallbackBridge {
}
DEBUG_STRING.append("CursorPos=").append(x).append(", ").append(y).append("\n");
mouseX = (int) x;
mouseY = (int) y;
mouseX = x;
mouseY = y;
nativeSendCursorPos(mouseX, mouseY);
}
@ -201,7 +201,7 @@ public class CallbackBridge {
private static native boolean nativeSendCharMods(char codepoint, int mods);
private static native void nativeSendKey(int key, int scancode, int action, int mods);
// private static native void nativeSendCursorEnter(int entered);
private static native void nativeSendCursorPos(int x, int y);
private static native void nativeSendCursorPos(float x, float y);
private static native void nativeSendMouseButton(int button, int action, int mods);
private static native void nativeSendScroll(double xoffset, double yoffset);
private static native void nativeSendScreenSize(int width, int height);

View File

@ -37,7 +37,7 @@ typedef void GLFW_invoke_MouseButton_func(void* window, int button, int action,
typedef void GLFW_invoke_Scroll_func(void* window, double xoffset, double yoffset);
typedef void GLFW_invoke_WindowSize_func(void* window, int width, int height);
static int grabCursorX, grabCursorY, lastCursorX, lastCursorY;
static float grabCursorX, grabCursorY, lastCursorX, lastCursorY;
jclass inputBridgeClass_ANDROID, inputBridgeClass_JRE;
jmethodID inputBridgeMethod_ANDROID, inputBridgeMethod_JRE;
@ -126,7 +126,7 @@ void getJavaInputBridge(jclass* clazz, jmethodID* method) {
}
}
void sendData(int type, int i1, int i2, int i3, int i4) {
void sendData(int type, float i1, float i2, int i3, int i4) {
#ifdef DEBUG
LOGD("Debug: Send data, jnienv.isNull=%d\n", runtimeJNIEnvPtr_ANDROID == NULL);
#endif
@ -255,7 +255,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSendCursorEnter(
}
}
*/
JNIEXPORT void JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSendCursorPos(JNIEnv* env, jclass clazz, jint x, jint y) {
JNIEXPORT void JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSendCursorPos(JNIEnv* env, jclass clazz, jfloat x, jfloat y) {
if (GLFW_invoke_CursorPos && isInputReady) {
if (!isCursorEntered) {
if (GLFW_invoke_CursorEnter) {