input.h 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248
  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. * Most of the keys/buttons are modeled after USB HUT 1.12
  93. * (see http://www.usb.org/developers/hidpage).
  94. * Abbreviations in the comments:
  95. * AC - Application Control
  96. * AL - Application Launch Button
  97. * SC - System Control
  98. */
  99. #define KEY_RESERVED 0
  100. #define KEY_ESC 1
  101. #define KEY_1 2
  102. #define KEY_2 3
  103. #define KEY_3 4
  104. #define KEY_4 5
  105. #define KEY_5 6
  106. #define KEY_6 7
  107. #define KEY_7 8
  108. #define KEY_8 9
  109. #define KEY_9 10
  110. #define KEY_0 11
  111. #define KEY_MINUS 12
  112. #define KEY_EQUAL 13
  113. #define KEY_BACKSPACE 14
  114. #define KEY_TAB 15
  115. #define KEY_Q 16
  116. #define KEY_W 17
  117. #define KEY_E 18
  118. #define KEY_R 19
  119. #define KEY_T 20
  120. #define KEY_Y 21
  121. #define KEY_U 22
  122. #define KEY_I 23
  123. #define KEY_O 24
  124. #define KEY_P 25
  125. #define KEY_LEFTBRACE 26
  126. #define KEY_RIGHTBRACE 27
  127. #define KEY_ENTER 28
  128. #define KEY_LEFTCTRL 29
  129. #define KEY_A 30
  130. #define KEY_S 31
  131. #define KEY_D 32
  132. #define KEY_F 33
  133. #define KEY_G 34
  134. #define KEY_H 35
  135. #define KEY_J 36
  136. #define KEY_K 37
  137. #define KEY_L 38
  138. #define KEY_SEMICOLON 39
  139. #define KEY_APOSTROPHE 40
  140. #define KEY_GRAVE 41
  141. #define KEY_LEFTSHIFT 42
  142. #define KEY_BACKSLASH 43
  143. #define KEY_Z 44
  144. #define KEY_X 45
  145. #define KEY_C 46
  146. #define KEY_V 47
  147. #define KEY_B 48
  148. #define KEY_N 49
  149. #define KEY_M 50
  150. #define KEY_COMMA 51
  151. #define KEY_DOT 52
  152. #define KEY_SLASH 53
  153. #define KEY_RIGHTSHIFT 54
  154. #define KEY_KPASTERISK 55
  155. #define KEY_LEFTALT 56
  156. #define KEY_SPACE 57
  157. #define KEY_CAPSLOCK 58
  158. #define KEY_F1 59
  159. #define KEY_F2 60
  160. #define KEY_F3 61
  161. #define KEY_F4 62
  162. #define KEY_F5 63
  163. #define KEY_F6 64
  164. #define KEY_F7 65
  165. #define KEY_F8 66
  166. #define KEY_F9 67
  167. #define KEY_F10 68
  168. #define KEY_NUMLOCK 69
  169. #define KEY_SCROLLLOCK 70
  170. #define KEY_KP7 71
  171. #define KEY_KP8 72
  172. #define KEY_KP9 73
  173. #define KEY_KPMINUS 74
  174. #define KEY_KP4 75
  175. #define KEY_KP5 76
  176. #define KEY_KP6 77
  177. #define KEY_KPPLUS 78
  178. #define KEY_KP1 79
  179. #define KEY_KP2 80
  180. #define KEY_KP3 81
  181. #define KEY_KP0 82
  182. #define KEY_KPDOT 83
  183. #define KEY_ZENKAKUHANKAKU 85
  184. #define KEY_102ND 86
  185. #define KEY_F11 87
  186. #define KEY_F12 88
  187. #define KEY_RO 89
  188. #define KEY_KATAKANA 90
  189. #define KEY_HIRAGANA 91
  190. #define KEY_HENKAN 92
  191. #define KEY_KATAKANAHIRAGANA 93
  192. #define KEY_MUHENKAN 94
  193. #define KEY_KPJPCOMMA 95
  194. #define KEY_KPENTER 96
  195. #define KEY_RIGHTCTRL 97
  196. #define KEY_KPSLASH 98
  197. #define KEY_SYSRQ 99
  198. #define KEY_RIGHTALT 100
  199. #define KEY_LINEFEED 101
  200. #define KEY_HOME 102
  201. #define KEY_UP 103
  202. #define KEY_PAGEUP 104
  203. #define KEY_LEFT 105
  204. #define KEY_RIGHT 106
  205. #define KEY_END 107
  206. #define KEY_DOWN 108
  207. #define KEY_PAGEDOWN 109
  208. #define KEY_INSERT 110
  209. #define KEY_DELETE 111
  210. #define KEY_MACRO 112
  211. #define KEY_MUTE 113
  212. #define KEY_VOLUMEDOWN 114
  213. #define KEY_VOLUMEUP 115
  214. #define KEY_POWER 116 /* SC System Power Down */
  215. #define KEY_KPEQUAL 117
  216. #define KEY_KPPLUSMINUS 118
  217. #define KEY_PAUSE 119
  218. #define KEY_KPCOMMA 121
  219. #define KEY_HANGEUL 122
  220. #define KEY_HANGUEL KEY_HANGEUL
  221. #define KEY_HANJA 123
  222. #define KEY_YEN 124
  223. #define KEY_LEFTMETA 125
  224. #define KEY_RIGHTMETA 126
  225. #define KEY_COMPOSE 127
  226. #define KEY_STOP 128 /* AC Stop */
  227. #define KEY_AGAIN 129
  228. #define KEY_PROPS 130 /* AC Properties */
  229. #define KEY_UNDO 131 /* AC Undo */
  230. #define KEY_FRONT 132
  231. #define KEY_COPY 133 /* AC Copy */
  232. #define KEY_OPEN 134 /* AC Open */
  233. #define KEY_PASTE 135 /* AC Paste */
  234. #define KEY_FIND 136 /* AC Search */
  235. #define KEY_CUT 137 /* AC Cut */
  236. #define KEY_HELP 138 /* AL Integrated Help Center */
  237. #define KEY_MENU 139 /* Menu (show menu) */
  238. #define KEY_CALC 140 /* AL Calculator */
  239. #define KEY_SETUP 141
  240. #define KEY_SLEEP 142 /* SC System Sleep */
  241. #define KEY_WAKEUP 143 /* System Wake Up */
  242. #define KEY_FILE 144 /* AL Local Machine Browser */
  243. #define KEY_SENDFILE 145
  244. #define KEY_DELETEFILE 146
  245. #define KEY_XFER 147
  246. #define KEY_PROG1 148
  247. #define KEY_PROG2 149
  248. #define KEY_WWW 150 /* AL Internet Browser */
  249. #define KEY_MSDOS 151
  250. #define KEY_COFFEE 152 /* AL Terminal Lock/Screensaver */
  251. #define KEY_SCREENLOCK KEY_COFFEE
  252. #define KEY_DIRECTION 153
  253. #define KEY_CYCLEWINDOWS 154
  254. #define KEY_MAIL 155
  255. #define KEY_BOOKMARKS 156 /* AC Bookmarks */
  256. #define KEY_COMPUTER 157
  257. #define KEY_BACK 158 /* AC Back */
  258. #define KEY_FORWARD 159 /* AC Forward */
  259. #define KEY_CLOSECD 160
  260. #define KEY_EJECTCD 161
  261. #define KEY_EJECTCLOSECD 162
  262. #define KEY_NEXTSONG 163
  263. #define KEY_PLAYPAUSE 164
  264. #define KEY_PREVIOUSSONG 165
  265. #define KEY_STOPCD 166
  266. #define KEY_RECORD 167
  267. #define KEY_REWIND 168
  268. #define KEY_PHONE 169 /* Media Select Telephone */
  269. #define KEY_ISO 170
  270. #define KEY_CONFIG 171 /* AL Consumer Control Configuration */
  271. #define KEY_HOMEPAGE 172 /* AC Home */
  272. #define KEY_REFRESH 173 /* AC Refresh */
  273. #define KEY_EXIT 174 /* AC Exit */
  274. #define KEY_MOVE 175
  275. #define KEY_EDIT 176
  276. #define KEY_SCROLLUP 177
  277. #define KEY_SCROLLDOWN 178
  278. #define KEY_KPLEFTPAREN 179
  279. #define KEY_KPRIGHTPAREN 180
  280. #define KEY_NEW 181 /* AC New */
  281. #define KEY_REDO 182 /* AC Redo/Repeat */
  282. #define KEY_F13 183
  283. #define KEY_F14 184
  284. #define KEY_F15 185
  285. #define KEY_F16 186
  286. #define KEY_F17 187
  287. #define KEY_F18 188
  288. #define KEY_F19 189
  289. #define KEY_F20 190
  290. #define KEY_F21 191
  291. #define KEY_F22 192
  292. #define KEY_F23 193
  293. #define KEY_F24 194
  294. #define KEY_PLAYCD 200
  295. #define KEY_PAUSECD 201
  296. #define KEY_PROG3 202
  297. #define KEY_PROG4 203
  298. #define KEY_SUSPEND 205
  299. #define KEY_CLOSE 206 /* AC Close */
  300. #define KEY_PLAY 207
  301. #define KEY_FASTFORWARD 208
  302. #define KEY_BASSBOOST 209
  303. #define KEY_PRINT 210 /* AC Print */
  304. #define KEY_HP 211
  305. #define KEY_CAMERA 212
  306. #define KEY_SOUND 213
  307. #define KEY_QUESTION 214
  308. #define KEY_EMAIL 215
  309. #define KEY_CHAT 216
  310. #define KEY_SEARCH 217
  311. #define KEY_CONNECT 218
  312. #define KEY_FINANCE 219 /* AL Checkbook/Finance */
  313. #define KEY_SPORT 220
  314. #define KEY_SHOP 221
  315. #define KEY_ALTERASE 222
  316. #define KEY_CANCEL 223 /* AC Cancel */
  317. #define KEY_BRIGHTNESSDOWN 224
  318. #define KEY_BRIGHTNESSUP 225
  319. #define KEY_MEDIA 226
  320. #define KEY_SWITCHVIDEOMODE 227
  321. #define KEY_KBDILLUMTOGGLE 228
  322. #define KEY_KBDILLUMDOWN 229
  323. #define KEY_KBDILLUMUP 230
  324. #define KEY_SEND 231 /* AC Send */
  325. #define KEY_REPLY 232 /* AC Reply */
  326. #define KEY_FORWARDMAIL 233 /* AC Forward Msg */
  327. #define KEY_SAVE 234 /* AC Save */
  328. #define KEY_DOCUMENTS 235
  329. #define KEY_BATTERY 236
  330. #define KEY_BLUETOOTH 237
  331. #define KEY_WLAN 238
  332. #define KEY_UNKNOWN 240
  333. #define BTN_MISC 0x100
  334. #define BTN_0 0x100
  335. #define BTN_1 0x101
  336. #define BTN_2 0x102
  337. #define BTN_3 0x103
  338. #define BTN_4 0x104
  339. #define BTN_5 0x105
  340. #define BTN_6 0x106
  341. #define BTN_7 0x107
  342. #define BTN_8 0x108
  343. #define BTN_9 0x109
  344. #define BTN_MOUSE 0x110
  345. #define BTN_LEFT 0x110
  346. #define BTN_RIGHT 0x111
  347. #define BTN_MIDDLE 0x112
  348. #define BTN_SIDE 0x113
  349. #define BTN_EXTRA 0x114
  350. #define BTN_FORWARD 0x115
  351. #define BTN_BACK 0x116
  352. #define BTN_TASK 0x117
  353. #define BTN_JOYSTICK 0x120
  354. #define BTN_TRIGGER 0x120
  355. #define BTN_THUMB 0x121
  356. #define BTN_THUMB2 0x122
  357. #define BTN_TOP 0x123
  358. #define BTN_TOP2 0x124
  359. #define BTN_PINKIE 0x125
  360. #define BTN_BASE 0x126
  361. #define BTN_BASE2 0x127
  362. #define BTN_BASE3 0x128
  363. #define BTN_BASE4 0x129
  364. #define BTN_BASE5 0x12a
  365. #define BTN_BASE6 0x12b
  366. #define BTN_DEAD 0x12f
  367. #define BTN_GAMEPAD 0x130
  368. #define BTN_A 0x130
  369. #define BTN_B 0x131
  370. #define BTN_C 0x132
  371. #define BTN_X 0x133
  372. #define BTN_Y 0x134
  373. #define BTN_Z 0x135
  374. #define BTN_TL 0x136
  375. #define BTN_TR 0x137
  376. #define BTN_TL2 0x138
  377. #define BTN_TR2 0x139
  378. #define BTN_SELECT 0x13a
  379. #define BTN_START 0x13b
  380. #define BTN_MODE 0x13c
  381. #define BTN_THUMBL 0x13d
  382. #define BTN_THUMBR 0x13e
  383. #define BTN_DIGI 0x140
  384. #define BTN_TOOL_PEN 0x140
  385. #define BTN_TOOL_RUBBER 0x141
  386. #define BTN_TOOL_BRUSH 0x142
  387. #define BTN_TOOL_PENCIL 0x143
  388. #define BTN_TOOL_AIRBRUSH 0x144
  389. #define BTN_TOOL_FINGER 0x145
  390. #define BTN_TOOL_MOUSE 0x146
  391. #define BTN_TOOL_LENS 0x147
  392. #define BTN_TOUCH 0x14a
  393. #define BTN_STYLUS 0x14b
  394. #define BTN_STYLUS2 0x14c
  395. #define BTN_TOOL_DOUBLETAP 0x14d
  396. #define BTN_TOOL_TRIPLETAP 0x14e
  397. #define BTN_WHEEL 0x150
  398. #define BTN_GEAR_DOWN 0x150
  399. #define BTN_GEAR_UP 0x151
  400. #define KEY_OK 0x160
  401. #define KEY_SELECT 0x161
  402. #define KEY_GOTO 0x162
  403. #define KEY_CLEAR 0x163
  404. #define KEY_POWER2 0x164
  405. #define KEY_OPTION 0x165
  406. #define KEY_INFO 0x166 /* AL OEM Features/Tips/Tutorial */
  407. #define KEY_TIME 0x167
  408. #define KEY_VENDOR 0x168
  409. #define KEY_ARCHIVE 0x169
  410. #define KEY_PROGRAM 0x16a /* Media Select Program Guide */
  411. #define KEY_CHANNEL 0x16b
  412. #define KEY_FAVORITES 0x16c
  413. #define KEY_EPG 0x16d
  414. #define KEY_PVR 0x16e /* Media Select Home */
  415. #define KEY_MHP 0x16f
  416. #define KEY_LANGUAGE 0x170
  417. #define KEY_TITLE 0x171
  418. #define KEY_SUBTITLE 0x172
  419. #define KEY_ANGLE 0x173
  420. #define KEY_ZOOM 0x174
  421. #define KEY_MODE 0x175
  422. #define KEY_KEYBOARD 0x176
  423. #define KEY_SCREEN 0x177
  424. #define KEY_PC 0x178 /* Media Select Computer */
  425. #define KEY_TV 0x179 /* Media Select TV */
  426. #define KEY_TV2 0x17a /* Media Select Cable */
  427. #define KEY_VCR 0x17b /* Media Select VCR */
  428. #define KEY_VCR2 0x17c /* VCR Plus */
  429. #define KEY_SAT 0x17d /* Media Select Satellite */
  430. #define KEY_SAT2 0x17e
  431. #define KEY_CD 0x17f /* Media Select CD */
  432. #define KEY_TAPE 0x180 /* Media Select Tape */
  433. #define KEY_RADIO 0x181
  434. #define KEY_TUNER 0x182 /* Media Select Tuner */
  435. #define KEY_PLAYER 0x183
  436. #define KEY_TEXT 0x184
  437. #define KEY_DVD 0x185 /* Media Select DVD */
  438. #define KEY_AUX 0x186
  439. #define KEY_MP3 0x187
  440. #define KEY_AUDIO 0x188
  441. #define KEY_VIDEO 0x189
  442. #define KEY_DIRECTORY 0x18a
  443. #define KEY_LIST 0x18b
  444. #define KEY_MEMO 0x18c /* Media Select Messages */
  445. #define KEY_CALENDAR 0x18d
  446. #define KEY_RED 0x18e
  447. #define KEY_GREEN 0x18f
  448. #define KEY_YELLOW 0x190
  449. #define KEY_BLUE 0x191
  450. #define KEY_CHANNELUP 0x192 /* Channel Increment */
  451. #define KEY_CHANNELDOWN 0x193 /* Channel Decrement */
  452. #define KEY_FIRST 0x194
  453. #define KEY_LAST 0x195 /* Recall Last */
  454. #define KEY_AB 0x196
  455. #define KEY_NEXT 0x197
  456. #define KEY_RESTART 0x198
  457. #define KEY_SLOW 0x199
  458. #define KEY_SHUFFLE 0x19a
  459. #define KEY_BREAK 0x19b
  460. #define KEY_PREVIOUS 0x19c
  461. #define KEY_DIGITS 0x19d
  462. #define KEY_TEEN 0x19e
  463. #define KEY_TWEN 0x19f
  464. #define KEY_VIDEOPHONE 0x1a0 /* Media Select Video Phone */
  465. #define KEY_GAMES 0x1a1 /* Media Select Games */
  466. #define KEY_ZOOMIN 0x1a2 /* AC Zoom In */
  467. #define KEY_ZOOMOUT 0x1a3 /* AC Zoom Out */
  468. #define KEY_ZOOMRESET 0x1a4 /* AC Zoom */
  469. #define KEY_WORDPROCESSOR 0x1a5 /* AL Word Processor */
  470. #define KEY_EDITOR 0x1a6 /* AL Text Editor */
  471. #define KEY_SPREADSHEET 0x1a7 /* AL Spreadsheet */
  472. #define KEY_GRAPHICSEDITOR 0x1a8 /* AL Graphics Editor */
  473. #define KEY_PRESENTATION 0x1a9 /* AL Presentation App */
  474. #define KEY_DATABASE 0x1aa /* AL Database App */
  475. #define KEY_NEWS 0x1ab /* AL Newsreader */
  476. #define KEY_VOICEMAIL 0x1ac /* AL Voicemail */
  477. #define KEY_ADDRESSBOOK 0x1ad /* AL Contacts/Address Book */
  478. #define KEY_MESSENGER 0x1ae /* AL Instant Messaging */
  479. #define KEY_DISPLAYTOGGLE 0x1af /* Turn display (LCD) on and off */
  480. #define KEY_DEL_EOL 0x1c0
  481. #define KEY_DEL_EOS 0x1c1
  482. #define KEY_INS_LINE 0x1c2
  483. #define KEY_DEL_LINE 0x1c3
  484. #define KEY_FN 0x1d0
  485. #define KEY_FN_ESC 0x1d1
  486. #define KEY_FN_F1 0x1d2
  487. #define KEY_FN_F2 0x1d3
  488. #define KEY_FN_F3 0x1d4
  489. #define KEY_FN_F4 0x1d5
  490. #define KEY_FN_F5 0x1d6
  491. #define KEY_FN_F6 0x1d7
  492. #define KEY_FN_F7 0x1d8
  493. #define KEY_FN_F8 0x1d9
  494. #define KEY_FN_F9 0x1da
  495. #define KEY_FN_F10 0x1db
  496. #define KEY_FN_F11 0x1dc
  497. #define KEY_FN_F12 0x1dd
  498. #define KEY_FN_1 0x1de
  499. #define KEY_FN_2 0x1df
  500. #define KEY_FN_D 0x1e0
  501. #define KEY_FN_E 0x1e1
  502. #define KEY_FN_F 0x1e2
  503. #define KEY_FN_S 0x1e3
  504. #define KEY_FN_B 0x1e4
  505. #define KEY_BRL_DOT1 0x1f1
  506. #define KEY_BRL_DOT2 0x1f2
  507. #define KEY_BRL_DOT3 0x1f3
  508. #define KEY_BRL_DOT4 0x1f4
  509. #define KEY_BRL_DOT5 0x1f5
  510. #define KEY_BRL_DOT6 0x1f6
  511. #define KEY_BRL_DOT7 0x1f7
  512. #define KEY_BRL_DOT8 0x1f8
  513. /* We avoid low common keys in module aliases so they don't get huge. */
  514. #define KEY_MIN_INTERESTING KEY_MUTE
  515. #define KEY_MAX 0x1ff
  516. /*
  517. * Relative axes
  518. */
  519. #define REL_X 0x00
  520. #define REL_Y 0x01
  521. #define REL_Z 0x02
  522. #define REL_RX 0x03
  523. #define REL_RY 0x04
  524. #define REL_RZ 0x05
  525. #define REL_HWHEEL 0x06
  526. #define REL_DIAL 0x07
  527. #define REL_WHEEL 0x08
  528. #define REL_MISC 0x09
  529. #define REL_MAX 0x0f
  530. /*
  531. * Absolute axes
  532. */
  533. #define ABS_X 0x00
  534. #define ABS_Y 0x01
  535. #define ABS_Z 0x02
  536. #define ABS_RX 0x03
  537. #define ABS_RY 0x04
  538. #define ABS_RZ 0x05
  539. #define ABS_THROTTLE 0x06
  540. #define ABS_RUDDER 0x07
  541. #define ABS_WHEEL 0x08
  542. #define ABS_GAS 0x09
  543. #define ABS_BRAKE 0x0a
  544. #define ABS_HAT0X 0x10
  545. #define ABS_HAT0Y 0x11
  546. #define ABS_HAT1X 0x12
  547. #define ABS_HAT1Y 0x13
  548. #define ABS_HAT2X 0x14
  549. #define ABS_HAT2Y 0x15
  550. #define ABS_HAT3X 0x16
  551. #define ABS_HAT3Y 0x17
  552. #define ABS_PRESSURE 0x18
  553. #define ABS_DISTANCE 0x19
  554. #define ABS_TILT_X 0x1a
  555. #define ABS_TILT_Y 0x1b
  556. #define ABS_TOOL_WIDTH 0x1c
  557. #define ABS_VOLUME 0x20
  558. #define ABS_MISC 0x28
  559. #define ABS_MAX 0x3f
  560. /*
  561. * Switch events
  562. */
  563. #define SW_LID 0x00 /* set = lid shut */
  564. #define SW_TABLET_MODE 0x01 /* set = tablet mode */
  565. #define SW_HEADPHONE_INSERT 0x02 /* set = inserted */
  566. #define SW_RADIO 0x03 /* set = radio enabled */
  567. #define SW_MAX 0x0f
  568. /*
  569. * Misc events
  570. */
  571. #define MSC_SERIAL 0x00
  572. #define MSC_PULSELED 0x01
  573. #define MSC_GESTURE 0x02
  574. #define MSC_RAW 0x03
  575. #define MSC_SCAN 0x04
  576. #define MSC_MAX 0x07
  577. /*
  578. * LEDs
  579. */
  580. #define LED_NUML 0x00
  581. #define LED_CAPSL 0x01
  582. #define LED_SCROLLL 0x02
  583. #define LED_COMPOSE 0x03
  584. #define LED_KANA 0x04
  585. #define LED_SLEEP 0x05
  586. #define LED_SUSPEND 0x06
  587. #define LED_MUTE 0x07
  588. #define LED_MISC 0x08
  589. #define LED_MAIL 0x09
  590. #define LED_CHARGING 0x0a
  591. #define LED_MAX 0x0f
  592. /*
  593. * Autorepeat values
  594. */
  595. #define REP_DELAY 0x00
  596. #define REP_PERIOD 0x01
  597. #define REP_MAX 0x01
  598. /*
  599. * Sounds
  600. */
  601. #define SND_CLICK 0x00
  602. #define SND_BELL 0x01
  603. #define SND_TONE 0x02
  604. #define SND_MAX 0x07
  605. /*
  606. * IDs.
  607. */
  608. #define ID_BUS 0
  609. #define ID_VENDOR 1
  610. #define ID_PRODUCT 2
  611. #define ID_VERSION 3
  612. #define BUS_PCI 0x01
  613. #define BUS_ISAPNP 0x02
  614. #define BUS_USB 0x03
  615. #define BUS_HIL 0x04
  616. #define BUS_BLUETOOTH 0x05
  617. #define BUS_VIRTUAL 0x06
  618. #define BUS_ISA 0x10
  619. #define BUS_I8042 0x11
  620. #define BUS_XTKBD 0x12
  621. #define BUS_RS232 0x13
  622. #define BUS_GAMEPORT 0x14
  623. #define BUS_PARPORT 0x15
  624. #define BUS_AMIGA 0x16
  625. #define BUS_ADB 0x17
  626. #define BUS_I2C 0x18
  627. #define BUS_HOST 0x19
  628. #define BUS_GSC 0x1A
  629. #define BUS_ATARI 0x1B
  630. /*
  631. * Values describing the status of a force-feedback effect
  632. */
  633. #define FF_STATUS_STOPPED 0x00
  634. #define FF_STATUS_PLAYING 0x01
  635. #define FF_STATUS_MAX 0x01
  636. /*
  637. * Structures used in ioctls to upload effects to a device
  638. * They are pieces of a bigger structure (called ff_effect)
  639. */
  640. /*
  641. * All duration values are expressed in ms. Values above 32767 ms (0x7fff)
  642. * should not be used and have unspecified results.
  643. */
  644. /**
  645. * struct ff_replay - defines scheduling of the force-feedback effect
  646. * @length: duration of the effect
  647. * @delay: delay before effect should start playing
  648. */
  649. struct ff_replay {
  650. __u16 length;
  651. __u16 delay;
  652. };
  653. /**
  654. * struct ff_trigger - defines what triggers the force-feedback effect
  655. * @button: number of the button triggering the effect
  656. * @interval: controls how soon the effect can be re-triggered
  657. */
  658. struct ff_trigger {
  659. __u16 button;
  660. __u16 interval;
  661. };
  662. /**
  663. * struct ff_envelope - generic force-feedback effect envelope
  664. * @attack_length: duration of the attack (ms)
  665. * @attack_level: level at the beginning of the attack
  666. * @fade_length: duration of fade (ms)
  667. * @fade_level: level at the end of fade
  668. *
  669. * The @attack_level and @fade_level are absolute values; when applying
  670. * envelope force-feedback core will convert to positive/negative
  671. * value based on polarity of the default level of the effect.
  672. * Valid range for the attack and fade levels is 0x0000 - 0x7fff
  673. */
  674. struct ff_envelope {
  675. __u16 attack_length;
  676. __u16 attack_level;
  677. __u16 fade_length;
  678. __u16 fade_level;
  679. };
  680. /**
  681. * struct ff_constant_effect - defines parameters of a constant force-feedback effect
  682. * @level: strength of the effect; may be negative
  683. * @envelope: envelope data
  684. */
  685. struct ff_constant_effect {
  686. __s16 level;
  687. struct ff_envelope envelope;
  688. };
  689. /**
  690. * struct ff_ramp_effect - defines parameters of a ramp force-feedback effect
  691. * @start_level: beginning strength of the effect; may be negative
  692. * @end_level: final strength of the effect; may be negative
  693. * @envelope: envelope data
  694. */
  695. struct ff_ramp_effect {
  696. __s16 start_level;
  697. __s16 end_level;
  698. struct ff_envelope envelope;
  699. };
  700. /**
  701. * struct ff_condition_effect - defines a spring or friction force-feedback effect
  702. * @right_saturation: maximum level when joystick moved all way to the right
  703. * @left_saturation: same for the left side
  704. * @right_coeff: controls how fast the force grows when the joystick moves
  705. * to the right
  706. * @left_coeff: same for the left side
  707. * @deadband: size of the dead zone, where no force is produced
  708. * @center: position of the dead zone
  709. */
  710. struct ff_condition_effect {
  711. __u16 right_saturation;
  712. __u16 left_saturation;
  713. __s16 right_coeff;
  714. __s16 left_coeff;
  715. __u16 deadband;
  716. __s16 center;
  717. };
  718. /**
  719. * struct ff_periodic_effect - defines parameters of a periodic force-feedback effect
  720. * @waveform: kind of the effect (wave)
  721. * @period: period of the wave (ms)
  722. * @magnitude: peak value
  723. * @offset: mean value of the wave (roughly)
  724. * @phase: 'horizontal' shift
  725. * @envelope: envelope data
  726. * @custom_len: number of samples (FF_CUSTOM only)
  727. * @custom_data: buffer of samples (FF_CUSTOM only)
  728. *
  729. * Known waveforms - FF_SQUARE, FF_TRIANGLE, FF_SINE, FF_SAW_UP,
  730. * FF_SAW_DOWN, FF_CUSTOM. The exact syntax FF_CUSTOM is undefined
  731. * for the time being as no driver supports it yet.
  732. *
  733. * Note: the data pointed by custom_data is copied by the driver.
  734. * You can therefore dispose of the memory after the upload/update.
  735. */
  736. struct ff_periodic_effect {
  737. __u16 waveform;
  738. __u16 period;
  739. __s16 magnitude;
  740. __s16 offset;
  741. __u16 phase;
  742. struct ff_envelope envelope;
  743. __u32 custom_len;
  744. __s16 *custom_data;
  745. };
  746. /**
  747. * struct ff_rumble_effect - defines parameters of a periodic force-feedback effect
  748. * @strong_magnitude: magnitude of the heavy motor
  749. * @weak_magnitude: magnitude of the light one
  750. *
  751. * Some rumble pads have two motors of different weight. Strong_magnitude
  752. * represents the magnitude of the vibration generated by the heavy one.
  753. */
  754. struct ff_rumble_effect {
  755. __u16 strong_magnitude;
  756. __u16 weak_magnitude;
  757. };
  758. /**
  759. * struct ff_effect - defines force feedback effect
  760. * @type: type of the effect (FF_CONSTANT, FF_PERIODIC, FF_RAMP, FF_SPRING,
  761. * FF_FRICTION, FF_DAMPER, FF_RUMBLE, FF_INERTIA, or FF_CUSTOM)
  762. * @id: an unique id assigned to an effect
  763. * @direction: direction of the effect
  764. * @trigger: trigger conditions (struct ff_trigger)
  765. * @replay: scheduling of the effect (struct ff_replay)
  766. * @u: effect-specific structure (one of ff_constant_effect, ff_ramp_effect,
  767. * ff_periodic_effect, ff_condition_effect, ff_rumble_effect) further
  768. * defining effect parameters
  769. *
  770. * This structure is sent through ioctl from the application to the driver.
  771. * To create a new effect aplication should set its @id to -1; the kernel
  772. * will return assigned @id which can later be used to update or delete
  773. * this effect.
  774. *
  775. * Direction of the effect is encoded as follows:
  776. * 0 deg -> 0x0000 (down)
  777. * 90 deg -> 0x4000 (left)
  778. * 180 deg -> 0x8000 (up)
  779. * 270 deg -> 0xC000 (right)
  780. */
  781. struct ff_effect {
  782. __u16 type;
  783. __s16 id;
  784. __u16 direction;
  785. struct ff_trigger trigger;
  786. struct ff_replay replay;
  787. union {
  788. struct ff_constant_effect constant;
  789. struct ff_ramp_effect ramp;
  790. struct ff_periodic_effect periodic;
  791. struct ff_condition_effect condition[2]; /* One for each axis */
  792. struct ff_rumble_effect rumble;
  793. } u;
  794. };
  795. /*
  796. * Force feedback effect types
  797. */
  798. #define FF_RUMBLE 0x50
  799. #define FF_PERIODIC 0x51
  800. #define FF_CONSTANT 0x52
  801. #define FF_SPRING 0x53
  802. #define FF_FRICTION 0x54
  803. #define FF_DAMPER 0x55
  804. #define FF_INERTIA 0x56
  805. #define FF_RAMP 0x57
  806. #define FF_EFFECT_MIN FF_RUMBLE
  807. #define FF_EFFECT_MAX FF_RAMP
  808. /*
  809. * Force feedback periodic effect types
  810. */
  811. #define FF_SQUARE 0x58
  812. #define FF_TRIANGLE 0x59
  813. #define FF_SINE 0x5a
  814. #define FF_SAW_UP 0x5b
  815. #define FF_SAW_DOWN 0x5c
  816. #define FF_CUSTOM 0x5d
  817. #define FF_WAVEFORM_MIN FF_SQUARE
  818. #define FF_WAVEFORM_MAX FF_CUSTOM
  819. /*
  820. * Set ff device properties
  821. */
  822. #define FF_GAIN 0x60
  823. #define FF_AUTOCENTER 0x61
  824. #define FF_MAX 0x7f
  825. #ifdef __KERNEL__
  826. /*
  827. * In-kernel definitions.
  828. */
  829. #include <linux/device.h>
  830. #include <linux/fs.h>
  831. #include <linux/timer.h>
  832. #include <linux/mod_devicetable.h>
  833. #define NBITS(x) (((x)/BITS_PER_LONG)+1)
  834. #define BIT(x) (1UL<<((x)%BITS_PER_LONG))
  835. #define LONG(x) ((x)/BITS_PER_LONG)
  836. struct input_dev {
  837. void *private;
  838. const char *name;
  839. const char *phys;
  840. const char *uniq;
  841. struct input_id id;
  842. unsigned long evbit[NBITS(EV_MAX)];
  843. unsigned long keybit[NBITS(KEY_MAX)];
  844. unsigned long relbit[NBITS(REL_MAX)];
  845. unsigned long absbit[NBITS(ABS_MAX)];
  846. unsigned long mscbit[NBITS(MSC_MAX)];
  847. unsigned long ledbit[NBITS(LED_MAX)];
  848. unsigned long sndbit[NBITS(SND_MAX)];
  849. unsigned long ffbit[NBITS(FF_MAX)];
  850. unsigned long swbit[NBITS(SW_MAX)];
  851. unsigned int keycodemax;
  852. unsigned int keycodesize;
  853. void *keycode;
  854. int (*setkeycode)(struct input_dev *dev, int scancode, int keycode);
  855. int (*getkeycode)(struct input_dev *dev, int scancode, int *keycode);
  856. struct ff_device *ff;
  857. unsigned int repeat_key;
  858. struct timer_list timer;
  859. int state;
  860. int sync;
  861. int abs[ABS_MAX + 1];
  862. int rep[REP_MAX + 1];
  863. unsigned long key[NBITS(KEY_MAX)];
  864. unsigned long led[NBITS(LED_MAX)];
  865. unsigned long snd[NBITS(SND_MAX)];
  866. unsigned long sw[NBITS(SW_MAX)];
  867. int absmax[ABS_MAX + 1];
  868. int absmin[ABS_MAX + 1];
  869. int absfuzz[ABS_MAX + 1];
  870. int absflat[ABS_MAX + 1];
  871. int (*open)(struct input_dev *dev);
  872. void (*close)(struct input_dev *dev);
  873. int (*flush)(struct input_dev *dev, struct file *file);
  874. int (*event)(struct input_dev *dev, unsigned int type, unsigned int code, int value);
  875. struct input_handle *grab;
  876. struct mutex mutex; /* serializes open and close operations */
  877. unsigned int users;
  878. struct class_device cdev;
  879. union { /* temporarily so while we switching to struct device */
  880. struct device *parent;
  881. } dev;
  882. struct list_head h_list;
  883. struct list_head node;
  884. };
  885. #define to_input_dev(d) container_of(d, struct input_dev, cdev)
  886. /*
  887. * Verify that we are in sync with input_device_id mod_devicetable.h #defines
  888. */
  889. #if EV_MAX != INPUT_DEVICE_ID_EV_MAX
  890. #error "EV_MAX and INPUT_DEVICE_ID_EV_MAX do not match"
  891. #endif
  892. #if KEY_MIN_INTERESTING != INPUT_DEVICE_ID_KEY_MIN_INTERESTING
  893. #error "KEY_MIN_INTERESTING and INPUT_DEVICE_ID_KEY_MIN_INTERESTING do not match"
  894. #endif
  895. #if KEY_MAX != INPUT_DEVICE_ID_KEY_MAX
  896. #error "KEY_MAX and INPUT_DEVICE_ID_KEY_MAX do not match"
  897. #endif
  898. #if REL_MAX != INPUT_DEVICE_ID_REL_MAX
  899. #error "REL_MAX and INPUT_DEVICE_ID_REL_MAX do not match"
  900. #endif
  901. #if ABS_MAX != INPUT_DEVICE_ID_ABS_MAX
  902. #error "ABS_MAX and INPUT_DEVICE_ID_ABS_MAX do not match"
  903. #endif
  904. #if MSC_MAX != INPUT_DEVICE_ID_MSC_MAX
  905. #error "MSC_MAX and INPUT_DEVICE_ID_MSC_MAX do not match"
  906. #endif
  907. #if LED_MAX != INPUT_DEVICE_ID_LED_MAX
  908. #error "LED_MAX and INPUT_DEVICE_ID_LED_MAX do not match"
  909. #endif
  910. #if SND_MAX != INPUT_DEVICE_ID_SND_MAX
  911. #error "SND_MAX and INPUT_DEVICE_ID_SND_MAX do not match"
  912. #endif
  913. #if FF_MAX != INPUT_DEVICE_ID_FF_MAX
  914. #error "FF_MAX and INPUT_DEVICE_ID_FF_MAX do not match"
  915. #endif
  916. #if SW_MAX != INPUT_DEVICE_ID_SW_MAX
  917. #error "SW_MAX and INPUT_DEVICE_ID_SW_MAX do not match"
  918. #endif
  919. #define INPUT_DEVICE_ID_MATCH_DEVICE \
  920. (INPUT_DEVICE_ID_MATCH_BUS | INPUT_DEVICE_ID_MATCH_VENDOR | INPUT_DEVICE_ID_MATCH_PRODUCT)
  921. #define INPUT_DEVICE_ID_MATCH_DEVICE_AND_VERSION \
  922. (INPUT_DEVICE_ID_MATCH_DEVICE | INPUT_DEVICE_ID_MATCH_VERSION)
  923. struct input_handle;
  924. /**
  925. * struct input_handler - implements one of interfaces for input devices
  926. * @private: driver-specific data
  927. * @event: event handler
  928. * @connect: called when attaching a handler to an input device
  929. * @disconnect: disconnects a handler from input device
  930. * @start: starts handler for given handle. This function is called by
  931. * input core right after connect() method and also when a process
  932. * that "grabbed" a device releases it
  933. * @fops: file operations this driver implements
  934. * @minor: beginning of range of 32 minors for devices this driver
  935. * can provide
  936. * @name: name of the handler, to be shown in /proc/bus/input/handlers
  937. * @id_table: pointer to a table of input_device_ids this driver can
  938. * handle
  939. * @blacklist: prointer to a table of input_device_ids this driver should
  940. * ignore even if they match @id_table
  941. * @h_list: list of input handles associated with the handler
  942. * @node: for placing the driver onto input_handler_list
  943. */
  944. struct input_handler {
  945. void *private;
  946. void (*event)(struct input_handle *handle, unsigned int type, unsigned int code, int value);
  947. int (*connect)(struct input_handler *handler, struct input_dev *dev, const struct input_device_id *id);
  948. void (*disconnect)(struct input_handle *handle);
  949. void (*start)(struct input_handle *handle);
  950. const struct file_operations *fops;
  951. int minor;
  952. const char *name;
  953. const struct input_device_id *id_table;
  954. const struct input_device_id *blacklist;
  955. struct list_head h_list;
  956. struct list_head node;
  957. };
  958. struct input_handle {
  959. void *private;
  960. int open;
  961. const char *name;
  962. struct input_dev *dev;
  963. struct input_handler *handler;
  964. struct list_head d_node;
  965. struct list_head h_node;
  966. };
  967. #define to_dev(n) container_of(n,struct input_dev,node)
  968. #define to_handler(n) container_of(n,struct input_handler,node)
  969. #define to_handle(n) container_of(n,struct input_handle,d_node)
  970. #define to_handle_h(n) container_of(n,struct input_handle,h_node)
  971. struct input_dev *input_allocate_device(void);
  972. void input_free_device(struct input_dev *dev);
  973. static inline struct input_dev *input_get_device(struct input_dev *dev)
  974. {
  975. return to_input_dev(class_device_get(&dev->cdev));
  976. }
  977. static inline void input_put_device(struct input_dev *dev)
  978. {
  979. class_device_put(&dev->cdev);
  980. }
  981. static inline void *input_get_drvdata(struct input_dev *dev)
  982. {
  983. return dev->private;
  984. }
  985. static inline void input_set_drvdata(struct input_dev *dev, void *data)
  986. {
  987. dev->private = data;
  988. }
  989. int input_register_device(struct input_dev *);
  990. void input_unregister_device(struct input_dev *);
  991. int input_register_handler(struct input_handler *);
  992. void input_unregister_handler(struct input_handler *);
  993. int input_register_handle(struct input_handle *);
  994. void input_unregister_handle(struct input_handle *);
  995. int input_grab_device(struct input_handle *);
  996. void input_release_device(struct input_handle *);
  997. int input_open_device(struct input_handle *);
  998. void input_close_device(struct input_handle *);
  999. int input_flush_device(struct input_handle* handle, struct file* file);
  1000. void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value);
  1001. void input_inject_event(struct input_handle *handle, unsigned int type, unsigned int code, int value);
  1002. static inline void input_report_key(struct input_dev *dev, unsigned int code, int value)
  1003. {
  1004. input_event(dev, EV_KEY, code, !!value);
  1005. }
  1006. static inline void input_report_rel(struct input_dev *dev, unsigned int code, int value)
  1007. {
  1008. input_event(dev, EV_REL, code, value);
  1009. }
  1010. static inline void input_report_abs(struct input_dev *dev, unsigned int code, int value)
  1011. {
  1012. input_event(dev, EV_ABS, code, value);
  1013. }
  1014. static inline void input_report_ff_status(struct input_dev *dev, unsigned int code, int value)
  1015. {
  1016. input_event(dev, EV_FF_STATUS, code, value);
  1017. }
  1018. static inline void input_report_switch(struct input_dev *dev, unsigned int code, int value)
  1019. {
  1020. input_event(dev, EV_SW, code, !!value);
  1021. }
  1022. static inline void input_sync(struct input_dev *dev)
  1023. {
  1024. input_event(dev, EV_SYN, SYN_REPORT, 0);
  1025. }
  1026. void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int code);
  1027. static inline void input_set_abs_params(struct input_dev *dev, int axis, int min, int max, int fuzz, int flat)
  1028. {
  1029. dev->absmin[axis] = min;
  1030. dev->absmax[axis] = max;
  1031. dev->absfuzz[axis] = fuzz;
  1032. dev->absflat[axis] = flat;
  1033. dev->absbit[LONG(axis)] |= BIT(axis);
  1034. }
  1035. extern struct class input_class;
  1036. /**
  1037. * struct ff_device - force-feedback part of an input device
  1038. * @upload: Called to upload an new effect into device
  1039. * @erase: Called to erase an effect from device
  1040. * @playback: Called to request device to start playing specified effect
  1041. * @set_gain: Called to set specified gain
  1042. * @set_autocenter: Called to auto-center device
  1043. * @destroy: called by input core when parent input device is being
  1044. * destroyed
  1045. * @private: driver-specific data, will be freed automatically
  1046. * @ffbit: bitmap of force feedback capabilities truly supported by
  1047. * device (not emulated like ones in input_dev->ffbit)
  1048. * @mutex: mutex for serializing access to the device
  1049. * @max_effects: maximum number of effects supported by device
  1050. * @effects: pointer to an array of effects currently loaded into device
  1051. * @effect_owners: array of effect owners; when file handle owning
  1052. * an effect gets closed the effcet is automatically erased
  1053. *
  1054. * Every force-feedback device must implement upload() and playback()
  1055. * methods; erase() is optional. set_gain() and set_autocenter() need
  1056. * only be implemented if driver sets up FF_GAIN and FF_AUTOCENTER
  1057. * bits.
  1058. */
  1059. struct ff_device {
  1060. int (*upload)(struct input_dev *dev, struct ff_effect *effect,
  1061. struct ff_effect *old);
  1062. int (*erase)(struct input_dev *dev, int effect_id);
  1063. int (*playback)(struct input_dev *dev, int effect_id, int value);
  1064. void (*set_gain)(struct input_dev *dev, u16 gain);
  1065. void (*set_autocenter)(struct input_dev *dev, u16 magnitude);
  1066. void (*destroy)(struct ff_device *);
  1067. void *private;
  1068. unsigned long ffbit[NBITS(FF_MAX)];
  1069. struct mutex mutex;
  1070. int max_effects;
  1071. struct ff_effect *effects;
  1072. struct file *effect_owners[];
  1073. };
  1074. int input_ff_create(struct input_dev *dev, int max_effects);
  1075. void input_ff_destroy(struct input_dev *dev);
  1076. int input_ff_event(struct input_dev *dev, unsigned int type, unsigned int code, int value);
  1077. int input_ff_upload(struct input_dev *dev, struct ff_effect *effect, struct file *file);
  1078. int input_ff_erase(struct input_dev *dev, int effect_id, struct file *file);
  1079. int input_ff_create_memless(struct input_dev *dev, void *data,
  1080. int (*play_effect)(struct input_dev *, void *, struct ff_effect *));
  1081. #endif
  1082. #endif