mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-18 17:15:40 -04:00
"Fix" mouse poll based event
This commit is contained in:
parent
3cfcae85de
commit
5289c0164f
@ -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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user