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