Genymobile / scrcpy

Display and control your Android device
Apache License 2.0
112.19k stars 10.73k forks source link

Switch control shortcut option for pc to android or android to pc #4919

Open idlukakas opened 6 months ago

idlukakas commented 6 months ago

By using the command scrcpy.exe -KM --no-video, I can only gain control of the Android device if I click on the scrcpy window, and to release control back to the PC, I need to press Alt. It would be nice if I could switch control between the PC and the Android device using a shortcut.

Perhaps using an option like: scrcpy.exe -KM --no-video --switch-control-shortcut

rom1v commented 6 months ago

The SDL window must have focus to receive keyboard (or mouse) events.

idlukakas commented 6 months ago

Scrcpy server can bind some shortcut from the desktop OS to gain focus on it's window if possible.

idlukakas commented 6 months ago

I did: scrcpy.exe --stay-awake --push-target=/sdcard/ --no-video -KM --window-height=50 --window-width=50 --window-x 940 --window-y 1090 --window-borderless

Then I set AutoHotKey to gain focus the scrcpy window and click on it automatically when I press Alt + S

Thanks for explain the behavior

rom1v commented 6 months ago

Refs https://wiki.libsdl.org/SDL2/SDL_SetWindowKeyboardGrab (but not sure this allows to do what we want)

idlukakas commented 6 months ago

Good to know. Who knows, it could be reachable for using it.