mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-13 23:00:45 -04:00
Remove dedicated thread from Touchpad
This commit is contained in:
parent
d3d1b5a0fb
commit
b9529a5f59
@ -40,6 +40,20 @@ public class Touchpad extends FrameLayout {
|
||||
private float mPrevX, mPrevY;
|
||||
/* Last first pointer positions non-scaled, used to scroll distance */
|
||||
private float mScrollLastInitialX, mScrollLastInitialY;
|
||||
/* Handler and message to check if we are grabbing */
|
||||
private final Runnable mGrabRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!CallbackBridge.isGrabbing() && mDisplayState && getVisibility() != VISIBLE) {
|
||||
enable();
|
||||
}else{
|
||||
if ((CallbackBridge.isGrabbing() && getVisibility() != View.GONE) || !mDisplayState && getVisibility() == VISIBLE) {
|
||||
disable();
|
||||
}
|
||||
}
|
||||
postDelayed(this, 250);
|
||||
}
|
||||
};
|
||||
|
||||
public Touchpad(@NonNull Context context) {
|
||||
this(context, null);
|
||||
@ -170,20 +184,7 @@ public class Touchpad extends FrameLayout {
|
||||
// When the game is grabbing, we should not display the mouse
|
||||
disable();
|
||||
mDisplayState = false;
|
||||
Thread virtualMouseGrabThread = new Thread(() -> {
|
||||
while (true) {
|
||||
if (!CallbackBridge.isGrabbing() && mDisplayState && getVisibility() != VISIBLE) {
|
||||
post(this::enable);
|
||||
}else{
|
||||
if ((CallbackBridge.isGrabbing() && getVisibility() != View.GONE) || !mDisplayState && getVisibility() == VISIBLE) {
|
||||
post(this::disable);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}, "VirtualMouseGrabThread");
|
||||
virtualMouseGrabThread.setPriority(Thread.MIN_PRIORITY);
|
||||
virtualMouseGrabThread.start();
|
||||
postDelayed(mGrabRunnable, 250);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user