From 86b50cc8ab1c944c1a8fc59b44c4a33e54ef2185 Mon Sep 17 00:00:00 2001 From: Quantum Date: Fri, 30 Jul 2021 00:37:57 -0400 Subject: [PATCH] [client] imgui: initialize keymap This allows ImGui to understand some of the basic key presses. Also moved the include guard from kb.c to kb.h where it actually makes sense. --- client/src/kb.c | 30 ++++++++++++++++++++++++++---- client/src/kb.h | 7 +++++++ client/src/main.c | 3 +++ 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/client/src/kb.c b/client/src/kb.c index cd9fe8c0..97083441 100644 --- a/client/src/kb.c +++ b/client/src/kb.c @@ -18,10 +18,8 @@ * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _H_LG_KB_ -#define _H_LG_KB_ - #include "kb.h" +#include "cimgui.h" const uint32_t xfree86_to_ps2[KEY_MAX] = { @@ -392,4 +390,28 @@ const char * xfree86_to_display[KEY_MAX] = [KEY_PRINT] = "Print", }; -#endif +void initImGuiKeyMap(int * keymap) +{ + keymap[ImGuiKey_Tab ] = KEY_TAB; + keymap[ImGuiKey_LeftArrow ] = KEY_LEFT; + keymap[ImGuiKey_RightArrow ] = KEY_RIGHT; + keymap[ImGuiKey_UpArrow ] = KEY_UP; + keymap[ImGuiKey_DownArrow ] = KEY_DOWN; + keymap[ImGuiKey_PageUp ] = KEY_PAGEUP; + keymap[ImGuiKey_PageDown ] = KEY_PAGEDOWN; + keymap[ImGuiKey_Home ] = KEY_HOME; + keymap[ImGuiKey_End ] = KEY_END; + keymap[ImGuiKey_Insert ] = KEY_INSERT; + keymap[ImGuiKey_Delete ] = KEY_DELETE; + keymap[ImGuiKey_Backspace ] = KEY_BACKSPACE; + keymap[ImGuiKey_Space ] = KEY_SPACE; + keymap[ImGuiKey_Enter ] = KEY_ENTER; + keymap[ImGuiKey_Escape ] = KEY_SPACE; + keymap[ImGuiKey_KeyPadEnter] = KEY_KPENTER; + keymap[ImGuiKey_A ] = KEY_A; + keymap[ImGuiKey_C ] = KEY_C; + keymap[ImGuiKey_V ] = KEY_V; + keymap[ImGuiKey_X ] = KEY_X; + keymap[ImGuiKey_Y ] = KEY_Y; + keymap[ImGuiKey_Z ] = KEY_Z; +} diff --git a/client/src/kb.h b/client/src/kb.h index c4402f5b..b40418ac 100644 --- a/client/src/kb.h +++ b/client/src/kb.h @@ -18,9 +18,16 @@ * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifndef _H_LG_KB_ +#define _H_LG_KB_ + #include #include extern const uint32_t xfree86_to_ps2[KEY_MAX]; extern const char * xfree86_to_str[KEY_MAX]; extern const char * xfree86_to_display[KEY_MAX]; + +void initImGuiKeyMap(int * keymap); + +#endif diff --git a/client/src/main.c b/client/src/main.c index f39623e4..4fb10a3b 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -53,6 +53,7 @@ #include "app.h" #include "keybind.h" #include "clipboard.h" +#include "kb.h" #include "ll.h" #include "egl_dynprocs.h" #include "overlays.h" @@ -800,6 +801,8 @@ static int lg_run(void) overlayGraph_register("RENDER", g_state.renderTimings, 0.0f, 50.0f); overlayGraph_register("UPLOAD", g_state.frameTimings , 0.0f, 50.0f); + initImGuiKeyMap(g_state.io->KeyMap); + // search for the best displayserver ops to use for(int i = 0; i < LG_DISPLAYSERVER_COUNT; ++i) if (LG_DisplayServers[i]->probe())