linux_input 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 60db76cc4c7bc2652c578fe9e1835f423b661d3d
4
+ data.tar.gz: 8eae0f28d0c77b3d044fdbf960816a78b2fa15ae
5
+ SHA512:
6
+ metadata.gz: b88319fd7cf7439720e047454e5d17221b56751bd819d07970cd2eb831d313a7289cbecc2361b1de00112f7b9cd2f2b6891cb7b3e75d2f9a9d7c168f9af7def6
7
+ data.tar.gz: da3e4f72f1d057ec17400afb14a264390eec943b9fa0862d492c87f1cee23ed39b53e6c47f693a13a349a3a0ab27cbbc3b9188fff724656659e720fac90fcc78
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Christopher Aue
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # LinuxInput
2
+
3
+ FFI structs and constants for linux's input subsystem found in linux/input.h
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'linux_input'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install linux_input
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ require 'linux_input'
25
+ ```
26
+
27
+ All constants and structures are accessible through the LinuxInput module.
28
+
29
+ snake_case C structure names are transformed into CamelCase Ruby constant names:
30
+
31
+ ```ruby
32
+ LinuxInput::InputEvent # input_event struct
33
+ LinuxInput::FfEffect # ff_effect struct
34
+ # and so on ...
35
+ ```
36
+
37
+ Constant names are left untouched:
38
+
39
+ ```ruby
40
+ LinuxInput::EV_KEY # => 0x01 (key event bit)
41
+ LinuxInput::KEY_A # => 30 (key code of the a key)
42
+ # and so on ...
43
+ ```
44
+
45
+ Ioctl constants and macros:
46
+
47
+ ```ruby
48
+ LinuxInput::EVIOCGID
49
+ LinuxInput::EVIOCGNAME(len)
50
+ # and so on ...
51
+ ```
52
+
53
+ Mapping a received event to the input_event struct:
54
+
55
+ ```ruby
56
+ file = File.open('/dev/input/event0')
57
+
58
+ loop do
59
+ raw_event = file.read LinuxInput::InputEvent.size
60
+ raw_event_ptr = FFI::MemoryPointer.from_string(raw_event)
61
+ event = LinuxInput::InputEvent.new(raw_event_ptr)
62
+ puts Time.at(event[:time][:tv_sec])
63
+ puts event[:type]
64
+ puts event[:code]
65
+ puts event[:value]
66
+ end
67
+ ```
68
+
69
+ ## (Re-)Compiling the interface on a linux machine
70
+
71
+ Reads your local linux/input.h
72
+
73
+ ```
74
+ $ rake ffi:generate
75
+ ```
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ Dir[File.expand_path("tasks/*.rake", File.dirname(__FILE__))].each { |ext| load ext }
4
+
@@ -0,0 +1,9 @@
1
+ require "linux_input/version"
2
+ require 'ffi'
3
+
4
+ module LinuxInput
5
+
6
+ end
7
+
8
+ require 'linux_input/ioctl.rb'
9
+ require 'linux_input/input.rb'
@@ -0,0 +1,839 @@
1
+ class InputEvent < FFI::Struct
2
+ layout(
3
+ :time, Timeval,
4
+ :type, :ushort,
5
+ :code, :ushort,
6
+ :value, :int
7
+ )
8
+ end
9
+ EV_VERSION = 0x010001
10
+ class InputId < FFI::Struct
11
+ layout(
12
+ :bustype, :ushort,
13
+ :vendor, :ushort,
14
+ :product, :ushort,
15
+ :version, :ushort
16
+ )
17
+ end
18
+ class InputAbsinfo < FFI::Struct
19
+ layout(
20
+ :value, :int,
21
+ :minimum, :int,
22
+ :maximum, :int,
23
+ :fuzz, :int,
24
+ :flat, :int,
25
+ :resolution, :int
26
+ )
27
+ end
28
+ INPUT_KEYMAP_BY_INDEX = (1 << 0)
29
+ class InputKeymapEntry < FFI::Struct
30
+ layout(
31
+ :flags, :uchar,
32
+ :len, :uchar,
33
+ :index, :ushort,
34
+ :keycode, :uint,
35
+ :scancode, [:uchar, 32]
36
+ )
37
+ end
38
+ INPUT_PROP_POINTER = 0x00
39
+ INPUT_PROP_DIRECT = 0x01
40
+ INPUT_PROP_BUTTONPAD = 0x02
41
+ INPUT_PROP_SEMI_MT = 0x03
42
+ INPUT_PROP_TOPBUTTONPAD = 0x04
43
+ INPUT_PROP_POINTING_STICK = 0x05
44
+ INPUT_PROP_ACCELEROMETER = 0x06
45
+ INPUT_PROP_MAX = 0x1f
46
+ INPUT_PROP_CNT = (0x1f+1)
47
+ EV_SYN = 0x00
48
+ EV_KEY = 0x01
49
+ EV_REL = 0x02
50
+ EV_ABS = 0x03
51
+ EV_MSC = 0x04
52
+ EV_SW = 0x05
53
+ EV_LED = 0x11
54
+ EV_SND = 0x12
55
+ EV_REP = 0x14
56
+ EV_FF = 0x15
57
+ EV_PWR = 0x16
58
+ EV_FF_STATUS = 0x17
59
+ EV_MAX = 0x1f
60
+ EV_CNT = (0x1f+1)
61
+ SYN_REPORT = 0
62
+ SYN_CONFIG = 1
63
+ SYN_MT_REPORT = 2
64
+ SYN_DROPPED = 3
65
+ SYN_MAX = 0xf
66
+ SYN_CNT = (0xf+1)
67
+ KEY_RESERVED = 0
68
+ KEY_ESC = 1
69
+ KEY_1 = 2
70
+ KEY_2 = 3
71
+ KEY_3 = 4
72
+ KEY_4 = 5
73
+ KEY_5 = 6
74
+ KEY_6 = 7
75
+ KEY_7 = 8
76
+ KEY_8 = 9
77
+ KEY_9 = 10
78
+ KEY_0 = 11
79
+ KEY_MINUS = 12
80
+ KEY_EQUAL = 13
81
+ KEY_BACKSPACE = 14
82
+ KEY_TAB = 15
83
+ KEY_Q = 16
84
+ KEY_W = 17
85
+ KEY_E = 18
86
+ KEY_R = 19
87
+ KEY_T = 20
88
+ KEY_Y = 21
89
+ KEY_U = 22
90
+ KEY_I = 23
91
+ KEY_O = 24
92
+ KEY_P = 25
93
+ KEY_LEFTBRACE = 26
94
+ KEY_RIGHTBRACE = 27
95
+ KEY_ENTER = 28
96
+ KEY_LEFTCTRL = 29
97
+ KEY_A = 30
98
+ KEY_S = 31
99
+ KEY_D = 32
100
+ KEY_F = 33
101
+ KEY_G = 34
102
+ KEY_H = 35
103
+ KEY_J = 36
104
+ KEY_K = 37
105
+ KEY_L = 38
106
+ KEY_SEMICOLON = 39
107
+ KEY_APOSTROPHE = 40
108
+ KEY_GRAVE = 41
109
+ KEY_LEFTSHIFT = 42
110
+ KEY_BACKSLASH = 43
111
+ KEY_Z = 44
112
+ KEY_X = 45
113
+ KEY_C = 46
114
+ KEY_V = 47
115
+ KEY_B = 48
116
+ KEY_N = 49
117
+ KEY_M = 50
118
+ KEY_COMMA = 51
119
+ KEY_DOT = 52
120
+ KEY_SLASH = 53
121
+ KEY_RIGHTSHIFT = 54
122
+ KEY_KPASTERISK = 55
123
+ KEY_LEFTALT = 56
124
+ KEY_SPACE = 57
125
+ KEY_CAPSLOCK = 58
126
+ KEY_F1 = 59
127
+ KEY_F2 = 60
128
+ KEY_F3 = 61
129
+ KEY_F4 = 62
130
+ KEY_F5 = 63
131
+ KEY_F6 = 64
132
+ KEY_F7 = 65
133
+ KEY_F8 = 66
134
+ KEY_F9 = 67
135
+ KEY_F10 = 68
136
+ KEY_NUMLOCK = 69
137
+ KEY_SCROLLLOCK = 70
138
+ KEY_KP7 = 71
139
+ KEY_KP8 = 72
140
+ KEY_KP9 = 73
141
+ KEY_KPMINUS = 74
142
+ KEY_KP4 = 75
143
+ KEY_KP5 = 76
144
+ KEY_KP6 = 77
145
+ KEY_KPPLUS = 78
146
+ KEY_KP1 = 79
147
+ KEY_KP2 = 80
148
+ KEY_KP3 = 81
149
+ KEY_KP0 = 82
150
+ KEY_KPDOT = 83
151
+ KEY_ZENKAKUHANKAKU = 85
152
+ KEY_102ND = 86
153
+ KEY_F11 = 87
154
+ KEY_F12 = 88
155
+ KEY_RO = 89
156
+ KEY_KATAKANA = 90
157
+ KEY_HIRAGANA = 91
158
+ KEY_HENKAN = 92
159
+ KEY_KATAKANAHIRAGANA = 93
160
+ KEY_MUHENKAN = 94
161
+ KEY_KPJPCOMMA = 95
162
+ KEY_KPENTER = 96
163
+ KEY_RIGHTCTRL = 97
164
+ KEY_KPSLASH = 98
165
+ KEY_SYSRQ = 99
166
+ KEY_RIGHTALT = 100
167
+ KEY_LINEFEED = 101
168
+ KEY_HOME = 102
169
+ KEY_UP = 103
170
+ KEY_PAGEUP = 104
171
+ KEY_LEFT = 105
172
+ KEY_RIGHT = 106
173
+ KEY_END = 107
174
+ KEY_DOWN = 108
175
+ KEY_PAGEDOWN = 109
176
+ KEY_INSERT = 110
177
+ KEY_DELETE = 111
178
+ KEY_MACRO = 112
179
+ KEY_MUTE = 113
180
+ KEY_VOLUMEDOWN = 114
181
+ KEY_VOLUMEUP = 115
182
+ KEY_POWER = 116
183
+ KEY_KPEQUAL = 117
184
+ KEY_KPPLUSMINUS = 118
185
+ KEY_PAUSE = 119
186
+ KEY_SCALE = 120
187
+ KEY_KPCOMMA = 121
188
+ KEY_HANGEUL = 122
189
+ KEY_HANGUEL = 122
190
+ KEY_HANJA = 123
191
+ KEY_YEN = 124
192
+ KEY_LEFTMETA = 125
193
+ KEY_RIGHTMETA = 126
194
+ KEY_COMPOSE = 127
195
+ KEY_STOP = 128
196
+ KEY_AGAIN = 129
197
+ KEY_PROPS = 130
198
+ KEY_UNDO = 131
199
+ KEY_FRONT = 132
200
+ KEY_COPY = 133
201
+ KEY_OPEN = 134
202
+ KEY_PASTE = 135
203
+ KEY_FIND = 136
204
+ KEY_CUT = 137
205
+ KEY_HELP = 138
206
+ KEY_MENU = 139
207
+ KEY_CALC = 140
208
+ KEY_SETUP = 141
209
+ KEY_SLEEP = 142
210
+ KEY_WAKEUP = 143
211
+ KEY_FILE = 144
212
+ KEY_SENDFILE = 145
213
+ KEY_DELETEFILE = 146
214
+ KEY_XFER = 147
215
+ KEY_PROG1 = 148
216
+ KEY_PROG2 = 149
217
+ KEY_WWW = 150
218
+ KEY_MSDOS = 151
219
+ KEY_COFFEE = 152
220
+ KEY_SCREENLOCK = 152
221
+ KEY_DIRECTION = 153
222
+ KEY_CYCLEWINDOWS = 154
223
+ KEY_MAIL = 155
224
+ KEY_BOOKMARKS = 156
225
+ KEY_COMPUTER = 157
226
+ KEY_BACK = 158
227
+ KEY_FORWARD = 159
228
+ KEY_CLOSECD = 160
229
+ KEY_EJECTCD = 161
230
+ KEY_EJECTCLOSECD = 162
231
+ KEY_NEXTSONG = 163
232
+ KEY_PLAYPAUSE = 164
233
+ KEY_PREVIOUSSONG = 165
234
+ KEY_STOPCD = 166
235
+ KEY_RECORD = 167
236
+ KEY_REWIND = 168
237
+ KEY_PHONE = 169
238
+ KEY_ISO = 170
239
+ KEY_CONFIG = 171
240
+ KEY_HOMEPAGE = 172
241
+ KEY_REFRESH = 173
242
+ KEY_EXIT = 174
243
+ KEY_MOVE = 175
244
+ KEY_EDIT = 176
245
+ KEY_SCROLLUP = 177
246
+ KEY_SCROLLDOWN = 178
247
+ KEY_KPLEFTPAREN = 179
248
+ KEY_KPRIGHTPAREN = 180
249
+ KEY_NEW = 181
250
+ KEY_REDO = 182
251
+ KEY_F13 = 183
252
+ KEY_F14 = 184
253
+ KEY_F15 = 185
254
+ KEY_F16 = 186
255
+ KEY_F17 = 187
256
+ KEY_F18 = 188
257
+ KEY_F19 = 189
258
+ KEY_F20 = 190
259
+ KEY_F21 = 191
260
+ KEY_F22 = 192
261
+ KEY_F23 = 193
262
+ KEY_F24 = 194
263
+ KEY_PLAYCD = 200
264
+ KEY_PAUSECD = 201
265
+ KEY_PROG3 = 202
266
+ KEY_PROG4 = 203
267
+ KEY_DASHBOARD = 204
268
+ KEY_SUSPEND = 205
269
+ KEY_CLOSE = 206
270
+ KEY_PLAY = 207
271
+ KEY_FASTFORWARD = 208
272
+ KEY_BASSBOOST = 209
273
+ KEY_PRINT = 210
274
+ KEY_HP = 211
275
+ KEY_CAMERA = 212
276
+ KEY_SOUND = 213
277
+ KEY_QUESTION = 214
278
+ KEY_EMAIL = 215
279
+ KEY_CHAT = 216
280
+ KEY_SEARCH = 217
281
+ KEY_CONNECT = 218
282
+ KEY_FINANCE = 219
283
+ KEY_SPORT = 220
284
+ KEY_SHOP = 221
285
+ KEY_ALTERASE = 222
286
+ KEY_CANCEL = 223
287
+ KEY_BRIGHTNESSDOWN = 224
288
+ KEY_BRIGHTNESSUP = 225
289
+ KEY_MEDIA = 226
290
+ KEY_SWITCHVIDEOMODE = 227
291
+ KEY_KBDILLUMTOGGLE = 228
292
+ KEY_KBDILLUMDOWN = 229
293
+ KEY_KBDILLUMUP = 230
294
+ KEY_SEND = 231
295
+ KEY_REPLY = 232
296
+ KEY_FORWARDMAIL = 233
297
+ KEY_SAVE = 234
298
+ KEY_DOCUMENTS = 235
299
+ KEY_BATTERY = 236
300
+ KEY_BLUETOOTH = 237
301
+ KEY_WLAN = 238
302
+ KEY_UWB = 239
303
+ KEY_UNKNOWN = 240
304
+ KEY_VIDEO_NEXT = 241
305
+ KEY_VIDEO_PREV = 242
306
+ KEY_BRIGHTNESS_CYCLE = 243
307
+ KEY_BRIGHTNESS_AUTO = 244
308
+ KEY_BRIGHTNESS_ZERO = 244
309
+ KEY_DISPLAY_OFF = 245
310
+ KEY_WWAN = 246
311
+ KEY_WIMAX = 246
312
+ KEY_RFKILL = 247
313
+ KEY_MICMUTE = 248
314
+ BTN_MISC = 0x100
315
+ BTN_0 = 0x100
316
+ BTN_1 = 0x101
317
+ BTN_2 = 0x102
318
+ BTN_3 = 0x103
319
+ BTN_4 = 0x104
320
+ BTN_5 = 0x105
321
+ BTN_6 = 0x106
322
+ BTN_7 = 0x107
323
+ BTN_8 = 0x108
324
+ BTN_9 = 0x109
325
+ BTN_MOUSE = 0x110
326
+ BTN_LEFT = 0x110
327
+ BTN_RIGHT = 0x111
328
+ BTN_MIDDLE = 0x112
329
+ BTN_SIDE = 0x113
330
+ BTN_EXTRA = 0x114
331
+ BTN_FORWARD = 0x115
332
+ BTN_BACK = 0x116
333
+ BTN_TASK = 0x117
334
+ BTN_JOYSTICK = 0x120
335
+ BTN_TRIGGER = 0x120
336
+ BTN_THUMB = 0x121
337
+ BTN_THUMB2 = 0x122
338
+ BTN_TOP = 0x123
339
+ BTN_TOP2 = 0x124
340
+ BTN_PINKIE = 0x125
341
+ BTN_BASE = 0x126
342
+ BTN_BASE2 = 0x127
343
+ BTN_BASE3 = 0x128
344
+ BTN_BASE4 = 0x129
345
+ BTN_BASE5 = 0x12a
346
+ BTN_BASE6 = 0x12b
347
+ BTN_DEAD = 0x12f
348
+ BTN_GAMEPAD = 0x130
349
+ BTN_SOUTH = 0x130
350
+ BTN_A = 0x130
351
+ BTN_EAST = 0x131
352
+ BTN_B = 0x131
353
+ BTN_C = 0x132
354
+ BTN_NORTH = 0x133
355
+ BTN_X = 0x133
356
+ BTN_WEST = 0x134
357
+ BTN_Y = 0x134
358
+ BTN_Z = 0x135
359
+ BTN_TL = 0x136
360
+ BTN_TR = 0x137
361
+ BTN_TL2 = 0x138
362
+ BTN_TR2 = 0x139
363
+ BTN_SELECT = 0x13a
364
+ BTN_START = 0x13b
365
+ BTN_MODE = 0x13c
366
+ BTN_THUMBL = 0x13d
367
+ BTN_THUMBR = 0x13e
368
+ BTN_DIGI = 0x140
369
+ BTN_TOOL_PEN = 0x140
370
+ BTN_TOOL_RUBBER = 0x141
371
+ BTN_TOOL_BRUSH = 0x142
372
+ BTN_TOOL_PENCIL = 0x143
373
+ BTN_TOOL_AIRBRUSH = 0x144
374
+ BTN_TOOL_FINGER = 0x145
375
+ BTN_TOOL_MOUSE = 0x146
376
+ BTN_TOOL_LENS = 0x147
377
+ BTN_TOOL_QUINTTAP = 0x148
378
+ BTN_TOUCH = 0x14a
379
+ BTN_STYLUS = 0x14b
380
+ BTN_STYLUS2 = 0x14c
381
+ BTN_TOOL_DOUBLETAP = 0x14d
382
+ BTN_TOOL_TRIPLETAP = 0x14e
383
+ BTN_TOOL_QUADTAP = 0x14f
384
+ BTN_WHEEL = 0x150
385
+ BTN_GEAR_DOWN = 0x150
386
+ BTN_GEAR_UP = 0x151
387
+ KEY_OK = 0x160
388
+ KEY_SELECT = 0x161
389
+ KEY_GOTO = 0x162
390
+ KEY_CLEAR = 0x163
391
+ KEY_POWER2 = 0x164
392
+ KEY_OPTION = 0x165
393
+ KEY_INFO = 0x166
394
+ KEY_TIME = 0x167
395
+ KEY_VENDOR = 0x168
396
+ KEY_ARCHIVE = 0x169
397
+ KEY_PROGRAM = 0x16a
398
+ KEY_CHANNEL = 0x16b
399
+ KEY_FAVORITES = 0x16c
400
+ KEY_EPG = 0x16d
401
+ KEY_PVR = 0x16e
402
+ KEY_MHP = 0x16f
403
+ KEY_LANGUAGE = 0x170
404
+ KEY_TITLE = 0x171
405
+ KEY_SUBTITLE = 0x172
406
+ KEY_ANGLE = 0x173
407
+ KEY_ZOOM = 0x174
408
+ KEY_MODE = 0x175
409
+ KEY_KEYBOARD = 0x176
410
+ KEY_SCREEN = 0x177
411
+ KEY_PC = 0x178
412
+ KEY_TV = 0x179
413
+ KEY_TV2 = 0x17a
414
+ KEY_VCR = 0x17b
415
+ KEY_VCR2 = 0x17c
416
+ KEY_SAT = 0x17d
417
+ KEY_SAT2 = 0x17e
418
+ KEY_CD = 0x17f
419
+ KEY_TAPE = 0x180
420
+ KEY_RADIO = 0x181
421
+ KEY_TUNER = 0x182
422
+ KEY_PLAYER = 0x183
423
+ KEY_TEXT = 0x184
424
+ KEY_DVD = 0x185
425
+ KEY_AUX = 0x186
426
+ KEY_MP3 = 0x187
427
+ KEY_AUDIO = 0x188
428
+ KEY_VIDEO = 0x189
429
+ KEY_DIRECTORY = 0x18a
430
+ KEY_LIST = 0x18b
431
+ KEY_MEMO = 0x18c
432
+ KEY_CALENDAR = 0x18d
433
+ KEY_RED = 0x18e
434
+ KEY_GREEN = 0x18f
435
+ KEY_YELLOW = 0x190
436
+ KEY_BLUE = 0x191
437
+ KEY_CHANNELUP = 0x192
438
+ KEY_CHANNELDOWN = 0x193
439
+ KEY_FIRST = 0x194
440
+ KEY_LAST = 0x195
441
+ KEY_AB = 0x196
442
+ KEY_NEXT = 0x197
443
+ KEY_RESTART = 0x198
444
+ KEY_SLOW = 0x199
445
+ KEY_SHUFFLE = 0x19a
446
+ KEY_BREAK = 0x19b
447
+ KEY_PREVIOUS = 0x19c
448
+ KEY_DIGITS = 0x19d
449
+ KEY_TEEN = 0x19e
450
+ KEY_TWEN = 0x19f
451
+ KEY_VIDEOPHONE = 0x1a0
452
+ KEY_GAMES = 0x1a1
453
+ KEY_ZOOMIN = 0x1a2
454
+ KEY_ZOOMOUT = 0x1a3
455
+ KEY_ZOOMRESET = 0x1a4
456
+ KEY_WORDPROCESSOR = 0x1a5
457
+ KEY_EDITOR = 0x1a6
458
+ KEY_SPREADSHEET = 0x1a7
459
+ KEY_GRAPHICSEDITOR = 0x1a8
460
+ KEY_PRESENTATION = 0x1a9
461
+ KEY_DATABASE = 0x1aa
462
+ KEY_NEWS = 0x1ab
463
+ KEY_VOICEMAIL = 0x1ac
464
+ KEY_ADDRESSBOOK = 0x1ad
465
+ KEY_MESSENGER = 0x1ae
466
+ KEY_DISPLAYTOGGLE = 0x1af
467
+ KEY_BRIGHTNESS_TOGGLE = 0x1af
468
+ KEY_SPELLCHECK = 0x1b0
469
+ KEY_LOGOFF = 0x1b1
470
+ KEY_DOLLAR = 0x1b2
471
+ KEY_EURO = 0x1b3
472
+ KEY_FRAMEBACK = 0x1b4
473
+ KEY_FRAMEFORWARD = 0x1b5
474
+ KEY_CONTEXT_MENU = 0x1b6
475
+ KEY_MEDIA_REPEAT = 0x1b7
476
+ KEY_10CHANNELSUP = 0x1b8
477
+ KEY_10CHANNELSDOWN = 0x1b9
478
+ KEY_IMAGES = 0x1ba
479
+ KEY_DEL_EOL = 0x1c0
480
+ KEY_DEL_EOS = 0x1c1
481
+ KEY_INS_LINE = 0x1c2
482
+ KEY_DEL_LINE = 0x1c3
483
+ KEY_FN = 0x1d0
484
+ KEY_FN_ESC = 0x1d1
485
+ KEY_FN_F1 = 0x1d2
486
+ KEY_FN_F2 = 0x1d3
487
+ KEY_FN_F3 = 0x1d4
488
+ KEY_FN_F4 = 0x1d5
489
+ KEY_FN_F5 = 0x1d6
490
+ KEY_FN_F6 = 0x1d7
491
+ KEY_FN_F7 = 0x1d8
492
+ KEY_FN_F8 = 0x1d9
493
+ KEY_FN_F9 = 0x1da
494
+ KEY_FN_F10 = 0x1db
495
+ KEY_FN_F11 = 0x1dc
496
+ KEY_FN_F12 = 0x1dd
497
+ KEY_FN_1 = 0x1de
498
+ KEY_FN_2 = 0x1df
499
+ KEY_FN_D = 0x1e0
500
+ KEY_FN_E = 0x1e1
501
+ KEY_FN_F = 0x1e2
502
+ KEY_FN_S = 0x1e3
503
+ KEY_FN_B = 0x1e4
504
+ KEY_BRL_DOT1 = 0x1f1
505
+ KEY_BRL_DOT2 = 0x1f2
506
+ KEY_BRL_DOT3 = 0x1f3
507
+ KEY_BRL_DOT4 = 0x1f4
508
+ KEY_BRL_DOT5 = 0x1f5
509
+ KEY_BRL_DOT6 = 0x1f6
510
+ KEY_BRL_DOT7 = 0x1f7
511
+ KEY_BRL_DOT8 = 0x1f8
512
+ KEY_BRL_DOT9 = 0x1f9
513
+ KEY_BRL_DOT10 = 0x1fa
514
+ KEY_NUMERIC_0 = 0x200
515
+ KEY_NUMERIC_1 = 0x201
516
+ KEY_NUMERIC_2 = 0x202
517
+ KEY_NUMERIC_3 = 0x203
518
+ KEY_NUMERIC_4 = 0x204
519
+ KEY_NUMERIC_5 = 0x205
520
+ KEY_NUMERIC_6 = 0x206
521
+ KEY_NUMERIC_7 = 0x207
522
+ KEY_NUMERIC_8 = 0x208
523
+ KEY_NUMERIC_9 = 0x209
524
+ KEY_NUMERIC_STAR = 0x20a
525
+ KEY_NUMERIC_POUND = 0x20b
526
+ KEY_CAMERA_FOCUS = 0x210
527
+ KEY_WPS_BUTTON = 0x211
528
+ KEY_TOUCHPAD_TOGGLE = 0x212
529
+ KEY_TOUCHPAD_ON = 0x213
530
+ KEY_TOUCHPAD_OFF = 0x214
531
+ KEY_CAMERA_ZOOMIN = 0x215
532
+ KEY_CAMERA_ZOOMOUT = 0x216
533
+ KEY_CAMERA_UP = 0x217
534
+ KEY_CAMERA_DOWN = 0x218
535
+ KEY_CAMERA_LEFT = 0x219
536
+ KEY_CAMERA_RIGHT = 0x21a
537
+ KEY_ATTENDANT_ON = 0x21b
538
+ KEY_ATTENDANT_OFF = 0x21c
539
+ KEY_ATTENDANT_TOGGLE = 0x21d
540
+ KEY_LIGHTS_TOGGLE = 0x21e
541
+ BTN_DPAD_UP = 0x220
542
+ BTN_DPAD_DOWN = 0x221
543
+ BTN_DPAD_LEFT = 0x222
544
+ BTN_DPAD_RIGHT = 0x223
545
+ KEY_ALS_TOGGLE = 0x230
546
+ KEY_BUTTONCONFIG = 0x240
547
+ KEY_TASKMANAGER = 0x241
548
+ KEY_JOURNAL = 0x242
549
+ KEY_CONTROLPANEL = 0x243
550
+ KEY_APPSELECT = 0x244
551
+ KEY_SCREENSAVER = 0x245
552
+ KEY_VOICECOMMAND = 0x246
553
+ KEY_BRIGHTNESS_MIN = 0x250
554
+ KEY_BRIGHTNESS_MAX = 0x251
555
+ KEY_KBDINPUTASSIST_PREV = 0x260
556
+ KEY_KBDINPUTASSIST_NEXT = 0x261
557
+ KEY_KBDINPUTASSIST_PREVGROUP = 0x262
558
+ KEY_KBDINPUTASSIST_NEXTGROUP = 0x263
559
+ KEY_KBDINPUTASSIST_ACCEPT = 0x264
560
+ KEY_KBDINPUTASSIST_CANCEL = 0x265
561
+ BTN_TRIGGER_HAPPY = 0x2c0
562
+ BTN_TRIGGER_HAPPY1 = 0x2c0
563
+ BTN_TRIGGER_HAPPY2 = 0x2c1
564
+ BTN_TRIGGER_HAPPY3 = 0x2c2
565
+ BTN_TRIGGER_HAPPY4 = 0x2c3
566
+ BTN_TRIGGER_HAPPY5 = 0x2c4
567
+ BTN_TRIGGER_HAPPY6 = 0x2c5
568
+ BTN_TRIGGER_HAPPY7 = 0x2c6
569
+ BTN_TRIGGER_HAPPY8 = 0x2c7
570
+ BTN_TRIGGER_HAPPY9 = 0x2c8
571
+ BTN_TRIGGER_HAPPY10 = 0x2c9
572
+ BTN_TRIGGER_HAPPY11 = 0x2ca
573
+ BTN_TRIGGER_HAPPY12 = 0x2cb
574
+ BTN_TRIGGER_HAPPY13 = 0x2cc
575
+ BTN_TRIGGER_HAPPY14 = 0x2cd
576
+ BTN_TRIGGER_HAPPY15 = 0x2ce
577
+ BTN_TRIGGER_HAPPY16 = 0x2cf
578
+ BTN_TRIGGER_HAPPY17 = 0x2d0
579
+ BTN_TRIGGER_HAPPY18 = 0x2d1
580
+ BTN_TRIGGER_HAPPY19 = 0x2d2
581
+ BTN_TRIGGER_HAPPY20 = 0x2d3
582
+ BTN_TRIGGER_HAPPY21 = 0x2d4
583
+ BTN_TRIGGER_HAPPY22 = 0x2d5
584
+ BTN_TRIGGER_HAPPY23 = 0x2d6
585
+ BTN_TRIGGER_HAPPY24 = 0x2d7
586
+ BTN_TRIGGER_HAPPY25 = 0x2d8
587
+ BTN_TRIGGER_HAPPY26 = 0x2d9
588
+ BTN_TRIGGER_HAPPY27 = 0x2da
589
+ BTN_TRIGGER_HAPPY28 = 0x2db
590
+ BTN_TRIGGER_HAPPY29 = 0x2dc
591
+ BTN_TRIGGER_HAPPY30 = 0x2dd
592
+ BTN_TRIGGER_HAPPY31 = 0x2de
593
+ BTN_TRIGGER_HAPPY32 = 0x2df
594
+ BTN_TRIGGER_HAPPY33 = 0x2e0
595
+ BTN_TRIGGER_HAPPY34 = 0x2e1
596
+ BTN_TRIGGER_HAPPY35 = 0x2e2
597
+ BTN_TRIGGER_HAPPY36 = 0x2e3
598
+ BTN_TRIGGER_HAPPY37 = 0x2e4
599
+ BTN_TRIGGER_HAPPY38 = 0x2e5
600
+ BTN_TRIGGER_HAPPY39 = 0x2e6
601
+ BTN_TRIGGER_HAPPY40 = 0x2e7
602
+ KEY_MIN_INTERESTING = 113
603
+ KEY_MAX = 0x2ff
604
+ KEY_CNT = (0x2ff+1)
605
+ REL_X = 0x00
606
+ REL_Y = 0x01
607
+ REL_Z = 0x02
608
+ REL_RX = 0x03
609
+ REL_RY = 0x04
610
+ REL_RZ = 0x05
611
+ REL_HWHEEL = 0x06
612
+ REL_DIAL = 0x07
613
+ REL_WHEEL = 0x08
614
+ REL_MISC = 0x09
615
+ REL_MAX = 0x0f
616
+ REL_CNT = (0x0f+1)
617
+ ABS_X = 0x00
618
+ ABS_Y = 0x01
619
+ ABS_Z = 0x02
620
+ ABS_RX = 0x03
621
+ ABS_RY = 0x04
622
+ ABS_RZ = 0x05
623
+ ABS_THROTTLE = 0x06
624
+ ABS_RUDDER = 0x07
625
+ ABS_WHEEL = 0x08
626
+ ABS_GAS = 0x09
627
+ ABS_BRAKE = 0x0a
628
+ ABS_HAT0X = 0x10
629
+ ABS_HAT0Y = 0x11
630
+ ABS_HAT1X = 0x12
631
+ ABS_HAT1Y = 0x13
632
+ ABS_HAT2X = 0x14
633
+ ABS_HAT2Y = 0x15
634
+ ABS_HAT3X = 0x16
635
+ ABS_HAT3Y = 0x17
636
+ ABS_PRESSURE = 0x18
637
+ ABS_DISTANCE = 0x19
638
+ ABS_TILT_X = 0x1a
639
+ ABS_TILT_Y = 0x1b
640
+ ABS_TOOL_WIDTH = 0x1c
641
+ ABS_VOLUME = 0x20
642
+ ABS_MISC = 0x28
643
+ ABS_MT_SLOT = 0x2f
644
+ ABS_MT_TOUCH_MAJOR = 0x30
645
+ ABS_MT_TOUCH_MINOR = 0x31
646
+ ABS_MT_WIDTH_MAJOR = 0x32
647
+ ABS_MT_WIDTH_MINOR = 0x33
648
+ ABS_MT_ORIENTATION = 0x34
649
+ ABS_MT_POSITION_X = 0x35
650
+ ABS_MT_POSITION_Y = 0x36
651
+ ABS_MT_TOOL_TYPE = 0x37
652
+ ABS_MT_BLOB_ID = 0x38
653
+ ABS_MT_TRACKING_ID = 0x39
654
+ ABS_MT_PRESSURE = 0x3a
655
+ ABS_MT_DISTANCE = 0x3b
656
+ ABS_MT_TOOL_X = 0x3c
657
+ ABS_MT_TOOL_Y = 0x3d
658
+ ABS_MAX = 0x3f
659
+ ABS_CNT = (0x3f+1)
660
+ SW_LID = 0x00
661
+ SW_TABLET_MODE = 0x01
662
+ SW_HEADPHONE_INSERT = 0x02
663
+ SW_RFKILL_ALL = 0x03
664
+ SW_RADIO = 0x03
665
+ SW_MICROPHONE_INSERT = 0x04
666
+ SW_DOCK = 0x05
667
+ SW_LINEOUT_INSERT = 0x06
668
+ SW_JACK_PHYSICAL_INSERT = 0x07
669
+ SW_VIDEOOUT_INSERT = 0x08
670
+ SW_CAMERA_LENS_COVER = 0x09
671
+ SW_KEYPAD_SLIDE = 0x0a
672
+ SW_FRONT_PROXIMITY = 0x0b
673
+ SW_ROTATE_LOCK = 0x0c
674
+ SW_LINEIN_INSERT = 0x0d
675
+ SW_MUTE_DEVICE = 0x0e
676
+ SW_MAX = 0x0f
677
+ SW_CNT = (0x0f+1)
678
+ MSC_SERIAL = 0x00
679
+ MSC_PULSELED = 0x01
680
+ MSC_GESTURE = 0x02
681
+ MSC_RAW = 0x03
682
+ MSC_SCAN = 0x04
683
+ MSC_TIMESTAMP = 0x05
684
+ MSC_MAX = 0x07
685
+ MSC_CNT = (0x07+1)
686
+ LED_NUML = 0x00
687
+ LED_CAPSL = 0x01
688
+ LED_SCROLLL = 0x02
689
+ LED_COMPOSE = 0x03
690
+ LED_KANA = 0x04
691
+ LED_SLEEP = 0x05
692
+ LED_SUSPEND = 0x06
693
+ LED_MUTE = 0x07
694
+ LED_MISC = 0x08
695
+ LED_MAIL = 0x09
696
+ LED_CHARGING = 0x0a
697
+ LED_MAX = 0x0f
698
+ LED_CNT = (0x0f+1)
699
+ REP_DELAY = 0x00
700
+ REP_PERIOD = 0x01
701
+ REP_MAX = 0x01
702
+ REP_CNT = (0x01+1)
703
+ SND_CLICK = 0x00
704
+ SND_BELL = 0x01
705
+ SND_TONE = 0x02
706
+ SND_MAX = 0x07
707
+ SND_CNT = (0x07+1)
708
+ ID_BUS = 0
709
+ ID_VENDOR = 1
710
+ ID_PRODUCT = 2
711
+ ID_VERSION = 3
712
+ BUS_PCI = 0x01
713
+ BUS_ISAPNP = 0x02
714
+ BUS_USB = 0x03
715
+ BUS_HIL = 0x04
716
+ BUS_BLUETOOTH = 0x05
717
+ BUS_VIRTUAL = 0x06
718
+ BUS_ISA = 0x10
719
+ BUS_I8042 = 0x11
720
+ BUS_XTKBD = 0x12
721
+ BUS_RS232 = 0x13
722
+ BUS_GAMEPORT = 0x14
723
+ BUS_PARPORT = 0x15
724
+ BUS_AMIGA = 0x16
725
+ BUS_ADB = 0x17
726
+ BUS_I2C = 0x18
727
+ BUS_HOST = 0x19
728
+ BUS_GSC = 0x1A
729
+ BUS_ATARI = 0x1B
730
+ BUS_SPI = 0x1C
731
+ MT_TOOL_FINGER = 0
732
+ MT_TOOL_PEN = 1
733
+ MT_TOOL_PALM = 2
734
+ MT_TOOL_MAX = 2
735
+ FF_STATUS_STOPPED = 0x00
736
+ FF_STATUS_PLAYING = 0x01
737
+ FF_STATUS_MAX = 0x01
738
+ class FfReplay < FFI::Struct
739
+ layout(
740
+ :length, :ushort,
741
+ :delay, :ushort
742
+ )
743
+ end
744
+ class FfTrigger < FFI::Struct
745
+ layout(
746
+ :button, :ushort,
747
+ :interval, :ushort
748
+ )
749
+ end
750
+ class FfEnvelope < FFI::Struct
751
+ layout(
752
+ :attack_length, :ushort,
753
+ :attack_level, :ushort,
754
+ :fade_length, :ushort,
755
+ :fade_level, :ushort
756
+ )
757
+ end
758
+ class FfConstantEffect < FFI::Struct
759
+ layout(
760
+ :level, :short,
761
+ :envelope, FfEnvelope
762
+ )
763
+ end
764
+ class FfRampEffect < FFI::Struct
765
+ layout(
766
+ :start_level, :short,
767
+ :end_level, :short,
768
+ :envelope, FfEnvelope
769
+ )
770
+ end
771
+ class FfConditionEffect < FFI::Struct
772
+ layout(
773
+ :right_saturation, :ushort,
774
+ :left_saturation, :ushort,
775
+ :right_coeff, :short,
776
+ :left_coeff, :short,
777
+ :deadband, :ushort,
778
+ :center, :short
779
+ )
780
+ end
781
+ class FfPeriodicEffect < FFI::Struct
782
+ layout(
783
+ :waveform, :ushort,
784
+ :period, :ushort,
785
+ :magnitude, :short,
786
+ :offset, :short,
787
+ :phase, :ushort,
788
+ :envelope, FfEnvelope,
789
+ :custom_len, :uint,
790
+ :custom_data, :pointer
791
+ )
792
+ end
793
+ class FfRumbleEffect < FFI::Struct
794
+ layout(
795
+ :strong_magnitude, :ushort,
796
+ :weak_magnitude, :ushort
797
+ )
798
+ end
799
+ class FfEffectU < FFI::Union
800
+ layout(
801
+ :constant, FfConstantEffect,
802
+ :ramp, FfRampEffect,
803
+ :periodic, FfPeriodicEffect,
804
+ :condition, [FfConditionEffect, 2],
805
+ :rumble, FfRumbleEffect
806
+ )
807
+ end
808
+ class FfEffect < FFI::Struct
809
+ layout(
810
+ :type, :ushort,
811
+ :id, :short,
812
+ :direction, :ushort,
813
+ :trigger, FfTrigger,
814
+ :replay, FfReplay,
815
+ :u, FfEffectU
816
+ )
817
+ end
818
+ FF_RUMBLE = 0x50
819
+ FF_PERIODIC = 0x51
820
+ FF_CONSTANT = 0x52
821
+ FF_SPRING = 0x53
822
+ FF_FRICTION = 0x54
823
+ FF_DAMPER = 0x55
824
+ FF_INERTIA = 0x56
825
+ FF_RAMP = 0x57
826
+ FF_EFFECT_MIN = 0x50
827
+ FF_EFFECT_MAX = 0x57
828
+ FF_SQUARE = 0x58
829
+ FF_TRIANGLE = 0x59
830
+ FF_SINE = 0x5a
831
+ FF_SAW_UP = 0x5b
832
+ FF_SAW_DOWN = 0x5c
833
+ FF_CUSTOM = 0x5d
834
+ FF_WAVEFORM_MIN = 0x58
835
+ FF_WAVEFORM_MAX = 0x5d
836
+ FF_GAIN = 0x60
837
+ FF_AUTOCENTER = 0x61
838
+ FF_MAX = 0x7f
839
+ FF_CNT = (0x7f+1)
@@ -0,0 +1,20 @@
1
+ IOC_NRBITS = 8
2
+ IOC_TYPEBITS = 8
3
+ IOC_SIZEBITS = 14
4
+ IOC_DIRBITS = 2
5
+ IOC_NRMASK = ((1 << 8) -1)
6
+ IOC_TYPEMASK = ((1 << 8) -1)
7
+ IOC_SIZEMASK = ((1 << 14) -1)
8
+ IOC_DIRMASK = ((1 << 2) -1)
9
+ IOC_NRSHIFT = 0
10
+ IOC_TYPESHIFT = (0+8)
11
+ IOC_SIZESHIFT = ((0+8) +8)
12
+ IOC_DIRSHIFT = (((0+8) +8) +14)
13
+ IOC_NONE = 0
14
+ IOC_WRITE = 1
15
+ IOC_READ = 2
16
+ IOC_IN = (1 << (((0+8) +8) +14))
17
+ IOC_OUT = (2 << (((0+8) +8) +14))
18
+ IOC_INOUT = ((1|2) << (((0+8) +8) +14))
19
+ IOCSIZE_MASK = (((1 << 14) -1) << ((0+8) +8))
20
+ IOCSIZE_SHIFT = (((0+8) +8))
@@ -0,0 +1,43 @@
1
+ module LinuxInput
2
+ class Timeval < FFI::Struct
3
+ layout(
4
+ :tv_sec, :__time_t,
5
+ :tv_usec, :__suseconds_t
6
+ )
7
+ end
8
+
9
+ class_eval File.read(File.join(File.dirname(__FILE__), 'generated/input.rb'))
10
+
11
+ INPUT_IOCTL_BASE = ?E.ord
12
+
13
+ EVIOCGVERSION = Ioctl.IOR(INPUT_IOCTL_BASE, 0x01, :int)
14
+ EVIOCGID = Ioctl.IOR(INPUT_IOCTL_BASE, 0x02, InputId.by_value)
15
+ EVIOCGREP = Ioctl.IOR(INPUT_IOCTL_BASE, 0x03, :pointer)
16
+ EVIOCSREP = Ioctl.IOW(INPUT_IOCTL_BASE, 0x03, :pointer)
17
+ EVIOCGKEYCODE = Ioctl.IOR(INPUT_IOCTL_BASE, 0x04, :pointer)
18
+ EVIOCGKEYCODE_V2 = Ioctl.IOR(INPUT_IOCTL_BASE, 0x04, InputKeymapEntry.by_value)
19
+ EVIOCSKEYCODE = Ioctl.IOW(INPUT_IOCTL_BASE, 0x04, :pointer)
20
+ EVIOCSKEYCODE_V2 = Ioctl.IOW(INPUT_IOCTL_BASE, 0x04, InputKeymapEntry.by_value)
21
+
22
+ class << self
23
+ def EVIOCGNAME(len) Ioctl.IOC(Ioctl::IOC_READ, INPUT_IOCTL_BASE, 0x06, len) end
24
+ def EVIOCGPHYS(len) Ioctl.IOC(Ioctl::IOC_READ, INPUT_IOCTL_BASE, 0x07, len) end
25
+ def EVIOCGUNIQ(len) Ioctl.IOC(Ioctl::IOC_READ, INPUT_IOCTL_BASE, 0x08, len) end
26
+ def EVIOCGPROP(len) Ioctl.IOC(Ioctl::IOC_READ, INPUT_IOCTL_BASE, 0x09, len) end
27
+ def EVIOCGMTSLOTS(len) Ioctl.IOC(Ioctl::IOC_READ, INPUT_IOCTL_BASE, 0x0a, len) end
28
+ def EVIOCGKEY(len) Ioctl.IOC(Ioctl::IOC_READ, INPUT_IOCTL_BASE, 0x18, len) end
29
+ def EVIOCGLED(len) Ioctl.IOC(Ioctl::IOC_READ, INPUT_IOCTL_BASE, 0x19, len) end
30
+ def EVIOCGSND(len) Ioctl.IOC(Ioctl::IOC_READ, INPUT_IOCTL_BASE, 0x1a, len) end
31
+ def EVIOCGSW(len) Ioctl.IOC(Ioctl::IOC_READ, INPUT_IOCTL_BASE, 0x1b, len) end
32
+ def EVIOCGBIT(ev, len) Ioctl.IOC(Ioctl::IOC_READ, INPUT_IOCTL_BASE, 0x20 + ev, len) end
33
+ def EVIOCGABS(abs) Ioctl.IOR(INPUT_IOCTL_BASE, 0x40 + abs, InputAbsinfo.by_value) end
34
+ def EVIOCSABS(abs) Ioctl.IOW(INPUT_IOCTL_BASE, 0xc0 + abs, InputAbsinfo.by_value) end
35
+ end
36
+
37
+ EVIOCSFF = Ioctl.IOC(Ioctl::IOC_WRITE, INPUT_IOCTL_BASE, 0x80, FfEffect.size)
38
+ EVIOCRMFF = Ioctl.IOW(INPUT_IOCTL_BASE, 0x81, :int)
39
+ EVIOCGEFFECTS = Ioctl.IOR(INPUT_IOCTL_BASE, 0x84, :int)
40
+ EVIOCGRAB = Ioctl.IOW(INPUT_IOCTL_BASE, 0x90, :int)
41
+ EVIOCREVOKE = Ioctl.IOW(INPUT_IOCTL_BASE, 0x91, :int)
42
+ EVIOCSCLOCKID = Ioctl.IOW(INPUT_IOCTL_BASE, 0xa0, :int)
43
+ end
@@ -0,0 +1,23 @@
1
+ module Ioctl
2
+ class_eval File.read(File.join(File.dirname(__FILE__), 'generated/ioctl.rb'))
3
+
4
+ class << self
5
+ def IOC(dir, type, nr, size)
6
+ (dir << IOC_DIRSHIFT) | (type << IOC_TYPESHIFT) | (nr << IOC_NRSHIFT) | (size << IOC_SIZESHIFT)
7
+ end
8
+
9
+ def IO(type, nr) IOC(IOC_NONE, type, nr, 0) end
10
+ def IOR(type, nr, size) IOC(IOC_READ, type, nr, FFI.type_size(size)) end
11
+ def IOW(type, nr, size) IOC(IOC_WRITE, type, nr, FFI.type_size(size)) end
12
+ def IOWR(type, nr, size) IOC(IOC_READ | IOC_WRITE, type, nr, FFI.type_size(size)) end
13
+ def IOR_BAD(type, nr, size) IOC(IOC_READ, type, nr, FFI.type_size(size)) end
14
+ def IOW_BAD(type, nr, size) IOC(IOC_WRITE, type, nr, FFI.type_size(size)) end
15
+ def IOWR_BAD(type, nr, size) IOC(IOC_READ | IOC_WRITE, type, nr, FFI.type_size(size)) end
16
+
17
+ def IOC_DIR(nr) (nr >> IOC_DIRSHIFT) & IOC_DIRMASK end
18
+ def IOC_TYPE(nr) (nr >> IOC_TYPESHIFT) & IOC_TYPEMASK end
19
+ def IOC_NR(nr) (nr >> IOC_NRSHIFT) & IOC_NRMASK end
20
+ def IOC_SIZE(nr) (nr >> IOC_SIZESHIFT) & IOC_SIZEMASK end
21
+ end
22
+ end
23
+
@@ -0,0 +1,3 @@
1
+ module LinuxInput
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'linux_input/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "linux_input"
8
+ spec.version = LinuxInput::VERSION
9
+ spec.authors = ["Christopher Aue"]
10
+ spec.email = ["mail@christopheraue.net"]
11
+
12
+ spec.summary = %q{FFI structs and constants for linux's input subsystem}
13
+ spec.homepage = "http://github.com/christopheraue/ruby-linux_input"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_runtime_dependency 'ffi', '~> 1.9'
21
+ spec.add_development_dependency "bundler", "~> 1.8"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "ffi-swig-generator", '~> 0'
24
+ end
data/swig/input.i ADDED
@@ -0,0 +1,20 @@
1
+ %module input
2
+
3
+ typedef char __s8;
4
+ typedef unsigned char __u8;
5
+
6
+ typedef short __s16;
7
+ typedef unsigned short __u16;
8
+
9
+ typedef int __s32;
10
+ typedef unsigned int __u32;
11
+
12
+ #ifdef __GNUC__
13
+ __extension__ typedef long long __s64;
14
+ __extension__ typedef unsigned long long __u64;
15
+ #else
16
+ typedef long long __s64;
17
+ typedef unsigned long long __u64;
18
+ #endif
19
+
20
+ %include "linux/input.h"
data/swig/ioctl.i ADDED
@@ -0,0 +1,2 @@
1
+ %module ioctl
2
+ %include "asm-generic/ioctl.h"
data/tasks/ffi.rake ADDED
@@ -0,0 +1,16 @@
1
+ namespace :ffi do
2
+ desc 'Generate ffi interface'
3
+ task :generate do
4
+ `swig -xml -o ioctl_wrap.xml -I/usr/include swig/ioctl.i`
5
+ `swig -xml -o input_wrap.xml -I/usr/include swig/input.i`
6
+
7
+ `ffi-gen ioctl_wrap.xml lib/linux_input/generated/ioctl.rb`
8
+ `ffi-gen input_wrap.xml lib/linux_input/generated/input.rb`
9
+
10
+ `sed -i 's/\\([0-9]\\)U/\\1/g' lib/linux_input/generated/ioctl.rb`
11
+ `sed -i 's/_IO/IO/g' lib/linux_input/generated/ioctl.rb`
12
+ `sed -i 's/ff_effect_u/FfEffectU/g' lib/linux_input/generated/input.rb`
13
+
14
+ `rm -f ioctl_wrap.xml input_wrap.xml`
15
+ end
16
+ end
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: linux_input
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Christopher Aue
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ffi
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.9'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.8'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: ffi-swig-generator
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description:
70
+ email:
71
+ - mail@christopheraue.net
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - lib/linux_input.rb
84
+ - lib/linux_input/generated/input.rb
85
+ - lib/linux_input/generated/ioctl.rb
86
+ - lib/linux_input/input.rb
87
+ - lib/linux_input/ioctl.rb
88
+ - lib/linux_input/version.rb
89
+ - linux_input.gemspec
90
+ - swig/input.i
91
+ - swig/ioctl.i
92
+ - tasks/ffi.rake
93
+ homepage: http://github.com/christopheraue/ruby-linux_input
94
+ licenses:
95
+ - MIT
96
+ metadata: {}
97
+ post_install_message:
98
+ rdoc_options: []
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ requirements: []
112
+ rubyforge_project:
113
+ rubygems_version: 2.4.8
114
+ signing_key:
115
+ specification_version: 4
116
+ summary: FFI structs and constants for linux's input subsystem
117
+ test_files: []