1
0
mirror of https://github.com/libretro/RetroArch synced 2024-07-08 12:15:49 +00:00

Use XLookupKeysym instead. Add test.

XKeycodeToKeysym is deprecated.
This commit is contained in:
Themaister 2012-12-08 12:50:05 +01:00
parent 94f89b4a70
commit 6709dcb274
2 changed files with 12 additions and 2 deletions

View File

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

View File

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