scrcpy icon indicating copy to clipboard operation
scrcpy copied to clipboard

scrcpy reporting hover events with tool type mouse, but click with tool type finger

Open gmackall opened this issue 7 months ago • 1 comments

Hi, I have a question about how scrcpy delivers MotionEvents https://github.com/Genymobile/scrcpy/blob/c5ed2cfc28ee7c7b59b11eb4db1258ac1c633bff/server/src/main/java/com/genymobile/scrcpy/control/Controller.java#L408C68-L408C83

https://github.com/Genymobile/scrcpy/blob/c5ed2cfc28ee7c7b59b11eb4db1258ac1c633bff/server/src/main/java/com/genymobile/scrcpy/control/Controller.java#L413

In particular, why does scrcpy deliver mouse clicks as originating from a TOOL_TYPE_FINGER, (or more generally MotionEvents that are not of type MotionEvent.ACTION_HOVER_MOVE, and therefore continue to the else case)? Is this intentional?

My motivation for asking is that I'm wondering how Flutter should handle these inputs from scrcpy, as it is currently the source of a bug (https://github.com/flutter/flutter/issues/160144)

gmackall avatar May 21 '25 22:05 gmackall

In particular, why does scrcpy deliver mouse clicks as originating from a TOOL_TYPE_FINGER, (or more generally MotionEvents that are not of type MotionEvent.ACTION_HOVER_MOVE, and therefore continue to the else case)? Is this intentional?

Yes. The root cause is that when the user uses the computer mouse, we really want to inject events as if they originated from a finger, not a mouse, because the behavior is different. For example, the selection vs scroll is different with a mouse and a finger. And in some games, the mouse just does not work.

But at the same time, secondary clicks (right or middle click) and hover, which require a mouse type, must still work. So there is no perfect solution.

More details in these commits:

  • c7b1d0ea9af8bb9603ec8f713f1a5fbf3f628b6a
  • 6808288823239b0f3a76f9be377e4de82e91b35a
  • 773c23fda298fd3dace4ded5a89e8716d3c0fc76
  • 51fee79bf50b124223523eb51c437c1267c2724a

rom1v avatar May 22 '25 07:05 rom1v

Thanks for the clarification! Closing as I've gotten the info I need, we will adjust to handle the potential different tool types here

gmackall avatar Jun 26 '25 21:06 gmackall