input.h 26 KB

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