1 #include "../../kernel/openbox.h"
6 static guint translate_modifier(char *str)
8 if (!g_ascii_strcasecmp("Mod1", str) ||
9 !g_ascii_strcasecmp("A", str)) return Mod1Mask;
10 else if (!g_ascii_strcasecmp("Mod2", str)) return Mod2Mask;
11 else if (!g_ascii_strcasecmp("Mod3", str)) return Mod3Mask;
12 else if (!g_ascii_strcasecmp("Mod4", str) ||
13 !g_ascii_strcasecmp("W", str)) return Mod4Mask;
14 else if (!g_ascii_strcasecmp("Mod5", str)) return Mod5Mask;
15 else if (!g_ascii_strcasecmp("Control", str) ||
16 !g_ascii_strcasecmp("C", str)) return ControlMask;
17 else if (!g_ascii_strcasecmp("Shift", str) ||
18 !g_ascii_strcasecmp("S", str)) return ShiftMask;
19 g_warning("Invalid modifier '%s' in binding.", str);
23 gboolean translate_button(char *str, guint *state, guint *button)
30 parsed = g_strsplit(str, "-", -1);
32 /* first, find the button (last token) */
34 for (i = 0; parsed[i] != NULL; ++i)
37 goto translation_fail;
39 /* figure out the mod mask */
41 for (i = 0; parsed[i] != l; ++i) {
42 guint m = translate_modifier(parsed[i]);
43 if (!m) goto translation_fail;
47 /* figure out the button */
48 if (!g_ascii_strcasecmp("Left", l)) *button = 1;
49 else if (!g_ascii_strcasecmp("Middle", l)) *button = 2;
50 else if (!g_ascii_strcasecmp("Right", l)) *button = 3;
51 else if (!g_ascii_strcasecmp("Up", l)) *button = 4;
52 else if (!g_ascii_strcasecmp("Down", l)) *button = 5;
53 else if (!g_ascii_strncasecmp("Button", l, 6)) *button = atoi(l+6);
55 g_warning("Invalid button '%s' in pointer binding.", l);
56 goto translation_fail;