diff options
| author | 3gg <3gg@shellblade.net> | 2026-03-06 13:26:57 -0800 |
|---|---|---|
| committer | 3gg <3gg@shellblade.net> | 2026-03-06 13:26:57 -0800 |
| commit | f5c89b3bd5d74849757fd5b4d1a300068522a3ca (patch) | |
| tree | d6f6e4c81745b393d7594b334710f30c0b2df3bd /SDL-3.2.8/src/core/linux/SDL_evdev_capabilities.h | |
Diffstat (limited to 'SDL-3.2.8/src/core/linux/SDL_evdev_capabilities.h')
| -rw-r--r-- | SDL-3.2.8/src/core/linux/SDL_evdev_capabilities.h | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/SDL-3.2.8/src/core/linux/SDL_evdev_capabilities.h b/SDL-3.2.8/src/core/linux/SDL_evdev_capabilities.h new file mode 100644 index 0000000..5a70bdd --- /dev/null +++ b/SDL-3.2.8/src/core/linux/SDL_evdev_capabilities.h | |||
| @@ -0,0 +1,76 @@ | |||
| 1 | /* | ||
| 2 | Simple DirectMedia Layer | ||
| 3 | Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org> | ||
| 4 | Copyright (C) 2020 Collabora Ltd. | ||
| 5 | |||
| 6 | This software is provided 'as-is', without any express or implied | ||
| 7 | warranty. In no event will the authors be held liable for any damages | ||
| 8 | arising from the use of this software. | ||
| 9 | |||
| 10 | Permission is granted to anyone to use this software for any purpose, | ||
| 11 | including commercial applications, and to alter it and redistribute it | ||
| 12 | freely, subject to the following restrictions: | ||
| 13 | |||
| 14 | 1. The origin of this software must not be misrepresented; you must not | ||
| 15 | claim that you wrote the original software. If you use this software | ||
| 16 | in a product, an acknowledgment in the product documentation would be | ||
| 17 | appreciated but is not required. | ||
| 18 | 2. Altered source versions must be plainly marked as such, and must not be | ||
| 19 | misrepresented as being the original software. | ||
| 20 | 3. This notice may not be removed or altered from any source distribution. | ||
| 21 | */ | ||
| 22 | #include "SDL_internal.h" | ||
| 23 | |||
| 24 | #ifndef SDL_evdev_capabilities_h_ | ||
| 25 | #define SDL_evdev_capabilities_h_ | ||
| 26 | |||
| 27 | #ifdef HAVE_LINUX_INPUT_H | ||
| 28 | |||
| 29 | #include <linux/input.h> | ||
| 30 | |||
| 31 | #ifndef INPUT_PROP_SEMI_MT | ||
| 32 | #define INPUT_PROP_SEMI_MT 0x03 | ||
| 33 | #endif | ||
| 34 | #ifndef INPUT_PROP_TOPBUTTONPAD | ||
| 35 | #define INPUT_PROP_TOPBUTTONPAD 0x04 | ||
| 36 | #endif | ||
| 37 | #ifndef INPUT_PROP_POINTING_STICK | ||
| 38 | #define INPUT_PROP_POINTING_STICK 0x05 | ||
| 39 | #endif | ||
| 40 | #ifndef INPUT_PROP_ACCELEROMETER | ||
| 41 | #define INPUT_PROP_ACCELEROMETER 0x06 | ||
| 42 | #endif | ||
| 43 | #ifndef INPUT_PROP_MAX | ||
| 44 | #define INPUT_PROP_MAX 0x1f | ||
| 45 | #endif | ||
| 46 | |||
| 47 | // A device can be any combination of these classes | ||
| 48 | typedef enum | ||
| 49 | { | ||
| 50 | SDL_UDEV_DEVICE_UNKNOWN = 0x0000, | ||
| 51 | SDL_UDEV_DEVICE_MOUSE = 0x0001, | ||
| 52 | SDL_UDEV_DEVICE_KEYBOARD = 0x0002, | ||
| 53 | SDL_UDEV_DEVICE_JOYSTICK = 0x0004, | ||
| 54 | SDL_UDEV_DEVICE_SOUND = 0x0008, | ||
| 55 | SDL_UDEV_DEVICE_TOUCHSCREEN = 0x0010, | ||
| 56 | SDL_UDEV_DEVICE_ACCELEROMETER = 0x0020, | ||
| 57 | SDL_UDEV_DEVICE_TOUCHPAD = 0x0040, | ||
| 58 | SDL_UDEV_DEVICE_HAS_KEYS = 0x0080, | ||
| 59 | SDL_UDEV_DEVICE_VIDEO_CAPTURE = 0x0100, | ||
| 60 | } SDL_UDEV_deviceclass; | ||
| 61 | |||
| 62 | #define BITS_PER_LONG (sizeof(unsigned long) * 8) | ||
| 63 | #define NBITS(x) ((((x)-1) / BITS_PER_LONG) + 1) | ||
| 64 | #define EVDEV_OFF(x) ((x) % BITS_PER_LONG) | ||
| 65 | #define EVDEV_LONG(x) ((x) / BITS_PER_LONG) | ||
| 66 | #define test_bit(bit, array) ((array[EVDEV_LONG(bit)] >> EVDEV_OFF(bit)) & 1) | ||
| 67 | |||
| 68 | extern int SDL_EVDEV_GuessDeviceClass(const unsigned long bitmask_props[NBITS(INPUT_PROP_MAX)], | ||
| 69 | const unsigned long bitmask_ev[NBITS(EV_MAX)], | ||
| 70 | const unsigned long bitmask_abs[NBITS(ABS_MAX)], | ||
| 71 | const unsigned long bitmask_key[NBITS(KEY_MAX)], | ||
| 72 | const unsigned long bitmask_rel[NBITS(REL_MAX)]); | ||
| 73 | |||
| 74 | #endif // HAVE_LINUX_INPUT_H | ||
| 75 | |||
| 76 | #endif // SDL_evdev_capabilities_h_ | ||
