Genymobile / scrcpy

Display and control your Android device
Apache License 2.0
106.01k stars 10.27k forks source link

Feature Request: Keyboard Shortcut for Forwarding Clicks #5055

Open rom1v opened 2 weeks ago

rom1v commented 2 weeks ago

A feature request posted on reddit:

So with the recent Scrcpy release, the forwarding clicks behavior changed. So I added this:

--mouse-bind=bhsn

to get

-KM --no-video --no-audio --mouse-bind=bhsn

So that I get the old behavior back, with right click for BACK and middle click for HOME.

But I realized that a keyboard shortcut that could forward clicks would be very useful. This way, we can get use mouse click shortcuts when needed, and use a modifier key to forward the click for apps that make use of it. Like Alt + right click = forward right click.

Or can implement the inverse; clicks are forwarded by default, and act as shortcuts when using the modifier key. Idk the best method, but I feel this would be useful, so please check :)

Thanks!

rom1v commented 2 weeks ago

My first comment:

I like the idea. However, Alt is already used to capture/uncapture the mouse when video mirroring is disabled, and Alt+right and Alt+middle clicks are often captured by the window manager (e.g. to resize the window). Ctrl+click and Shift+click are used to simulate several fingers (but only for left click, so Ctrl could be used for additional shortcuts in theory).

So I keep the idea in mind, but for now I don't know how to expose it properly.

rom1v commented 2 weeks ago

One unexpected difficulty is related to the injection of either finger or mouse: c7b1d0e and #3568.

If there is a possibility of secondary click, then we must use a mouse even for left click for consistency. But that prevents multi-fingers to work on some devices (but not all), for example for pinch-to-zoom, rotate and tilt simulation.

The workaround was: use mouse if --forward-all-clicks (now if there is at least one click forwarded in --mouse-bind=xxxx), finger otherwise.

But if we add key+click, forwarding secondary clicks will always be possible (either with key pressed or unpressed), so it won't use "finger" by default anymore, breaking the behavior on some devices.

rom1v commented 1 week ago

Implemented by #5076.