Skip to content

evdev: Distinguish between full keyboards and devices that merely have some keys #7827

@smcv

Description

@smcv

In both udev and steam-runtime-tools, the equivalent of SDL_UDEV_DEVICE_KEYBOARD is split into two:

  • KEYBOARD is a reasonably full alphanumeric keyboard that you could use to type commands or your password;
  • HAS_KEYS is anything that can produce keyboard events, including USB numeric keypads, Bluetooth headset volume buttons, ACPI power buttons and even a few game controllers

At the moment SDL_UDEV_DEVICE_KEYBOARD is basically udev's HAS_KEYS.

If we want to change this in SDL 3, I would suggest renaming SDL_UDEV_DEVICE_KEYBOARD to SDL_UDEV_DEVICE_HAS_KEYS and introducing a new SDL_UDEV_DEVICE_FULL_KEYBOARD, so that anyone porting SDL 2 code is forced to decide which one they meant.

The logic in steam-runtime-tools, and I think also udev, is that a keyboard is assumed to be a full alphanumeric keyboard if it has at least Escape, 0-9 and Q-D, so the end of SDL_EVDEV_GuessDeviceClass would change to something like this:

    keyboard_mask = 0xFFFFFFFE;
    if ((bitmask_key[0] & keyboard_mask) != 0) {
        devclass |= SDL_UDEV_DEVICE_HAS_KEYS;
    }

    if ((bitmask_key[0] & keyboard_mask) == keyboard_mask) {
        devclass |= SDL_UDEV_DEVICE_FULL_KEYBOARD;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions