"Fix" mouse poll based event

This commit is contained in:
SerpentSpirale 2021-11-26 00:06:32 +01:00
parent 3cfcae85de
commit 5289c0164f

View File

@ -3,6 +3,9 @@ import java.io.*;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.FloatBuffer; import java.nio.FloatBuffer;
import java.util.*; import java.util.*;
import android.os.Handler;
import android.os.Looper;
import android.widget.*; import android.widget.*;
import net.kdt.pojavlaunch.*; import net.kdt.pojavlaunch.*;
import android.content.*; import android.content.*;
@ -18,24 +21,11 @@ public class CallbackBridge {
public static float mouseX, mouseY; public static float mouseX, mouseY;
public static StringBuilder DEBUG_STRING = new StringBuilder(); public static StringBuilder DEBUG_STRING = new StringBuilder();
// volatile private static boolean isGrabbing = false;
public static class PusherRunnable implements Runnable { public static void putMouseEventWithCoords(int button, float x, float y) {
int button; float x; float y; putMouseEventWithCoords(button, true, x, y);
public PusherRunnable(int button, float x, float y) { Handler handler = new Handler(Looper.getMainLooper());
this.button = button; handler.postDelayed(() -> putMouseEventWithCoords(button, false, x, y), 18);
this.x = x;
this.y = y;
}
@Override
public void run() {
putMouseEventWithCoords(button, true, x, y);
//try { Thread.sleep(1); } catch (InterruptedException e) {}
putMouseEventWithCoords(button, false, x, y);
}
}
public static void putMouseEventWithCoords(int button, float x, float y /* , int dz, long nanos */) {
new Thread(new PusherRunnable(button,x,y)).run();
}
public static void putMouseEventWithCoords(int button, boolean isDown, float x, float y /* , int dz, long nanos */) { public static void putMouseEventWithCoords(int button, boolean isDown, float x, float y /* , int dz, long nanos */) {
sendCursorPos(x, y); sendCursorPos(x, y);