From e3cbdd18a03615084a1d0a521d657de8c38835bd Mon Sep 17 00:00:00 2001
From: feltcat <58396817+feltcat@users.noreply.github.com>
Date: Wed, 22 Apr 2020 17:31:30 +0100
Subject: [PATCH] [client] add quit keybind
---
client/README.md | 1 +
client/src/main.c | 7 +++++++
client/src/main.h | 1 +
3 files changed, 9 insertions(+)
diff --git a/client/README.md b/client/README.md
index 30ec68a4..4a2aeec6 100644
--- a/client/README.md
+++ b/client/README.md
@@ -46,6 +46,7 @@ Below are a list of current key bindings:
| ScrLk+F | Full Screen toggle |
| ScrLk+I | Spice keyboard & mouse enable toggle |
| ScrLk+N | Toggle night vision mode (EGL renderer only!) |
+| ScrLk+Q | Quit |
| ScrLk+Insert | Increase mouse sensitivity (in capture mode only) |
| ScrLk+Del | Decrease mouse sensitivity (in capture mode only) |
| ScrLk+F1 | Send Ctrl+Alt+F1 to the guest |
diff --git a/client/src/main.c b/client/src/main.c
index bf0d7b59..87f348f5 100644
--- a/client/src/main.c
+++ b/client/src/main.c
@@ -1082,6 +1082,11 @@ static void toggle_input(SDL_Scancode key, void * opaque)
);
}
+static void quit(SDL_Scancode key, void * opaque)
+{
+ state.running = false;
+}
+
static void mouse_sens_inc(SDL_Scancode key, void * opaque)
{
char * msg;
@@ -1130,6 +1135,7 @@ 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.kbQuit = app_register_keybind(SDL_SCANCODE_Q , quit , 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);
@@ -1151,6 +1157,7 @@ static void release_key_binds()
{
app_release_keybind(&state.kbFS);
app_release_keybind(&state.kbInput);
+ app_release_keybind(&state.kbQuit);
for(int i = 0; i < 12; ++i)
app_release_keybind(&state.kbCtrlAltFn[i]);
}
diff --git a/client/src/main.h b/client/src/main.h
index 4a2955b9..de8812e1 100644
--- a/client/src/main.h
+++ b/client/src/main.h
@@ -87,6 +87,7 @@ struct AppState
KeybindHandle kbFS;
KeybindHandle kbInput;
+ KeybindHandle kbQuit;
KeybindHandle kbMouseSensInc;
KeybindHandle kbMouseSensDec;
KeybindHandle kbCtrlAltFn[12];