From e18f7d3365e066ca7908fe0f7937a0941cebe979 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Tue, 26 Jan 2021 02:41:10 +1100 Subject: [PATCH] [client] app: replace old SDL_Scancode with int --- client/include/app.h | 3 +-- client/src/app.c | 10 +++++----- client/src/main.c | 1 + client/src/main.h | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/client/include/app.h b/client/include/app.h index 4d503798..4c7cee29 100644 --- a/client/include/app.h +++ b/client/include/app.h @@ -35,7 +35,6 @@ typedef enum LG_MsgAlert } LG_MsgAlert; - SDL_Window * app_getWindow(void); bool app_getProp(LG_DSProperty prop, void * ret); @@ -81,7 +80,7 @@ void app_alert(LG_MsgAlert type, const char * fmt, ...); * @retval A handle for the binding or NULL on failure. * The caller is required to release the handle via `app_releaseKeybind` when it is no longer required */ -KeybindHandle app_registerKeybind(uint32_t sc, SuperEventFn callback, void * opaque); +KeybindHandle app_registerKeybind(int sc, SuperEventFn callback, void * opaque); /** * Release an existing key binding diff --git a/client/src/app.c b/client/src/app.c index 555cece6..8c7925c2 100644 --- a/client/src/app.c +++ b/client/src/app.c @@ -55,21 +55,21 @@ void app_alert(LG_MsgAlert type, const char * fmt, ...) free(buffer); } -KeybindHandle app_registerKeybind(SDL_Scancode key, SuperEventFn callback, void * opaque) +KeybindHandle app_registerKeybind(int sc, SuperEventFn callback, void * opaque) { // don't allow duplicate binds - if (g_state.bindings[key]) + if (g_state.bindings[sc]) { DEBUG_INFO("Key already bound"); return NULL; } KeybindHandle handle = (KeybindHandle)malloc(sizeof(struct KeybindHandle)); - handle->key = key; + handle->sc = sc; handle->callback = callback; handle->opaque = opaque; - g_state.bindings[key] = handle; + g_state.bindings[sc] = handle; return handle; } @@ -78,7 +78,7 @@ void app_releaseKeybind(KeybindHandle * handle) if (!*handle) return; - g_state.bindings[(*handle)->key] = NULL; + g_state.bindings[(*handle)->sc] = NULL; free(*handle); *handle = NULL; } diff --git a/client/src/main.c b/client/src/main.c index eb6517c2..b7f5e286 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -1231,6 +1231,7 @@ static void lg_shutdown(void) ivshmemClose(&g_state.shm); + // this must run last to ensure that we don't free any pointers still in use app_releaseAllKeybinds(); SDL_Quit(); diff --git a/client/src/main.h b/client/src/main.h index 58ec4b2d..06a26b12 100644 --- a/client/src/main.h +++ b/client/src/main.h @@ -154,7 +154,7 @@ struct CBRequest struct KeybindHandle { - SDL_Scancode key; + int sc; SuperEventFn callback; void * opaque; };