mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-04-24 18:38:48 +02:00
linux: Distinguish between "device with keys" and a full keyboard
udev distinguishes between ID_INPUT_KEY, a device with any keyboard keys at all (including for example USB numeric keypads, Bluetooth headsets with volume control buttons, and some game controllers; and ID_INPUT_KEYBOARD, a reasonably fully-featured keyboard that you could use for general-purpose text entry. If we do the same here, then it's useful input to our heuristics for identifying devices: for example, a device with ID_INPUT_KEY could reasonably be a gamepad, but a device with ID_INPUT_KEYBOARD certainly isn't. Resolves: https://github.com/libsdl-org/SDL/issues/7827 Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
committed by
Sam Lantinga
parent
9b7a9ca666
commit
fa0ca3d41e
@@ -131,14 +131,15 @@ SDL_EVDEV_GuessDeviceClass(const unsigned long bitmask_ev[NBITS(EV_MAX)],
|
||||
}
|
||||
|
||||
if (found > 0) {
|
||||
devclass |= SDL_UDEV_DEVICE_KEYBOARD; /* ID_INPUT_KEY */
|
||||
devclass |= SDL_UDEV_DEVICE_HAS_KEYS; /* ID_INPUT_KEY */
|
||||
}
|
||||
}
|
||||
|
||||
/* the first 32 bits are ESC, numbers, and Q to D; if we have any of
|
||||
* those, consider it a keyboard device; do not test KEY_RESERVED, though */
|
||||
/* the first 32 bits are ESC, numbers, and Q to D, so if we have all of
|
||||
* those, consider it to be a fully-featured keyboard;
|
||||
* do not test KEY_RESERVED, though */
|
||||
keyboard_mask = 0xFFFFFFFE;
|
||||
if ((bitmask_key[0] & keyboard_mask) != 0) {
|
||||
if ((bitmask_key[0] & keyboard_mask) == keyboard_mask) {
|
||||
devclass |= SDL_UDEV_DEVICE_KEYBOARD; /* ID_INPUT_KEYBOARD */
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user