joystick.h 3.6 KB

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