diff --git a/src/mir_init.c b/src/mir_init.c index 7385bb74..dfe84f9e 100644 --- a/src/mir_init.c +++ b/src/mir_init.c @@ -35,7 +35,10 @@ // static void createKeyTables(void) { + int scancode; + memset(_glfw.mir.publicKeys, -1, sizeof(_glfw.mir.publicKeys)); + memset(_glfw.mir.nativeKeys, -1, sizeof(_glfw.mir.nativeKeys)); _glfw.mir.publicKeys[KEY_GRAVE] = GLFW_KEY_GRAVE_ACCENT; _glfw.mir.publicKeys[KEY_1] = GLFW_KEY_1; @@ -153,6 +156,12 @@ static void createKeyTables(void) _glfw.mir.publicKeys[KEY_KPCOMMA] = GLFW_KEY_KP_DECIMAL; _glfw.mir.publicKeys[KEY_KPEQUAL] = GLFW_KEY_KP_EQUAL; _glfw.mir.publicKeys[KEY_KPENTER] = GLFW_KEY_KP_ENTER; + + for (scancode = 0; scancode < 256; scancode++) + { + if (_glfw.mir.publicKeys[scancode] > 0) + _glfw.mir.nativeKeys[_glfw.mir.publicKeys[scancode]] = scancode; + } } diff --git a/src/mir_platform.h b/src/mir_platform.h index 2bd9b621..fc483928 100644 --- a/src/mir_platform.h +++ b/src/mir_platform.h @@ -108,6 +108,7 @@ typedef struct _GLFWlibraryMir EventQueue* event_queue; short int publicKeys[256]; + short int nativeKeys[GLFW_KEY_LAST + 1]; pthread_mutex_t event_mutex; pthread_cond_t event_cond; diff --git a/src/wl_init.c b/src/wl_init.c index 1b590091..3b591c03 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -440,7 +440,10 @@ static const struct wl_registry_listener registryListener = { // static void createKeyTables(void) { + int scancode; + memset(_glfw.wl.publicKeys, -1, sizeof(_glfw.wl.publicKeys)); + memset(_glfw.wl.nativeKeys, -1, sizeof(_glfw.wl.nativeKeys)); _glfw.wl.publicKeys[KEY_GRAVE] = GLFW_KEY_GRAVE_ACCENT; _glfw.wl.publicKeys[KEY_1] = GLFW_KEY_1; @@ -558,6 +561,12 @@ static void createKeyTables(void) _glfw.wl.publicKeys[KEY_KPCOMMA] = GLFW_KEY_KP_DECIMAL; _glfw.wl.publicKeys[KEY_KPEQUAL] = GLFW_KEY_KP_EQUAL; _glfw.wl.publicKeys[KEY_KPENTER] = GLFW_KEY_KP_ENTER; + + for (scancode = 0; scancode < 256; scancode++) + { + if (_glfw.wl.publicKeys[scancode] > 0) + _glfw.wl.nativeKeys[_glfw.wl.publicKeys[scancode]] = scancode; + } } diff --git a/src/wl_platform.h b/src/wl_platform.h index e2d3d43b..862f05a3 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -130,6 +130,7 @@ typedef struct _GLFWlibraryWayland int monitorsSize; short int publicKeys[256]; + short int nativeKeys[GLFW_KEY_LAST + 1]; struct { struct xkb_context* context;