1 #ifndef LIBDS_INTERFACES_KEYBOARD_H
2 #define LIBDS_INTERFACES_KEYBOARD_H
4 #include <wayland-server.h>
5 #include <xkbcommon/xkbcommon.h>
7 #include <libds/keyboard.h>
11 enum ds_keyboard_led {
12 DS_LED_NUM_LOCK = 1 << 0,
13 DS_LED_CAPS_LOCK = 1 << 1,
14 DS_LED_SCROLL_LOCK = 1 << 2,
17 #define DS_MODIFIER_COUNT 8
19 enum ds_keyboard_modifier {
20 DS_MODIFIER_SHIFT = 1 << 0,
21 DS_MODIFIER_CAPS = 1 << 1,
22 DS_MODIFIER_CTRL = 1 << 2,
23 DS_MODIFIER_ALT = 1 << 3,
24 DS_MODIFIER_MOD2 = 1 << 4,
25 DS_MODIFIER_MOD3 = 1 << 5,
26 DS_MODIFIER_LOGO = 1 << 6,
27 DS_MODIFIER_MOD5 = 1 << 7,
30 #define DS_KEYBOARD_KEYS_CAP 32
34 struct ds_keyboard_interface
36 void (*destroy)(struct ds_keyboard *keyboard);
39 struct ds_keyboard_modifiers
41 xkb_mod_mask_t depressed;
42 xkb_mod_mask_t latched;
43 xkb_mod_mask_t locked;
49 const struct ds_keyboard_interface *iface;
54 struct xkb_keymap *keymap;
55 struct xkb_state *xkb_state;
56 xkb_led_index_t led_indexes[DS_LED_COUNT];
57 xkb_mod_index_t mod_indexes[DS_MODIFIER_COUNT];
59 uint32_t keycodes[DS_KEYBOARD_KEYS_CAP];
61 struct ds_keyboard_modifiers modifiers;
69 struct wl_signal destroy;
71 struct wl_signal modifiers;
72 struct wl_signal keymap;
73 struct wl_signal repeat_info;
77 void ds_keyboard_init(struct ds_keyboard *keyboard,
78 const struct ds_keyboard_interface *iface);
80 void ds_keyboard_destroy(struct ds_keyboard *keyboard);
82 void ds_keyboard_notify_key(struct ds_keyboard *keyboard,
83 struct ds_event_keyboard_key *event);
85 void ds_keyboard_notify_modifiers(struct ds_keyboard *keyboard,
86 uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked,