Skip to content

Commit 625a029

Browse files
committed
fix(Pointer): Properly handle hold-clicks
1 parent 4dafce0 commit 625a029

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/MinecraftGLSurface.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package net.kdt.pojavlaunch;
22

33
import static net.kdt.pojavlaunch.MainActivity.touchCharInput;
4+
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_MOUSE_GRAB_FORCE;
45
import static net.kdt.pojavlaunch.utils.MCOptionUtils.getMcScale;
56
import static org.lwjgl.glfw.CallbackBridge.sendMouseButton;
67
import static org.lwjgl.glfw.CallbackBridge.windowHeight;
@@ -193,6 +194,13 @@ public boolean onTouchEvent(MotionEvent e) {
193194
if(toolType == MotionEvent.TOOL_TYPE_MOUSE) {
194195
if(Tools.isAndroid8OrHigher() &&
195196
mPointerCapture != null) {
197+
// Can't handleAutomaticCapture if mouse isn't captured
198+
if (!CallbackBridge.isGrabbing() // Only capture if not in menu and user said so
199+
&& !PREF_MOUSE_GRAB_FORCE) {
200+
// This returns true but we really can't consume this.
201+
// Else we don't receive ACTION_MOVE
202+
return !dispatchGenericMotionEvent(e);
203+
}
196204
mPointerCapture.handleAutomaticCapture();
197205
return true;
198206
}
@@ -241,9 +249,9 @@ public boolean dispatchGenericMotionEvent(MotionEvent event) {
241249

242250
// Make sure we grabbed the mouse if necessary
243251
updateGrabState(CallbackBridge.isGrabbing());
244-
245252
switch(event.getActionMasked()) {
246253
case MotionEvent.ACTION_HOVER_MOVE:
254+
case MotionEvent.ACTION_MOVE:
247255
CallbackBridge.mouseX = (event.getX(mouseCursorIndex) * LauncherPreferences.PREF_SCALE_FACTOR);
248256
CallbackBridge.mouseY = (event.getY(mouseCursorIndex) * LauncherPreferences.PREF_SCALE_FACTOR);
249257
CallbackBridge.sendCursorPos(CallbackBridge.mouseX, CallbackBridge.mouseY);

0 commit comments

Comments
 (0)