• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Lint as: python2, python3
2# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6# Description:
7#
8# Python version of include/linux/input.h
9#  as of kernel v2.6.39
10
11from __future__ import division
12from __future__ import print_function
13from six.moves import range
14
15from linux_ioctl import *
16# The event structure itself
17#   struct input_event {
18#       struct timeval time;
19#       __u16 type;
20#       __u16 code;
21#       __s32 value;
22#   };
23#
24#   struct timeval {
25#       __kernel_time_t         tv_sec;         /* seconds */
26#       __kernel_suseconds_t    tv_usec;        /* microseconds */
27#   };
28input_event_t = 'LLHHi'
29
30
31# Protocol version.
32EV_VERSION = 0x010001
33
34# IOCTLs (0x00 - 0x7f)
35
36#   struct input_id {
37#       __u16 bustype;
38#       __u16 vendor;
39#       __u16 product;
40#       __u16 version;
41#   };
42input_id_t = 'HHHH'
43
44# struct input_absinfo - used by EVIOCGABS/EVIOCSABS ioctls
45# @value: latest reported value for the axis.
46# @minimum: specifies minimum value for the axis.
47# @maximum: specifies maximum value for the axis.
48# @fuzz: specifies fuzz value used to filter noise from the event stream.
49# @flat: values within this value are reported as 0.
50# @resolution: specifies resolution for the values reported for the axis.
51#
52# Note that input core does not clamp reported values to the
53# [minimum, maximum] limits, such task is left to userspace.
54#
55# Resolution for main axes (ABS_X, ABS_Y, ABS_Z) is reported in
56# units per millimeter (units/mm), resolution for rotational axes
57# (ABS_RX, ABS_RY, ABS_RZ) is reported in units per radian.
58#
59#   struct input_absinfo {
60#       __s32 value;
61#       __s32 minimum;
62#       __s32 maximum;
63#       __s32 fuzz;
64#       __s32 flat;
65#       __s32 resolution;
66#   };
67input_absinfo_t = 'iiiiii'
68
69# struct input_keymap_entry - used by EVIOCGKEYCODE/EVIOCSKEYCODE ioctls
70# @scancode: scancode represented in machine-endian form.
71# @len: length of the scancode that resides in @scancode buffer.
72# @index: index in the keymap, may be used instead of scancode
73# @flags: allows to specify how kernel should handle the request. For
74# example, setting INPUT_KEYMAP_BY_INDEX flag indicates that kernel
75# should perform lookup in keymap by @index instead of @scancode
76# @keycode: key code assigned to this scancode
77#
78# The structure is used to retrieve and modify keymap data. Users have
79# option of performing lookup either by @scancode itself or by @index
80# in keymap entry. EVIOCGKEYCODE will also return scancode or index
81# (depending on which element was used to perform lookup).
82#
83#   struct input_keymap_entry {
84#       __u8  flags;
85#       __u8  len;
86#       __u16 index;
87#       __u32 keycode;
88#       __u8  scancode[32];
89#   };
90input_keymap_entry_t = 'BBHI32B'
91
92EVIOCGVERSION           = IOR('E', 0x01, 'i')           # get driver version
93EVIOCGID                = IOR('E', 0x02, input_id_t)    # get device ID
94EVIOCGREP               = IOR('E', 0x03, '2I')          # get repeat settings
95EVIOCSREP               = IOW('E', 0x03, '2I')          # set repeat settings
96
97EVIOCGKEYCODE           = IOR('E', 0x04, '2I')          # get keycode
98EVIOCGKEYCODE_V2        = IOR('E', 0x04, input_keymap_entry_t)
99EVIOCSKEYCODE           = IOW('E', 0x04, '2I')          # set keycode
100EVIOCSKEYCODE_V2        = IOW('E', 0x04, input_keymap_entry_t)
101
102def EVIOCGNAME(length):
103    return IOC(IOC_READ, 'E', 0x06, length)  # get device name
104
105def EVIOCGPHYS(length):
106    return IOC(IOC_READ, 'E', 0x07, length)  # get physical location
107
108def EVIOCGUNIQ(length):
109    return IOC(IOC_READ, 'E', 0x08, length)  # get unique identifier
110
111def EVIOCGPROP(length):
112    return IOC(IOC_READ, 'E', 0x09, length)  # get device properties
113
114def EVIOCGMTSLOTS(length):
115    return IOC(IOC_READ, 'E', 0x0a, length)  # get mt slot values
116
117def EVIOCGKEY(length):
118    return IOC(IOC_READ, 'E', 0x18, length)  # get global key state
119
120def EVIOCGLED(length):
121    return IOC(IOC_READ, 'E', 0x19, length)  # get all LEDs
122
123def EVIOCGSND(length):
124    return IOC(IOC_READ, 'E', 0x1a, length)  # get all sounds status
125
126def EVIOCGSW(length):
127    return IOC(IOC_READ, 'E', 0x1b, length)  # get all switch states
128
129def EVIOCGBIT(ev,length):
130    return IOC(IOC_READ, 'E', 0x20 + ev, length)  # get event bits
131
132def EVIOCGABS(axis):
133    return IOR('E', 0x40 + axis, input_absinfo_t)  # get abs value/limits
134
135def EVIOCSABS(axis):
136    return IOW('E', 0xc0 + axis, input_absinfo_t)  # set abs value/limits
137
138# send a force effect to a force feedback device
139"""  TODO: Support force feedback. """
140
141
142#EVIOCSFF                = IOW('E', 0x80, ff_effect_t)
143# Erase a force effect
144EVIOCRMFF               = IOW('E', 0x81, 'i')
145# Report number of effects playable at the same time
146EVIOCGEFFECTS           = IOR('E', 0x84, 'i')
147# Grab/Release device
148EVIOCGRAB               = IOW('E', 0x90, 'i')
149
150# Device properties and quirks
151INPUT_PROP_POINTER   = 0x00 # needs a pointer
152INPUT_PROP_DIRECT    = 0x01 # direct input devices
153INPUT_PROP_BUTTONPAD = 0x02 # has button(s) under pad
154INPUT_PROP_SEMI_MT   = 0x03 # touch rectangle only
155
156INPUT_PROP_MAX       = 0x1f
157INPUT_PROP_CNT       = (INPUT_PROP_MAX + 1)
158
159# Event types
160EV_SYN          = 0x00
161EV_KEY          = 0x01
162EV_REL          = 0x02
163EV_ABS          = 0x03
164EV_MSC          = 0x04
165EV_SW           = 0x05
166EV_LED          = 0x11
167EV_SND          = 0x12
168EV_REP          = 0x14
169EV_FF           = 0x15
170EV_PWR          = 0x16
171EV_FF_STATUS    = 0x17
172EV_MAX          = 0x1f
173EV_CNT          = (EV_MAX + 1)
174
175# Synchronization events.
176
177SYN_REPORT      = 0
178SYN_CONFIG      = 1
179SYN_MT_REPORT   = 2
180SYN_DROPPED     = 3
181
182"""
183 * Keys and buttons
184 *
185 * Most of the keys/buttons are modeled after USB HUT 1.12
186 * (see http://www.usb.org/developers/hidpage).
187 * Abbreviations in the comments:
188 * AC - Application Control
189 * AL - Application Launch Button
190 * SC - System Control
191"""
192
193KEY_RESERVED    =  0
194KEY_ESC         =  1
195KEY_1           =  2
196KEY_2           =  3
197KEY_3           =  4
198KEY_4           =  5
199KEY_5           =  6
200KEY_6           =  7
201KEY_7           =  8
202KEY_8           =  9
203KEY_9           = 10
204KEY_0           = 11
205KEY_MINUS       = 12
206KEY_EQUAL       = 13
207KEY_BACKSPACE   = 14
208KEY_TAB         = 15
209KEY_Q           = 16
210KEY_W           = 17
211KEY_E           = 18
212KEY_R           = 19
213KEY_T           = 20
214KEY_Y           = 21
215KEY_U           = 22
216KEY_I           = 23
217KEY_O           = 24
218KEY_P           = 25
219KEY_LEFTBRACE   = 26
220KEY_RIGHTBRACE  = 27
221KEY_ENTER       = 28
222KEY_LEFTCTRL    = 29
223KEY_A           = 30
224KEY_S           = 31
225KEY_D           = 32
226KEY_F           = 33
227KEY_G           = 34
228KEY_H           = 35
229KEY_J           = 36
230KEY_K           = 37
231KEY_L           = 38
232KEY_SEMICOLON   = 39
233KEY_APOSTROPHE  = 40
234KEY_GRAVE       = 41
235KEY_LEFTSHIFT   = 42
236KEY_BACKSLASH   = 43
237KEY_Z           = 44
238KEY_X           = 45
239KEY_C           = 46
240KEY_V           = 47
241KEY_B           = 48
242KEY_N           = 49
243KEY_M           = 50
244KEY_COMMA       = 51
245KEY_DOT         = 52
246KEY_SLASH       = 53
247KEY_RIGHTSHIFT  = 54
248KEY_KPASTERISK  = 55
249KEY_LEFTALT     = 56
250KEY_SPACE       = 57
251KEY_CAPSLOCK    = 58
252KEY_F1          = 59
253KEY_F2          = 60
254KEY_F3          = 61
255KEY_F4          = 62
256KEY_F5          = 63
257KEY_F6          = 64
258KEY_F7          = 65
259KEY_F8          = 66
260KEY_F9          = 67
261KEY_F10         = 68
262KEY_NUMLOCK     = 69
263KEY_SCROLLLOCK  = 70
264KEY_KP7         = 71
265KEY_KP8         = 72
266KEY_KP9         = 73
267KEY_KPMINUS     = 74
268KEY_KP4         = 75
269KEY_KP5         = 76
270KEY_KP6         = 77
271KEY_KPPLUS      = 78
272KEY_KP1         = 79
273KEY_KP2         = 80
274KEY_KP3         = 81
275KEY_KP0         = 82
276KEY_KPDOT       = 83
277
278KEY_ZENKAKUHANKAKU = 85
279KEY_102ND       = 86
280KEY_F11         = 87
281KEY_F12         = 88
282KEY_RO          = 89
283KEY_KATAKANA    = 90
284KEY_HIRAGANA    = 91
285KEY_HENKAN      = 92
286KEY_KATAKANAHIRAGANA = 93
287KEY_MUHENKAN    = 94
288KEY_KPJPCOMMA   = 95
289KEY_KPENTER     = 96
290KEY_RIGHTCTRL   = 97
291KEY_KPSLASH     = 98
292KEY_SYSRQ       = 99
293KEY_RIGHTALT    = 100
294KEY_LINEFEED    = 101
295KEY_HOME        = 102
296KEY_UP          = 103
297KEY_PAGEUP      = 104
298KEY_LEFT        = 105
299KEY_RIGHT       = 106
300KEY_END         = 107
301KEY_DOWN        = 108
302KEY_PAGEDOWN    = 109
303KEY_INSERT      = 110
304KEY_DELETE      = 111
305KEY_MACRO       = 112
306KEY_MUTE        = 113
307KEY_VOLUMEDOWN  = 114
308KEY_VOLUMEUP    = 115
309KEY_POWER       = 116     # SC System Power Down
310KEY_KPEQUAL     = 117
311KEY_KPPLUSMINUS = 118
312KEY_PAUSE       = 119
313KEY_SCALE       = 120     # AL Compiz Scale (Expose)
314
315KEY_KPCOMMA     = 121
316KEY_HANGEUL     = 122
317KEY_HANGUEL     = KEY_HANGEUL
318KEY_HANJA       = 123
319KEY_YEN         = 124
320KEY_LEFTMETA    = 125
321KEY_RIGHTMETA   = 126
322KEY_COMPOSE     = 127
323
324KEY_STOP        = 128   # AC Stop
325KEY_AGAIN       = 129
326KEY_PROPS       = 130   # AC Properties
327KEY_UNDO        = 131   # AC Undo
328KEY_FRONT       = 132
329KEY_COPY        = 133   # AC Copy
330KEY_OPEN        = 134   # AC Open
331KEY_PASTE       = 135   # AC Paste
332KEY_FIND        = 136   # AC Search
333KEY_CUT         = 137   # AC Cut
334KEY_HELP        = 138   # AL Integrated Help Center
335KEY_MENU        = 139   # Menu (show menu)
336KEY_CALC        = 140   # AL Calculator
337KEY_SETUP       = 141
338KEY_SLEEP       = 142   # SC System Sleep
339KEY_WAKEUP      = 143   # System Wake Up
340KEY_FILE        = 144   # AL Local Machine Browser
341KEY_SENDFILE    = 145
342KEY_DELETEFILE  = 146
343KEY_XFER        = 147
344KEY_PROG1       = 148
345KEY_PROG2       = 149
346KEY_WWW         = 150   # AL Internet Browser
347KEY_MSDOS       = 151
348KEY_COFFEE      = 152   # AL Terminal Lock/Screensaver
349KEY_SCREENLOCK  = KEY_COFFEE
350KEY_DIRECTION   = 153
351KEY_CYCLEWINDOWS = 154
352KEY_MAIL        = 155
353KEY_BOOKMARKS   = 156   # AC Bookmarks
354KEY_COMPUTER    = 157
355KEY_BACK        = 158   # AC Back
356KEY_FORWARD     = 159   # AC Forward
357KEY_CLOSECD     = 160
358KEY_EJECTCD     = 161
359KEY_EJECTCLOSECD = 162
360KEY_NEXTSONG    = 163
361KEY_PLAYPAUSE   = 164
362KEY_PREVIOUSSONG = 165
363KEY_STOPCD      = 166
364KEY_RECORD      = 167
365KEY_REWIND      = 168
366KEY_PHONE       = 169   # Media Select Telephone
367KEY_ISO         = 170
368KEY_CONFIG      = 171   # AL Consumer Control Configuration
369KEY_HOMEPAGE    = 172   # AC Home
370KEY_REFRESH     = 173   # AC Refresh
371KEY_EXIT        = 174   # AC Exit
372KEY_MOVE        = 175
373KEY_EDIT        = 176
374KEY_SCROLLUP    = 177
375KEY_SCROLLDOWN  = 178
376KEY_KPLEFTPAREN = 179
377KEY_KPRIGHTPAREN = 180
378KEY_NEW         = 181   # AC New
379KEY_REDO        = 182   # AC Redo/Repeat
380
381KEY_F13         = 183
382KEY_F14         = 184
383KEY_F15         = 185
384KEY_F16         = 186
385KEY_F17         = 187
386KEY_F18         = 188
387KEY_F19         = 189
388KEY_F20         = 190
389KEY_F21         = 191
390KEY_F22         = 192
391KEY_F23         = 193
392KEY_F24         = 194
393
394KEY_PLAYCD      = 200
395KEY_PAUSECD     = 201
396KEY_PROG3       = 202
397KEY_PROG4       = 203
398KEY_DASHBOARD   = 204   # AL Dashboard
399KEY_SUSPEND     = 205
400KEY_CLOSE       = 206   # AC Close
401KEY_PLAY        = 207
402KEY_FASTFORWARD = 208
403KEY_BASSBOOST   = 209
404KEY_PRINT       = 210   # AC Print
405KEY_HP          = 211
406KEY_CAMERA      = 212
407KEY_SOUND       = 213
408KEY_QUESTION    = 214
409KEY_EMAIL       = 215
410KEY_CHAT        = 216
411KEY_SEARCH      = 217
412KEY_CONNECT     = 218
413KEY_FINANCE     = 219   #AL Checkbook/Finance
414KEY_SPORT       = 220
415KEY_SHOP        = 221
416KEY_ALTERASE    = 222
417KEY_CANCEL      = 223   # AC Cancel
418KEY_BRIGHTNESSDOWN = 224
419KEY_BRIGHTNESSUP = 225
420KEY_MEDIA       = 226
421
422KEY_SWITCHVIDEOMODE = 227   # Cycle between available video
423                            # outputs (Monitor/LCD/TV-out/etc)
424KEY_KBDILLUMTOGGLE  = 228
425KEY_KBDILLUMDOWN    = 229
426KEY_KBDILLUMUP      = 230
427
428KEY_SEND            = 231   # AC Send
429KEY_REPLY           = 232   # AC Reply
430KEY_FORWARDMAIL     = 233   # AC Forward Msg
431KEY_SAVE            = 234   # AC Save
432KEY_DOCUMENTS       = 235
433
434KEY_BATTERY         = 236
435
436KEY_BLUETOOTH       = 237
437KEY_WLAN            = 238
438KEY_UWB             = 239
439
440KEY_UNKNOWN         = 240
441
442KEY_VIDEO_NEXT      = 241   # drive next video source
443KEY_VIDEO_PREV      = 242   # drive previous video source
444KEY_BRIGHTNESS_CYCLE = 243  # brightness up, after max is min
445KEY_BRIGHTNESS_ZERO = 244   # brightness off, use ambient
446KEY_DISPLAY_OFF     = 245   # display device to off state
447
448KEY_WIMAX           = 246
449KEY_RFKILL          = 247   # Key that controls all radios
450
451# Code 255 is reserved for special needs of AT keyboard driver
452
453BTN_MISC        = 0x100
454BTN_0           = 0x100
455BTN_1           = 0x101
456BTN_2           = 0x102
457BTN_3           = 0x103
458BTN_4           = 0x104
459BTN_5           = 0x105
460BTN_6           = 0x106
461BTN_7           = 0x107
462BTN_8           = 0x108
463BTN_9           = 0x109
464
465BTN_MOUSE       = 0x110
466BTN_LEFT        = 0x110
467BTN_RIGHT       = 0x111
468BTN_MIDDLE      = 0x112
469BTN_SIDE        = 0x113
470BTN_EXTRA       = 0x114
471BTN_FORWARD     = 0x115
472BTN_BACK        = 0x116
473BTN_TASK        = 0x117
474
475BTN_JOYSTICK    = 0x120
476BTN_TRIGGER     = 0x120
477BTN_THUMB       = 0x121
478BTN_THUMB2      = 0x122
479BTN_TOP         = 0x123
480BTN_TOP2        = 0x124
481BTN_PINKIE      = 0x125
482BTN_BASE        = 0x126
483BTN_BASE2       = 0x127
484BTN_BASE3       = 0x128
485BTN_BASE4       = 0x129
486BTN_BASE5       = 0x12a
487BTN_BASE6       = 0x12b
488BTN_DEAD        = 0x12f
489
490BTN_GAMEPAD     = 0x130
491BTN_A           = 0x130
492BTN_B           = 0x131
493BTN_C           = 0x132
494BTN_X           = 0x133
495BTN_Y           = 0x134
496BTN_Z           = 0x135
497BTN_TL          = 0x136
498BTN_TR          = 0x137
499BTN_TL2         = 0x138
500BTN_TR2         = 0x139
501BTN_SELECT      = 0x13a
502BTN_START       = 0x13b
503BTN_MODE        = 0x13c
504BTN_THUMBL      = 0x13d
505BTN_THUMBR      = 0x13e
506
507BTN_DIGI        = 0x140
508BTN_TOOL_PEN    = 0x140
509BTN_TOOL_RUBBER = 0x141
510BTN_TOOL_BRUSH  = 0x142
511BTN_TOOL_PENCIL = 0x143
512BTN_TOOL_AIRBRUSH = 0x144
513BTN_TOOL_FINGER = 0x145
514BTN_TOOL_MOUSE  = 0x146
515BTN_TOOL_LENS   = 0x147
516BTN_TOOL_QUINTTAP = 0x148  # Five fingers on trackpad
517BTN_TOUCH       = 0x14a
518BTN_STYLUS      = 0x14b
519BTN_STYLUS2     = 0x14c
520BTN_TOOL_DOUBLETAP = 0x14d
521BTN_TOOL_TRIPLETAP = 0x14e
522BTN_TOOL_QUADTAP = 0x14f   # Four fingers on trackpad
523
524BTN_WHEEL       = 0x150
525BTN_GEAR_DOWN   = 0x150
526BTN_GEAR_UP     = 0x151
527
528
529KEY_OK          = 0x160
530KEY_SELECT      = 0x161
531KEY_GOTO        = 0x162
532KEY_CLEAR       = 0x163
533KEY_POWER2      = 0x164
534KEY_OPTION      = 0x165
535KEY_INFO        = 0x166   #AL OEM Features/Tips/Tutorial
536KEY_TIME        = 0x167
537KEY_VENDOR      = 0x168
538KEY_ARCHIVE     = 0x169
539KEY_PROGRAM     = 0x16a   # Media Select Program Guide
540KEY_CHANNEL     = 0x16b
541KEY_FAVORITES   = 0x16c
542KEY_EPG         = 0x16d
543KEY_PVR         = 0x16e   # Media Select Home
544KEY_MHP         = 0x16f
545KEY_LANGUAGE    = 0x170
546KEY_TITLE       = 0x171
547KEY_SUBTITLE    = 0x172
548KEY_ANGLE       = 0x173
549KEY_ZOOM        = 0x174
550KEY_MODE        = 0x175
551KEY_KEYBOARD    = 0x176
552KEY_SCREEN      = 0x177
553KEY_PC          = 0x178   # Media Select Computer
554KEY_TV          = 0x179   # Media Select TV
555KEY_TV2         = 0x17a   # Media Select Cable
556KEY_VCR         = 0x17b   # Media Select VCR
557KEY_VCR2        = 0x17c   # VCR Plus
558KEY_SAT         = 0x17d   # Media Select Satellite
559KEY_SAT2        = 0x17e
560KEY_CD          = 0x17f   # Media Select CD
561KEY_TAPE        = 0x180   # Select Tape
562KEY_RADIO       = 0x181
563KEY_TUNER       = 0x182   # Media Select Tuner
564KEY_PLAYER      = 0x183
565KEY_TEXT        = 0x184
566KEY_DVD         = 0x185   # Media Select DVD
567KEY_AUX         = 0x186
568KEY_MP3         = 0x187
569KEY_AUDIO       = 0x188   # AL Audio Browser
570KEY_VIDEO       = 0x189   # AL Movie Browser
571KEY_DIRECTORY   = 0x18a
572KEY_LIST        = 0x18b
573KEY_MEMO        = 0x18   # Media Select Messages
574KEY_CALENDAR    = 0x18d
575KEY_RED         = 0x18e
576KEY_GREEN       = 0x18f
577KEY_YELLOW      = 0x190
578KEY_BLUE        = 0x191
579KEY_CHANNELUP   = 0x192   # Channel Increment
580KEY_CHANNELDOWN = 0x193   # Channel Decrement
581KEY_FIRST       = 0x194
582KEY_LAST        = 0x195   # Recall Last
583KEY_AB          = 0x196
584KEY_NEXT        = 0x197
585KEY_RESTART     = 0x198
586KEY_SLOW        = 0x199
587KEY_SHUFFLE     = 0x19a
588KEY_BREAK       = 0x19b
589KEY_PREVIOUS    = 0x19c
590KEY_DIGITS      = 0x19d
591KEY_TEEN        = 0x19e
592KEY_TWEN        = 0x19f
593KEY_VIDEOPHONE  = 0x1a0   # Media Select Video Phone
594KEY_GAMES       = 0x1a1   # Media Select Games
595KEY_ZOOMIN      = 0x1a2   # AC Zoom In
596KEY_ZOOMOUT     = 0x1a3   # AC Zoom Out
597KEY_ZOOMRESET   = 0x1a4   # AC Zoom
598KEY_WORDPROCESSOR = 0x1a5   # AL Word Processor
599KEY_EDITOR      = 0x1a6   # AL Text Editor
600KEY_SPREADSHEET = 0x1a7   # AL Spreadsheet
601KEY_GRAPHICSEDITOR = 0x1a8   # AL Graphics Editor
602KEY_PRESENTATION = 0x1a9   # AL Presentation App
603KEY_DATABASE    = 0x1aa   # AL Database App
604KEY_NEWS        = 0x1ab   # AL Newsreader
605KEY_VOICEMAIL   = 0x1ac   # AL Voicemail
606KEY_ADDRESSBOOK = 0x1ad   # AL Contacts/Address Book
607KEY_MESSENGER   = 0x1ae   # AL Instant Messaging
608KEY_DISPLAYTOGGLE = 0x1af   # Turn display (LCD) on and off
609KEY_SPELLCHECK  = 0x1b0   # AL Spell Check
610KEY_LOGOFF      = 0x1b1   #* AL Logoff
611
612KEY_DOLLAR      = 0x1b2
613KEY_EURO        = 0x1b3
614
615KEY_FRAMEBACK   = 0x1b4   # Consumer - transport controls
616KEY_FRAMEFORWARD = 0x1b5
617KEY_CONTEXT_MENU = 0x1b6   # GenDesc - system context menu
618KEY_MEDIA_REPEAT = 0x1b7   # Consumer - transport control
619KEY_10CHANNELSUP = 0x1b8   # 10 channels up (10+)
620KEY_10CHANNELSDOWN = 0x1b9   # 10 channels down (10-)
621KEY_IMAGES       = 0x1ba   # AL Image Browser
622
623KEY_DEL_EOL      = 0x1c0
624KEY_DEL_EOS      = 0x1c1
625KEY_INS_LINE     = 0x1c2
626KEY_DEL_LINE     = 0x1c3
627
628KEY_FN           = 0x1d0
629KEY_FN_ESC       = 0x1d1
630KEY_FN_F1        = 0x1d2
631KEY_FN_F2        = 0x1d3
632KEY_FN_F3        = 0x1d4
633KEY_FN_F4        = 0x1d5
634KEY_FN_F5        = 0x1d6
635KEY_FN_F6        = 0x1d7
636KEY_FN_F7        = 0x1d8
637KEY_FN_F8        = 0x1d9
638KEY_FN_F9        = 0x1da
639KEY_FN_F10       = 0x1db
640KEY_FN_F11       = 0x1dc
641KEY_FN_F12       = 0x1dd
642KEY_FN_1         = 0x1de
643KEY_FN_2         = 0x1df
644KEY_FN_D         = 0x1e0
645KEY_FN_E         = 0x1e1
646KEY_FN_F         = 0x1e2
647KEY_FN_S         = 0x1e3
648KEY_FN_B         = 0x1e4
649
650KEY_BRL_DOT1     = 0x1f1
651KEY_BRL_DOT2     = 0x1f2
652KEY_BRL_DOT3     = 0x1f3
653KEY_BRL_DOT4     = 0x1f4
654KEY_BRL_DOT5     = 0x1f5
655KEY_BRL_DOT6     = 0x1f6
656KEY_BRL_DOT7     = 0x1f7
657KEY_BRL_DOT8     = 0x1f8
658KEY_BRL_DOT9     = 0x1f9
659KEY_BRL_DOT10    = 0x1fa
660
661KEY_NUMERIC_0    = 0x200   # used by phones, remote controls,
662KEY_NUMERIC_1    = 0x201   # and other keypads
663KEY_NUMERIC_2    = 0x202
664KEY_NUMERIC_3    = 0x203
665KEY_NUMERIC_4    = 0x204
666KEY_NUMERIC_5    = 0x205
667KEY_NUMERIC_6    = 0x206
668KEY_NUMERIC_7    = 0x207
669KEY_NUMERIC_8    = 0x208
670KEY_NUMERIC_9    = 0x209
671KEY_NUMERIC_STAR = 0x20a
672KEY_NUMERIC_POUND = 0x20b
673
674KEY_CAMERA_FOCUS = 0x210
675KEY_WPS_BUTTON   = 0x211   # WiFi Protected Setup key
676
677KEY_TOUCHPAD_TOGGLE = 0x212   # Request switch touchpad on or off
678KEY_TOUCHPAD_ON  = 0x213
679KEY_TOUCHPAD_OFF = 0x214
680
681KEY_CAMERA_ZOOMIN = 0x215
682KEY_CAMERA_ZOOMOUT = 0x216
683KEY_CAMERA_UP    = 0x217
684KEY_CAMERA_DOWN  = 0x218
685KEY_CAMERA_LEFT  = 0x219
686KEY_CAMERA_RIGHT = 0x21a
687
688BTN_TRIGGER_HAPPY  = 0x2c0
689BTN_TRIGGER_HAPPY1 = 0x2c0
690BTN_TRIGGER_HAPPY2 = 0x2c1
691BTN_TRIGGER_HAPPY3 = 0x2c2
692BTN_TRIGGER_HAPPY4 = 0x2c3
693BTN_TRIGGER_HAPPY5 = 0x2c4
694BTN_TRIGGER_HAPPY6 = 0x2c5
695BTN_TRIGGER_HAPPY7 = 0x2c6
696BTN_TRIGGER_HAPPY8 = 0x2c7
697BTN_TRIGGER_HAPPY9 = 0x2c8
698BTN_TRIGGER_HAPPY10 = 0x2c9
699BTN_TRIGGER_HAPPY11 = 0x2ca
700BTN_TRIGGER_HAPPY12 = 0x2cb
701BTN_TRIGGER_HAPPY13 = 0x2cc
702BTN_TRIGGER_HAPPY14 = 0x2cd
703BTN_TRIGGER_HAPPY15 = 0x2ce
704BTN_TRIGGER_HAPPY16 = 0x2cf
705BTN_TRIGGER_HAPPY17 = 0x2d0
706BTN_TRIGGER_HAPPY18 = 0x2d1
707BTN_TRIGGER_HAPPY19 = 0x2d2
708BTN_TRIGGER_HAPPY20 = 0x2d3
709BTN_TRIGGER_HAPPY21 = 0x2d4
710BTN_TRIGGER_HAPPY22 = 0x2d5
711BTN_TRIGGER_HAPPY23 = 0x2d6
712BTN_TRIGGER_HAPPY24 = 0x2d7
713BTN_TRIGGER_HAPPY25 = 0x2d8
714BTN_TRIGGER_HAPPY26 = 0x2d9
715BTN_TRIGGER_HAPPY27 = 0x2da
716BTN_TRIGGER_HAPPY28 = 0x2db
717BTN_TRIGGER_HAPPY29 = 0x2dc
718BTN_TRIGGER_HAPPY30 = 0x2dd
719BTN_TRIGGER_HAPPY31 = 0x2de
720BTN_TRIGGER_HAPPY32 = 0x2df
721BTN_TRIGGER_HAPPY33 = 0x2e0
722BTN_TRIGGER_HAPPY34 = 0x2e1
723BTN_TRIGGER_HAPPY35 = 0x2e2
724BTN_TRIGGER_HAPPY36 = 0x2e3
725BTN_TRIGGER_HAPPY37 = 0x2e4
726BTN_TRIGGER_HAPPY38 = 0x2e5
727BTN_TRIGGER_HAPPY39 = 0x2e6
728BTN_TRIGGER_HAPPY40 = 0x2e7
729
730
731# We avoid low common keys in module aliases so they don't get huge
732#KEY_MIN_INTERESTING = KEY_MUTE
733KEY_MAX             = 0x2ff
734KEY_CNT             = (KEY_MAX + 1)
735
736# Relative axes
737REL_X               = 0x00
738REL_Y               = 0x01
739REL_Z               = 0x02
740REL_RX              = 0x03
741REL_RY              = 0x04
742REL_RZ              = 0x05
743REL_HWHEEL          = 0x06
744REL_DIAL            = 0x07
745REL_WHEEL           = 0x08
746REL_MISC            = 0x09
747REL_RESERVED        = 0x0a
748REL_WHEEL_HI_RES    = 0x0b
749REL_HWHEEL_HI_RES   = 0x0c
750REL_MAX             = 0x0f
751REL_CNT             = (REL_MAX + 1)
752
753# Absolute axes
754ABS_X               = 0x00
755ABS_Y               = 0x01
756ABS_Z               = 0x02
757ABS_RX              = 0x03
758ABS_RY              = 0x04
759ABS_RZ              = 0x05
760ABS_THROTTLE        = 0x06
761ABS_RUDDER          = 0x07
762ABS_WHEEL           = 0x08
763ABS_GAS             = 0x09
764ABS_BRAKE           = 0x0a
765ABS_HAT0X           = 0x10
766ABS_HAT0Y           = 0x11
767ABS_HAT1X           = 0x12
768ABS_HAT1Y           = 0x13
769ABS_HAT2X           = 0x14
770ABS_HAT2Y           = 0x15
771ABS_HAT3X           = 0x16
772ABS_HAT3Y           = 0x17
773ABS_PRESSURE        = 0x18
774ABS_DISTANCE        = 0x19
775ABS_TILT_X          = 0x1a
776ABS_TILT_Y          = 0x1b
777ABS_TOOL_WIDTH      = 0x1c
778
779ABS_VOLUME          = 0x20
780
781ABS_MISC            = 0x28
782
783ABS_MT_SLOT         = 0x2f  # MT slot being modified
784ABS_MT_TOUCH_MAJOR  = 0x30  # Major axis of touching ellipse
785ABS_MT_TOUCH_MINOR  = 0x31  # Minor axis (omit if circular)
786ABS_MT_WIDTH_MAJOR  = 0x32  # Major axis of approaching ellipse
787ABS_MT_WIDTH_MINOR  = 0x33  # Minor axis (omit if circular)
788ABS_MT_ORIENTATION  = 0x34  # Ellipse orientation
789ABS_MT_POSITION_X   = 0x35  # Center X ellipse position
790ABS_MT_POSITION_Y   = 0x36  # Center Y ellipse position
791ABS_MT_TOOL_TYPE    = 0x37  # Type of touching device
792ABS_MT_BLOB_ID      = 0x38  # Group a set of packets as a blob
793ABS_MT_TRACKING_ID  = 0x39  # Unique ID of initiated contact
794ABS_MT_PRESSURE     = 0x3a  # Pressure on contact area
795ABS_MT_DISTANCE     = 0x3b  # Contact hover distance
796
797ABS_MT_FIRST        = ABS_MT_TOUCH_MAJOR
798ABS_MT_LAST         = ABS_MT_DISTANCE
799ABS_MT_RANGE        = list(range(ABS_MT_FIRST, ABS_MT_LAST+1))
800
801ABS_MAX             = 0x3f
802ABS_CNT             = (ABS_MAX + 1)
803
804# Switch events
805SW_LID                  = 0x00  # set = lid shut
806SW_TABLET_MODE          = 0x01  # set = tablet mode
807SW_HEADPHONE_INSERT     = 0x02  # set = inserted
808SW_RFKILL_ALL           = 0x03  # rfkill main switch, type "any"
809                                # set = radio enabled
810SW_RADIO = SW_RFKILL_ALL        # deprecated
811SW_MICROPHONE_INSERT    = 0x04  # set = inserted
812SW_DOCK                 = 0x05  # set = plugged into dock
813SW_LINEOUT_INSERT       = 0x06  # set = inserted
814SW_JACK_PHYSICAL_INSERT = 0x07  # set = mechanical switch set
815SW_VIDEOOUT_INSERT      = 0x08  # set = inserted
816SW_CAMERA_LENS_COVER    = 0x09  # set = lens covered
817SW_KEYPAD_SLIDE         = 0x0a  # set = keypad slide out
818SW_FRONT_PROXIMITY      = 0x0b  # set = front proximity sensor active
819SW_ROTATE_LOCK          = 0x0c  # set = rotate locked/disabled
820SW_MAX                  = 0x0f
821SW_CNT                  = (SW_MAX + 1)
822
823# Misc events
824MSC_SERIAL      = 0x00
825MSC_PULSELED    = 0x01
826MSC_GESTURE     = 0x02
827MSC_RAW         = 0x03
828MSC_SCAN        = 0x04
829MSC_MAX         = 0x07
830MSC_CNT         = (MSC_MAX + 1)
831
832# LEDs
833LED_NUML        = 0x00
834LED_CAPSL       = 0x01
835LED_SCROLLL     = 0x02
836LED_COMPOSE     = 0x03
837LED_KANA        = 0x04
838LED_SLEEP       = 0x05
839LED_SUSPEND     = 0x06
840LED_MUTE        = 0x07
841LED_MISC        = 0x08
842LED_MAIL        = 0x09
843LED_CHARGING    = 0x0a
844LED_MAX         = 0x0f
845LED_CNT         = (LED_MAX + 1)
846
847# Autorepeat values
848REP_DELAY       = 0x00
849REP_PERIOD      = 0x01
850REP_MAX         = 0x01
851REP_CNT         = (REP_MAX + 1)
852
853# Sounds
854SND_CLICK       = 0x00
855SND_BELL        = 0x01
856SND_TONE        = 0x02
857SND_MAX         = 0x07
858SND_CNT         = (SND_MAX + 1)
859
860# IDs.
861ID_BUS          = 0
862ID_VENDOR       = 1
863ID_PRODUCT      = 2
864ID_VERSION      = 3
865
866BUS_PCI         = 0x01
867BUS_ISAPNP      = 0x02
868BUS_USB         = 0x03
869BUS_HIL         = 0x04
870BUS_BLUETOOTH   = 0x05
871BUS_VIRTUAL     = 0x06
872
873BUS_ISA         = 0x10
874BUS_I8042       = 0x11
875BUS_XTKBD       = 0x12
876BUS_RS232       = 0x13
877BUS_GAMEPORT    = 0x14
878BUS_PARPORT     = 0x15
879BUS_AMIGA       = 0x16
880BUS_ADB         = 0x17
881BUS_I2C         = 0x18
882BUS_HOST        = 0x19
883BUS_GSC         = 0x1A
884BUS_ATARI       = 0x1B
885BUS_SPI         = 0x1C
886
887# MT_TOOL types
888MT_TOOL_FINGER  = 0
889MT_TOOL_PEN     = 1
890MT_TOOL_MAX     = 1
891
892# Values describing the status of a force-feedback effect
893FF_STATUS_STOPPED   = 0x00
894FF_STATUS_PLAYING   = 0x01
895FF_STATUS_MAX       = 0x01
896FF_STATUS_CNT       = (FF_STATUS_MAX + 1)
897
898# Structures used in ioctls to upload effects to a device
899# They are pieces of a bigger structure (called ff_effect)
900
901# All duration values are expressed in ms. Values above 32767 ms (0x7fff)
902# should not be used and have unspecified results.
903
904"""
905 * struct ff_replay - defines scheduling of the force-feedback effect
906 * @length: duration of the effect
907 * @delay: delay before effect should start playing
908struct ff_replay {
909  __u16 length;
910  __u16 delay;
911};
912"""
913
914"""
915 * struct ff_trigger - defines what triggers the force-feedback effect
916 * @button: number of the button triggering the effect
917 * @interval: controls how soon the effect can be re-triggered
918struct ff_trigger {
919  __u16 button;
920  __u16 interval;
921};
922"""
923
924"""
925 * struct ff_envelope - generic force-feedback effect envelope
926 * @attack_length: duration of the attack (ms)
927 * @attack_level: level at the beginning of the attack
928 * @fade_length: duration of fade (ms)
929 * @fade_level: level at the end of fade
930 *
931 * The @attack_level and @fade_level are absolute values; when applying
932 * envelope force-feedback core will convert to positive/negative
933 * value based on polarity of the default level of the effect.
934 * Valid range for the attack and fade levels is 0x0000 - 0x7fff
935struct ff_envelope {
936  __u16 attack_length;
937  __u16 attack_level;
938  __u16 fade_length;
939  __u16 fade_level;
940};
941"""
942
943"""
944 * struct ff_constant_effect - params of a constant force-feedback effect
945 * @level: strength of the effect; may be negative
946 * @envelope: envelope data
947struct ff_constant_effect {
948  __s16 level;
949  struct ff_envelope envelope;
950};
951"""
952
953"""
954 * struct ff_ramp_effect - params of a ramp force-feedback effect
955 * @start_level: beginning strength of the effect; may be negative
956 * @end_level: final strength of the effect; may be negative
957 * @envelope: envelope data
958struct ff_ramp_effect {
959  __s16 start_level;
960  __s16 end_level;
961  struct ff_envelope envelope;
962};
963"""
964
965"""
966 * struct ff_condition_effect - spring or friction force-feedback effect
967 * @right_saturation: maximum level when joystick moved all way to the right
968 * @left_saturation: same for the left side
969 * @right_coeff: controls how fast the force grows when the joystick moves
970 *  to the right
971 * @left_coeff: same for the left side
972 * @deadband: size of the dead zone, where no force is produced
973 * @center: position of the dead zone
974struct ff_condition_effect {
975  __u16 right_saturation;
976  __u16 left_saturation;
977
978  __s16 right_coeff;
979  __s16 left_coeff;
980
981  __u16 deadband;
982  __s16 center;
983};
984"""
985
986
987"""
988 * struct ff_periodic_effect - params of a periodic force-feedback effect
989 * @waveform: kind of the effect (wave)
990 * @period: period of the wave (ms)
991 * @magnitude: peak value
992 * @offset: mean value of the wave (roughly)
993 * @phase: 'horizontal' shift
994 * @envelope: envelope data
995 * @custom_len: number of samples (FF_CUSTOM only)
996 * @custom_data: buffer of samples (FF_CUSTOM only)
997 *
998 * Known waveforms - FF_SQUARE, FF_TRIANGLE, FF_SINE, FF_SAW_UP,
999 * FF_SAW_DOWN, FF_CUSTOM. The exact syntax FF_CUSTOM is undefined
1000 * for the time being as no driver supports it yet.
1001 *
1002 * Note: the data pointed by custom_data is copied by the driver.
1003 * You can therefore dispose of the memory after the upload/update.
1004struct ff_periodic_effect {
1005  __u16 waveform;
1006  __u16 period;
1007  __s16 magnitude;
1008  __s16 offset;
1009  __u16 phase;
1010
1011  struct ff_envelope envelope;
1012
1013  __u32 custom_len;
1014  __s16 __user *custom_data;
1015};
1016"""
1017
1018"""
1019 * struct ff_rumble_effect - params of a periodic force-feedback effect
1020 * @strong_magnitude: magnitude of the heavy motor
1021 * @weak_magnitude: magnitude of the light one
1022 *
1023 * Some rumble pads have two motors of different weight. Strong_magnitude
1024 * represents the magnitude of the vibration generated by the heavy one.
1025struct ff_rumble_effect {
1026  __u16 strong_magnitude;
1027  __u16 weak_magnitude;
1028};
1029"""
1030
1031"""
1032 * struct ff_effect - defines force feedback effect
1033 * @type: type of the effect (FF_CONSTANT, FF_PERIODIC, FF_RAMP, FF_SPRING,
1034 *  FF_FRICTION, FF_DAMPER, FF_RUMBLE, FF_INERTIA, or FF_CUSTOM)
1035 * @id: an unique id assigned to an effect
1036 * @direction: direction of the effect
1037 * @trigger: trigger conditions (struct ff_trigger)
1038 * @replay: scheduling of the effect (struct ff_replay)
1039 * @u: effect-specific structure (one of ff_constant_effect, ff_ramp_effect,
1040 *  ff_periodic_effect, ff_condition_effect, ff_rumble_effect) further
1041 *  defining effect parameters
1042 *
1043 * This structure is sent through ioctl from the application to the driver.
1044 * To create a new effect application should set its @id to -1; the kernel
1045 * will return assigned @id which can later be used to update or delete
1046 * this effect.
1047 *
1048 * Direction of the effect is encoded as follows:
1049 *  0 deg -> 0x0000 (down)
1050 *  90 deg -> 0x4000 (left)
1051 *  180 deg -> 0x8000 (up)
1052 *  270 deg -> 0xC000 (right)
1053struct ff_effect {
1054  __u16 type;
1055  __s16 id;
1056  __u16 direction;
1057  struct ff_trigger trigger;
1058  struct ff_replay replay;
1059
1060  union {
1061    struct ff_constant_effect constant;
1062    struct ff_ramp_effect ramp;
1063    struct ff_periodic_effect periodic;
1064    struct ff_condition_effect condition[2]; /* One for each axis */
1065    struct ff_rumble_effect rumble;
1066  } u;
1067};
1068"""
1069
1070# Force feedback effect types
1071FF_RUMBLE       = 0x50
1072FF_PERIODIC     = 0x51
1073FF_CONSTANT     = 0x52
1074FF_SPRING       = 0x53
1075FF_FRICTION     = 0x54
1076FF_DAMPER       = 0x55
1077FF_INERTIA      = 0x56
1078FF_RAMP         = 0x57
1079
1080FF_EFFECT_MIN   = FF_RUMBLE
1081FF_EFFECT_MAX   = FF_RAMP
1082
1083# Force feedback periodic effect types
1084FF_SQUARE       = 0x58
1085FF_TRIANGLE     = 0x59
1086FF_SINE         = 0x5a
1087FF_SAW_UP       = 0x5b
1088FF_SAW_DOWN     = 0x5c
1089FF_CUSTOM       = 0x5d
1090
1091FF_WAVEFORM_MIN = FF_SQUARE
1092FF_WAVEFORM_MAX = FF_CUSTOM
1093
1094# Set ff device properties
1095FF_GAIN         = 0x60
1096FF_AUTOCENTER   = 0x61
1097
1098FF_MAX          = 0x7f
1099FF_CNT          = (FF_MAX + 1)
1100
1101
1102"""
1103The following constants, functions and dicts are not part of the original linux
1104input header file.  They are included here to make it easier to use the linux
1105input subsystem from python scripts.
1106"""
1107
1108BITS_PER_WORD = 8
1109
1110def NBITS(x):
1111    return ((x - 1) // BITS_PER_WORD) + 1
1112
1113def OFFSET(x):
1114    return (x % BITS_PER_WORD)
1115
1116def BIT(x):
1117    return (1 << OFFSET(x))
1118
1119def INDEX(x):
1120    return (x // BITS_PER_WORD)
1121
1122def test_bit(b, a):
1123    return ((a[INDEX(b)] >> OFFSET(b)) & 1)
1124
1125EV_TYPES = {
1126    EV_SYN : 'EV_SYN',
1127    EV_KEY : 'EV_KEY',
1128    EV_REL : 'EV_REL',
1129    EV_ABS : 'EV_ABS',
1130    EV_MSC : 'EV_MSC',
1131    EV_SW  : 'EV_SW',
1132    EV_LED : 'EV_LED',
1133    EV_SND : 'EV_SND',
1134    EV_REP : 'EV_REP',
1135    EV_FF  : 'EV_FF',
1136    EV_PWR : 'EV_PWR',
1137    EV_FF_STATUS : 'EV_FF_STATUS'
1138}
1139
1140EV_SIZES = {
1141    EV_KEY : KEY_CNT,
1142    EV_REL : REL_CNT,
1143    EV_ABS : ABS_CNT,
1144    EV_MSC : MSC_CNT,
1145    EV_SW  : SW_CNT,
1146    EV_LED : LED_CNT,
1147    EV_SND : SND_CNT,
1148    EV_REP : REP_CNT,
1149    EV_FF  : FF_CNT,
1150    EV_FF_STATUS : FF_STATUS_CNT
1151}
1152
1153EV_STRINGS = {
1154    # Keys (only buttons, for now)
1155    EV_KEY: {
1156        BTN_0           : '0',
1157        BTN_1           : '1',
1158        BTN_2           : '0',
1159        BTN_3           : '3',
1160        BTN_4           : '4',
1161        BTN_5           : '5',
1162        BTN_6           : '6',
1163        BTN_7           : '7',
1164        BTN_8           : '8',
1165        BTN_9           : '9',
1166        BTN_LEFT        : 'LEFT',
1167        BTN_RIGHT       : 'RIGHT',
1168        BTN_MIDDLE      : 'MIDDLE',
1169        BTN_SIDE        : 'SIDE',
1170        BTN_EXTRA       : 'EXTRA',
1171        BTN_FORWARD     : 'FORWARD',
1172        BTN_BACK        : 'BACK',
1173        BTN_TASK        : 'TASK',
1174        BTN_TRIGGER     : 'TRIGGER',
1175        BTN_THUMB       : 'THUMB',
1176        BTN_THUMB2      : 'THUMB2',
1177        BTN_TOP         : 'TOP',
1178        BTN_TOP2        : 'TOP2',
1179        BTN_PINKIE      : 'PINKIE',
1180        BTN_BASE        : 'BASE',
1181        BTN_BASE2       : 'BASE2',
1182        BTN_BASE3       : 'BASE3',
1183        BTN_BASE4       : 'BASE4',
1184        BTN_BASE5       : 'BASE5',
1185        BTN_BASE6       : 'BASE6',
1186        BTN_DEAD        : 'DEAD',
1187        BTN_A           : 'A',
1188        BTN_B           : 'B',
1189        BTN_C           : 'C',
1190        BTN_X           : 'X',
1191        BTN_Y           : 'Y',
1192        BTN_Z           : 'Z',
1193        BTN_TL          : 'TL',
1194        BTN_TR          : 'TR',
1195        BTN_TL2         : 'TL2',
1196        BTN_TR2         : 'TR2',
1197        BTN_SELECT      : 'SELECT',
1198        BTN_START       : 'START',
1199        BTN_MODE        : 'MODE',
1200        BTN_THUMBL      : 'THUMBL',
1201        BTN_THUMBR      : 'THUMBR',
1202        BTN_TOOL_PEN    : 'TOOL_PEN',
1203        BTN_TOOL_RUBBER : 'TOOL_RUBBER',
1204        BTN_TOOL_BRUSH  : 'TOOL_BRUSH',
1205        BTN_TOOL_PENCIL : 'TOOL_PENCIL',
1206        BTN_TOOL_AIRBRUSH : 'TOOL_AIRBRUSH',
1207        BTN_TOOL_FINGER : 'TOOL_FINGER',
1208        BTN_TOOL_MOUSE  : 'TOOL_MOUSE',
1209        BTN_TOOL_LENS   : 'TOOL_LENS',
1210        BTN_TOOL_QUINTTAP : 'TOOL_QUINTTAP',
1211        BTN_TOUCH       : 'TOUCH',
1212        BTN_STYLUS      : 'STYLUS',
1213        BTN_STYLUS2     : 'STYLUS2',
1214        BTN_TOOL_DOUBLETAP : 'TOOL_DOUBLETAP',
1215        BTN_TOOL_TRIPLETAP : 'TOOL_TRIPLETAP',
1216        BTN_TOOL_QUADTAP : 'TOOL_QUADTAP',
1217        BTN_GEAR_DOWN   : 'TOOL_GEAR_DOWN',
1218        BTN_GEAR_UP     : 'TOOL_GEAR_UP',
1219    },
1220
1221    # Relative axes
1222    EV_REL: {
1223        REL_X           : 'X',
1224        REL_Y           : 'Y',
1225        REL_Z           : 'Z',
1226        REL_RX          : 'RX',
1227        REL_RY          : 'RY',
1228        REL_RZ          : 'RZ',
1229        REL_HWHEEL      : 'HWHEEL',
1230        REL_DIAL        : 'DIAL',
1231        REL_WHEEL       : 'WHEEL',
1232        REL_MISC        : 'MISC',
1233    },
1234
1235    # Absolute axes
1236    EV_ABS: {
1237        ABS_X               : 'X',
1238        ABS_Y               : 'Y',
1239        ABS_Z               : 'Z',
1240        ABS_RX              : 'RX',
1241        ABS_RY              : 'RY',
1242        ABS_RZ              : 'RZ',
1243        ABS_THROTTLE        : 'THROTTLE',
1244        ABS_RUDDER          : 'RUDDER',
1245        ABS_WHEEL           : 'WHEEL',
1246        ABS_GAS             : 'GAS',
1247        ABS_BRAKE           : 'BRAKE',
1248        ABS_HAT0X           : 'HAT0X',
1249        ABS_HAT0Y           : 'HAT0Y',
1250        ABS_HAT1X           : 'HAT1X',
1251        ABS_HAT1Y           : 'HAT1Y',
1252        ABS_HAT2X           : 'HAT2X',
1253        ABS_HAT2Y           : 'HAT2Y',
1254        ABS_HAT3X           : 'HAT3X',
1255        ABS_HAT3Y           : 'HAT3Y',
1256        ABS_PRESSURE        : 'PRESSURE',
1257        ABS_DISTANCE        : 'DISTANCE',
1258        ABS_TILT_X          : 'TILT_X',
1259        ABS_TILT_Y          : 'TILT_Y',
1260        ABS_TOOL_WIDTH      : 'TOOL_WIDTH',
1261        ABS_VOLUME          : 'VOLUME',
1262        ABS_MISC            : 'MISC',
1263        ABS_MT_SLOT         : 'MT_SLOT',
1264        ABS_MT_TOUCH_MAJOR  : 'MT_TOUCH_MAJOR',
1265        ABS_MT_TOUCH_MINOR  : 'MT_TOUCH_MINOR',
1266        ABS_MT_WIDTH_MAJOR  : 'MT_WIDTH_MAJOR',
1267        ABS_MT_WIDTH_MINOR  : 'MT_WIDTH_MINOR',
1268        ABS_MT_ORIENTATION  : 'MT_ORIENTATION',
1269        ABS_MT_POSITION_X   : 'MT_POSITION_X',
1270        ABS_MT_POSITION_Y   : 'MT_POSITION_Y',
1271        ABS_MT_TOOL_TYPE    : 'MT_TOOL_TYPE',
1272        ABS_MT_BLOB_ID      : 'MT_BLOB_ID',
1273        ABS_MT_TRACKING_ID  : 'MT_TRACKING_ID',
1274        ABS_MT_PRESSURE     : 'MT_PRESSURE',
1275        ABS_MT_DISTANCE     : 'MT_DISTANCE'
1276    },
1277
1278    # Switches
1279    EV_SW: {
1280        SW_LID                  : 'LID',
1281        SW_TABLET_MODE          : 'TABLET_MODE',
1282        SW_HEADPHONE_INSERT     : 'HEADPHONE_INSERT',
1283        SW_RFKILL_ALL           : 'RFKILL_ALL',
1284        SW_MICROPHONE_INSERT    : 'MICROPHONE_INSERT',
1285        SW_DOCK                 : 'DOCK',
1286        SW_LINEOUT_INSERT       : 'LINEOUT_INSERT',
1287        SW_JACK_PHYSICAL_INSERT : 'JACK_PHYSICAL_INSERT',
1288        SW_VIDEOOUT_INSERT      : 'VIDEOOUT_INSERT',
1289        SW_CAMERA_LENS_COVER    : 'CAMERA_LENS_COVER',
1290        SW_KEYPAD_SLIDE         : 'KEYPAD_SLIDE',
1291        SW_FRONT_PROXIMITY      : 'FRONT_PROXIMITY',
1292        SW_ROTATE_LOCK          : 'ROTATE_LOCK',
1293    },
1294
1295    # Misc events
1296    EV_MSC: {
1297        MSC_SERIAL      : 'SERIAL',
1298        MSC_PULSELED    : 'PULSELED',
1299        MSC_GESTURE     : 'GESTURE',
1300        MSC_RAW         : 'RAW',
1301        MSC_SCAN        : 'SCAN',
1302    },
1303
1304    # LEDs
1305    EV_LED: {
1306        LED_NUML        : 'NUML',
1307        LED_CAPSL       : 'CAPSL',
1308        LED_SCROLLL     : 'SCROLLL',
1309        LED_COMPOSE     : 'COMPOSE',
1310        LED_KANA        : 'KANA',
1311        LED_SLEEP       : 'SLEEP',
1312        LED_SUSPEND     : 'SLEEP',
1313        LED_MUTE        : 'SLEEP',
1314        LED_MISC        : 'SLEEP',
1315        LED_MAIL        : 'SLEEP',
1316        LED_CHARGING    : 'SLEEP',
1317    },
1318
1319    # Autorepeat values
1320    EV_REP: {
1321        REP_DELAY       : 'DELAY',
1322        REP_PERIOD      : 'PERIOD',
1323    },
1324
1325    # Sounds
1326    EV_SND: {
1327        SND_CLICK       : 'CLICK',
1328        SND_BELL        : 'BELL'
1329    }
1330}
1331