[PATCH weston 4/4] input: Detect keyboard capabilities

Bill Spitzak spitzak at gmail.com
Tue May 5 13:59:28 PDT 2015


It sure seems like it would be better to just provide the list of 
available keys to the client programs, and let them make up their own 
categories of device types.

I'm not sure if requiring every Latin letter is a good test for a 
keyboard either. Aren't there some foreign layouts that omit some?

On 05/05/2015 01:01 PM, Derek Foreman wrote:

> +static enum evdev_device_seat_capability
> +keyboard_caps(struct libinput_device *dev)
> +{
> +	bool letters = true, digits = true;
> +	uint32_t alpha_keys[] = {
> +		KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F,
> +		KEY_G, KEY_H, KEY_I, KEY_J, KEY_K, KEY_L,
> +		KEY_M, KEY_N, KEY_O, KEY_P, KEY_Q, KEY_R,
> +		KEY_S, KEY_T, KEY_U, KEY_V, KEY_W, KEY_X,
> +		KEY_Y, KEY_Z, KEY_RESERVED
> +	};
> +	uint32_t digit_keys[] = {
> +		KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6,
> +		KEY_7, KEY_8, KEY_9, KEY_0, KEY_RESERVED
> +	};
> +	int i;
> +
> +	for (i = 0; letters && alpha_keys[i] != KEY_RESERVED; i++)
> +		letters &= libinput_device_keyboard_has_key(dev,
> +							    alpha_keys[i]);
> +
> +	for (i = 0; digits && digit_keys[i] != KEY_RESERVED; i++)
> +		digits &= libinput_device_keyboard_has_key(dev,
> +							   digit_keys[i]);
> +
> +	return EVDEV_SEAT_KEYBOARD |
> +	       (letters ? EVDEV_SEAT_KEYBOARD_LETTERS : 0) |
> +	       (digits ? EVDEV_SEAT_KEYBOARD_DIGITS : 0);
> +}



More information about the wayland-devel mailing list