diff --git a/gfx/context/glx_ctx.c b/gfx/context/glx_ctx.c index eb89ee820c..0e1a2756e4 100644 --- a/gfx/context/glx_ctx.c +++ b/gfx/context/glx_ctx.c @@ -222,13 +222,13 @@ static void gfx_ctx_check_window(bool *quit, { static XComposeStatus state; char keybuf[32]; - const unsigned x_keycode = XKeycodeToKeysym(g_dpy, event.xkey.keycode, 0); + const unsigned x_keycode = XLookupKeysym(&event.xkey, 0); bool down = event.type == KeyPress; uint32_t character = 0; unsigned key = RETROK_UNKNOWN; - for (int i = 0; i != RETROK_LAST; i ++) + for (int i = 0; i < RETROK_LAST; i++) { if (keysym_lut[i] == x_keycode) { diff --git a/libretro-test/libretro-test.c b/libretro-test/libretro-test.c index a579efae29..d0e6c0fc32 100644 --- a/libretro-test/libretro-test.c +++ b/libretro-test/libretro-test.c @@ -187,6 +187,13 @@ void retro_run(void) render_audio(); } +static void keyboard_cb(bool down, unsigned keycode, + uint32_t character, uint16_t mod) +{ + fprintf(stderr, "Down: %s, Code: %d, Char: %u, Mod: %u.\n", + down ? "yes" : "no", keycode, character, mod); +} + bool retro_load_game(const struct retro_game_info *info) { struct retro_input_descriptor desc[] = { @@ -206,6 +213,9 @@ bool retro_load_game(const struct retro_game_info *info) return false; } + struct retro_keyboard_callback cb = { keyboard_cb }; + environ_cb(RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK, &cb); + (void)info; return true; }