+
+gchar *obt_keyboard_keycode_to_string(guint keycode)
+{
+ KeySym sym;
+
+ if ((sym = XKeycodeToKeysym(obt_display, keycode, 0)) != NoSymbol)
+ return g_locale_to_utf8(XKeysymToString(sym), -1, NULL, NULL, NULL);
+ return NULL;
+}
+
+gunichar obt_keyboard_keycode_to_unichar(guint keycode)
+{
+ gunichar unikey = 0;
+ char *key;
+
+ if ((key = obt_keyboard_keycode_to_string(keycode)) != NULL &&
+ /* don't accept keys that aren't a single letter, like "space" */
+ key[1] == '\0')
+ {
+ unikey = g_utf8_get_char_validated(key, -1);
+ if (unikey == (gunichar)-1 || unikey == (gunichar)-2 || unikey == 0)
+ unikey = 0;
+ }
+ g_free(key);
+ return unikey;
+}