joystick.h 3.8 KB

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