joystick.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * Copyright (C) 1996-2000 Vojtech Pavlik
  3. *
  4. * Sponsored by SuSE
  5. */
  6. /*
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. *
  21. * Should you need to contact me, the author, you can do so either by
  22. * e-mail - mail your message to <vojtech@suse.cz>, or by paper mail:
  23. * Vojtech Pavlik, Ucitelska 1576, Prague 8, 182 00 Czech Republic
  24. */
  25. #ifndef _UAPI_LINUX_JOYSTICK_H
  26. #define _UAPI_LINUX_JOYSTICK_H
  27. #include <linux/types.h>
  28. #include <linux/input.h>
  29. /*
  30. * Version
  31. */
  32. #define JS_VERSION 0x020100
  33. /*
  34. * Types and constants for reading from /dev/js
  35. */
  36. #define JS_EVENT_BUTTON 0x01 /* button pressed/released */
  37. #define JS_EVENT_AXIS 0x02 /* joystick moved */
  38. #define JS_EVENT_INIT 0x80 /* initial state of device */
  39. struct js_event {
  40. __u32 time; /* event timestamp in milliseconds */
  41. __s16 value; /* value */
  42. __u8 type; /* event type */
  43. __u8 number; /* axis/button number */
  44. };
  45. /*
  46. * IOCTL commands for joystick driver
  47. */
  48. #define JSIOCGVERSION _IOR('j', 0x01, __u32) /* get driver version */
  49. #define JSIOCGAXES _IOR('j', 0x11, __u8) /* get number of axes */
  50. #define JSIOCGBUTTONS _IOR('j', 0x12, __u8) /* get number of buttons */
  51. #define JSIOCGNAME(len) _IOC(_IOC_READ, 'j', 0x13, len) /* get identifier string */
  52. #define JSIOCSCORR _IOW('j', 0x21, struct js_corr) /* set correction values */
  53. #define JSIOCGCORR _IOR('j', 0x22, struct js_corr) /* get correction values */
  54. #define JSIOCSAXMAP _IOW('j', 0x31, __u8[ABS_CNT]) /* set axis mapping */
  55. #define JSIOCGAXMAP _IOR('j', 0x32, __u8[ABS_CNT]) /* get axis mapping */
  56. #define JSIOCSBTNMAP _IOW('j', 0x33, __u16[KEY_MAX - BTN_MISC + 1]) /* set button mapping */
  57. #define JSIOCGBTNMAP _IOR('j', 0x34, __u16[KEY_MAX - BTN_MISC + 1]) /* get button mapping */
  58. /*
  59. * Types and constants for get/set correction
  60. */
  61. #define JS_CORR_NONE 0x00 /* returns raw values */
  62. #define JS_CORR_BROKEN 0x01 /* broken line */
  63. struct js_corr {
  64. __s32 coef[8];
  65. __s16 prec;
  66. __u16 type;
  67. };
  68. /*
  69. * v0.x compatibility definitions
  70. */
  71. #define JS_RETURN sizeof(struct JS_DATA_TYPE)
  72. #define JS_TRUE 1
  73. #define JS_FALSE 0
  74. #define JS_X_0 0x01
  75. #define JS_Y_0 0x02
  76. #define JS_X_1 0x04
  77. #define JS_Y_1 0x08
  78. #define JS_MAX 2
  79. #define JS_DEF_TIMEOUT 0x1300
  80. #define JS_DEF_CORR 0
  81. #define JS_DEF_TIMELIMIT 10L
  82. #define JS_SET_CAL 1
  83. #define JS_GET_CAL 2
  84. #define JS_SET_TIMEOUT 3
  85. #define JS_GET_TIMEOUT 4
  86. #define JS_SET_TIMELIMIT 5
  87. #define JS_GET_TIMELIMIT 6
  88. #define JS_GET_ALL 7
  89. #define JS_SET_ALL 8
  90. struct JS_DATA_TYPE {
  91. __s32 buttons;
  92. __s32 x;
  93. __s32 y;
  94. };
  95. struct JS_DATA_SAVE_TYPE_32 {
  96. __s32 JS_TIMEOUT;
  97. __s32 BUSY;
  98. __s32 JS_EXPIRETIME;
  99. __s32 JS_TIMELIMIT;
  100. struct JS_DATA_TYPE JS_SAVE;
  101. struct JS_DATA_TYPE JS_CORR;
  102. };
  103. struct JS_DATA_SAVE_TYPE_64 {
  104. __s32 JS_TIMEOUT;
  105. __s32 BUSY;
  106. __s64 JS_EXPIRETIME;
  107. __s64 JS_TIMELIMIT;
  108. struct JS_DATA_TYPE JS_SAVE;
  109. struct JS_DATA_TYPE JS_CORR;
  110. };
  111. #endif /* _UAPI_LINUX_JOYSTICK_H */