SDL_evdev_capabilities.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2022 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. #if HAVE_LINUX_INPUT_H
  23. #include <linux/input.h>
  24. /* A device can be any combination of these classes */
  25. typedef enum
  26. {
  27. SDL_UDEV_DEVICE_UNKNOWN = 0x0000,
  28. SDL_UDEV_DEVICE_MOUSE = 0x0001,
  29. SDL_UDEV_DEVICE_KEYBOARD = 0x0002,
  30. SDL_UDEV_DEVICE_JOYSTICK = 0x0004,
  31. SDL_UDEV_DEVICE_SOUND = 0x0008,
  32. SDL_UDEV_DEVICE_TOUCHSCREEN = 0x0010,
  33. SDL_UDEV_DEVICE_ACCELEROMETER = 0x0020,
  34. SDL_UDEV_DEVICE_TOUCHPAD = 0x0040
  35. } SDL_UDEV_deviceclass;
  36. #define BITS_PER_LONG (sizeof(unsigned long) * 8)
  37. #define NBITS(x) ((((x)-1) / BITS_PER_LONG) + 1)
  38. #define EVDEV_OFF(x) ((x) % BITS_PER_LONG)
  39. #define EVDEV_LONG(x) ((x) / BITS_PER_LONG)
  40. #define test_bit(bit, array) ((array[EVDEV_LONG(bit)] >> EVDEV_OFF(bit)) & 1)
  41. extern int SDL_EVDEV_GuessDeviceClass(const unsigned long bitmask_ev[NBITS(EV_MAX)],
  42. const unsigned long bitmask_abs[NBITS(ABS_MAX)],
  43. const unsigned long bitmask_key[NBITS(KEY_MAX)],
  44. const unsigned long bitmask_rel[NBITS(REL_MAX)]);
  45. #endif /* HAVE_LINUX_INPUT_H */
  46. #endif /* SDL_evdev_capabilities_h_ */
  47. /* vi: set ts=4 sw=4 expandtab: */