SDL_evdev_capabilities.h 2.7 KB

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