From 0308ef43f22b5e3e937869b30326bd7209242e9a Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Mon, 15 Mar 2021 18:43:30 +0100 Subject: [PATCH] Do not set buttons on touch events BUTTON_PRIMARY must not be set for touch events: > This button constant is not set in response to simple touches with a > finger or stylus tip. The user must actually push a button. Fixes #2169 --- server/src/main/java/com/genymobile/scrcpy/Controller.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server/src/main/java/com/genymobile/scrcpy/Controller.java b/server/src/main/java/com/genymobile/scrcpy/Controller.java index 2c5a1277..8f262ab6 100644 --- a/server/src/main/java/com/genymobile/scrcpy/Controller.java +++ b/server/src/main/java/com/genymobile/scrcpy/Controller.java @@ -208,6 +208,10 @@ public class Controller { // Right-click and middle-click only work if the source is a mouse boolean nonPrimaryButtonPressed = (buttons & ~MotionEvent.BUTTON_PRIMARY) != 0; int source = nonPrimaryButtonPressed ? InputDevice.SOURCE_MOUSE : InputDevice.SOURCE_TOUCHSCREEN; + if (source != InputDevice.SOURCE_MOUSE) { + // Buttons must not be set for touch events + buttons = 0; + } MotionEvent event = MotionEvent .obtain(lastTouchDown, now, action, pointerCount, pointerProperties, pointerCoords, 0, buttons, 1f, 1f, DEFAULT_DEVICE_ID, 0, source,