static gboolean started = FALSE;
-void obt_keyboard_reload()
+void obt_keyboard_reload(void)
{
gint i, j, k;
modkeys_keys[OBT_KEYBOARD_MODKEY_CONTROL] = ControlMask;
}
-void obt_keyboard_shutdown()
+void obt_keyboard_shutdown(void)
{
XFreeModifiermap(modmap);
modmap = NULL;
/* CapsLock, Shift, and Control are special and hard-coded */
}
-KeyCode obt_keyboard_keysym_to_keycode(KeySym sym)
+KeyCode* obt_keyboard_keysym_to_keycode(KeySym sym)
{
- gint i, j;
+ KeyCode *ret;
+ gint i, j, n;
+
+ ret = g_new(KeyCode, 1);
+ n = 0;
+ ret[n] = 0;
/* go through each keycode and look for the keysym */
for (i = min_keycode; i <= max_keycode; ++i)
for (j = 0; j < keysyms_per_keycode; ++j)
- if (sym == keymap[(i-min_keycode) * keysyms_per_keycode + j])
- return i;
- return 0;
+ if (sym == keymap[(i-min_keycode) * keysyms_per_keycode + j]) {
+ ret = g_renew(KeyCode, ret, ++n);
+ ret[n-1] = i;
+ ret[n] = 0;
+ }
+ return ret;
}
-const gchar *obt_keyboard_keycode_to_string(guint keycode)
+gchar *obt_keyboard_keycode_to_string(guint keycode)
{
KeySym sym;
- const gchar *ret = NULL;
if ((sym = XKeycodeToKeysym(obt_display, keycode, 0)) != NoSymbol)
- ret = XKeysymToString(sym);
- return g_locale_to_utf8(ret, -1, NULL, NULL, NULL);
+ 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;
- const 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')