Skip to content

Commit 773c23f

Browse files
committed
Inject finger input whenever possible
Even if the pointer is a mouse, inject it as a finger unless it is required to be a mouse, that is: - when it is a HOVER_MOUSE event, or - when a secondary button is pressed. Some apps/games only accept events from a finger/touchscreen, so using a mouse by default does not work for them. For simplicity, make this change on the server side just before event injection (so that the client does not need to know about this hacky behavior). Refs 6808288 Refs c7b1d0e Fixes #5162 <#5162> Fixes #5163 <#5163>
1 parent 992b492 commit 773c23f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

server/src/main/java/com/genymobile/scrcpy/control/Controller.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,9 @@ private boolean injectTouch(int action, long pointerId, Position position, float
278278
pointer.setPressure(pressure);
279279

280280
int source;
281-
if (pointerId == POINTER_ID_MOUSE) {
282-
// real mouse event
281+
boolean activeSecondaryButtons = ((actionButton | buttons) & ~MotionEvent.BUTTON_PRIMARY) != 0;
282+
if (pointerId == POINTER_ID_MOUSE && (action == MotionEvent.ACTION_HOVER_MOVE || activeSecondaryButtons)) {
283+
// real mouse event, or event incompatible with a finger
283284
pointerProperties[pointerIndex].toolType = MotionEvent.TOOL_TYPE_MOUSE;
284285
source = InputDevice.SOURCE_MOUSE;
285286
pointer.setUp(buttons == 0);

0 commit comments

Comments
 (0)