|
|
@ -21,24 +21,41 @@ static void keyboard_led_update(struct wlr_keyboard *keyboard) {
|
|
|
|
wlr_keyboard_led_update(keyboard, leds);
|
|
|
|
wlr_keyboard_led_update(keyboard, leds);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void wlr_keyboard_update_state(struct wlr_keyboard *keyboard,
|
|
|
|
|
|
|
|
struct wlr_event_keyboard_key *event) {
|
|
|
|
|
|
|
|
uint32_t keycode = event->keycode + 8;
|
|
|
|
|
|
|
|
xkb_state_update_key(keyboard->xkb_state, keycode,
|
|
|
|
|
|
|
|
event->state == WLR_KEY_PRESSED ? XKB_KEY_DOWN : XKB_KEY_UP);
|
|
|
|
|
|
|
|
keyboard_led_update(keyboard);
|
|
|
|
|
|
|
|
wl_signal_emit(&keyboard->events.key, event);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void wlr_keyboard_update_modifiers(struct wlr_keyboard *keyboard,
|
|
|
|
void wlr_keyboard_update_modifiers(struct wlr_keyboard *keyboard,
|
|
|
|
uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked,
|
|
|
|
uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked,
|
|
|
|
uint32_t group) {
|
|
|
|
uint32_t group) {
|
|
|
|
|
|
|
|
if (mods_depressed == keyboard->modifiers.depressed &&
|
|
|
|
|
|
|
|
mods_latched == keyboard->modifiers.latched &&
|
|
|
|
|
|
|
|
mods_locked == keyboard->modifiers.locked &&
|
|
|
|
|
|
|
|
group == keyboard->modifiers.group) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
keyboard->modifiers.depressed = mods_depressed;
|
|
|
|
keyboard->modifiers.depressed = mods_depressed;
|
|
|
|
keyboard->modifiers.latched = mods_latched;
|
|
|
|
keyboard->modifiers.latched = mods_latched;
|
|
|
|
keyboard->modifiers.locked = mods_locked;
|
|
|
|
keyboard->modifiers.locked = mods_locked;
|
|
|
|
keyboard->modifiers.group = group;
|
|
|
|
keyboard->modifiers.group = group;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void wlr_keyboard_update_state(struct wlr_keyboard *keyboard,
|
|
|
|
|
|
|
|
struct wlr_event_keyboard_key *event) {
|
|
|
|
|
|
|
|
uint32_t keycode = event->keycode + 8;
|
|
|
|
|
|
|
|
xkb_state_update_key(keyboard->xkb_state, keycode,
|
|
|
|
|
|
|
|
event->state == WLR_KEY_PRESSED ? XKB_KEY_DOWN : XKB_KEY_UP);
|
|
|
|
|
|
|
|
keyboard_led_update(keyboard);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xkb_mod_mask_t depressed = xkb_state_serialize_mods(keyboard->xkb_state,
|
|
|
|
|
|
|
|
XKB_STATE_MODS_DEPRESSED);
|
|
|
|
|
|
|
|
xkb_mod_mask_t latched = xkb_state_serialize_mods(keyboard->xkb_state,
|
|
|
|
|
|
|
|
XKB_STATE_MODS_LATCHED);
|
|
|
|
|
|
|
|
xkb_mod_mask_t locked = xkb_state_serialize_mods(keyboard->xkb_state,
|
|
|
|
|
|
|
|
XKB_STATE_MODS_LOCKED);
|
|
|
|
|
|
|
|
xkb_mod_mask_t group = xkb_state_serialize_layout(keyboard->xkb_state,
|
|
|
|
|
|
|
|
XKB_STATE_LAYOUT_EFFECTIVE);
|
|
|
|
|
|
|
|
wlr_keyboard_update_modifiers(keyboard, depressed, latched, locked, group);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wl_signal_emit(&keyboard->events.key, event);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void wlr_keyboard_init(struct wlr_keyboard *kb,
|
|
|
|
void wlr_keyboard_init(struct wlr_keyboard *kb,
|
|
|
|
struct wlr_keyboard_impl *impl) {
|
|
|
|
struct wlr_keyboard_impl *impl) {
|
|
|
|
kb->impl = impl;
|
|
|
|
kb->impl = impl;
|
|
|
|