diff --git a/app/src/main/java/xtr/keymapper/server/Input.java b/app/src/main/java/xtr/keymapper/server/Input.java index 5666fd73..87ee176f 100644 --- a/app/src/main/java/xtr/keymapper/server/Input.java +++ b/app/src/main/java/xtr/keymapper/server/Input.java @@ -26,6 +26,7 @@ public class Input { private long lastTouchDown; private final SmoothScroll scrollHandler = new SmoothScroll(); private Handler mHandler; + public int pointerCount; private void initPointers() { for (int i = 0; i < PointersState.MAX_POINTERS; ++i) { @@ -58,7 +59,7 @@ public void injectTouch(int action, int pointerId, float pressure, float x, floa pointer.setPressure(pressure); pointer.setUp(action == MotionEvent.ACTION_UP); - int pointerCount = pointersState.update(pointerProperties, pointerCoords); + pointerCount = pointersState.update(pointerProperties, pointerCoords); if (pointerCount == 1) { if (action == MotionEvent.ACTION_DOWN) { diff --git a/app/src/main/java/xtr/keymapper/server/InputService.java b/app/src/main/java/xtr/keymapper/server/InputService.java index d53a0d52..34035a3c 100644 --- a/app/src/main/java/xtr/keymapper/server/InputService.java +++ b/app/src/main/java/xtr/keymapper/server/InputService.java @@ -21,6 +21,7 @@ public class InputService implements IInputInterface { private final IRemoteServiceCallback mCallback; final int supportsUinput; boolean stopEvents = false; + boolean pointerUp = false; private final boolean isWaylandClient; public InputService(KeymapProfile profile, KeymapConfig keymapConfig, IRemoteServiceCallback mCallback, int screenWidth, int screenHeight, boolean isWaylandClient){ @@ -40,9 +41,11 @@ public InputService(KeymapProfile profile, KeymapConfig keymapConfig, IRemoteSer public void injectEvent(float x, float y, int action, int pointerId) { switch (action) { case UP: + pointerUp = true; input.injectTouch(MotionEvent.ACTION_UP, pointerId, 0.0f, x, y); break; case DOWN: + pointerUp = false; input.injectTouch(MotionEvent.ACTION_DOWN, pointerId, 1.0f, x, y); break; case MOVE: @@ -89,6 +92,8 @@ public void moveCursorX(float x) { mCallback.cursorSetX((int) x); } catch (RemoteException ignored) { } + if (input.pointerCount < 1) cursorSetX((int) x); + else if (input.pointerCount == 1 && pointerUp) cursorSetX((int) x); } public void moveCursorY(float y) { @@ -96,6 +101,8 @@ public void moveCursorY(float y) { mCallback.cursorSetY((int) y); } catch (RemoteException ignored) { } + if (input.pointerCount < 1) cursorSetY((int) y); + else if (input.pointerCount == 1 && pointerUp) cursorSetY((int) y); } public void reloadKeymap() {