[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.
This commit is contained in:
Quantum 2021-07-30 00:37:57 -04:00 committed by Geoffrey McRae
parent 10a27e7a27
commit 86b50cc8ab
3 changed files with 36 additions and 4 deletions

View File

@ -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;
}

View File

@ -18,9 +18,16 @@
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _H_LG_KB_
#define _H_LG_KB_
#include <linux/input.h>
#include <stdint.h>
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

View File

@ -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())