From dd7413f973550e8c7a8a363edfd7dd98d64a8374 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Fri, 31 May 2019 16:39:55 +1000 Subject: [PATCH] [client] added keybinds to send Ctrl+Alt+Fn Fixes #165 --- VERSION | 2 +- client/src/main.c | 30 ++++++++++++++++++++++++++++++ client/src/main.h | 3 ++- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index b4b79187..a8ab71ca 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -B1-rc5-2-g97024041f3+1 \ No newline at end of file +B1-rc5-3-g0851fd13e6+1 \ No newline at end of file diff --git a/client/src/main.c b/client/src/main.c index 6391c51e..96a8fd64 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -947,18 +947,48 @@ static void mouse_sens_dec(SDL_Scancode key, void * opaque) free(msg); } +static void ctrl_alt_fn(SDL_Scancode key, void * opaque) +{ + const uint32_t ctrl = mapScancode(SDL_SCANCODE_LCTRL); + const uint32_t alt = mapScancode(SDL_SCANCODE_LALT ); + const uint32_t fn = mapScancode(key); + + spice_key_down(ctrl); + spice_key_down(alt ); + spice_key_down(fn ); + + spice_key_up(ctrl); + spice_key_up(alt ); + spice_key_up(fn ); +} + static void register_key_binds() { state.kbFS = app_register_keybind(SDL_SCANCODE_F , toggle_fullscreen, NULL); state.kbInput = app_register_keybind(SDL_SCANCODE_I , toggle_input , NULL); state.kbMouseSensInc = app_register_keybind(SDL_SCANCODE_INSERT, mouse_sens_inc , NULL); state.kbMouseSensDec = app_register_keybind(SDL_SCANCODE_DELETE, mouse_sens_dec , NULL); + + state.kbCtrlAltFn[0 ] = app_register_keybind(SDL_SCANCODE_F1 , ctrl_alt_fn, NULL); + state.kbCtrlAltFn[1 ] = app_register_keybind(SDL_SCANCODE_F2 , ctrl_alt_fn, NULL); + state.kbCtrlAltFn[2 ] = app_register_keybind(SDL_SCANCODE_F3 , ctrl_alt_fn, NULL); + state.kbCtrlAltFn[3 ] = app_register_keybind(SDL_SCANCODE_F4 , ctrl_alt_fn, NULL); + state.kbCtrlAltFn[4 ] = app_register_keybind(SDL_SCANCODE_F5 , ctrl_alt_fn, NULL); + state.kbCtrlAltFn[5 ] = app_register_keybind(SDL_SCANCODE_F6 , ctrl_alt_fn, NULL); + state.kbCtrlAltFn[6 ] = app_register_keybind(SDL_SCANCODE_F7 , ctrl_alt_fn, NULL); + state.kbCtrlAltFn[7 ] = app_register_keybind(SDL_SCANCODE_F8 , ctrl_alt_fn, NULL); + state.kbCtrlAltFn[8 ] = app_register_keybind(SDL_SCANCODE_F9 , ctrl_alt_fn, NULL); + state.kbCtrlAltFn[9 ] = app_register_keybind(SDL_SCANCODE_F10, ctrl_alt_fn, NULL); + state.kbCtrlAltFn[10] = app_register_keybind(SDL_SCANCODE_F11, ctrl_alt_fn, NULL); + state.kbCtrlAltFn[11] = app_register_keybind(SDL_SCANCODE_F12, ctrl_alt_fn, NULL); } static void release_key_binds() { app_release_keybind(&state.kbFS); app_release_keybind(&state.kbInput); + for(int i = 0; i < 12; ++i) + app_release_keybind(&state.kbCtrlAltFn[i]); } int run() diff --git a/client/src/main.h b/client/src/main.h index 8cc0e61b..3321d5b7 100644 --- a/client/src/main.h +++ b/client/src/main.h @@ -68,6 +68,7 @@ struct AppState KeybindHandle kbInput; KeybindHandle kbMouseSensInc; KeybindHandle kbMouseSensDec; + KeybindHandle kbCtrlAltFn[12]; int mouseSens; float sensX, sensY; @@ -128,4 +129,4 @@ struct KeybindHandle // forwards extern struct AppState state; -extern struct AppParams params; +extern struct AppParams params; \ No newline at end of file