Documentation for <wlr/types/wlr_keyboard.h>

Back to index

Table of contents

struct wlr_keyboard

struct wlr_keyboard {
	struct wlr_input_device base;
	
	const struct wlr_keyboard_impl *impl;
	struct wlr_keyboard_group *group;
	
	char *keymap_string;
	size_t keymap_size;
	int keymap_fd;
	struct xkb_keymap *keymap;
	struct xkb_state *xkb_state;
	xkb_led_index_t led_indexes[];
	xkb_mod_index_t mod_indexes[];
	
	uint32_t leds;
	uint32_t keycodes[];
	size_t num_keycodes;
	struct wlr_keyboard_modifiers modifiers;
	
	struct {
		int32_t rate;
		int32_t delay;
	} repeat_info;
	
	struct {
		/**
		 * The `key` event signals with a struct wlr_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).
		 */
		struct wl_signal key;
		
		/**
		 * The `modifiers` event signals that the modifier state of the
		 * struct wlr_keyboard has been updated. At this time, you can read the
		 * modifier state of the struct wlr_keyboard and handle the updated
		 * state by sending it to clients.
		 */
		struct wl_signal modifiers;
		struct wl_signal keymap;
		struct wl_signal repeat_info;
	} events;
	
	void *data;
};

wlr_keyboard_from_input_device()

struct wlr_keyboard *wlr_keyboard_from_input_device(​struct wlr_input_device *input_device);

Get a struct wlr_keyboard from a struct wlr_input_device.

Asserts that the input device is a keyboard.

wlr_keyboard_get_modifiers()

uint32_t wlr_keyboard_get_modifiers(​struct wlr_keyboard *keyboard);

Get the set of currently depressed or latched modifiers.

A bitmask of enum wlr_keyboard_modifier is returned.

struct wlr_keyboard_key_event

struct wlr_keyboard_key_event {
	uint32_t time_msec;
	uint32_t keycode;
	bool update_state; // if backend doesn't update modifiers on its own
	enum wl_keyboard_key_state state;
};

wlr_keyboard_keymaps_match()

bool wlr_keyboard_keymaps_match(​struct xkb_keymap *km1, struct xkb_keymap *km2);

WLR_KEYBOARD_KEYS_CAP

#define WLR_KEYBOARD_KEYS_CAP

enum wlr_keyboard_led

enum wlr_keyboard_led {
	WLR_LED_NUM_LOCK,
	WLR_LED_CAPS_LOCK,
	WLR_LED_SCROLL_LOCK,
};

wlr_keyboard_led_update()

void wlr_keyboard_led_update(​struct wlr_keyboard *keyboard, uint32_t leds);

Update the LEDs on the device, if any.

leds is a bitmask of enum wlr_keyboard_led.

If the device doesn't have the provided LEDs, this function is a no-op.

enum wlr_keyboard_modifier

enum wlr_keyboard_modifier {
	WLR_MODIFIER_SHIFT,
	WLR_MODIFIER_CAPS,
	WLR_MODIFIER_CTRL,
	WLR_MODIFIER_ALT,
	WLR_MODIFIER_MOD2,
	WLR_MODIFIER_MOD3,
	WLR_MODIFIER_LOGO,
	WLR_MODIFIER_MOD5,
};

struct wlr_keyboard_modifiers

struct wlr_keyboard_modifiers {
	xkb_mod_mask_t depressed;
	xkb_mod_mask_t latched;
	xkb_mod_mask_t locked;
	xkb_layout_index_t group;
};

wlr_keyboard_set_keymap()

bool wlr_keyboard_set_keymap(​struct wlr_keyboard *kb, struct xkb_keymap *keymap);

wlr_keyboard_set_repeat_info()

void wlr_keyboard_set_repeat_info(​struct wlr_keyboard *kb, int32_t rate_hz, int32_t delay_ms);

Set the keyboard repeat info.

rate is in key repeats/second and delay is in milliseconds.

WLR_LED_COUNT

#define WLR_LED_COUNT

WLR_MODIFIER_COUNT

#define WLR_MODIFIER_COUNT