Open MonDV opened 3 years ago
Just to test, this works:
diff --git a/app/src/event_converter.c b/app/src/event_converter.c
index ab48898d..dc88c239 100644
--- a/app/src/event_converter.c
+++ b/app/src/event_converter.c
@@ -96,6 +96,9 @@ convert_keycode(SDL_Keycode from, enum android_keycode *to, uint16_t mod,
MAP(SDLK_RCTRL, AKEYCODE_CTRL_RIGHT);
MAP(SDLK_LSHIFT, AKEYCODE_SHIFT_LEFT);
MAP(SDLK_RSHIFT, AKEYCODE_SHIFT_RIGHT);
+ MAP(SDLK_F9, AKEYCODE_MEDIA_PLAY_PAUSE);
+ MAP(SDLK_F10, AKEYCODE_MEDIA_REWIND);
+ MAP(SDLK_F11, AKEYCODE_MEDIA_FAST_FORWARD);
}
if (!(mod & (KMOD_NUM | KMOD_SHIFT))) {
But there is no customizable mapping on scrcpy (and media keys are not correctly received by SDL, for example I never receive SDLK_AUDIOPLAY
if I click on my mediakey PLAY).
Just to test, this works:
diff --git a/app/src/event_converter.c b/app/src/event_converter.c index ab48898d..dc88c239 100644 --- a/app/src/event_converter.c +++ b/app/src/event_converter.c @@ -96,6 +96,9 @@ convert_keycode(SDL_Keycode from, enum android_keycode *to, uint16_t mod, MAP(SDLK_RCTRL, AKEYCODE_CTRL_RIGHT); MAP(SDLK_LSHIFT, AKEYCODE_SHIFT_LEFT); MAP(SDLK_RSHIFT, AKEYCODE_SHIFT_RIGHT); + MAP(SDLK_F9, AKEYCODE_MEDIA_PLAY_PAUSE); + MAP(SDLK_F10, AKEYCODE_MEDIA_REWIND); + MAP(SDLK_F11, AKEYCODE_MEDIA_FAST_FORWARD); } if (!(mod & (KMOD_NUM | KMOD_SHIFT))) {
But there is no customizable mapping on scrcpy (and media keys are not correctly received by SDL, for example I never receive
SDLK_AUDIOPLAY
if I click on my mediakey PLAY).
How to use this ? click on F9, F10 and f11 ? Doesn't seems to works for me. But I'm on MI9T's Android 10 MIUI, is it the reason why it doesn't work
Does it work for you:
adb shell input keyevent MEDIA_PLAY_PAUSE
?
On some laptops, Fn is "enabled" by default (customizable from BIOS/UEFI), so you need to press Fn+F9.
adb shell input keyevent MEDIA_PLAY_PAUSE
Running this works for me. Music paused and played
And I disabled Fn a while back on my laptop, as I am using F2 very frequently for renaming, so this is not the problem for me I
@hafizidev How did you compiled scrcpy including this patch?
@hafizidev How did you compiled scrcpy including this patch?
I am very sorry, I didn't notice that this is development feature. I use the release version, not development, no wonder it didn't work. Sorry again
Does it work for you:
adb shell input keyevent MEDIA_PLAY_PAUSE
?
On some laptops, Fn is "enabled" by default (customizable from BIOS/UEFI), so you need to press Fn+F9.
What about next track or previous track
Does it work for you:
adb shell input keyevent MEDIA_PLAY_PAUSE
? On some laptops, Fn is "enabled" by default (customizable from BIOS/UEFI), so you need to press Fn+F9.
What about next track or previous track
Checkout Android Key Events docs: https://developer.android.com/reference/android/view/KeyEvent
maybe related: #4080
Background, why this might be not enough on linux systems: On most Desktop environments, the wayland shell/Xwindow manager will receive these button events and handle them theirselves. For sharing actions with the actual applications, so that they can respond to these actions, these applications implement dbus MPRIS. I'm currently looking at an implementation for mpv which looks quite minimal (as minimal as it gets with dbus...) to maybe port this over to scrcpy.
I have been using vysor to control my FireTV devices and since they upgraded to v3 it's been a complete cluster****. Found your tool yesterday and it does 99% of everything I need and it is GREAT!
There is one issue/request. Can you add media control shortcuts? Specifically to rewind, play/pause, forward media. For the FireTV the keycodes are:
KEYCODE_MEDIA_PLAY_PAUSE KEYCODE_MEDIA_REWIND KEYCODE_MEDIA_FAST_FORWARD
In vysor, I modify the settings so that my current laptop buttons for these 'functions' is linked to the keycode (currently F9, F10 and F11 buttons).
It would be great to add shortcuts that would pass those keycodes so that it is possible to control media play through scrcpy.
FYI, I am not a programmer and I don't know the complexity of this request. Best, MonDV (Thanks for the great tool!!!)