From eb1774f955eb194220e3d51ae320b6a0d56eb131 Mon Sep 17 00:00:00 2001 From: Quantum Date: Wed, 1 Jun 2022 23:00:22 -0400 Subject: [PATCH] [client] keybind: add ScrollLock+C to cycle microphone defaults This makes it possible to change the default action taken the next time an application tries to open the microphone without restarting the client. --- client/src/keybind.c | 23 +++++++++++++++++++++++ client/src/main.h | 1 + 2 files changed, 24 insertions(+) diff --git a/client/src/keybind.c b/client/src/keybind.c index 16b60bae..e6532133 100644 --- a/client/src/keybind.c +++ b/client/src/keybind.c @@ -139,6 +139,27 @@ void keybind_commonRegister(void) "Toggle overlay"); } +#if ENABLE_AUDIO +static void bind_toggleMicDefault(int sc, void * opaque) +{ + g_state.micDefaultState = (g_state.micDefaultState + 1) % MIC_DEFAULT_MAX; + + switch (g_state.micDefaultState) + { + case MIC_DEFAULT_PROMPT: + app_alert(LG_ALERT_INFO, "Microphone access will prompt"); + break; + + case MIC_DEFAULT_ALLOW: + app_alert(LG_ALERT_INFO, "Microphone access allowed by default"); + break; + + case MIC_DEFAULT_DENY: + app_alert(LG_ALERT_INFO, "Microphone access denied by default"); + } +} +#endif + void keybind_spiceRegister(void) { /* register the common keybinds for spice */ @@ -170,6 +191,8 @@ void keybind_spiceRegister(void) { app_registerKeybind(0, 'E', audio_recordToggleKeybind, NULL, "Toggle audio recording"); + app_registerKeybind(0, 'C', bind_toggleMicDefault, NULL, + "Cycle audio recording default"); } #endif diff --git a/client/src/main.h b/client/src/main.h index 74279936..9769cc45 100644 --- a/client/src/main.h +++ b/client/src/main.h @@ -50,6 +50,7 @@ enum MicDefaultState { MIC_DEFAULT_ALLOW, MIC_DEFAULT_DENY }; +#define MIC_DEFAULT_MAX (MIC_DEFAULT_DENY + 1) struct AppState {