aboutsummaryrefslogtreecommitdiff
path: root/src/libui_sdl/libui/unix/area.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libui_sdl/libui/unix/area.c')
-rw-r--r--src/libui_sdl/libui/unix/area.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/libui_sdl/libui/unix/area.c b/src/libui_sdl/libui/unix/area.c
index 40f8624..2da9bab 100644
--- a/src/libui_sdl/libui/unix/area.c
+++ b/src/libui_sdl/libui/unix/area.c
@@ -523,16 +523,26 @@ char* uiKeyName(int scancode)
{
scancode = scancode_normal2unix(scancode);
+ char* ret;
guint* keyvals; int num;
- GdkKeymap* keymap = gdk_keymap_get_default();
- gdk_keymap_get_entries_for_keycode(keymap, scancode, NULL, &keyvals, &num);
-
- // TODO: pick smarter??
- int keyval = keyvals[0];
-
- g_free(keyvals);
+ GdkKeymap* keymap = gdk_keymap_get_for_display(gdk_display_get_default());
+ if (gdk_keymap_get_entries_for_keycode(keymap, scancode, NULL, &keyvals, &num))
+ {
+ // TODO: pick smarter??
+ int keyval = keyvals[0];
+
+ g_free(keyvals);
+
+ ret = gdk_keyval_name(keyval);
+ }
+ else
+ {
+ char tmp[16];
+ sprintf(tmp, "#%03X", scancode);
+ ret = tmp;
+ }
- return uiUnixStrdupText(gdk_keyval_name(keyval));
+ return uiUnixStrdupText(ret);
}
enum {