1 #include "../../kernel/openbox.h"
6 guint keyboard_translate_modifier(char *str)
8 if (!strcmp("Mod1", str) || !strcmp("A", str)) return Mod1Mask;
9 else if (!strcmp("Mod2", str)) return Mod2Mask;
10 else if (!strcmp("Mod3", str)) return Mod3Mask;
11 else if (!strcmp("Mod4", str) || !strcmp("W", str)) return Mod4Mask;
12 else if (!strcmp("Mod5", str)) return Mod5Mask;
13 else if (!strcmp("C", str)) return ControlMask;
14 else if (!strcmp("S", str)) return ShiftMask;
15 g_warning("Invalid modifier '%s' in binding.", str);
19 gboolean translate_key(char *str, guint *state, guint *keycode)
27 parsed = g_strsplit(str, "-", -1);
29 /* first, find the key (last token) */
31 for (i = 0; parsed[i] != NULL; ++i)
34 goto translation_fail;
36 /* figure out the mod mask */
38 for (i = 0; parsed[i] != l; ++i) {
39 guint m = keyboard_translate_modifier(parsed[i]);
40 if (!m) goto translation_fail;
44 /* figure out the keycode */
45 sym = XStringToKeysym(l);
46 if (sym == NoSymbol) {
47 g_warning("Invalid key name '%s' in key binding.", l);
48 goto translation_fail;
50 *keycode = XKeysymToKeycode(ob_display, sym);
52 g_warning("Key '%s' does not exist on the display.", l);
53 goto translation_fail;