]>
Dogcows Code - chaz/openbox/blob - plugins/keyboard/translate.c
1 #include "../../kernel/openbox.h"
5 static guint
translate_modifier(char *str
)
7 if (!strcmp("Mod1", str
) || !strcmp("A", str
)) return Mod1Mask
;
8 else if (!strcmp("Mod2", str
)) return Mod2Mask
;
9 else if (!strcmp("Mod3", str
)) return Mod3Mask
;
10 else if (!strcmp("Mod4", str
) || !strcmp("W", str
)) return Mod4Mask
;
11 else if (!strcmp("Mod5", str
)) return Mod5Mask
;
12 else if (!strcmp("C", str
)) return ControlMask
;
13 else if (!strcmp("S", str
)) return ShiftMask
;
14 g_warning("Invalid modifier '%s' in binding.", str
);
18 gboolean
translate_key(char *str
, guint
*state
, guint
*keycode
)
26 parsed
= g_strsplit(str
, "-", -1);
28 /* first, find the key (last token) */
30 for (i
= 0; parsed
[i
] != NULL
; ++i
)
33 goto translation_fail
;
35 /* figure out the mod mask */
37 for (i
= 0; parsed
[i
] != l
; ++i
) {
38 guint m
= translate_modifier(parsed
[i
]);
39 if (!m
) goto translation_fail
;
43 /* figure out the keycode */
44 sym
= XStringToKeysym(l
);
45 if (sym
== NoSymbol
) {
46 g_warning("Invalid key name '%s' in key binding.", l
);
47 goto translation_fail
;
49 *keycode
= XKeysymToKeycode(ob_display
, sym
);
51 g_warning("Key '%s' does not exist on the display.", l
);
52 goto translation_fail
;
This page took 0.040392 seconds and 4 git commands to generate.