Fix for real this time

This commit is contained in:
SerpentSpirale 2021-11-23 10:35:08 +01:00 committed by Boulay Mathias
parent 3a6c8cf893
commit 8ed8dee6f8

View file

@ -34,6 +34,8 @@ import org.lwjgl.glfw.CallbackBridge;
public class Touchpad extends FrameLayout {
/* Whether the Touchpad should be displayed */
private boolean displayState;
/* The last grabbed state from the CallbackBridge */
boolean lastGrab = false;
/* Mouse pointer icon used by the touchpad */
private final ImageView mousePointer = new ImageView(getContext());
@ -75,21 +77,25 @@ public class Touchpad extends FrameLayout {
}
// When the game is grabbing, we should not display the mouse
Thread isGrabbingThread = new Thread(() -> {
while(true){
if(!displayState || CallbackBridge.isGrabbing()){
post(() -> disable());
}else {
disable();
displayState = false;
Thread virtualMouseGrabThread = new Thread(() -> {
while (true) {
if (lastGrab != CallbackBridge.isGrabbing())
post(() -> {
if(displayState) enable();
if (!CallbackBridge.isGrabbing() && displayState) {
enable();
}else{
if (CallbackBridge.isGrabbing() && getVisibility() != View.GONE) {
disable();
}
}
lastGrab = CallbackBridge.isGrabbing();
});
}
}
});
isGrabbingThread.setPriority(Thread.MIN_PRIORITY);
isGrabbingThread.start();
}, "VirtualMouseGrabThread");
virtualMouseGrabThread.setPriority(Thread.MIN_PRIORITY);
virtualMouseGrabThread.start();
}
/** Enable the touchpad */