linux_joystick.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //========================================================================
  2. // GLFW 3.4 Linux - www.glfw.org
  3. //------------------------------------------------------------------------
  4. // Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
  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
  17. // be appreciated but is not required.
  18. //
  19. // 2. Altered source versions must be plainly marked as such, and must not
  20. // be misrepresented as being the original software.
  21. //
  22. // 3. This notice may not be removed or altered from any source
  23. // distribution.
  24. //
  25. //========================================================================
  26. #include <linux/input.h>
  27. #include <linux/limits.h>
  28. #include <regex.h>
  29. #define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickLinux linjs
  30. #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE _GLFWlibraryLinux linjs;
  31. #define _GLFW_PLATFORM_MAPPING_NAME "Linux"
  32. // Linux-specific joystick data
  33. //
  34. typedef struct _GLFWjoystickLinux
  35. {
  36. int fd;
  37. char path[PATH_MAX];
  38. int keyMap[KEY_CNT - BTN_MISC];
  39. int absMap[ABS_CNT];
  40. struct input_absinfo absInfo[ABS_CNT];
  41. int hats[4][2];
  42. } _GLFWjoystickLinux;
  43. // Linux-specific joystick API data
  44. //
  45. typedef struct _GLFWlibraryLinux
  46. {
  47. int inotify;
  48. int watch;
  49. regex_t regex;
  50. bool dropped;
  51. } _GLFWlibraryLinux;
  52. void _glfwDetectJoystickConnectionLinux(void);