input.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059
  1. #ifndef _INPUT_H
  2. #define _INPUT_H
  3. /*
  4. * Copyright (c) 1999-2002 Vojtech Pavlik
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License version 2 as published by
  8. * the Free Software Foundation.
  9. */
  10. #ifdef __KERNEL__
  11. #include <linux/time.h>
  12. #include <linux/list.h>
  13. #else
  14. #include <sys/time.h>
  15. #include <sys/ioctl.h>
  16. #include <asm/types.h>
  17. #endif
  18. /*
  19. * The event structure itself
  20. */
  21. struct input_event {
  22. struct timeval time;
  23. __u16 type;
  24. __u16 code;
  25. __s32 value;
  26. };
  27. /*
  28. * Protocol version.
  29. */
  30. #define EV_VERSION 0x010000
  31. /*
  32. * IOCTLs (0x00 - 0x7f)
  33. */
  34. struct input_id {
  35. __u16 bustype;
  36. __u16 vendor;
  37. __u16 product;
  38. __u16 version;
  39. };
  40. struct input_absinfo {
  41. __s32 value;
  42. __s32 minimum;
  43. __s32 maximum;
  44. __s32 fuzz;
  45. __s32 flat;
  46. };
  47. #define EVIOCGVERSION _IOR('E', 0x01, int) /* get driver version */
  48. #define EVIOCGID _IOR('E', 0x02, struct input_id) /* get device ID */
  49. #define EVIOCGKEYCODE _IOR('E', 0x04, int[2]) /* get keycode */
  50. #define EVIOCSKEYCODE _IOW('E', 0x04, int[2]) /* set keycode */
  51. #define EVIOCGNAME(len) _IOC(_IOC_READ, 'E', 0x06, len) /* get device name */
  52. #define EVIOCGPHYS(len) _IOC(_IOC_READ, 'E', 0x07, len) /* get physical location */
  53. #define EVIOCGUNIQ(len) _IOC(_IOC_READ, 'E', 0x08, len) /* get unique identifier */
  54. #define EVIOCGKEY(len) _IOC(_IOC_READ, 'E', 0x18, len) /* get global keystate */
  55. #define EVIOCGLED(len) _IOC(_IOC_READ, 'E', 0x19, len) /* get all LEDs */
  56. #define EVIOCGSND(len) _IOC(_IOC_READ, 'E', 0x1a, len) /* get all sounds status */
  57. #define EVIOCGSW(len) _IOC(_IOC_READ, 'E', 0x1b, len) /* get all switch states */
  58. #define EVIOCGBIT(ev,len) _IOC(_IOC_READ, 'E', 0x20 + ev, len) /* get event bits */
  59. #define EVIOCGABS(abs) _IOR('E', 0x40 + abs, struct input_absinfo) /* get abs value/limits */
  60. #define EVIOCSABS(abs) _IOW('E', 0xc0 + abs, struct input_absinfo) /* set abs value/limits */
  61. #define EVIOCSFF _IOC(_IOC_WRITE, 'E', 0x80, sizeof(struct ff_effect)) /* send a force effect to a force feedback device */
  62. #define EVIOCRMFF _IOW('E', 0x81, int) /* Erase a force effect */
  63. #define EVIOCGEFFECTS _IOR('E', 0x84, int) /* Report number of effects playable at the same time */
  64. #define EVIOCGRAB _IOW('E', 0x90, int) /* Grab/Release device */
  65. /*
  66. * Event types
  67. */
  68. #define EV_SYN 0x00
  69. #define EV_KEY 0x01
  70. #define EV_REL 0x02
  71. #define EV_ABS 0x03
  72. #define EV_MSC 0x04
  73. #define EV_SW 0x05
  74. #define EV_LED 0x11
  75. #define EV_SND 0x12
  76. #define EV_REP 0x14
  77. #define EV_FF 0x15
  78. #define EV_PWR 0x16
  79. #define EV_FF_STATUS 0x17
  80. #define EV_MAX 0x1f
  81. /*
  82. * Synchronization events.
  83. */
  84. #define SYN_REPORT 0
  85. #define SYN_CONFIG 1
  86. /*
  87. * Keys and buttons
  88. */
  89. #define KEY_RESERVED 0
  90. #define KEY_ESC 1
  91. #define KEY_1 2
  92. #define KEY_2 3
  93. #define KEY_3 4
  94. #define KEY_4 5
  95. #define KEY_5 6
  96. #define KEY_6 7
  97. #define KEY_7 8
  98. #define KEY_8 9
  99. #define KEY_9 10
  100. #define KEY_0 11
  101. #define KEY_MINUS 12
  102. #define KEY_EQUAL 13
  103. #define KEY_BACKSPACE 14
  104. #define KEY_TAB 15
  105. #define KEY_Q 16
  106. #define KEY_W 17
  107. #define KEY_E 18
  108. #define KEY_R 19
  109. #define KEY_T 20
  110. #define KEY_Y 21
  111. #define KEY_U 22
  112. #define KEY_I 23
  113. #define KEY_O 24
  114. #define KEY_P 25
  115. #define KEY_LEFTBRACE 26
  116. #define KEY_RIGHTBRACE 27
  117. #define KEY_ENTER 28
  118. #define KEY_LEFTCTRL 29
  119. #define KEY_A 30
  120. #define KEY_S 31
  121. #define KEY_D 32
  122. #define KEY_F 33
  123. #define KEY_G 34
  124. #define KEY_H 35
  125. #define KEY_J 36
  126. #define KEY_K 37
  127. #define KEY_L 38
  128. #define KEY_SEMICOLON 39
  129. #define KEY_APOSTROPHE 40
  130. #define KEY_GRAVE 41
  131. #define KEY_LEFTSHIFT 42
  132. #define KEY_BACKSLASH 43
  133. #define KEY_Z 44
  134. #define KEY_X 45
  135. #define KEY_C 46
  136. #define KEY_V 47
  137. #define KEY_B 48
  138. #define KEY_N 49
  139. #define KEY_M 50
  140. #define KEY_COMMA 51
  141. #define KEY_DOT 52
  142. #define KEY_SLASH 53
  143. #define KEY_RIGHTSHIFT 54
  144. #define KEY_KPASTERISK 55
  145. #define KEY_LEFTALT 56
  146. #define KEY_SPACE 57
  147. #define KEY_CAPSLOCK 58
  148. #define KEY_F1 59
  149. #define KEY_F2 60
  150. #define KEY_F3 61
  151. #define KEY_F4 62
  152. #define KEY_F5 63
  153. #define KEY_F6 64
  154. #define KEY_F7 65
  155. #define KEY_F8 66
  156. #define KEY_F9 67
  157. #define KEY_F10 68
  158. #define KEY_NUMLOCK 69
  159. #define KEY_SCROLLLOCK 70
  160. #define KEY_KP7 71
  161. #define KEY_KP8 72
  162. #define KEY_KP9 73
  163. #define KEY_KPMINUS 74
  164. #define KEY_KP4 75
  165. #define KEY_KP5 76
  166. #define KEY_KP6 77
  167. #define KEY_KPPLUS 78
  168. #define KEY_KP1 79
  169. #define KEY_KP2 80
  170. #define KEY_KP3 81
  171. #define KEY_KP0 82
  172. #define KEY_KPDOT 83
  173. #define KEY_ZENKAKUHANKAKU 85
  174. #define KEY_102ND 86
  175. #define KEY_F11 87
  176. #define KEY_F12 88
  177. #define KEY_RO 89
  178. #define KEY_KATAKANA 90
  179. #define KEY_HIRAGANA 91
  180. #define KEY_HENKAN 92
  181. #define KEY_KATAKANAHIRAGANA 93
  182. #define KEY_MUHENKAN 94
  183. #define KEY_KPJPCOMMA 95
  184. #define KEY_KPENTER 96
  185. #define KEY_RIGHTCTRL 97
  186. #define KEY_KPSLASH 98
  187. #define KEY_SYSRQ 99
  188. #define KEY_RIGHTALT 100
  189. #define KEY_LINEFEED 101
  190. #define KEY_HOME 102
  191. #define KEY_UP 103
  192. #define KEY_PAGEUP 104
  193. #define KEY_LEFT 105
  194. #define KEY_RIGHT 106
  195. #define KEY_END 107
  196. #define KEY_DOWN 108
  197. #define KEY_PAGEDOWN 109
  198. #define KEY_INSERT 110
  199. #define KEY_DELETE 111
  200. #define KEY_MACRO 112
  201. #define KEY_MUTE 113
  202. #define KEY_VOLUMEDOWN 114
  203. #define KEY_VOLUMEUP 115
  204. #define KEY_POWER 116
  205. #define KEY_KPEQUAL 117
  206. #define KEY_KPPLUSMINUS 118
  207. #define KEY_PAUSE 119
  208. #define KEY_KPCOMMA 121
  209. #define KEY_HANGUEL 122
  210. #define KEY_HANJA 123
  211. #define KEY_YEN 124
  212. #define KEY_LEFTMETA 125
  213. #define KEY_RIGHTMETA 126
  214. #define KEY_COMPOSE 127
  215. #define KEY_STOP 128
  216. #define KEY_AGAIN 129
  217. #define KEY_PROPS 130
  218. #define KEY_UNDO 131
  219. #define KEY_FRONT 132
  220. #define KEY_COPY 133
  221. #define KEY_OPEN 134
  222. #define KEY_PASTE 135
  223. #define KEY_FIND 136
  224. #define KEY_CUT 137
  225. #define KEY_HELP 138
  226. #define KEY_MENU 139
  227. #define KEY_CALC 140
  228. #define KEY_SETUP 141
  229. #define KEY_SLEEP 142
  230. #define KEY_WAKEUP 143
  231. #define KEY_FILE 144
  232. #define KEY_SENDFILE 145
  233. #define KEY_DELETEFILE 146
  234. #define KEY_XFER 147
  235. #define KEY_PROG1 148
  236. #define KEY_PROG2 149
  237. #define KEY_WWW 150
  238. #define KEY_MSDOS 151
  239. #define KEY_COFFEE 152
  240. #define KEY_DIRECTION 153
  241. #define KEY_CYCLEWINDOWS 154
  242. #define KEY_MAIL 155
  243. #define KEY_BOOKMARKS 156
  244. #define KEY_COMPUTER 157
  245. #define KEY_BACK 158
  246. #define KEY_FORWARD 159
  247. #define KEY_CLOSECD 160
  248. #define KEY_EJECTCD 161
  249. #define KEY_EJECTCLOSECD 162
  250. #define KEY_NEXTSONG 163
  251. #define KEY_PLAYPAUSE 164
  252. #define KEY_PREVIOUSSONG 165
  253. #define KEY_STOPCD 166
  254. #define KEY_RECORD 167
  255. #define KEY_REWIND 168
  256. #define KEY_PHONE 169
  257. #define KEY_ISO 170
  258. #define KEY_CONFIG 171
  259. #define KEY_HOMEPAGE 172
  260. #define KEY_REFRESH 173
  261. #define KEY_EXIT 174
  262. #define KEY_MOVE 175
  263. #define KEY_EDIT 176
  264. #define KEY_SCROLLUP 177
  265. #define KEY_SCROLLDOWN 178
  266. #define KEY_KPLEFTPAREN 179
  267. #define KEY_KPRIGHTPAREN 180
  268. #define KEY_NEW 181
  269. #define KEY_REDO 182
  270. #define KEY_F13 183
  271. #define KEY_F14 184
  272. #define KEY_F15 185
  273. #define KEY_F16 186
  274. #define KEY_F17 187
  275. #define KEY_F18 188
  276. #define KEY_F19 189
  277. #define KEY_F20 190
  278. #define KEY_F21 191
  279. #define KEY_F22 192
  280. #define KEY_F23 193
  281. #define KEY_F24 194
  282. #define KEY_PLAYCD 200
  283. #define KEY_PAUSECD 201
  284. #define KEY_PROG3 202
  285. #define KEY_PROG4 203
  286. #define KEY_SUSPEND 205
  287. #define KEY_CLOSE 206
  288. #define KEY_PLAY 207
  289. #define KEY_FASTFORWARD 208
  290. #define KEY_BASSBOOST 209
  291. #define KEY_PRINT 210
  292. #define KEY_HP 211
  293. #define KEY_CAMERA 212
  294. #define KEY_SOUND 213
  295. #define KEY_QUESTION 214
  296. #define KEY_EMAIL 215
  297. #define KEY_CHAT 216
  298. #define KEY_SEARCH 217
  299. #define KEY_CONNECT 218
  300. #define KEY_FINANCE 219
  301. #define KEY_SPORT 220
  302. #define KEY_SHOP 221
  303. #define KEY_ALTERASE 222
  304. #define KEY_CANCEL 223
  305. #define KEY_BRIGHTNESSDOWN 224
  306. #define KEY_BRIGHTNESSUP 225
  307. #define KEY_MEDIA 226
  308. #define KEY_SWITCHVIDEOMODE 227
  309. #define KEY_KBDILLUMTOGGLE 228
  310. #define KEY_KBDILLUMDOWN 229
  311. #define KEY_KBDILLUMUP 230
  312. #define KEY_SEND 231
  313. #define KEY_REPLY 232
  314. #define KEY_FORWARDMAIL 233
  315. #define KEY_SAVE 234
  316. #define KEY_DOCUMENTS 235
  317. #define KEY_UNKNOWN 240
  318. #define BTN_MISC 0x100
  319. #define BTN_0 0x100
  320. #define BTN_1 0x101
  321. #define BTN_2 0x102
  322. #define BTN_3 0x103
  323. #define BTN_4 0x104
  324. #define BTN_5 0x105
  325. #define BTN_6 0x106
  326. #define BTN_7 0x107
  327. #define BTN_8 0x108
  328. #define BTN_9 0x109
  329. #define BTN_MOUSE 0x110
  330. #define BTN_LEFT 0x110
  331. #define BTN_RIGHT 0x111
  332. #define BTN_MIDDLE 0x112
  333. #define BTN_SIDE 0x113
  334. #define BTN_EXTRA 0x114
  335. #define BTN_FORWARD 0x115
  336. #define BTN_BACK 0x116
  337. #define BTN_TASK 0x117
  338. #define BTN_JOYSTICK 0x120
  339. #define BTN_TRIGGER 0x120
  340. #define BTN_THUMB 0x121
  341. #define BTN_THUMB2 0x122
  342. #define BTN_TOP 0x123
  343. #define BTN_TOP2 0x124
  344. #define BTN_PINKIE 0x125
  345. #define BTN_BASE 0x126
  346. #define BTN_BASE2 0x127
  347. #define BTN_BASE3 0x128
  348. #define BTN_BASE4 0x129
  349. #define BTN_BASE5 0x12a
  350. #define BTN_BASE6 0x12b
  351. #define BTN_DEAD 0x12f
  352. #define BTN_GAMEPAD 0x130
  353. #define BTN_A 0x130
  354. #define BTN_B 0x131
  355. #define BTN_C 0x132
  356. #define BTN_X 0x133
  357. #define BTN_Y 0x134
  358. #define BTN_Z 0x135
  359. #define BTN_TL 0x136
  360. #define BTN_TR 0x137
  361. #define BTN_TL2 0x138
  362. #define BTN_TR2 0x139
  363. #define BTN_SELECT 0x13a
  364. #define BTN_START 0x13b
  365. #define BTN_MODE 0x13c
  366. #define BTN_THUMBL 0x13d
  367. #define BTN_THUMBR 0x13e
  368. #define BTN_DIGI 0x140
  369. #define BTN_TOOL_PEN 0x140
  370. #define BTN_TOOL_RUBBER 0x141
  371. #define BTN_TOOL_BRUSH 0x142
  372. #define BTN_TOOL_PENCIL 0x143
  373. #define BTN_TOOL_AIRBRUSH 0x144
  374. #define BTN_TOOL_FINGER 0x145
  375. #define BTN_TOOL_MOUSE 0x146
  376. #define BTN_TOOL_LENS 0x147
  377. #define BTN_TOUCH 0x14a
  378. #define BTN_STYLUS 0x14b
  379. #define BTN_STYLUS2 0x14c
  380. #define BTN_TOOL_DOUBLETAP 0x14d
  381. #define BTN_TOOL_TRIPLETAP 0x14e
  382. #define BTN_WHEEL 0x150
  383. #define BTN_GEAR_DOWN 0x150
  384. #define BTN_GEAR_UP 0x151
  385. #define KEY_OK 0x160
  386. #define KEY_SELECT 0x161
  387. #define KEY_GOTO 0x162
  388. #define KEY_CLEAR 0x163
  389. #define KEY_POWER2 0x164
  390. #define KEY_OPTION 0x165
  391. #define KEY_INFO 0x166
  392. #define KEY_TIME 0x167
  393. #define KEY_VENDOR 0x168
  394. #define KEY_ARCHIVE 0x169
  395. #define KEY_PROGRAM 0x16a
  396. #define KEY_CHANNEL 0x16b
  397. #define KEY_FAVORITES 0x16c
  398. #define KEY_EPG 0x16d
  399. #define KEY_PVR 0x16e
  400. #define KEY_MHP 0x16f
  401. #define KEY_LANGUAGE 0x170
  402. #define KEY_TITLE 0x171
  403. #define KEY_SUBTITLE 0x172
  404. #define KEY_ANGLE 0x173
  405. #define KEY_ZOOM 0x174
  406. #define KEY_MODE 0x175
  407. #define KEY_KEYBOARD 0x176
  408. #define KEY_SCREEN 0x177
  409. #define KEY_PC 0x178
  410. #define KEY_TV 0x179
  411. #define KEY_TV2 0x17a
  412. #define KEY_VCR 0x17b
  413. #define KEY_VCR2 0x17c
  414. #define KEY_SAT 0x17d
  415. #define KEY_SAT2 0x17e
  416. #define KEY_CD 0x17f
  417. #define KEY_TAPE 0x180
  418. #define KEY_RADIO 0x181
  419. #define KEY_TUNER 0x182
  420. #define KEY_PLAYER 0x183
  421. #define KEY_TEXT 0x184
  422. #define KEY_DVD 0x185
  423. #define KEY_AUX 0x186
  424. #define KEY_MP3 0x187
  425. #define KEY_AUDIO 0x188
  426. #define KEY_VIDEO 0x189
  427. #define KEY_DIRECTORY 0x18a
  428. #define KEY_LIST 0x18b
  429. #define KEY_MEMO 0x18c
  430. #define KEY_CALENDAR 0x18d
  431. #define KEY_RED 0x18e
  432. #define KEY_GREEN 0x18f
  433. #define KEY_YELLOW 0x190
  434. #define KEY_BLUE 0x191
  435. #define KEY_CHANNELUP 0x192
  436. #define KEY_CHANNELDOWN 0x193
  437. #define KEY_FIRST 0x194
  438. #define KEY_LAST 0x195
  439. #define KEY_AB 0x196
  440. #define KEY_NEXT 0x197
  441. #define KEY_RESTART 0x198
  442. #define KEY_SLOW 0x199
  443. #define KEY_SHUFFLE 0x19a
  444. #define KEY_BREAK 0x19b
  445. #define KEY_PREVIOUS 0x19c
  446. #define KEY_DIGITS 0x19d
  447. #define KEY_TEEN 0x19e
  448. #define KEY_TWEN 0x19f
  449. #define KEY_DEL_EOL 0x1c0
  450. #define KEY_DEL_EOS 0x1c1
  451. #define KEY_INS_LINE 0x1c2
  452. #define KEY_DEL_LINE 0x1c3
  453. #define KEY_FN 0x1d0
  454. #define KEY_FN_ESC 0x1d1
  455. #define KEY_FN_F1 0x1d2
  456. #define KEY_FN_F2 0x1d3
  457. #define KEY_FN_F3 0x1d4
  458. #define KEY_FN_F4 0x1d5
  459. #define KEY_FN_F5 0x1d6
  460. #define KEY_FN_F6 0x1d7
  461. #define KEY_FN_F7 0x1d8
  462. #define KEY_FN_F8 0x1d9
  463. #define KEY_FN_F9 0x1da
  464. #define KEY_FN_F10 0x1db
  465. #define KEY_FN_F11 0x1dc
  466. #define KEY_FN_F12 0x1dd
  467. #define KEY_FN_1 0x1de
  468. #define KEY_FN_2 0x1df
  469. #define KEY_FN_D 0x1e0
  470. #define KEY_FN_E 0x1e1
  471. #define KEY_FN_F 0x1e2
  472. #define KEY_FN_S 0x1e3
  473. #define KEY_FN_B 0x1e4
  474. #define KEY_MAX 0x1ff
  475. /*
  476. * Relative axes
  477. */
  478. #define REL_X 0x00
  479. #define REL_Y 0x01
  480. #define REL_Z 0x02
  481. #define REL_RX 0x03
  482. #define REL_RY 0x04
  483. #define REL_RZ 0x05
  484. #define REL_HWHEEL 0x06
  485. #define REL_DIAL 0x07
  486. #define REL_WHEEL 0x08
  487. #define REL_MISC 0x09
  488. #define REL_MAX 0x0f
  489. /*
  490. * Absolute axes
  491. */
  492. #define ABS_X 0x00
  493. #define ABS_Y 0x01
  494. #define ABS_Z 0x02
  495. #define ABS_RX 0x03
  496. #define ABS_RY 0x04
  497. #define ABS_RZ 0x05
  498. #define ABS_THROTTLE 0x06
  499. #define ABS_RUDDER 0x07
  500. #define ABS_WHEEL 0x08
  501. #define ABS_GAS 0x09
  502. #define ABS_BRAKE 0x0a
  503. #define ABS_HAT0X 0x10
  504. #define ABS_HAT0Y 0x11
  505. #define ABS_HAT1X 0x12
  506. #define ABS_HAT1Y 0x13
  507. #define ABS_HAT2X 0x14
  508. #define ABS_HAT2Y 0x15
  509. #define ABS_HAT3X 0x16
  510. #define ABS_HAT3Y 0x17
  511. #define ABS_PRESSURE 0x18
  512. #define ABS_DISTANCE 0x19
  513. #define ABS_TILT_X 0x1a
  514. #define ABS_TILT_Y 0x1b
  515. #define ABS_TOOL_WIDTH 0x1c
  516. #define ABS_VOLUME 0x20
  517. #define ABS_MISC 0x28
  518. #define ABS_MAX 0x3f
  519. /*
  520. * Switch events
  521. */
  522. #define SW_0 0x00
  523. #define SW_1 0x01
  524. #define SW_2 0x02
  525. #define SW_3 0x03
  526. #define SW_4 0x04
  527. #define SW_5 0x05
  528. #define SW_6 0x06
  529. #define SW_7 0x07
  530. #define SW_MAX 0x0f
  531. /*
  532. * Misc events
  533. */
  534. #define MSC_SERIAL 0x00
  535. #define MSC_PULSELED 0x01
  536. #define MSC_GESTURE 0x02
  537. #define MSC_RAW 0x03
  538. #define MSC_SCAN 0x04
  539. #define MSC_MAX 0x07
  540. /*
  541. * LEDs
  542. */
  543. #define LED_NUML 0x00
  544. #define LED_CAPSL 0x01
  545. #define LED_SCROLLL 0x02
  546. #define LED_COMPOSE 0x03
  547. #define LED_KANA 0x04
  548. #define LED_SLEEP 0x05
  549. #define LED_SUSPEND 0x06
  550. #define LED_MUTE 0x07
  551. #define LED_MISC 0x08
  552. #define LED_MAIL 0x09
  553. #define LED_CHARGING 0x0a
  554. #define LED_MAX 0x0f
  555. /*
  556. * Autorepeat values
  557. */
  558. #define REP_DELAY 0x00
  559. #define REP_PERIOD 0x01
  560. #define REP_MAX 0x01
  561. /*
  562. * Sounds
  563. */
  564. #define SND_CLICK 0x00
  565. #define SND_BELL 0x01
  566. #define SND_TONE 0x02
  567. #define SND_MAX 0x07
  568. /*
  569. * IDs.
  570. */
  571. #define ID_BUS 0
  572. #define ID_VENDOR 1
  573. #define ID_PRODUCT 2
  574. #define ID_VERSION 3
  575. #define BUS_PCI 0x01
  576. #define BUS_ISAPNP 0x02
  577. #define BUS_USB 0x03
  578. #define BUS_HIL 0x04
  579. #define BUS_BLUETOOTH 0x05
  580. #define BUS_ISA 0x10
  581. #define BUS_I8042 0x11
  582. #define BUS_XTKBD 0x12
  583. #define BUS_RS232 0x13
  584. #define BUS_GAMEPORT 0x14
  585. #define BUS_PARPORT 0x15
  586. #define BUS_AMIGA 0x16
  587. #define BUS_ADB 0x17
  588. #define BUS_I2C 0x18
  589. #define BUS_HOST 0x19
  590. #define BUS_GSC 0x1A
  591. /*
  592. * Values describing the status of an effect
  593. */
  594. #define FF_STATUS_STOPPED 0x00
  595. #define FF_STATUS_PLAYING 0x01
  596. #define FF_STATUS_MAX 0x01
  597. /*
  598. * Structures used in ioctls to upload effects to a device
  599. * The first structures are not passed directly by using ioctls.
  600. * They are sub-structures of the actually sent structure (called ff_effect)
  601. */
  602. struct ff_replay {
  603. __u16 length; /* Duration of an effect in ms. All other times are also expressed in ms */
  604. __u16 delay; /* Time to wait before to start playing an effect */
  605. };
  606. struct ff_trigger {
  607. __u16 button; /* Number of button triggering an effect */
  608. __u16 interval; /* Time to wait before an effect can be re-triggered (ms) */
  609. };
  610. struct ff_envelope {
  611. __u16 attack_length; /* Duration of attack (ms) */
  612. __u16 attack_level; /* Level at beginning of attack */
  613. __u16 fade_length; /* Duration of fade (ms) */
  614. __u16 fade_level; /* Level at end of fade */
  615. };
  616. /* FF_CONSTANT */
  617. struct ff_constant_effect {
  618. __s16 level; /* Strength of effect. Negative values are OK */
  619. struct ff_envelope envelope;
  620. };
  621. /* FF_RAMP */
  622. struct ff_ramp_effect {
  623. __s16 start_level;
  624. __s16 end_level;
  625. struct ff_envelope envelope;
  626. };
  627. /* FF_SPRING of FF_FRICTION */
  628. struct ff_condition_effect {
  629. __u16 right_saturation; /* Max level when joystick is on the right */
  630. __u16 left_saturation; /* Max level when joystick in on the left */
  631. __s16 right_coeff; /* Indicates how fast the force grows when the
  632. joystick moves to the right */
  633. __s16 left_coeff; /* Same for left side */
  634. __u16 deadband; /* Size of area where no force is produced */
  635. __s16 center; /* Position of dead zone */
  636. };
  637. /* FF_PERIODIC */
  638. struct ff_periodic_effect {
  639. __u16 waveform; /* Kind of wave (sine, square...) */
  640. __u16 period; /* in ms */
  641. __s16 magnitude; /* Peak value */
  642. __s16 offset; /* Mean value of wave (roughly) */
  643. __u16 phase; /* 'Horizontal' shift */
  644. struct ff_envelope envelope;
  645. /* Only used if waveform == FF_CUSTOM */
  646. __u32 custom_len; /* Number of samples */
  647. __s16 *custom_data; /* Buffer of samples */
  648. /* Note: the data pointed by custom_data is copied by the driver. You can
  649. * therefore dispose of the memory after the upload/update */
  650. };
  651. /* FF_RUMBLE */
  652. /* Some rumble pads have two motors of different weight.
  653. strong_magnitude represents the magnitude of the vibration generated
  654. by the heavy motor.
  655. */
  656. struct ff_rumble_effect {
  657. __u16 strong_magnitude; /* Magnitude of the heavy motor */
  658. __u16 weak_magnitude; /* Magnitude of the light one */
  659. };
  660. /*
  661. * Structure sent through ioctl from the application to the driver
  662. */
  663. struct ff_effect {
  664. __u16 type;
  665. /* Following field denotes the unique id assigned to an effect.
  666. * If user sets if to -1, a new effect is created, and its id is returned in the same field
  667. * Else, the user sets it to the effect id it wants to update.
  668. */
  669. __s16 id;
  670. __u16 direction; /* Direction. 0 deg -> 0x0000 (down)
  671. 90 deg -> 0x4000 (left)
  672. 180 deg -> 0x8000 (up)
  673. 270 deg -> 0xC000 (right)
  674. */
  675. struct ff_trigger trigger;
  676. struct ff_replay replay;
  677. union {
  678. struct ff_constant_effect constant;
  679. struct ff_ramp_effect ramp;
  680. struct ff_periodic_effect periodic;
  681. struct ff_condition_effect condition[2]; /* One for each axis */
  682. struct ff_rumble_effect rumble;
  683. } u;
  684. };
  685. /*
  686. * Force feedback effect types
  687. */
  688. #define FF_RUMBLE 0x50
  689. #define FF_PERIODIC 0x51
  690. #define FF_CONSTANT 0x52
  691. #define FF_SPRING 0x53
  692. #define FF_FRICTION 0x54
  693. #define FF_DAMPER 0x55
  694. #define FF_INERTIA 0x56
  695. #define FF_RAMP 0x57
  696. /*
  697. * Force feedback periodic effect types
  698. */
  699. #define FF_SQUARE 0x58
  700. #define FF_TRIANGLE 0x59
  701. #define FF_SINE 0x5a
  702. #define FF_SAW_UP 0x5b
  703. #define FF_SAW_DOWN 0x5c
  704. #define FF_CUSTOM 0x5d
  705. /*
  706. * Set ff device properties
  707. */
  708. #define FF_GAIN 0x60
  709. #define FF_AUTOCENTER 0x61
  710. #define FF_MAX 0x7f
  711. #ifdef __KERNEL__
  712. /*
  713. * In-kernel definitions.
  714. */
  715. #include <linux/fs.h>
  716. #include <linux/timer.h>
  717. #define NBITS(x) (((x)/BITS_PER_LONG)+1)
  718. #define BIT(x) (1UL<<((x)%BITS_PER_LONG))
  719. #define LONG(x) ((x)/BITS_PER_LONG)
  720. #define INPUT_KEYCODE(dev, scancode) ((dev->keycodesize == 1) ? ((u8*)dev->keycode)[scancode] : \
  721. ((dev->keycodesize == 2) ? ((u16*)dev->keycode)[scancode] : (((u32*)dev->keycode)[scancode])))
  722. #define SET_INPUT_KEYCODE(dev, scancode, val) \
  723. ({ unsigned __old; \
  724. switch (dev->keycodesize) { \
  725. case 1: { \
  726. u8 *k = (u8 *)dev->keycode; \
  727. __old = k[scancode]; \
  728. k[scancode] = val; \
  729. break; \
  730. } \
  731. case 2: { \
  732. u16 *k = (u16 *)dev->keycode; \
  733. __old = k[scancode]; \
  734. k[scancode] = val; \
  735. break; \
  736. } \
  737. default: { \
  738. u32 *k = (u32 *)dev->keycode; \
  739. __old = k[scancode]; \
  740. k[scancode] = val; \
  741. break; \
  742. } \
  743. } \
  744. __old; })
  745. struct input_dev {
  746. void *private;
  747. const char *name;
  748. const char *phys;
  749. const char *uniq;
  750. struct input_id id;
  751. unsigned long evbit[NBITS(EV_MAX)];
  752. unsigned long keybit[NBITS(KEY_MAX)];
  753. unsigned long relbit[NBITS(REL_MAX)];
  754. unsigned long absbit[NBITS(ABS_MAX)];
  755. unsigned long mscbit[NBITS(MSC_MAX)];
  756. unsigned long ledbit[NBITS(LED_MAX)];
  757. unsigned long sndbit[NBITS(SND_MAX)];
  758. unsigned long ffbit[NBITS(FF_MAX)];
  759. unsigned long swbit[NBITS(SW_MAX)];
  760. int ff_effects_max;
  761. unsigned int keycodemax;
  762. unsigned int keycodesize;
  763. void *keycode;
  764. unsigned int repeat_key;
  765. struct timer_list timer;
  766. struct pt_regs *regs;
  767. int state;
  768. int sync;
  769. int abs[ABS_MAX + 1];
  770. int rep[REP_MAX + 1];
  771. unsigned long key[NBITS(KEY_MAX)];
  772. unsigned long led[NBITS(LED_MAX)];
  773. unsigned long snd[NBITS(SND_MAX)];
  774. unsigned long sw[NBITS(SW_MAX)];
  775. int absmax[ABS_MAX + 1];
  776. int absmin[ABS_MAX + 1];
  777. int absfuzz[ABS_MAX + 1];
  778. int absflat[ABS_MAX + 1];
  779. int (*open)(struct input_dev *dev);
  780. void (*close)(struct input_dev *dev);
  781. int (*accept)(struct input_dev *dev, struct file *file);
  782. int (*flush)(struct input_dev *dev, struct file *file);
  783. int (*event)(struct input_dev *dev, unsigned int type, unsigned int code, int value);
  784. int (*upload_effect)(struct input_dev *dev, struct ff_effect *effect);
  785. int (*erase_effect)(struct input_dev *dev, int effect_id);
  786. struct input_handle *grab;
  787. struct semaphore sem; /* serializes open and close operations */
  788. unsigned int users;
  789. struct device *dev;
  790. struct list_head h_list;
  791. struct list_head node;
  792. };
  793. /*
  794. * Structure for hotplug & device<->driver matching.
  795. */
  796. #define INPUT_DEVICE_ID_MATCH_BUS 1
  797. #define INPUT_DEVICE_ID_MATCH_VENDOR 2
  798. #define INPUT_DEVICE_ID_MATCH_PRODUCT 4
  799. #define INPUT_DEVICE_ID_MATCH_VERSION 8
  800. #define INPUT_DEVICE_ID_MATCH_EVBIT 0x010
  801. #define INPUT_DEVICE_ID_MATCH_KEYBIT 0x020
  802. #define INPUT_DEVICE_ID_MATCH_RELBIT 0x040
  803. #define INPUT_DEVICE_ID_MATCH_ABSBIT 0x080
  804. #define INPUT_DEVICE_ID_MATCH_MSCIT 0x100
  805. #define INPUT_DEVICE_ID_MATCH_LEDBIT 0x200
  806. #define INPUT_DEVICE_ID_MATCH_SNDBIT 0x400
  807. #define INPUT_DEVICE_ID_MATCH_FFBIT 0x800
  808. #define INPUT_DEVICE_ID_MATCH_SWBIT 0x1000
  809. #define INPUT_DEVICE_ID_MATCH_DEVICE\
  810. (INPUT_DEVICE_ID_MATCH_BUS | INPUT_DEVICE_ID_MATCH_VENDOR | INPUT_DEVICE_ID_MATCH_PRODUCT)
  811. #define INPUT_DEVICE_ID_MATCH_DEVICE_AND_VERSION\
  812. (INPUT_DEVICE_ID_MATCH_DEVICE | INPUT_DEVICE_ID_MATCH_VERSION)
  813. struct input_device_id {
  814. unsigned long flags;
  815. struct input_id id;
  816. unsigned long evbit[NBITS(EV_MAX)];
  817. unsigned long keybit[NBITS(KEY_MAX)];
  818. unsigned long relbit[NBITS(REL_MAX)];
  819. unsigned long absbit[NBITS(ABS_MAX)];
  820. unsigned long mscbit[NBITS(MSC_MAX)];
  821. unsigned long ledbit[NBITS(LED_MAX)];
  822. unsigned long sndbit[NBITS(SND_MAX)];
  823. unsigned long ffbit[NBITS(FF_MAX)];
  824. unsigned long swbit[NBITS(SW_MAX)];
  825. unsigned long driver_info;
  826. };
  827. struct input_handle;
  828. struct input_handler {
  829. void *private;
  830. void (*event)(struct input_handle *handle, unsigned int type, unsigned int code, int value);
  831. struct input_handle* (*connect)(struct input_handler *handler, struct input_dev *dev, struct input_device_id *id);
  832. void (*disconnect)(struct input_handle *handle);
  833. struct file_operations *fops;
  834. int minor;
  835. char *name;
  836. struct input_device_id *id_table;
  837. struct input_device_id *blacklist;
  838. struct list_head h_list;
  839. struct list_head node;
  840. };
  841. struct input_handle {
  842. void *private;
  843. int open;
  844. char *name;
  845. struct input_dev *dev;
  846. struct input_handler *handler;
  847. struct list_head d_node;
  848. struct list_head h_node;
  849. };
  850. #define to_dev(n) container_of(n,struct input_dev,node)
  851. #define to_handler(n) container_of(n,struct input_handler,node);
  852. #define to_handle(n) container_of(n,struct input_handle,d_node)
  853. #define to_handle_h(n) container_of(n,struct input_handle,h_node)
  854. static inline void init_input_dev(struct input_dev *dev)
  855. {
  856. INIT_LIST_HEAD(&dev->h_list);
  857. INIT_LIST_HEAD(&dev->node);
  858. }
  859. void input_register_device(struct input_dev *);
  860. void input_unregister_device(struct input_dev *);
  861. void input_register_handler(struct input_handler *);
  862. void input_unregister_handler(struct input_handler *);
  863. int input_grab_device(struct input_handle *);
  864. void input_release_device(struct input_handle *);
  865. int input_open_device(struct input_handle *);
  866. void input_close_device(struct input_handle *);
  867. int input_accept_process(struct input_handle *handle, struct file *file);
  868. int input_flush_device(struct input_handle* handle, struct file* file);
  869. void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value);
  870. static inline void input_report_key(struct input_dev *dev, unsigned int code, int value)
  871. {
  872. input_event(dev, EV_KEY, code, !!value);
  873. }
  874. static inline void input_report_rel(struct input_dev *dev, unsigned int code, int value)
  875. {
  876. input_event(dev, EV_REL, code, value);
  877. }
  878. static inline void input_report_abs(struct input_dev *dev, unsigned int code, int value)
  879. {
  880. input_event(dev, EV_ABS, code, value);
  881. }
  882. static inline void input_report_ff(struct input_dev *dev, unsigned int code, int value)
  883. {
  884. input_event(dev, EV_FF, code, value);
  885. }
  886. static inline void input_report_ff_status(struct input_dev *dev, unsigned int code, int value)
  887. {
  888. input_event(dev, EV_FF_STATUS, code, value);
  889. }
  890. static inline void input_report_switch(struct input_dev *dev, unsigned int code, int value)
  891. {
  892. input_event(dev, EV_SW, code, !!value);
  893. }
  894. static inline void input_regs(struct input_dev *dev, struct pt_regs *regs)
  895. {
  896. dev->regs = regs;
  897. }
  898. static inline void input_sync(struct input_dev *dev)
  899. {
  900. input_event(dev, EV_SYN, SYN_REPORT, 0);
  901. dev->regs = NULL;
  902. }
  903. static inline void input_set_abs_params(struct input_dev *dev, int axis, int min, int max, int fuzz, int flat)
  904. {
  905. dev->absmin[axis] = min;
  906. dev->absmax[axis] = max;
  907. dev->absfuzz[axis] = fuzz;
  908. dev->absflat[axis] = flat;
  909. dev->absbit[LONG(axis)] |= BIT(axis);
  910. }
  911. extern struct class *input_class;
  912. #endif
  913. #endif