2018-07-13 14:40:56 +02:00
|
|
|
/*
|
|
|
|
* This an unstable interface of wlroots. No guarantees are made regarding the
|
|
|
|
* future consistency of this API.
|
|
|
|
*/
|
|
|
|
#ifndef WLR_USE_UNSTABLE
|
|
|
|
#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features"
|
|
|
|
#endif
|
|
|
|
|
2017-09-23 10:26:01 +02:00
|
|
|
#ifndef WLR_TYPES_WLR_KEYBOARD_H
|
|
|
|
#define WLR_TYPES_WLR_KEYBOARD_H
|
|
|
|
|
2017-10-09 03:55:59 +02:00
|
|
|
#include <stdbool.h>
|
2018-02-12 21:29:23 +01:00
|
|
|
#include <stdint.h>
|
2019-07-27 10:53:54 +02:00
|
|
|
#include <wayland-server-core.h>
|
|
|
|
#include <wayland-server-core.h>
|
2017-09-24 20:12:56 +02:00
|
|
|
#include <xkbcommon/xkbcommon.h>
|
2017-06-20 00:41:02 +02:00
|
|
|
|
2017-10-02 20:21:47 +02:00
|
|
|
#define WLR_LED_COUNT 3
|
|
|
|
|
2017-10-02 19:23:30 +02:00
|
|
|
enum wlr_keyboard_led {
|
2020-10-31 23:05:39 +01:00
|
|
|
WLR_LED_NUM_LOCK = 1 << 0,
|
|
|
|
WLR_LED_CAPS_LOCK = 1 << 1,
|
|
|
|
WLR_LED_SCROLL_LOCK = 1 << 2,
|
2017-06-20 00:41:02 +02:00
|
|
|
};
|
|
|
|
|
2017-10-02 20:21:47 +02:00
|
|
|
#define WLR_MODIFIER_COUNT 8
|
|
|
|
|
2017-10-02 19:23:30 +02:00
|
|
|
enum wlr_keyboard_modifier {
|
2020-10-31 23:05:39 +01:00
|
|
|
WLR_MODIFIER_SHIFT = 1 << 0,
|
|
|
|
WLR_MODIFIER_CAPS = 1 << 1,
|
|
|
|
WLR_MODIFIER_CTRL = 1 << 2,
|
|
|
|
WLR_MODIFIER_ALT = 1 << 3,
|
|
|
|
WLR_MODIFIER_MOD2 = 1 << 4,
|
|
|
|
WLR_MODIFIER_MOD3 = 1 << 5,
|
|
|
|
WLR_MODIFIER_LOGO = 1 << 6,
|
|
|
|
WLR_MODIFIER_MOD5 = 1 << 7,
|
2017-10-02 19:23:30 +02:00
|
|
|
};
|
|
|
|
|
2017-11-05 17:09:00 +01:00
|
|
|
#define WLR_KEYBOARD_KEYS_CAP 32
|
|
|
|
|
2017-06-20 00:41:02 +02:00
|
|
|
struct wlr_keyboard_impl;
|
|
|
|
|
2018-01-05 13:00:50 +01:00
|
|
|
struct wlr_keyboard_modifiers {
|
|
|
|
xkb_mod_mask_t depressed;
|
|
|
|
xkb_mod_mask_t latched;
|
|
|
|
xkb_mod_mask_t locked;
|
|
|
|
xkb_mod_mask_t group;
|
|
|
|
};
|
|
|
|
|
2017-06-20 00:41:02 +02:00
|
|
|
struct wlr_keyboard {
|
2018-04-28 13:55:36 +02:00
|
|
|
const struct wlr_keyboard_impl *impl;
|
Introduce wlr_keyboard_group
A wlr_keyboard_group allows for multiple keyboard devices to be
combined into one logical keyboard. Each keyboard device can only be
added to one keyboard group. This helps with the situation where one
physical keyboard is exposed as multiple keyboard devices. It is up to
the compositors on how they group keyboards together, if at all.
Since a wlr_keyboard_group is one logical keyboard, the keys are a set.
This means that if a key is pressed on multiple keyboard devices, the
key event will only be emitted once, but the internal state will count
the number of devices that the key is pressed on. Likewise, the key
release will not be emitted until the key is released from all devices.
If the compositor wants access to which keys are pressed and released
on each keyboard device, the events for those devices can be listened
to, as they currently are, in addition to the group keyboard's events.
Also, all keyboard devices in the group must share the same keymap. If
the keymap's differ, the keyboard device will not be able to be added
to the group. Once in the group, if the keymap or effective layout for
one keyboard device changes, it will be synced to all keyboard devices
in the group. The repeat info and keyboard modifiers are also synced
2019-11-03 20:18:41 +01:00
|
|
|
struct wlr_keyboard_group *group;
|
2017-09-24 20:12:56 +02:00
|
|
|
|
2018-09-18 00:17:33 +02:00
|
|
|
char *keymap_string;
|
2017-09-24 20:12:56 +02:00
|
|
|
size_t keymap_size;
|
|
|
|
struct xkb_keymap *keymap;
|
|
|
|
struct xkb_state *xkb_state;
|
2017-10-02 20:21:47 +02:00
|
|
|
xkb_led_index_t led_indexes[WLR_LED_COUNT];
|
|
|
|
xkb_mod_index_t mod_indexes[WLR_MODIFIER_COUNT];
|
2017-10-02 19:23:30 +02:00
|
|
|
|
2017-11-05 17:09:00 +01:00
|
|
|
uint32_t keycodes[WLR_KEYBOARD_KEYS_CAP];
|
2017-12-28 00:58:43 +01:00
|
|
|
size_t num_keycodes;
|
2018-01-17 14:31:15 +01:00
|
|
|
struct wlr_keyboard_modifiers modifiers;
|
2017-06-20 00:41:02 +02:00
|
|
|
|
2017-12-08 17:03:05 +01:00
|
|
|
struct {
|
|
|
|
int32_t rate;
|
|
|
|
int32_t delay;
|
|
|
|
} repeat_info;
|
|
|
|
|
2017-06-20 00:41:02 +02:00
|
|
|
struct {
|
2018-05-26 17:32:45 +02:00
|
|
|
/**
|
|
|
|
* The `key` event signals with a `wlr_event_keyboard_key` event that a
|
|
|
|
* key has been pressed or released on the keyboard. This event is
|
|
|
|
* emitted before the xkb state of the keyboard has been updated
|
|
|
|
* (including modifiers).
|
|
|
|
*/
|
2017-06-20 00:41:02 +02:00
|
|
|
struct wl_signal key;
|
2018-05-26 17:32:45 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The `modifiers` event signals that the modifier state of the
|
|
|
|
* `wlr_keyboard` has been updated. At this time, you can read the
|
|
|
|
* modifier state of the `wlr_keyboard` and handle the updated state by
|
|
|
|
* sending it to clients.
|
|
|
|
*/
|
2017-10-03 14:03:26 +02:00
|
|
|
struct wl_signal modifiers;
|
2017-09-24 20:12:56 +02:00
|
|
|
struct wl_signal keymap;
|
2017-12-08 17:03:05 +01:00
|
|
|
struct wl_signal repeat_info;
|
Introduce wlr_keyboard_group
A wlr_keyboard_group allows for multiple keyboard devices to be
combined into one logical keyboard. Each keyboard device can only be
added to one keyboard group. This helps with the situation where one
physical keyboard is exposed as multiple keyboard devices. It is up to
the compositors on how they group keyboards together, if at all.
Since a wlr_keyboard_group is one logical keyboard, the keys are a set.
This means that if a key is pressed on multiple keyboard devices, the
key event will only be emitted once, but the internal state will count
the number of devices that the key is pressed on. Likewise, the key
release will not be emitted until the key is released from all devices.
If the compositor wants access to which keys are pressed and released
on each keyboard device, the events for those devices can be listened
to, as they currently are, in addition to the group keyboard's events.
Also, all keyboard devices in the group must share the same keymap. If
the keymap's differ, the keyboard device will not be able to be added
to the group. Once in the group, if the keymap or effective layout for
one keyboard device changes, it will be synced to all keyboard devices
in the group. The repeat info and keyboard modifiers are also synced
2019-11-03 20:18:41 +01:00
|
|
|
struct wl_signal destroy;
|
2017-06-20 00:41:02 +02:00
|
|
|
} events;
|
2017-08-11 20:23:53 +02:00
|
|
|
|
|
|
|
void *data;
|
2017-06-20 00:41:02 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
enum wlr_key_state {
|
|
|
|
WLR_KEY_RELEASED,
|
|
|
|
WLR_KEY_PRESSED,
|
|
|
|
};
|
|
|
|
|
2017-06-21 20:07:09 +02:00
|
|
|
struct wlr_event_keyboard_key {
|
2017-10-30 11:40:06 +01:00
|
|
|
uint32_t time_msec;
|
2017-06-20 00:41:02 +02:00
|
|
|
uint32_t keycode;
|
2018-06-03 14:18:57 +02:00
|
|
|
bool update_state; // if backend doesn't update modifiers on its own
|
2017-06-20 00:41:02 +02:00
|
|
|
enum wlr_key_state state;
|
|
|
|
};
|
|
|
|
|
2020-03-24 00:18:18 +01:00
|
|
|
bool wlr_keyboard_set_keymap(struct wlr_keyboard *kb,
|
2017-10-02 19:23:30 +02:00
|
|
|
struct xkb_keymap *keymap);
|
2020-05-08 04:15:26 +02:00
|
|
|
|
|
|
|
bool wlr_keyboard_keymaps_match(struct xkb_keymap *km1, struct xkb_keymap *km2);
|
|
|
|
|
2017-12-08 17:06:31 +01:00
|
|
|
/**
|
|
|
|
* Sets the keyboard repeat info. `rate` is in key repeats/second and delay is
|
|
|
|
* in milliseconds.
|
|
|
|
*/
|
2017-12-08 17:03:05 +01:00
|
|
|
void wlr_keyboard_set_repeat_info(struct wlr_keyboard *kb, int32_t rate,
|
|
|
|
int32_t delay);
|
2017-10-02 20:21:47 +02:00
|
|
|
void wlr_keyboard_led_update(struct wlr_keyboard *keyboard, uint32_t leds);
|
|
|
|
uint32_t wlr_keyboard_get_modifiers(struct wlr_keyboard *keyboard);
|
2017-09-24 20:12:56 +02:00
|
|
|
|
2017-06-20 00:41:02 +02:00
|
|
|
#endif
|