From 5fe529f21360b7549b80225fe2568ceffc0af5c0 Mon Sep 17 00:00:00 2001 From: Quantum Date: Sat, 15 Jan 2022 00:14:47 -0500 Subject: [PATCH] [client] spice: allow volume control keys to be sent to the guest These are implemented as ScrollLock+Up/Down for volume up and down, and ScrollLock+M to toggle audio mute. These should prove useful especially when Looking Glass now supports streaming audio, and the volume is defined in the guest and set on the output stream. --- client/src/kb.h | 4 ++++ client/src/keybind.c | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/client/src/kb.h b/client/src/kb.h index 44c5cee1..011f006b 100644 --- a/client/src/kb.h +++ b/client/src/kb.h @@ -24,6 +24,10 @@ #include #include +#define PS2_MUTE 0xE020 +#define PS2_VOLUME_UP 0xE030 +#define PS2_VOLUME_DOWN 0xE02E + extern const uint32_t linux_to_ps2[KEY_MAX]; extern const char * linux_to_str[KEY_MAX]; extern const char * linux_to_display[KEY_MAX]; diff --git a/client/src/keybind.c b/client/src/keybind.c index 48523fe6..cfa85828 100644 --- a/client/src/keybind.c +++ b/client/src/keybind.c @@ -133,6 +133,12 @@ static void bind_toggleOverlay(int sc, void * opaque) app_setOverlay(!g_state.overlayInput); } +static void bind_toggleKey(int sc, void * opaque) +{ + purespice_keyDown((uintptr_t) opaque); + purespice_keyUp((uintptr_t) opaque); +} + void keybind_register(void) { app_registerKeybind(KEY_F, bind_fullscreen , NULL, "Full screen toggle"); @@ -162,5 +168,9 @@ void keybind_register(void) app_registerKeybind(KEY_LEFTMETA , bind_passthrough, NULL, "Send LWin to the guest"); app_registerKeybind(KEY_RIGHTMETA, bind_passthrough, NULL, "Send RWin to the guest"); + + app_registerKeybind(KEY_UP , bind_toggleKey, (void *) PS2_VOLUME_UP , "Send volume up to the guest"); + app_registerKeybind(KEY_DOWN, bind_toggleKey, (void *) PS2_VOLUME_DOWN, "Send volume down to the guest"); + app_registerKeybind(KEY_M , bind_toggleKey, (void *) PS2_MUTE , "Send mute to the guest"); } }