input.h 24 KB

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