uinput.h revision 5738f83aeb59361a0a2eda2460113f6dc9194271
1/******************************************************************************
2 *
3 *  Copyright (C) 2009-2012 Broadcom Corporation
4 *
5 *  Licensed under the Apache License, Version 2.0 (the "License");
6 *  you may not use this file except in compliance with the License.
7 *  You may obtain a copy of the License at:
8 *
9 *  http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *  Unless required by applicable law or agreed to in writing, software
12 *  distributed under the License is distributed on an "AS IS" BASIS,
13 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *  See the License for the specific language governing permissions and
15 *  limitations under the License.
16 *
17 ******************************************************************************/
18
19#ifndef __UINPUT_H
20#define __UINPUT_H
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26#include <stdint.h>
27#include <sys/time.h>
28#include <sys/ioctl.h>
29
30/*******************************************************************************
31**  Constants & Macros
32********************************************************************************/
33
34/* Events */
35
36#define EV_SYN          0x00
37#define EV_KEY          0x01
38#define EV_REL          0x02
39#define EV_ABS          0x03
40#define EV_MSC          0x04
41#define EV_LED          0x11
42#define EV_SND          0x12
43#define EV_REP          0x14
44#define EV_FF           0x15
45#define EV_PWR          0x16
46#define EV_FF_STATUS        0x17
47#define EV_MAX          0x1f
48
49/* Synchronization events */
50
51#define SYN_REPORT      0
52#define SYN_CONFIG      1
53
54/* Keys and buttons */
55
56#define KEY_RESERVED        0
57#define KEY_ESC         1
58#define KEY_1           2
59#define KEY_2           3
60#define KEY_3           4
61#define KEY_4           5
62#define KEY_5           6
63#define KEY_6           7
64#define KEY_7           8
65#define KEY_8           9
66#define KEY_9           10
67#define KEY_0           11
68#define KEY_MINUS       12
69#define KEY_EQUAL       13
70#define KEY_BACKSPACE       14
71#define KEY_TAB         15
72#define KEY_Q           16
73#define KEY_W           17
74#define KEY_E           18
75#define KEY_R           19
76#define KEY_T           20
77#define KEY_Y           21
78#define KEY_U           22
79#define KEY_I           23
80#define KEY_O           24
81#define KEY_P           25
82#define KEY_LEFTBRACE       26
83#define KEY_RIGHTBRACE      27
84#define KEY_ENTER       28
85#define KEY_LEFTCTRL        29
86#define KEY_A           30
87#define KEY_S           31
88#define KEY_D           32
89#define KEY_F           33
90#define KEY_G           34
91#define KEY_H           35
92#define KEY_J           36
93#define KEY_K           37
94#define KEY_L           38
95#define KEY_SEMICOLON       39
96#define KEY_APOSTROPHE      40
97#define KEY_GRAVE       41
98#define KEY_LEFTSHIFT       42
99#define KEY_BACKSLASH       43
100#define KEY_Z           44
101#define KEY_X           45
102#define KEY_C           46
103#define KEY_V           47
104#define KEY_B           48
105#define KEY_N           49
106#define KEY_M           50
107#define KEY_COMMA       51
108#define KEY_DOT         52
109#define KEY_SLASH       53
110#define KEY_RIGHTSHIFT      54
111#define KEY_KPASTERISK      55
112#define KEY_LEFTALT     56
113#define KEY_SPACE       57
114#define KEY_CAPSLOCK        58
115#define KEY_F1          59
116#define KEY_F2          60
117#define KEY_F3          61
118#define KEY_F4          62
119#define KEY_F5          63
120#define KEY_F6          64
121#define KEY_F7          65
122#define KEY_F8          66
123#define KEY_F9          67
124#define KEY_F10         68
125#define KEY_NUMLOCK     69
126#define KEY_SCROLLLOCK      70
127#define KEY_KP7         71
128#define KEY_KP8         72
129#define KEY_KP9         73
130#define KEY_KPMINUS     74
131#define KEY_KP4         75
132#define KEY_KP5         76
133#define KEY_KP6         77
134#define KEY_KPPLUS      78
135#define KEY_KP1         79
136#define KEY_KP2         80
137#define KEY_KP3         81
138#define KEY_KP0         82
139#define KEY_KPDOT       83
140#define KEY_103RD       84
141#define KEY_F13         85
142#define KEY_102ND       86
143#define KEY_F11         87
144#define KEY_F12         88
145#define KEY_F14         89
146#define KEY_F15         90
147#define KEY_F16         91
148#define KEY_F17         92
149#define KEY_F18         93
150#define KEY_F19         94
151#define KEY_F20         95
152#define KEY_KPENTER     96
153#define KEY_RIGHTCTRL       97
154#define KEY_KPSLASH     98
155#define KEY_SYSRQ       99
156#define KEY_RIGHTALT        100
157#define KEY_LINEFEED        101
158#define KEY_HOME        102
159#define KEY_UP          103
160#define KEY_PAGEUP      104
161#define KEY_LEFT        105
162#define KEY_RIGHT       106
163#define KEY_END         107
164#define KEY_DOWN        108
165#define KEY_PAGEDOWN        109
166#define KEY_INSERT      110
167#define KEY_DELETE      111
168#define KEY_MACRO       112
169#define KEY_MUTE        113
170#define KEY_VOLUMEDOWN      114
171#define KEY_VOLUMEUP        115
172#define KEY_POWER       116
173#define KEY_KPEQUAL     117
174#define KEY_KPPLUSMINUS     118
175#define KEY_PAUSE       119
176#define KEY_F21         120
177#define KEY_F22         121
178#define KEY_F23         122
179#define KEY_F24         123
180#define KEY_KPCOMMA     124
181#define KEY_LEFTMETA        125
182#define KEY_RIGHTMETA       126
183#define KEY_COMPOSE     127
184
185#define KEY_STOP        128
186#define KEY_AGAIN       129
187#define KEY_PROPS       130
188#define KEY_UNDO        131
189#define KEY_FRONT       132
190#define KEY_COPY        133
191#define KEY_OPEN        134
192#define KEY_PASTE       135
193#define KEY_FIND        136
194#define KEY_CUT         137
195#define KEY_HELP        138
196#define KEY_MENU        139
197#define KEY_CALC        140
198#define KEY_SETUP       141
199#define KEY_SLEEP       142
200#define KEY_WAKEUP      143
201#define KEY_FILE        144
202#define KEY_SENDFILE        145
203#define KEY_DELETEFILE      146
204#define KEY_XFER        147
205#define KEY_PROG1       148
206#define KEY_PROG2       149
207#define KEY_WWW         150
208#define KEY_MSDOS       151
209#define KEY_COFFEE      152
210#define KEY_DIRECTION       153
211#define KEY_CYCLEWINDOWS    154
212#define KEY_MAIL        155
213#define KEY_BOOKMARKS       156
214#define KEY_COMPUTER        157
215#define KEY_BACK        158
216#define KEY_FORWARD     159
217#define KEY_CLOSECD     160
218#define KEY_EJECTCD     161
219#define KEY_EJECTCLOSECD    162
220#define KEY_NEXTSONG        163
221#define KEY_PLAYPAUSE       164
222#define KEY_PREVIOUSSONG    165
223#define KEY_STOPCD      166
224#define KEY_RECORD      167
225#define KEY_REWIND      168
226#define KEY_PHONE       169
227#define KEY_ISO         170
228#define KEY_CONFIG      171
229#define KEY_HOMEPAGE        172
230#define KEY_REFRESH     173
231#define KEY_EXIT        174
232#define KEY_MOVE        175
233#define KEY_EDIT        176
234#define KEY_SCROLLUP        177
235#define KEY_SCROLLDOWN      178
236#define KEY_KPLEFTPAREN     179
237#define KEY_KPRIGHTPAREN    180
238
239#define KEY_INTL1       181
240#define KEY_INTL2       182
241#define KEY_INTL3       183
242#define KEY_INTL4       184
243#define KEY_INTL5       185
244#define KEY_INTL6       186
245#define KEY_INTL7       187
246#define KEY_INTL8       188
247#define KEY_INTL9       189
248#define KEY_LANG1       190
249#define KEY_LANG2       191
250#define KEY_LANG3       192
251#define KEY_LANG4       193
252#define KEY_LANG5       194
253#define KEY_LANG6       195
254#define KEY_LANG7       196
255#define KEY_LANG8       197
256#define KEY_LANG9       198
257
258#define KEY_PLAYCD      200
259#define KEY_PAUSECD     201
260#define KEY_PROG3       202
261#define KEY_PROG4       203
262#define KEY_SUSPEND     205
263#define KEY_CLOSE       206
264#define KEY_PLAY        207
265
266#define KEY_UNKNOWN     220
267
268#define KEY_BRIGHTNESSDOWN  224
269#define KEY_BRIGHTNESSUP    225
270
271#define BTN_MISC        0x100
272#define BTN_0           0x100
273#define BTN_1           0x101
274#define BTN_2           0x102
275#define BTN_3           0x103
276#define BTN_4           0x104
277#define BTN_5           0x105
278#define BTN_6           0x106
279#define BTN_7           0x107
280#define BTN_8           0x108
281#define BTN_9           0x109
282
283#define BTN_MOUSE       0x110
284#define BTN_LEFT        0x110
285#define BTN_RIGHT       0x111
286#define BTN_MIDDLE      0x112
287#define BTN_SIDE        0x113
288#define BTN_EXTRA       0x114
289#define BTN_FORWARD     0x115
290#define BTN_BACK        0x116
291#define BTN_TASK        0x117
292
293#define BTN_JOYSTICK        0x120
294#define BTN_TRIGGER     0x120
295#define BTN_THUMB       0x121
296#define BTN_THUMB2      0x122
297#define BTN_TOP         0x123
298#define BTN_TOP2        0x124
299#define BTN_PINKIE      0x125
300#define BTN_BASE        0x126
301#define BTN_BASE2       0x127
302#define BTN_BASE3       0x128
303#define BTN_BASE4       0x129
304#define BTN_BASE5       0x12a
305#define BTN_BASE6       0x12b
306#define BTN_DEAD        0x12f
307
308#define BTN_GAMEPAD     0x130
309#define BTN_A           0x130
310#define BTN_B           0x131
311#define BTN_C           0x132
312#define BTN_X           0x133
313#define BTN_Y           0x134
314#define BTN_Z           0x135
315#define BTN_TL          0x136
316#define BTN_TR          0x137
317#define BTN_TL2         0x138
318#define BTN_TR2         0x139
319#define BTN_SELECT      0x13a
320#define BTN_START       0x13b
321#define BTN_MODE        0x13c
322#define BTN_THUMBL      0x13d
323#define BTN_THUMBR      0x13e
324
325#define BTN_DIGI        0x140
326#define BTN_TOOL_PEN        0x140
327#define BTN_TOOL_RUBBER     0x141
328#define BTN_TOOL_BRUSH      0x142
329#define BTN_TOOL_PENCIL     0x143
330#define BTN_TOOL_AIRBRUSH   0x144
331#define BTN_TOOL_FINGER     0x145
332#define BTN_TOOL_MOUSE      0x146
333#define BTN_TOOL_LENS       0x147
334#define BTN_TOUCH       0x14a
335#define BTN_STYLUS      0x14b
336#define BTN_STYLUS2     0x14c
337#define BTN_TOOL_DOUBLETAP  0x14d
338#define BTN_TOOL_TRIPLETAP  0x14e
339
340#define BTN_WHEEL       0x150
341#define BTN_GEAR_DOWN       0x150
342#define BTN_GEAR_UP     0x151
343
344#define KEY_OK          0x160
345#define KEY_SELECT      0x161
346#define KEY_GOTO        0x162
347#define KEY_CLEAR       0x163
348#define KEY_POWER2      0x164
349#define KEY_OPTION      0x165
350#define KEY_INFO        0x166
351#define KEY_TIME        0x167
352#define KEY_VENDOR      0x168
353#define KEY_ARCHIVE     0x169
354#define KEY_PROGRAM     0x16a
355#define KEY_CHANNEL     0x16b
356#define KEY_FAVORITES       0x16c
357#define KEY_EPG         0x16d
358#define KEY_PVR         0x16e
359#define KEY_MHP         0x16f
360#define KEY_LANGUAGE        0x170
361#define KEY_TITLE       0x171
362#define KEY_SUBTITLE        0x172
363#define KEY_ANGLE       0x173
364#define KEY_ZOOM        0x174
365#define KEY_MODE        0x175
366#define KEY_KEYBOARD        0x176
367#define KEY_SCREEN      0x177
368#define KEY_PC          0x178
369#define KEY_TV          0x179
370#define KEY_TV2         0x17a
371#define KEY_VCR         0x17b
372#define KEY_VCR2        0x17c
373#define KEY_SAT         0x17d
374#define KEY_SAT2        0x17e
375#define KEY_CD          0x17f
376#define KEY_TAPE        0x180
377#define KEY_RADIO       0x181
378#define KEY_TUNER       0x182
379#define KEY_PLAYER      0x183
380#define KEY_TEXT        0x184
381#define KEY_DVD         0x185
382#define KEY_AUX         0x186
383#define KEY_MP3         0x187
384#define KEY_AUDIO       0x188
385#define KEY_VIDEO       0x189
386#define KEY_DIRECTORY       0x18a
387#define KEY_LIST        0x18b
388#define KEY_MEMO        0x18c
389#define KEY_CALENDAR        0x18d
390#define KEY_RED         0x18e
391#define KEY_GREEN       0x18f
392#define KEY_YELLOW      0x190
393#define KEY_BLUE        0x191
394#define KEY_CHANNELUP       0x192
395#define KEY_CHANNELDOWN     0x193
396#define KEY_FIRST       0x194
397#define KEY_LAST        0x195
398#define KEY_AB          0x196
399#define KEY_NEXT        0x197
400#define KEY_RESTART     0x198
401#define KEY_SLOW        0x199
402#define KEY_SHUFFLE     0x19a
403#define KEY_BREAK       0x19b
404#define KEY_PREVIOUS        0x19c
405#define KEY_DIGITS      0x19d
406#define KEY_TEEN        0x19e
407#define KEY_TWEN        0x19f
408
409#define KEY_FRAMEBACK       0x1b2
410#define KEY_FRAMEFORWARD    0x1b3
411#define KEY_CONTEXT_MENU    0x1fb
412
413#define KEY_MAX         0x1ff
414
415/* Relative axes */
416
417#define REL_X           0x00
418#define REL_Y           0x01
419#define REL_Z           0x02
420#define REL_RX          0x03
421#define REL_RY          0x04
422#define REL_RZ          0x05
423#define REL_HWHEEL      0x06
424#define REL_DIAL        0x07
425#define REL_WHEEL       0x08
426#define REL_MISC        0x09
427#define REL_MAX         0x0f
428
429/* Absolute axes */
430
431#define ABS_X           0x00
432#define ABS_Y           0x01
433#define ABS_Z           0x02
434#define ABS_RX          0x03
435#define ABS_RY          0x04
436#define ABS_RZ          0x05
437#define ABS_THROTTLE        0x06
438#define ABS_RUDDER      0x07
439#define ABS_WHEEL       0x08
440#define ABS_GAS         0x09
441#define ABS_BRAKE       0x0a
442#define ABS_HAT0X       0x10
443#define ABS_HAT0Y       0x11
444#define ABS_HAT1X       0x12
445#define ABS_HAT1Y       0x13
446#define ABS_HAT2X       0x14
447#define ABS_HAT2Y       0x15
448#define ABS_HAT3X       0x16
449#define ABS_HAT3Y       0x17
450#define ABS_PRESSURE        0x18
451#define ABS_DISTANCE        0x19
452#define ABS_TILT_X      0x1a
453#define ABS_TILT_Y      0x1b
454#define ABS_TOOL_WIDTH      0x1c
455#define ABS_VOLUME      0x20
456#define ABS_MISC        0x28
457#define ABS_MAX         0x3f
458
459/* Switch events */
460
461#define SW_0            0x00
462#define SW_1            0x01
463#define SW_2            0x02
464#define SW_3            0x03
465#define SW_4            0x04
466#define SW_5            0x05
467#define SW_6            0x06
468#define SW_7            0x07
469#define SW_MAX          0x0f
470
471/* Misc events */
472
473#define MSC_SERIAL      0x00
474#define MSC_PULSELED        0x01
475#define MSC_GESTURE     0x02
476#define MSC_RAW         0x03
477#define MSC_SCAN        0x04
478#define MSC_MAX         0x07
479
480/* LEDs */
481
482#define LED_NUML        0x00
483#define LED_CAPSL       0x01
484#define LED_SCROLLL     0x02
485#define LED_COMPOSE     0x03
486#define LED_KANA        0x04
487#define LED_SLEEP       0x05
488#define LED_SUSPEND     0x06
489#define LED_MUTE        0x07
490#define LED_MISC        0x08
491#define LED_MAIL        0x09
492#define LED_CHARGING        0x0a
493#define LED_MAX         0x0f
494
495/* Autorepeat values */
496
497#define REP_DELAY       0x00
498#define REP_PERIOD      0x01
499#define REP_MAX         0x01
500
501/* Sounds */
502
503#define SND_CLICK       0x00
504#define SND_BELL        0x01
505#define SND_TONE        0x02
506#define SND_MAX         0x07
507
508/* Identifiers */
509
510#define ID_BUS          0
511#define ID_VENDOR       1
512#define ID_PRODUCT      2
513#define ID_VERSION      3
514
515#define BUS_PCI         0x01
516#define BUS_ISAPNP      0x02
517#define BUS_USB         0x03
518#define BUS_HIL         0x04
519#define BUS_BLUETOOTH       0x05
520
521#define BUS_ISA         0x10
522#define BUS_I8042       0x11
523#define BUS_XTKBD       0x12
524#define BUS_RS232       0x13
525#define BUS_GAMEPORT        0x14
526#define BUS_PARPORT     0x15
527#define BUS_AMIGA       0x16
528#define BUS_ADB         0x17
529#define BUS_I2C         0x18
530#define BUS_HOST        0x19
531#define BUS_GSC         0x1A
532
533/* User input interface */
534
535#define UINPUT_IOCTL_BASE   'U'
536
537#define UI_DEV_CREATE       _IO(UINPUT_IOCTL_BASE, 1)
538#define UI_DEV_DESTROY      _IO(UINPUT_IOCTL_BASE, 2)
539
540#define UI_SET_EVBIT        _IOW(UINPUT_IOCTL_BASE, 100, int)
541#define UI_SET_KEYBIT       _IOW(UINPUT_IOCTL_BASE, 101, int)
542#define UI_SET_RELBIT       _IOW(UINPUT_IOCTL_BASE, 102, int)
543#define UI_SET_ABSBIT       _IOW(UINPUT_IOCTL_BASE, 103, int)
544#define UI_SET_MSCBIT       _IOW(UINPUT_IOCTL_BASE, 104, int)
545#define UI_SET_LEDBIT       _IOW(UINPUT_IOCTL_BASE, 105, int)
546#define UI_SET_SNDBIT       _IOW(UINPUT_IOCTL_BASE, 106, int)
547#define UI_SET_FFBIT        _IOW(UINPUT_IOCTL_BASE, 107, int)
548#define UI_SET_PHYS     _IOW(UINPUT_IOCTL_BASE, 108, char*)
549#define UI_SET_SWBIT        _IOW(UINPUT_IOCTL_BASE, 109, int)
550
551#ifndef NBITS
552#define NBITS(x) ((((x) - 1) / (sizeof(long) * 8)) + 1)
553#endif
554
555#define UINPUT_MAX_NAME_SIZE    80
556
557
558/*******************************************************************************
559**  Type definitions and return values
560********************************************************************************/
561
562struct uinput_id {
563    uint16_t bustype;
564    uint16_t vendor;
565    uint16_t product;
566    uint16_t version;
567};
568
569struct uinput_dev {
570    char name[UINPUT_MAX_NAME_SIZE];
571    struct uinput_id id;
572    int ff_effects_max;
573    int absmax[ABS_MAX + 1];
574    int absmin[ABS_MAX + 1];
575    int absfuzz[ABS_MAX + 1];
576    int absflat[ABS_MAX + 1];
577};
578
579struct uinput_event {
580    struct timeval time;
581    uint16_t type;
582    uint16_t code;
583    int32_t value;
584};
585
586#ifdef __cplusplus
587}
588#endif
589
590#endif /* __UINPUT_H */
591