commit caabeb3
Michael Forney
·
2013-12-05 22:35:21 +0000 UTC
parent ea0ab20
Use XKB_KEY macro rather than adding 8 to keycodes
3 files changed,
+7,
-7
+2,
-5
1@@ -49,15 +49,12 @@ static bool handle_key(struct swc_keyboard * keyboard, uint32_t time,
2 const xkb_keysym_t * keysyms;
3 int num_keysyms;
4
5- /* XKB key codes are offset by 8 */
6- key += 8;
7-
8- layout = xkb_state_key_get_layout(keyboard->xkb.state, key);
9+ layout = xkb_state_key_get_layout(keyboard->xkb.state, XKB_KEY(key));
10
11 /* XXX: Maybe someone might want to register a key binding for a
12 * keysym with a different shift-level? */
13 num_keysyms = xkb_keymap_key_get_syms_by_level
14- (keyboard->xkb.keymap.map, key, layout, 0, &keysyms);
15+ (keyboard->xkb.keymap.map, XKB_KEY(key), layout, 0, &keysyms);
16
17 if (num_keysyms == 1)
18 {
+2,
-2
1@@ -179,10 +179,10 @@ void swc_keyboard_handle_key(struct swc_keyboard * keyboard, uint32_t time,
2 key, state);
3 }
4
5- /* Update XKB state. Apparently the keycodes are offset by 8 in XKB. */
6+ /* Update XKB state. */
7 direction = state == WL_KEYBOARD_KEY_STATE_PRESSED ? XKB_KEY_DOWN
8 : XKB_KEY_UP;
9- xkb_state_update_key(xkb->state, key + 8, direction);
10+ xkb_state_update_key(xkb->state, XKB_KEY(key), direction);
11
12 mods_depressed = xkb_state_serialize_mods(xkb->state, XKB_STATE_DEPRESSED);
13 mods_latched = xkb_state_serialize_mods(xkb->state, XKB_STATE_LATCHED);
+3,
-0
1@@ -4,6 +4,9 @@
2 #ifndef SWC_XKB_H
3 #define SWC_XKB_H
4
5+/* Keycodes are offset by 8 in XKB. */
6+#define XKB_KEY(key) ((key) + 8)
7+
8 struct swc_xkb
9 {
10 struct xkb_context * context;