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

Derek Foreman derekf at osg.samsung.com
Wed May 6 09:24:55 PDT 2015


On 05/05/15 03:59 PM, Bill Spitzak wrote:
> 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 think desktop-shell is still going to want this information,
regardless of whether we implement new protocol to feed it on to
clients.  So it may be the case that clients want it too, but I don't
think it would be better to only provide it to clients.

a wl_keyboard is actually the union of all keyboard devices in a seat
right now, so I guess any protocol that give this information to clients
has to be capable of providing a list of new keys (hotplug) and revoking
keys already available (hot unplug).

If there's interest in such protocol I can put something together, but
I'd like to see some wider interest first, as it'd be a lot of wasted
time if the code won't land.

My use case for this is another patch series I'm working on that lets
the shell auto-hide the virtual keyboard.  I haven't seen any client
side use case for knowing about these capabilities yet.

> 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?

Entirely possible, if anyone can suggest a better test, I'd do that
instead.  As long as we don't recognize some gaming left hand keyboard
that just has WASD and a few other keys on it as something that's fully
capable of typing text, I'd be happy...

> 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