input.h 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251
  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 /* Cycle between available video
  321. outputs (Monitor/LCD/TV-out/etc) */
  322. #define KEY_KBDILLUMTOGGLE 228
  323. #define KEY_KBDILLUMDOWN 229
  324. #define KEY_KBDILLUMUP 230
  325. #define KEY_SEND 231 /* AC Send */
  326. #define KEY_REPLY 232 /* AC Reply */
  327. #define KEY_FORWARDMAIL 233 /* AC Forward Msg */
  328. #define KEY_SAVE 234 /* AC Save */
  329. #define KEY_DOCUMENTS 235
  330. #define KEY_BATTERY 236
  331. #define KEY_BLUETOOTH 237
  332. #define KEY_WLAN 238
  333. #define KEY_UNKNOWN 240
  334. #define BTN_MISC 0x100
  335. #define BTN_0 0x100
  336. #define BTN_1 0x101
  337. #define BTN_2 0x102
  338. #define BTN_3 0x103
  339. #define BTN_4 0x104
  340. #define BTN_5 0x105
  341. #define BTN_6 0x106
  342. #define BTN_7 0x107
  343. #define BTN_8 0x108
  344. #define BTN_9 0x109
  345. #define BTN_MOUSE 0x110
  346. #define BTN_LEFT 0x110
  347. #define BTN_RIGHT 0x111
  348. #define BTN_MIDDLE 0x112
  349. #define BTN_SIDE 0x113
  350. #define BTN_EXTRA 0x114
  351. #define BTN_FORWARD 0x115
  352. #define BTN_BACK 0x116
  353. #define BTN_TASK 0x117
  354. #define BTN_JOYSTICK 0x120
  355. #define BTN_TRIGGER 0x120
  356. #define BTN_THUMB 0x121
  357. #define BTN_THUMB2 0x122
  358. #define BTN_TOP 0x123
  359. #define BTN_TOP2 0x124
  360. #define BTN_PINKIE 0x125
  361. #define BTN_BASE 0x126
  362. #define BTN_BASE2 0x127
  363. #define BTN_BASE3 0x128
  364. #define BTN_BASE4 0x129
  365. #define BTN_BASE5 0x12a
  366. #define BTN_BASE6 0x12b
  367. #define BTN_DEAD 0x12f
  368. #define BTN_GAMEPAD 0x130
  369. #define BTN_A 0x130
  370. #define BTN_B 0x131
  371. #define BTN_C 0x132
  372. #define BTN_X 0x133
  373. #define BTN_Y 0x134
  374. #define BTN_Z 0x135
  375. #define BTN_TL 0x136
  376. #define BTN_TR 0x137
  377. #define BTN_TL2 0x138
  378. #define BTN_TR2 0x139
  379. #define BTN_SELECT 0x13a
  380. #define BTN_START 0x13b
  381. #define BTN_MODE 0x13c
  382. #define BTN_THUMBL 0x13d
  383. #define BTN_THUMBR 0x13e
  384. #define BTN_DIGI 0x140
  385. #define BTN_TOOL_PEN 0x140
  386. #define BTN_TOOL_RUBBER 0x141
  387. #define BTN_TOOL_BRUSH 0x142
  388. #define BTN_TOOL_PENCIL 0x143
  389. #define BTN_TOOL_AIRBRUSH 0x144
  390. #define BTN_TOOL_FINGER 0x145
  391. #define BTN_TOOL_MOUSE 0x146
  392. #define BTN_TOOL_LENS 0x147
  393. #define BTN_TOUCH 0x14a
  394. #define BTN_STYLUS 0x14b
  395. #define BTN_STYLUS2 0x14c
  396. #define BTN_TOOL_DOUBLETAP 0x14d
  397. #define BTN_TOOL_TRIPLETAP 0x14e
  398. #define BTN_WHEEL 0x150
  399. #define BTN_GEAR_DOWN 0x150
  400. #define BTN_GEAR_UP 0x151
  401. #define KEY_OK 0x160
  402. #define KEY_SELECT 0x161
  403. #define KEY_GOTO 0x162
  404. #define KEY_CLEAR 0x163
  405. #define KEY_POWER2 0x164
  406. #define KEY_OPTION 0x165
  407. #define KEY_INFO 0x166 /* AL OEM Features/Tips/Tutorial */
  408. #define KEY_TIME 0x167
  409. #define KEY_VENDOR 0x168
  410. #define KEY_ARCHIVE 0x169
  411. #define KEY_PROGRAM 0x16a /* Media Select Program Guide */
  412. #define KEY_CHANNEL 0x16b
  413. #define KEY_FAVORITES 0x16c
  414. #define KEY_EPG 0x16d
  415. #define KEY_PVR 0x16e /* Media Select Home */
  416. #define KEY_MHP 0x16f
  417. #define KEY_LANGUAGE 0x170
  418. #define KEY_TITLE 0x171
  419. #define KEY_SUBTITLE 0x172
  420. #define KEY_ANGLE 0x173
  421. #define KEY_ZOOM 0x174
  422. #define KEY_MODE 0x175
  423. #define KEY_KEYBOARD 0x176
  424. #define KEY_SCREEN 0x177
  425. #define KEY_PC 0x178 /* Media Select Computer */
  426. #define KEY_TV 0x179 /* Media Select TV */
  427. #define KEY_TV2 0x17a /* Media Select Cable */
  428. #define KEY_VCR 0x17b /* Media Select VCR */
  429. #define KEY_VCR2 0x17c /* VCR Plus */
  430. #define KEY_SAT 0x17d /* Media Select Satellite */
  431. #define KEY_SAT2 0x17e
  432. #define KEY_CD 0x17f /* Media Select CD */
  433. #define KEY_TAPE 0x180 /* Media Select Tape */
  434. #define KEY_RADIO 0x181
  435. #define KEY_TUNER 0x182 /* Media Select Tuner */
  436. #define KEY_PLAYER 0x183
  437. #define KEY_TEXT 0x184
  438. #define KEY_DVD 0x185 /* Media Select DVD */
  439. #define KEY_AUX 0x186
  440. #define KEY_MP3 0x187
  441. #define KEY_AUDIO 0x188
  442. #define KEY_VIDEO 0x189
  443. #define KEY_DIRECTORY 0x18a
  444. #define KEY_LIST 0x18b
  445. #define KEY_MEMO 0x18c /* Media Select Messages */
  446. #define KEY_CALENDAR 0x18d
  447. #define KEY_RED 0x18e
  448. #define KEY_GREEN 0x18f
  449. #define KEY_YELLOW 0x190
  450. #define KEY_BLUE 0x191
  451. #define KEY_CHANNELUP 0x192 /* Channel Increment */
  452. #define KEY_CHANNELDOWN 0x193 /* Channel Decrement */
  453. #define KEY_FIRST 0x194
  454. #define KEY_LAST 0x195 /* Recall Last */
  455. #define KEY_AB 0x196
  456. #define KEY_NEXT 0x197
  457. #define KEY_RESTART 0x198
  458. #define KEY_SLOW 0x199
  459. #define KEY_SHUFFLE 0x19a
  460. #define KEY_BREAK 0x19b
  461. #define KEY_PREVIOUS 0x19c
  462. #define KEY_DIGITS 0x19d
  463. #define KEY_TEEN 0x19e
  464. #define KEY_TWEN 0x19f
  465. #define KEY_VIDEOPHONE 0x1a0 /* Media Select Video Phone */
  466. #define KEY_GAMES 0x1a1 /* Media Select Games */
  467. #define KEY_ZOOMIN 0x1a2 /* AC Zoom In */
  468. #define KEY_ZOOMOUT 0x1a3 /* AC Zoom Out */
  469. #define KEY_ZOOMRESET 0x1a4 /* AC Zoom */
  470. #define KEY_WORDPROCESSOR 0x1a5 /* AL Word Processor */
  471. #define KEY_EDITOR 0x1a6 /* AL Text Editor */
  472. #define KEY_SPREADSHEET 0x1a7 /* AL Spreadsheet */
  473. #define KEY_GRAPHICSEDITOR 0x1a8 /* AL Graphics Editor */
  474. #define KEY_PRESENTATION 0x1a9 /* AL Presentation App */
  475. #define KEY_DATABASE 0x1aa /* AL Database App */
  476. #define KEY_NEWS 0x1ab /* AL Newsreader */
  477. #define KEY_VOICEMAIL 0x1ac /* AL Voicemail */
  478. #define KEY_ADDRESSBOOK 0x1ad /* AL Contacts/Address Book */
  479. #define KEY_MESSENGER 0x1ae /* AL Instant Messaging */
  480. #define KEY_DISPLAYTOGGLE 0x1af /* Turn display (LCD) on and off */
  481. #define KEY_DEL_EOL 0x1c0
  482. #define KEY_DEL_EOS 0x1c1
  483. #define KEY_INS_LINE 0x1c2
  484. #define KEY_DEL_LINE 0x1c3
  485. #define KEY_FN 0x1d0
  486. #define KEY_FN_ESC 0x1d1
  487. #define KEY_FN_F1 0x1d2
  488. #define KEY_FN_F2 0x1d3
  489. #define KEY_FN_F3 0x1d4
  490. #define KEY_FN_F4 0x1d5
  491. #define KEY_FN_F5 0x1d6
  492. #define KEY_FN_F6 0x1d7
  493. #define KEY_FN_F7 0x1d8
  494. #define KEY_FN_F8 0x1d9
  495. #define KEY_FN_F9 0x1da
  496. #define KEY_FN_F10 0x1db
  497. #define KEY_FN_F11 0x1dc
  498. #define KEY_FN_F12 0x1dd
  499. #define KEY_FN_1 0x1de
  500. #define KEY_FN_2 0x1df
  501. #define KEY_FN_D 0x1e0
  502. #define KEY_FN_E 0x1e1
  503. #define KEY_FN_F 0x1e2
  504. #define KEY_FN_S 0x1e3
  505. #define KEY_FN_B 0x1e4
  506. #define KEY_BRL_DOT1 0x1f1
  507. #define KEY_BRL_DOT2 0x1f2
  508. #define KEY_BRL_DOT3 0x1f3
  509. #define KEY_BRL_DOT4 0x1f4
  510. #define KEY_BRL_DOT5 0x1f5
  511. #define KEY_BRL_DOT6 0x1f6
  512. #define KEY_BRL_DOT7 0x1f7
  513. #define KEY_BRL_DOT8 0x1f8
  514. #define KEY_BRL_DOT9 0x1f9
  515. #define KEY_BRL_DOT10 0x1fa
  516. /* We avoid low common keys in module aliases so they don't get huge. */
  517. #define KEY_MIN_INTERESTING KEY_MUTE
  518. #define KEY_MAX 0x1ff
  519. /*
  520. * Relative axes
  521. */
  522. #define REL_X 0x00
  523. #define REL_Y 0x01
  524. #define REL_Z 0x02
  525. #define REL_RX 0x03
  526. #define REL_RY 0x04
  527. #define REL_RZ 0x05
  528. #define REL_HWHEEL 0x06
  529. #define REL_DIAL 0x07
  530. #define REL_WHEEL 0x08
  531. #define REL_MISC 0x09
  532. #define REL_MAX 0x0f
  533. /*
  534. * Absolute axes
  535. */
  536. #define ABS_X 0x00
  537. #define ABS_Y 0x01
  538. #define ABS_Z 0x02
  539. #define ABS_RX 0x03
  540. #define ABS_RY 0x04
  541. #define ABS_RZ 0x05
  542. #define ABS_THROTTLE 0x06
  543. #define ABS_RUDDER 0x07
  544. #define ABS_WHEEL 0x08
  545. #define ABS_GAS 0x09
  546. #define ABS_BRAKE 0x0a
  547. #define ABS_HAT0X 0x10
  548. #define ABS_HAT0Y 0x11
  549. #define ABS_HAT1X 0x12
  550. #define ABS_HAT1Y 0x13
  551. #define ABS_HAT2X 0x14
  552. #define ABS_HAT2Y 0x15
  553. #define ABS_HAT3X 0x16
  554. #define ABS_HAT3Y 0x17
  555. #define ABS_PRESSURE 0x18
  556. #define ABS_DISTANCE 0x19
  557. #define ABS_TILT_X 0x1a
  558. #define ABS_TILT_Y 0x1b
  559. #define ABS_TOOL_WIDTH 0x1c
  560. #define ABS_VOLUME 0x20
  561. #define ABS_MISC 0x28
  562. #define ABS_MAX 0x3f
  563. /*
  564. * Switch events
  565. */
  566. #define SW_LID 0x00 /* set = lid shut */
  567. #define SW_TABLET_MODE 0x01 /* set = tablet mode */
  568. #define SW_HEADPHONE_INSERT 0x02 /* set = inserted */
  569. #define SW_RADIO 0x03 /* set = radio enabled */
  570. #define SW_MAX 0x0f
  571. /*
  572. * Misc events
  573. */
  574. #define MSC_SERIAL 0x00
  575. #define MSC_PULSELED 0x01
  576. #define MSC_GESTURE 0x02
  577. #define MSC_RAW 0x03
  578. #define MSC_SCAN 0x04
  579. #define MSC_MAX 0x07
  580. /*
  581. * LEDs
  582. */
  583. #define LED_NUML 0x00
  584. #define LED_CAPSL 0x01
  585. #define LED_SCROLLL 0x02
  586. #define LED_COMPOSE 0x03
  587. #define LED_KANA 0x04
  588. #define LED_SLEEP 0x05
  589. #define LED_SUSPEND 0x06
  590. #define LED_MUTE 0x07
  591. #define LED_MISC 0x08
  592. #define LED_MAIL 0x09
  593. #define LED_CHARGING 0x0a
  594. #define LED_MAX 0x0f
  595. /*
  596. * Autorepeat values
  597. */
  598. #define REP_DELAY 0x00
  599. #define REP_PERIOD 0x01
  600. #define REP_MAX 0x01
  601. /*
  602. * Sounds
  603. */
  604. #define SND_CLICK 0x00
  605. #define SND_BELL 0x01
  606. #define SND_TONE 0x02
  607. #define SND_MAX 0x07
  608. /*
  609. * IDs.
  610. */
  611. #define ID_BUS 0
  612. #define ID_VENDOR 1
  613. #define ID_PRODUCT 2
  614. #define ID_VERSION 3
  615. #define BUS_PCI 0x01
  616. #define BUS_ISAPNP 0x02
  617. #define BUS_USB 0x03
  618. #define BUS_HIL 0x04
  619. #define BUS_BLUETOOTH 0x05
  620. #define BUS_VIRTUAL 0x06
  621. #define BUS_ISA 0x10
  622. #define BUS_I8042 0x11
  623. #define BUS_XTKBD 0x12
  624. #define BUS_RS232 0x13
  625. #define BUS_GAMEPORT 0x14
  626. #define BUS_PARPORT 0x15
  627. #define BUS_AMIGA 0x16
  628. #define BUS_ADB 0x17
  629. #define BUS_I2C 0x18
  630. #define BUS_HOST 0x19
  631. #define BUS_GSC 0x1A
  632. #define BUS_ATARI 0x1B
  633. /*
  634. * Values describing the status of a force-feedback effect
  635. */
  636. #define FF_STATUS_STOPPED 0x00
  637. #define FF_STATUS_PLAYING 0x01
  638. #define FF_STATUS_MAX 0x01
  639. /*
  640. * Structures used in ioctls to upload effects to a device
  641. * They are pieces of a bigger structure (called ff_effect)
  642. */
  643. /*
  644. * All duration values are expressed in ms. Values above 32767 ms (0x7fff)
  645. * should not be used and have unspecified results.
  646. */
  647. /**
  648. * struct ff_replay - defines scheduling of the force-feedback effect
  649. * @length: duration of the effect
  650. * @delay: delay before effect should start playing
  651. */
  652. struct ff_replay {
  653. __u16 length;
  654. __u16 delay;
  655. };
  656. /**
  657. * struct ff_trigger - defines what triggers the force-feedback effect
  658. * @button: number of the button triggering the effect
  659. * @interval: controls how soon the effect can be re-triggered
  660. */
  661. struct ff_trigger {
  662. __u16 button;
  663. __u16 interval;
  664. };
  665. /**
  666. * struct ff_envelope - generic force-feedback effect envelope
  667. * @attack_length: duration of the attack (ms)
  668. * @attack_level: level at the beginning of the attack
  669. * @fade_length: duration of fade (ms)
  670. * @fade_level: level at the end of fade
  671. *
  672. * The @attack_level and @fade_level are absolute values; when applying
  673. * envelope force-feedback core will convert to positive/negative
  674. * value based on polarity of the default level of the effect.
  675. * Valid range for the attack and fade levels is 0x0000 - 0x7fff
  676. */
  677. struct ff_envelope {
  678. __u16 attack_length;
  679. __u16 attack_level;
  680. __u16 fade_length;
  681. __u16 fade_level;
  682. };
  683. /**
  684. * struct ff_constant_effect - defines parameters of a constant force-feedback effect
  685. * @level: strength of the effect; may be negative
  686. * @envelope: envelope data
  687. */
  688. struct ff_constant_effect {
  689. __s16 level;
  690. struct ff_envelope envelope;
  691. };
  692. /**
  693. * struct ff_ramp_effect - defines parameters of a ramp force-feedback effect
  694. * @start_level: beginning strength of the effect; may be negative
  695. * @end_level: final strength of the effect; may be negative
  696. * @envelope: envelope data
  697. */
  698. struct ff_ramp_effect {
  699. __s16 start_level;
  700. __s16 end_level;
  701. struct ff_envelope envelope;
  702. };
  703. /**
  704. * struct ff_condition_effect - defines a spring or friction force-feedback effect
  705. * @right_saturation: maximum level when joystick moved all way to the right
  706. * @left_saturation: same for the left side
  707. * @right_coeff: controls how fast the force grows when the joystick moves
  708. * to the right
  709. * @left_coeff: same for the left side
  710. * @deadband: size of the dead zone, where no force is produced
  711. * @center: position of the dead zone
  712. */
  713. struct ff_condition_effect {
  714. __u16 right_saturation;
  715. __u16 left_saturation;
  716. __s16 right_coeff;
  717. __s16 left_coeff;
  718. __u16 deadband;
  719. __s16 center;
  720. };
  721. /**
  722. * struct ff_periodic_effect - defines parameters of a periodic force-feedback effect
  723. * @waveform: kind of the effect (wave)
  724. * @period: period of the wave (ms)
  725. * @magnitude: peak value
  726. * @offset: mean value of the wave (roughly)
  727. * @phase: 'horizontal' shift
  728. * @envelope: envelope data
  729. * @custom_len: number of samples (FF_CUSTOM only)
  730. * @custom_data: buffer of samples (FF_CUSTOM only)
  731. *
  732. * Known waveforms - FF_SQUARE, FF_TRIANGLE, FF_SINE, FF_SAW_UP,
  733. * FF_SAW_DOWN, FF_CUSTOM. The exact syntax FF_CUSTOM is undefined
  734. * for the time being as no driver supports it yet.
  735. *
  736. * Note: the data pointed by custom_data is copied by the driver.
  737. * You can therefore dispose of the memory after the upload/update.
  738. */
  739. struct ff_periodic_effect {
  740. __u16 waveform;
  741. __u16 period;
  742. __s16 magnitude;
  743. __s16 offset;
  744. __u16 phase;
  745. struct ff_envelope envelope;
  746. __u32 custom_len;
  747. __s16 *custom_data;
  748. };
  749. /**
  750. * struct ff_rumble_effect - defines parameters of a periodic force-feedback effect
  751. * @strong_magnitude: magnitude of the heavy motor
  752. * @weak_magnitude: magnitude of the light one
  753. *
  754. * Some rumble pads have two motors of different weight. Strong_magnitude
  755. * represents the magnitude of the vibration generated by the heavy one.
  756. */
  757. struct ff_rumble_effect {
  758. __u16 strong_magnitude;
  759. __u16 weak_magnitude;
  760. };
  761. /**
  762. * struct ff_effect - defines force feedback effect
  763. * @type: type of the effect (FF_CONSTANT, FF_PERIODIC, FF_RAMP, FF_SPRING,
  764. * FF_FRICTION, FF_DAMPER, FF_RUMBLE, FF_INERTIA, or FF_CUSTOM)
  765. * @id: an unique id assigned to an effect
  766. * @direction: direction of the effect
  767. * @trigger: trigger conditions (struct ff_trigger)
  768. * @replay: scheduling of the effect (struct ff_replay)
  769. * @u: effect-specific structure (one of ff_constant_effect, ff_ramp_effect,
  770. * ff_periodic_effect, ff_condition_effect, ff_rumble_effect) further
  771. * defining effect parameters
  772. *
  773. * This structure is sent through ioctl from the application to the driver.
  774. * To create a new effect aplication should set its @id to -1; the kernel
  775. * will return assigned @id which can later be used to update or delete
  776. * this effect.
  777. *
  778. * Direction of the effect is encoded as follows:
  779. * 0 deg -> 0x0000 (down)
  780. * 90 deg -> 0x4000 (left)
  781. * 180 deg -> 0x8000 (up)
  782. * 270 deg -> 0xC000 (right)
  783. */
  784. struct ff_effect {
  785. __u16 type;
  786. __s16 id;
  787. __u16 direction;
  788. struct ff_trigger trigger;
  789. struct ff_replay replay;
  790. union {
  791. struct ff_constant_effect constant;
  792. struct ff_ramp_effect ramp;
  793. struct ff_periodic_effect periodic;
  794. struct ff_condition_effect condition[2]; /* One for each axis */
  795. struct ff_rumble_effect rumble;
  796. } u;
  797. };
  798. /*
  799. * Force feedback effect types
  800. */
  801. #define FF_RUMBLE 0x50
  802. #define FF_PERIODIC 0x51
  803. #define FF_CONSTANT 0x52
  804. #define FF_SPRING 0x53
  805. #define FF_FRICTION 0x54
  806. #define FF_DAMPER 0x55
  807. #define FF_INERTIA 0x56
  808. #define FF_RAMP 0x57
  809. #define FF_EFFECT_MIN FF_RUMBLE
  810. #define FF_EFFECT_MAX FF_RAMP
  811. /*
  812. * Force feedback periodic effect types
  813. */
  814. #define FF_SQUARE 0x58
  815. #define FF_TRIANGLE 0x59
  816. #define FF_SINE 0x5a
  817. #define FF_SAW_UP 0x5b
  818. #define FF_SAW_DOWN 0x5c
  819. #define FF_CUSTOM 0x5d
  820. #define FF_WAVEFORM_MIN FF_SQUARE
  821. #define FF_WAVEFORM_MAX FF_CUSTOM
  822. /*
  823. * Set ff device properties
  824. */
  825. #define FF_GAIN 0x60
  826. #define FF_AUTOCENTER 0x61
  827. #define FF_MAX 0x7f
  828. #ifdef __KERNEL__
  829. /*
  830. * In-kernel definitions.
  831. */
  832. #include <linux/device.h>
  833. #include <linux/fs.h>
  834. #include <linux/timer.h>
  835. #include <linux/mod_devicetable.h>
  836. #define NBITS(x) (((x)/BITS_PER_LONG)+1)
  837. #define BIT(x) (1UL<<((x)%BITS_PER_LONG))
  838. #define LONG(x) ((x)/BITS_PER_LONG)
  839. struct input_dev {
  840. void *private;
  841. const char *name;
  842. const char *phys;
  843. const char *uniq;
  844. struct input_id id;
  845. unsigned long evbit[NBITS(EV_MAX)];
  846. unsigned long keybit[NBITS(KEY_MAX)];
  847. unsigned long relbit[NBITS(REL_MAX)];
  848. unsigned long absbit[NBITS(ABS_MAX)];
  849. unsigned long mscbit[NBITS(MSC_MAX)];
  850. unsigned long ledbit[NBITS(LED_MAX)];
  851. unsigned long sndbit[NBITS(SND_MAX)];
  852. unsigned long ffbit[NBITS(FF_MAX)];
  853. unsigned long swbit[NBITS(SW_MAX)];
  854. unsigned int keycodemax;
  855. unsigned int keycodesize;
  856. void *keycode;
  857. int (*setkeycode)(struct input_dev *dev, int scancode, int keycode);
  858. int (*getkeycode)(struct input_dev *dev, int scancode, int *keycode);
  859. struct ff_device *ff;
  860. unsigned int repeat_key;
  861. struct timer_list timer;
  862. int state;
  863. int sync;
  864. int abs[ABS_MAX + 1];
  865. int rep[REP_MAX + 1];
  866. unsigned long key[NBITS(KEY_MAX)];
  867. unsigned long led[NBITS(LED_MAX)];
  868. unsigned long snd[NBITS(SND_MAX)];
  869. unsigned long sw[NBITS(SW_MAX)];
  870. int absmax[ABS_MAX + 1];
  871. int absmin[ABS_MAX + 1];
  872. int absfuzz[ABS_MAX + 1];
  873. int absflat[ABS_MAX + 1];
  874. int (*open)(struct input_dev *dev);
  875. void (*close)(struct input_dev *dev);
  876. int (*flush)(struct input_dev *dev, struct file *file);
  877. int (*event)(struct input_dev *dev, unsigned int type, unsigned int code, int value);
  878. struct input_handle *grab;
  879. struct mutex mutex; /* serializes open and close operations */
  880. unsigned int users;
  881. struct device dev;
  882. union { /* temporarily so while we switching to struct device */
  883. struct device *dev;
  884. } cdev;
  885. struct list_head h_list;
  886. struct list_head node;
  887. };
  888. #define to_input_dev(d) container_of(d, struct input_dev, dev)
  889. /*
  890. * Verify that we are in sync with input_device_id mod_devicetable.h #defines
  891. */
  892. #if EV_MAX != INPUT_DEVICE_ID_EV_MAX
  893. #error "EV_MAX and INPUT_DEVICE_ID_EV_MAX do not match"
  894. #endif
  895. #if KEY_MIN_INTERESTING != INPUT_DEVICE_ID_KEY_MIN_INTERESTING
  896. #error "KEY_MIN_INTERESTING and INPUT_DEVICE_ID_KEY_MIN_INTERESTING do not match"
  897. #endif
  898. #if KEY_MAX != INPUT_DEVICE_ID_KEY_MAX
  899. #error "KEY_MAX and INPUT_DEVICE_ID_KEY_MAX do not match"
  900. #endif
  901. #if REL_MAX != INPUT_DEVICE_ID_REL_MAX
  902. #error "REL_MAX and INPUT_DEVICE_ID_REL_MAX do not match"
  903. #endif
  904. #if ABS_MAX != INPUT_DEVICE_ID_ABS_MAX
  905. #error "ABS_MAX and INPUT_DEVICE_ID_ABS_MAX do not match"
  906. #endif
  907. #if MSC_MAX != INPUT_DEVICE_ID_MSC_MAX
  908. #error "MSC_MAX and INPUT_DEVICE_ID_MSC_MAX do not match"
  909. #endif
  910. #if LED_MAX != INPUT_DEVICE_ID_LED_MAX
  911. #error "LED_MAX and INPUT_DEVICE_ID_LED_MAX do not match"
  912. #endif
  913. #if SND_MAX != INPUT_DEVICE_ID_SND_MAX
  914. #error "SND_MAX and INPUT_DEVICE_ID_SND_MAX do not match"
  915. #endif
  916. #if FF_MAX != INPUT_DEVICE_ID_FF_MAX
  917. #error "FF_MAX and INPUT_DEVICE_ID_FF_MAX do not match"
  918. #endif
  919. #if SW_MAX != INPUT_DEVICE_ID_SW_MAX
  920. #error "SW_MAX and INPUT_DEVICE_ID_SW_MAX do not match"
  921. #endif
  922. #define INPUT_DEVICE_ID_MATCH_DEVICE \
  923. (INPUT_DEVICE_ID_MATCH_BUS | INPUT_DEVICE_ID_MATCH_VENDOR | INPUT_DEVICE_ID_MATCH_PRODUCT)
  924. #define INPUT_DEVICE_ID_MATCH_DEVICE_AND_VERSION \
  925. (INPUT_DEVICE_ID_MATCH_DEVICE | INPUT_DEVICE_ID_MATCH_VERSION)
  926. struct input_handle;
  927. /**
  928. * struct input_handler - implements one of interfaces for input devices
  929. * @private: driver-specific data
  930. * @event: event handler
  931. * @connect: called when attaching a handler to an input device
  932. * @disconnect: disconnects a handler from input device
  933. * @start: starts handler for given handle. This function is called by
  934. * input core right after connect() method and also when a process
  935. * that "grabbed" a device releases it
  936. * @fops: file operations this driver implements
  937. * @minor: beginning of range of 32 minors for devices this driver
  938. * can provide
  939. * @name: name of the handler, to be shown in /proc/bus/input/handlers
  940. * @id_table: pointer to a table of input_device_ids this driver can
  941. * handle
  942. * @blacklist: prointer to a table of input_device_ids this driver should
  943. * ignore even if they match @id_table
  944. * @h_list: list of input handles associated with the handler
  945. * @node: for placing the driver onto input_handler_list
  946. */
  947. struct input_handler {
  948. void *private;
  949. void (*event)(struct input_handle *handle, unsigned int type, unsigned int code, int value);
  950. int (*connect)(struct input_handler *handler, struct input_dev *dev, const struct input_device_id *id);
  951. void (*disconnect)(struct input_handle *handle);
  952. void (*start)(struct input_handle *handle);
  953. const struct file_operations *fops;
  954. int minor;
  955. const char *name;
  956. const struct input_device_id *id_table;
  957. const struct input_device_id *blacklist;
  958. struct list_head h_list;
  959. struct list_head node;
  960. };
  961. struct input_handle {
  962. void *private;
  963. int open;
  964. const char *name;
  965. struct input_dev *dev;
  966. struct input_handler *handler;
  967. struct list_head d_node;
  968. struct list_head h_node;
  969. };
  970. #define to_dev(n) container_of(n, struct input_dev, node)
  971. #define to_handler(n) container_of(n, struct input_handler, node)
  972. #define to_handle(n) container_of(n, struct input_handle, d_node)
  973. #define to_handle_h(n) container_of(n, struct input_handle, h_node)
  974. struct input_dev *input_allocate_device(void);
  975. void input_free_device(struct input_dev *dev);
  976. static inline struct input_dev *input_get_device(struct input_dev *dev)
  977. {
  978. return to_input_dev(get_device(&dev->dev));
  979. }
  980. static inline void input_put_device(struct input_dev *dev)
  981. {
  982. put_device(&dev->dev);
  983. }
  984. static inline void *input_get_drvdata(struct input_dev *dev)
  985. {
  986. return dev->private;
  987. }
  988. static inline void input_set_drvdata(struct input_dev *dev, void *data)
  989. {
  990. dev->private = data;
  991. }
  992. int input_register_device(struct input_dev *);
  993. void input_unregister_device(struct input_dev *);
  994. int input_register_handler(struct input_handler *);
  995. void input_unregister_handler(struct input_handler *);
  996. int input_register_handle(struct input_handle *);
  997. void input_unregister_handle(struct input_handle *);
  998. int input_grab_device(struct input_handle *);
  999. void input_release_device(struct input_handle *);
  1000. int input_open_device(struct input_handle *);
  1001. void input_close_device(struct input_handle *);
  1002. int input_flush_device(struct input_handle* handle, struct file* file);
  1003. void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value);
  1004. void input_inject_event(struct input_handle *handle, unsigned int type, unsigned int code, int value);
  1005. static inline void input_report_key(struct input_dev *dev, unsigned int code, int value)
  1006. {
  1007. input_event(dev, EV_KEY, code, !!value);
  1008. }
  1009. static inline void input_report_rel(struct input_dev *dev, unsigned int code, int value)
  1010. {
  1011. input_event(dev, EV_REL, code, value);
  1012. }
  1013. static inline void input_report_abs(struct input_dev *dev, unsigned int code, int value)
  1014. {
  1015. input_event(dev, EV_ABS, code, value);
  1016. }
  1017. static inline void input_report_ff_status(struct input_dev *dev, unsigned int code, int value)
  1018. {
  1019. input_event(dev, EV_FF_STATUS, code, value);
  1020. }
  1021. static inline void input_report_switch(struct input_dev *dev, unsigned int code, int value)
  1022. {
  1023. input_event(dev, EV_SW, code, !!value);
  1024. }
  1025. static inline void input_sync(struct input_dev *dev)
  1026. {
  1027. input_event(dev, EV_SYN, SYN_REPORT, 0);
  1028. }
  1029. void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int code);
  1030. static inline void input_set_abs_params(struct input_dev *dev, int axis, int min, int max, int fuzz, int flat)
  1031. {
  1032. dev->absmin[axis] = min;
  1033. dev->absmax[axis] = max;
  1034. dev->absfuzz[axis] = fuzz;
  1035. dev->absflat[axis] = flat;
  1036. dev->absbit[LONG(axis)] |= BIT(axis);
  1037. }
  1038. extern struct class input_class;
  1039. /**
  1040. * struct ff_device - force-feedback part of an input device
  1041. * @upload: Called to upload an new effect into device
  1042. * @erase: Called to erase an effect from device
  1043. * @playback: Called to request device to start playing specified effect
  1044. * @set_gain: Called to set specified gain
  1045. * @set_autocenter: Called to auto-center device
  1046. * @destroy: called by input core when parent input device is being
  1047. * destroyed
  1048. * @private: driver-specific data, will be freed automatically
  1049. * @ffbit: bitmap of force feedback capabilities truly supported by
  1050. * device (not emulated like ones in input_dev->ffbit)
  1051. * @mutex: mutex for serializing access to the device
  1052. * @max_effects: maximum number of effects supported by device
  1053. * @effects: pointer to an array of effects currently loaded into device
  1054. * @effect_owners: array of effect owners; when file handle owning
  1055. * an effect gets closed the effcet is automatically erased
  1056. *
  1057. * Every force-feedback device must implement upload() and playback()
  1058. * methods; erase() is optional. set_gain() and set_autocenter() need
  1059. * only be implemented if driver sets up FF_GAIN and FF_AUTOCENTER
  1060. * bits.
  1061. */
  1062. struct ff_device {
  1063. int (*upload)(struct input_dev *dev, struct ff_effect *effect,
  1064. struct ff_effect *old);
  1065. int (*erase)(struct input_dev *dev, int effect_id);
  1066. int (*playback)(struct input_dev *dev, int effect_id, int value);
  1067. void (*set_gain)(struct input_dev *dev, u16 gain);
  1068. void (*set_autocenter)(struct input_dev *dev, u16 magnitude);
  1069. void (*destroy)(struct ff_device *);
  1070. void *private;
  1071. unsigned long ffbit[NBITS(FF_MAX)];
  1072. struct mutex mutex;
  1073. int max_effects;
  1074. struct ff_effect *effects;
  1075. struct file *effect_owners[];
  1076. };
  1077. int input_ff_create(struct input_dev *dev, int max_effects);
  1078. void input_ff_destroy(struct input_dev *dev);
  1079. int input_ff_event(struct input_dev *dev, unsigned int type, unsigned int code, int value);
  1080. int input_ff_upload(struct input_dev *dev, struct ff_effect *effect, struct file *file);
  1081. int input_ff_erase(struct input_dev *dev, int effect_id, struct file *file);
  1082. int input_ff_create_memless(struct input_dev *dev, void *data,
  1083. int (*play_effect)(struct input_dev *, void *, struct ff_effect *));
  1084. #endif
  1085. #endif