device_input 0.1.0.1 → 0.1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 803a063ac3069383c1d2f3cff0dc5ff5c7caf43a
4
- data.tar.gz: 97282e042e693fda103f18ccaf10d19eee397308
3
+ metadata.gz: 7b6a65816d84145d35e91685e6c65ade829cc898
4
+ data.tar.gz: d4bc6894c5763401e890e588a5bcd48757d71d01
5
5
  SHA512:
6
- metadata.gz: 970a6aab1d8d674cb3b8db5c2509c313ed195600dca3aefd4ed80ae826cc140ab20d86b7d50e166f10b7b7a5b37136c8ab8fd94b30406768df53892498e5fe50
7
- data.tar.gz: a83de5605ceec1982206ab8f9f072e40e65b0fd84eb00e1b28edbfc8a1b2beb8768972839c83dc7ec67783192f4cbaa557a65bc1e368b00e5008524e071a52a9
6
+ metadata.gz: 566ffdd5388b0b92751f158b8fdc20ef6d0ab5ea96b77b5b430e5d1328fab8a718d5e577ed4d3f8960ba76f0f060884ec41b6a86bd30a70372804133e82657df
7
+ data.tar.gz: 074f459314a86d675d7f9ca4612e7c108e3eb866d89fb067e333762ac94418300113a4c94a014fe826914f6600c9e3db9033cc87aa4167d437c9a406f9e21f8b
data/README.md CHANGED
@@ -22,7 +22,7 @@ to delimit individual messages and decode them. We can't simply read a byte
22
22
  at a time and try to make sense of it. In fact, on my system,
23
23
  `/dev/input/event0` refuses any read that is not a multiple of the struct /
24
24
  message size, so we need to know the message size before even attempting a
25
- read(), without even a decode().
25
+ `read()`, let alone a `decode()`.
26
26
 
27
27
  To determine the message size, we need to know the data structure. For a
28
28
  long time, it was pretty simple: events are 16 bytes:
@@ -34,8 +34,9 @@ long time, it was pretty simple: events are 16 bytes:
34
34
 
35
35
  However, this is only true for 32-bit platforms. On 64-bit platforms, event
36
36
  timestamps became 16 bytes, increasing the size of events from 16 to 24 bytes.
37
- This is because a timestamp is defined (ultimately) as two `long`s, and
38
- `long`s are bigger on 64-bit platforms. It's easy to remember:
37
+ This is because a timestamp is defined (ultimately) as two `long`s, and as
38
+ everyone knows, two longs don't make a light. No, wait -- it's that `long`s
39
+ are bigger on 64-bit platforms. It's easy to remember:
39
40
 
40
41
  * 32-bit platform: 32-bit `long` (4 bytes)
41
42
  * 64-bit platform: 64-bit `long` (8 bytes)
@@ -50,48 +51,94 @@ executable code to assist in examining kernel input events.
50
51
 
51
52
  # Installation
52
53
 
53
- Requirements: Ruby >= 2.0
54
+ **REQUIREMENTS**
54
55
 
55
- Dependencies: none
56
+ * Ruby >= 2.0
57
+
58
+ **DEPENDENCIES**
59
+
60
+ * none
56
61
 
57
62
  Install the gem:
58
- ```
63
+ ```shell
59
64
  $ gem install device_input # sudo as necessary
60
65
  ```
61
66
 
62
67
  Or, if using [Bundler](http://bundler.io/), add to your `Gemfile`:
63
- ```
64
- gem 'device_input', '~> 0.0'
68
+ ```ruby
69
+ gem 'device_input', '~> 0.1'
65
70
  ```
66
71
 
67
72
  # Usage
68
73
 
69
74
  ## Executable
70
75
 
71
- ```
76
+ ```shell
72
77
  $ sudo devsniff /dev/input/event0
73
78
  ```
74
79
 
75
80
  When the `f` key is pressed:
76
81
  ```
77
- Misc:ScanCode:33
78
- Key:F:1
79
- Sync:Sync:0
82
+ EV_MSC:ScanCode:33
83
+ EV_KEY:F:1
84
+ EV_SYN:SYN_REPORT:0
80
85
  ```
81
86
 
82
- And released:
87
+ And released immediately (1=pressed, 0=released):
83
88
  ```
84
- Misc:ScanCode:33
85
- Key:F:1
86
- Sync:Sync:0
87
- Misc:ScanCode:33
88
- Key:F:0
89
- Sync:Sync:0
89
+ EV_MSC:ScanCode:33
90
+ EV_KEY:F:1
91
+ EV_SYN:SYN_REPORT:0
92
+ EV_MSC:ScanCode:33
93
+ EV_KEY:F:0
94
+ EV_SYN:SYN_REPORT:0
90
95
  ```
91
96
 
92
- ## Library
97
+ How about pretty mode?
98
+ ```shell
99
+ $ sudo devsniff /dev/input/event0 pretty
100
+
101
+ # f
102
+
103
+ 2017-01-24 05:29:43.923 Misc:ScanCode:33
104
+ 2017-01-24 05:29:43.923 Key:F:1
105
+ 2017-01-24 05:29:43.923 Sync:Report:0
106
+ 2017-01-24 05:29:44.012 Misc:ScanCode:33
107
+ 2017-01-24 05:29:44.012 Key:F:0
108
+ 2017-01-24 05:29:44.012 Sync:Report:0
109
+ ```
93
110
 
111
+ We can pull off the labels and go raw:
112
+ ```shell
113
+ $ sudo devsniff /dev/input/event0 raw
114
+
115
+ # f
116
+
117
+ 4:4:33
118
+ 1:33:1
119
+ 0:0:0
120
+ 4:4:33
121
+ 1:33:0
122
+ 0:0:0
94
123
  ```
124
+
125
+ Fulfill your hacker-matrix fantasies:
126
+ ```shell
127
+ $ sudo devsniff /dev/input/event0 hex
128
+
129
+ # f
130
+
131
+ 00000000588757bd 00000000000046ca 0004 0004 00000021
132
+ 00000000588757bd 00000000000046ca 0001 0021 00000001
133
+ 00000000588757bd 00000000000046ca 0000 0000 00000000
134
+ 00000000588757bd 000000000001a298 0004 0004 00000021
135
+ 00000000588757bd 000000000001a298 0001 0021 00000000
136
+ 00000000588757bd 000000000001a298 0000 0000 00000000
137
+ ```
138
+
139
+ ## Library
140
+
141
+ ```ruby
95
142
  require 'device_input'
96
143
 
97
144
  # this loops forever and blocks waiting for input
@@ -110,7 +157,7 @@ An event has:
110
157
  * `#value`: Fixnum (signed) from `#data`
111
158
 
112
159
  You will probably want to write your own read loop for your own project.
113
- [`DeviceInput.read_from`](lib/device_input.rb#L111) is very simple and can
160
+ [`DeviceInput.read_from`](lib/device_input.rb#L100) is very simple and can
114
161
  easily be rewritten outside of this project's namespace and adapted for your
115
162
  needs.
116
163
 
@@ -213,5 +260,5 @@ value __s32 int32_t l
213
260
 
214
261
  * Inspired by https://github.com/prullmann/libdevinput (don't use it)
215
262
  - also the source of an early version of the
216
- [event code labels](lib/device_input/codes.rb)
263
+ [event code labels](lib/device_input/labels.rb)
217
264
  * Thanks to al2o3-cr from #ruby on Freenode for feedback
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.1.1
data/bin/devsniff CHANGED
@@ -13,7 +13,9 @@ end
13
13
  case mode
14
14
  when 'normal'
15
15
  mode = 'to_s'
16
- when 'pretty', 'raw', 'bytes'
16
+ when 'bytes' # legacy
17
+ mode = 'hex'
18
+ when 'pretty', 'raw', 'hex'
17
19
  # ok
18
20
  else
19
21
  raise "unsupported mode: #{mode}"
data/lib/device_input.rb CHANGED
@@ -1,38 +1,27 @@
1
+ require 'device_input/labels'
2
+
1
3
  module DeviceInput
2
4
  class Event
3
5
  DEFINITION = {
4
- :tv_sec => 'long',
5
- :tv_usec => 'long',
6
+ :tv_sec => 'long', # 64 bits on 64-bit platforms
7
+ :tv_usec => 'long', # 32 bits on 32-bit platforms
6
8
  :type => 'uint16_t',
7
9
  :code => 'uint16_t',
8
10
  :value => 'int32_t',
9
11
  }
10
12
  PACK_MAP = {
11
- 'long' => 'l!',
13
+ 'long' => 'l!', # platform-dependent
12
14
  'uint16_t' => 'S',
13
15
  'int32_t' => 'l',
14
16
  }
15
17
  PACK = DEFINITION.values.map { |v| PACK_MAP.fetch(v) }.join
16
18
 
17
- # this defines a class, i.e. class Data ...
19
+ # This defines a class, i.e. class Data ... with keys/ivars matching
20
+ # DEFINITION. Data instances will hold a value for each of the keys.
21
+ # Sorry for the name. It refers literally to the struct-of-integers
22
+ # representation we're creating here, every time we use the term `data`
18
23
  Data = Struct.new(*DEFINITION.keys)
19
24
 
20
- # these are just labels, not used internally
21
- TYPES = {
22
- 0x00 => ['EV_SYN', 'Sync'],
23
- 0x01 => ['EV_KEY', 'Key'],
24
- 0x02 => ['EV_REL', 'Relative'],
25
- 0x03 => ['EV_ABS', 'Absolute'],
26
- 0x04 => ['EV_MSC', 'Misc'],
27
- 0x05 => ['EV_SW', 'ToggleSwitch'],
28
- 0x17 => ['EV_LED', 'LED'],
29
- 0x18 => ['EV_SND', 'Sound'],
30
- 0x20 => ['EV_REP', 'Repeat'],
31
- 0x21 => ['EV_FF', 'ForceFeedback'],
32
- 0x22 => ['EV_PWR', 'Power'],
33
- 0x23 => ['EV_FF_STATUS', 'ForceFeedbackStatus'],
34
- }
35
-
36
25
  # convert Event::Data to a string
37
26
  def self.encode(data)
38
27
  data.values.pack(PACK)
@@ -40,23 +29,22 @@ module DeviceInput
40
29
 
41
30
  # convert string to Event::Data
42
31
  def self.decode(binstr)
43
- Data.new *binstr.unpack(PACK)
32
+ Data.new(*binstr.unpack(PACK))
44
33
  end
45
34
 
46
- # return an array from [raw ... pretty]
47
- def self.type_labels(type_code)
48
- TYPES[type_code] || ["UNK-#{type_code}"]
35
+ # return an array of equivalent labels, prettier toward the end
36
+ def self.type_labels(type_val)
37
+ TYPES[type_val] || ["UNK-#{type_val}"]
49
38
  end
50
39
 
51
- # return an array from [raw ... pretty]
52
- def self.code_labels(type_code, code_code)
53
- require 'device_input/codes'
54
- labels = DeviceInput::CODES.dig(type_code, code_code)
40
+ # return an array of equivalent labels, prettier toward the end
41
+ def self.code_labels(type_val, code_val)
42
+ labels = CODES.dig(type_val, code_val)
55
43
  if labels
56
44
  # not all labels have been converted to arrays yet
57
- labels.kind_of?(Enumerable) ? labels : [labels]
45
+ labels.kind_of?(String) ? [labels] : labels
58
46
  else
59
- ["UNK-#{type_code}-#{code_code}"]
47
+ ["UNK-#{type_val}-#{code_val}"]
60
48
  end
61
49
  end
62
50
 
@@ -67,7 +55,7 @@ module DeviceInput
67
55
  attr_reader :data, :time, :type, :code
68
56
 
69
57
  def initialize(data)
70
- @data = data
58
+ @data = data # sorry for the name. it's a Data. data everywhere
71
59
  @time = Time.at(data.tv_sec, data.tv_usec)
72
60
  # take the raw label, closest to the metal
73
61
  @type = self.class.type_labels(data.type).first
@@ -97,7 +85,7 @@ module DeviceInput
97
85
  end
98
86
 
99
87
  # display fields in hex
100
- def bytes
88
+ def hex
101
89
  require 'rbconfig/sizeof'
102
90
  DEFINITION.inject('') { |memo, (field, type)|
103
91
  int = @data.send(field)
@@ -0,0 +1,465 @@
1
+ module DeviceInput
2
+ class Event
3
+ # https://www.kernel.org/doc/Documentation/input/event-codes.txt
4
+ # linux.git/tree/include/uapi/linux/input-event-codes.h
5
+
6
+ EV_SYN = 0x00
7
+ EV_KEY = 0x01
8
+ EV_REL = 0x02
9
+ EV_ABS = 0x03
10
+ EV_MSC = 0x04
11
+ EV_SW = 0x05
12
+ EV_LED = 0x11
13
+ EV_SND = 0x12
14
+ EV_REP = 0x14
15
+ EV_FF = 0x15
16
+ EV_PWR = 0x16
17
+ EV_FF_STATUS = 0x17
18
+ EV_MAX = 0x1f
19
+ EV_CNT = EV_MAX + 1
20
+
21
+ TYPES = {
22
+ EV_SYN => ['EV_SYN', 'Sync'],
23
+ EV_KEY => ['EV_KEY', 'Key'],
24
+ EV_REL => ['EV_REL', 'Relative'],
25
+ EV_ABS => ['EV_ABS', 'Absolute'],
26
+ EV_MSC => ['EV_MSC', 'Misc'],
27
+ EV_SW => ['EV_SW', 'ToggleSwitch'],
28
+ EV_LED => ['EV_LED', 'LED'],
29
+ EV_SND => ['EV_SND', 'Sound'],
30
+ EV_REP => ['EV_REP', 'Repeat'],
31
+ EV_FF => ['EV_FF', 'ForceFeedback'],
32
+ EV_PWR => ['EV_PWR', 'Power'],
33
+ EV_FF_STATUS => ['EV_FF_STATUS', 'ForceFeedbackStatus'],
34
+ }
35
+
36
+ CODES = {
37
+ EV_SYN => {
38
+ 0 => ['SYN_REPORT', 'Report'],
39
+ 1 => ['SYN_CONFIG', 'Config'],
40
+ 2 => ['SYN_MT_REPORT', 'Multitouch'],
41
+ 3 => ['SYN_DROPPED', 'Desync'],
42
+ },
43
+
44
+ EV_KEY => {
45
+ 0 => 'Reserved',
46
+ 1 => 'Esc',
47
+ 2 => '1',
48
+ 3 => '2',
49
+ 4 => '3',
50
+ 5 => '4',
51
+ 6 => '5',
52
+ 7 => '6',
53
+ 8 => '7',
54
+ 9 => '8',
55
+ 10 => '9',
56
+ 11 => '0',
57
+ 12 => 'Minus',
58
+ 13 => 'Equal',
59
+ 14 => 'Backspace',
60
+ 15 => 'Tab',
61
+ 16 => 'Q',
62
+ 17 => 'W',
63
+ 18 => 'E',
64
+ 19 => 'R',
65
+ 20 => 'T',
66
+ 21 => 'Y',
67
+ 22 => 'U',
68
+ 23 => 'I',
69
+ 24 => 'O',
70
+ 25 => 'P',
71
+ 26 => 'LeftBrace',
72
+ 27 => 'RightBrace',
73
+ 28 => 'Enter',
74
+ 29 => 'LeftControl',
75
+ 30 => 'A',
76
+ 31 => 'S',
77
+ 32 => 'D',
78
+ 33 => 'F',
79
+ 34 => 'G',
80
+ 35 => 'H',
81
+ 36 => 'J',
82
+ 37 => 'K',
83
+ 38 => 'L',
84
+ 39 => 'Semicolon',
85
+ 40 => 'Apostrophe',
86
+ 41 => 'Grave',
87
+ 42 => 'LeftShift',
88
+ 43 => 'BackSlash',
89
+ 44 => 'Z',
90
+ 45 => 'X',
91
+ 46 => 'C',
92
+ 47 => 'V',
93
+ 48 => 'B',
94
+ 49 => 'N',
95
+ 50 => 'M',
96
+ 51 => 'Comma',
97
+ 52 => 'Dot',
98
+ 53 => 'Slash',
99
+ 54 => 'RightShift',
100
+ 55 => 'KPAsterisk',
101
+ 56 => 'LeftAlt',
102
+ 57 => 'Space',
103
+ 58 => 'CapsLock',
104
+ 59 => 'F1',
105
+ 60 => 'F2',
106
+ 61 => 'F3',
107
+ 62 => 'F4',
108
+ 63 => 'F5',
109
+ 64 => 'F6',
110
+ 65 => 'F7',
111
+ 66 => 'F8',
112
+ 67 => 'F9',
113
+ 68 => 'F10',
114
+ 69 => 'NumLock',
115
+ 70 => 'ScrollLock',
116
+ 71 => 'KP7',
117
+ 72 => 'KP8',
118
+ 73 => 'KP9',
119
+ 74 => 'KPMinus',
120
+ 75 => 'KP4',
121
+ 76 => 'KP5',
122
+ 77 => 'KP6',
123
+ 78 => 'KPPlus',
124
+ 79 => 'KP1',
125
+ 80 => 'KP2',
126
+ 81 => 'KP3',
127
+ 82 => 'KP0',
128
+ 83 => 'KPDot',
129
+ 85 => 'Zenkaku/Hankaku',
130
+ 86 => '102nd',
131
+ 87 => 'F11',
132
+ 88 => 'F12',
133
+ 89 => 'RO',
134
+ 90 => 'Katakana',
135
+ 91 => 'HIRAGANA',
136
+ 92 => 'Henkan',
137
+ 93 => 'Katakana/Hiragana',
138
+ 94 => 'Muhenkan',
139
+ 95 => 'KPJpComma',
140
+ 96 => 'KPEnter',
141
+ 97 => 'RightCtrl',
142
+ 98 => 'KPSlash',
143
+ 99 => 'SysRq',
144
+ 100 => 'RightAlt',
145
+ 101 => 'LineFeed',
146
+ 102 => 'Home',
147
+ 103 => 'Up',
148
+ 104 => 'PageUp',
149
+ 105 => 'Left',
150
+ 106 => 'Right',
151
+ 107 => 'End',
152
+ 108 => 'Down',
153
+ 109 => 'PageDown',
154
+ 110 => 'Insert',
155
+ 111 => 'Delete',
156
+ 112 => 'Macro',
157
+ 113 => 'Mute',
158
+ 114 => 'VolumeDown',
159
+ 115 => 'VolumeUp',
160
+ 116 => 'Power',
161
+ 117 => 'KPEqual',
162
+ 118 => 'KPPlusMinus',
163
+ 119 => 'Pause',
164
+ 121 => 'KPComma',
165
+ 122 => 'Hanguel',
166
+ 123 => 'Hanja',
167
+ 124 => 'Yen',
168
+ 125 => 'LeftMeta',
169
+ 126 => 'RightMeta',
170
+ 127 => 'Compose',
171
+ 128 => 'Stop',
172
+ 129 => 'Again',
173
+ 130 => 'Props',
174
+ 131 => 'Undo',
175
+ 132 => 'Front',
176
+ 133 => 'Copy',
177
+ 134 => 'Open',
178
+ 135 => 'Paste',
179
+ 136 => 'Find',
180
+ 137 => 'Cut',
181
+ 138 => 'Help',
182
+ 139 => 'Menu',
183
+ 140 => 'Calc',
184
+ 141 => 'Setup',
185
+ 142 => 'Sleep',
186
+ 143 => 'WakeUp',
187
+ 144 => 'File',
188
+ 145 => 'SendFile',
189
+ 146 => 'DeleteFile',
190
+ 147 => 'X-fer',
191
+ 148 => 'Prog1',
192
+ 149 => 'Prog2',
193
+ 150 => 'WWW',
194
+ 151 => 'MSDOS',
195
+ 152 => 'Coffee',
196
+ 153 => 'Direction',
197
+ 154 => 'CycleWindows',
198
+ 155 => 'Mail',
199
+ 156 => 'Bookmarks',
200
+ 157 => 'Computer',
201
+ 158 => 'Back',
202
+ 159 => 'Forward',
203
+ 160 => 'CloseCD',
204
+ 161 => 'EjectCD',
205
+ 162 => 'EjectCloseCD',
206
+ 163 => 'NextSong',
207
+ 164 => 'PlayPause',
208
+ 165 => 'PreviousSong',
209
+ 166 => 'StopCD',
210
+ 167 => 'Record',
211
+ 168 => 'Rewind',
212
+ 169 => 'Phone',
213
+ 170 => 'ISOKey',
214
+ 171 => 'Config',
215
+ 172 => 'HomePage',
216
+ 173 => 'Refresh',
217
+ 174 => 'Exit',
218
+ 175 => 'Move',
219
+ 176 => 'Edit',
220
+ 177 => 'ScrollUp',
221
+ 178 => 'ScrollDown',
222
+ 179 => 'KPLeftParenthesis',
223
+ 180 => 'KPRightParenthesis',
224
+ 183 => 'F13',
225
+ 184 => 'F14',
226
+ 185 => 'F15',
227
+ 186 => 'F16',
228
+ 187 => 'F17',
229
+ 188 => 'F18',
230
+ 189 => 'F19',
231
+ 190 => 'F20',
232
+ 191 => 'F21',
233
+ 192 => 'F22',
234
+ 193 => 'F23',
235
+ 194 => 'F24',
236
+ 200 => 'PlayCD',
237
+ 201 => 'PauseCD',
238
+ 202 => 'Prog3',
239
+ 203 => 'Prog4',
240
+ 205 => 'Suspend',
241
+ 206 => 'Close',
242
+ 207 => 'Play',
243
+ 208 => 'Fast Forward',
244
+ 209 => 'Bass Boost',
245
+ 210 => 'Print',
246
+ 211 => 'HP',
247
+ 212 => 'Camera',
248
+ 213 => 'Sound',
249
+ 214 => 'Question',
250
+ 215 => 'Email',
251
+ 216 => 'Chat',
252
+ 217 => 'Search',
253
+ 218 => 'Connect',
254
+ 219 => 'Finance',
255
+ 220 => 'Sport',
256
+ 221 => 'Shop',
257
+ 222 => 'Alternate Erase',
258
+ 223 => 'Cancel',
259
+ 224 => 'Brightness down',
260
+ 225 => 'Brightness up',
261
+ 226 => 'Media',
262
+ 240 => 'Unknown',
263
+ 256 => 'Btn0',
264
+ 257 => 'Btn1',
265
+ 258 => 'Btn2',
266
+ 259 => 'Btn3',
267
+ 260 => 'Btn4',
268
+ 261 => 'Btn5',
269
+ 262 => 'Btn6',
270
+ 263 => 'Btn7',
271
+ 264 => 'Btn8',
272
+ 265 => 'Btn9',
273
+ 272 => 'LeftBtn',
274
+ 273 => 'RightBtn',
275
+ 274 => 'MiddleBtn',
276
+ 275 => 'SideBtn',
277
+ 276 => 'ExtraBtn',
278
+ 277 => 'ForwardBtn',
279
+ 278 => 'BackBtn',
280
+ 279 => 'TaskBtn',
281
+ 288 => 'Trigger',
282
+ 289 => 'ThumbBtn',
283
+ 290 => 'ThumbBtn2',
284
+ 291 => 'TopBtn',
285
+ 292 => 'TopBtn2',
286
+ 293 => 'PinkieBtn',
287
+ 294 => 'BaseBtn',
288
+ 295 => 'BaseBtn2',
289
+ 296 => 'BaseBtn3',
290
+ 297 => 'BaseBtn4',
291
+ 298 => 'BaseBtn5',
292
+ 299 => 'BaseBtn6',
293
+ 303 => 'BtnDead',
294
+ 304 => 'BtnA',
295
+ 305 => 'BtnB',
296
+ 306 => 'BtnC',
297
+ 307 => 'BtnX',
298
+ 308 => 'BtnY',
299
+ 309 => 'BtnZ',
300
+ 310 => 'BtnTL',
301
+ 311 => 'BtnTR',
302
+ 312 => 'BtnTL2',
303
+ 313 => 'BtnTR2',
304
+ 314 => 'BtnSelect',
305
+ 315 => 'BtnStart',
306
+ 316 => 'BtnMode',
307
+ 317 => 'BtnThumbL',
308
+ 318 => 'BtnThumbR',
309
+ 320 => 'ToolPen',
310
+ 321 => 'ToolRubber',
311
+ 322 => 'ToolBrush',
312
+ 323 => 'ToolPencil',
313
+ 324 => 'ToolAirbrush',
314
+ 325 => 'ToolFinger',
315
+ 326 => 'ToolMouse',
316
+ 327 => 'ToolLens',
317
+ 330 => 'Touch',
318
+ 331 => 'Stylus',
319
+ 332 => 'Stylus2',
320
+ 333 => 'Tool Doubletap',
321
+ 334 => 'Tool Tripletap',
322
+ 336 => 'WheelBtn',
323
+ 337 => 'Gear up',
324
+ 352 => 'Ok',
325
+ 353 => 'Select',
326
+ 354 => 'Goto',
327
+ 355 => 'Clear',
328
+ 356 => 'Power2',
329
+ 357 => 'Option',
330
+ 358 => 'Info',
331
+ 359 => 'Time',
332
+ 360 => 'Vendor',
333
+ 361 => 'Archive',
334
+ 362 => 'Program',
335
+ 363 => 'Channel',
336
+ 364 => 'Favorites',
337
+ 365 => 'EPG',
338
+ 366 => 'PVR',
339
+ 367 => 'MHP',
340
+ 368 => 'Language',
341
+ 369 => 'Title',
342
+ 370 => 'Subtitle',
343
+ 371 => 'Angle',
344
+ 372 => 'Zoom',
345
+ 373 => 'Mode',
346
+ 374 => 'Keyboard',
347
+ 375 => 'Screen',
348
+ 376 => 'PC',
349
+ 377 => 'TV',
350
+ 378 => 'TV2',
351
+ 379 => 'VCR',
352
+ 380 => 'VCR2',
353
+ 381 => 'Sat',
354
+ 382 => 'Sat2',
355
+ 383 => 'CD',
356
+ 384 => 'Tape',
357
+ 385 => 'Radio',
358
+ 386 => 'Tuner',
359
+ 387 => 'Player',
360
+ 388 => 'Text',
361
+ 389 => 'DVD',
362
+ 390 => 'Aux',
363
+ 391 => 'MP3',
364
+ 392 => 'Audio',
365
+ 393 => 'Video',
366
+ 394 => 'Directory',
367
+ 395 => 'List',
368
+ 396 => 'Memo',
369
+ 397 => 'Calendar',
370
+ 398 => 'Red',
371
+ 399 => 'Green',
372
+ 400 => 'Yellow',
373
+ 401 => 'Blue',
374
+ 402 => 'ChannelUp',
375
+ 403 => 'ChannelDown',
376
+ 404 => 'First',
377
+ 405 => 'Last',
378
+ 406 => 'AB',
379
+ 407 => 'Next',
380
+ 408 => 'Restart',
381
+ 409 => 'Slow',
382
+ 410 => 'Shuffle',
383
+ 411 => 'Break',
384
+ 412 => 'Previous',
385
+ 413 => 'Digits',
386
+ 414 => 'TEEN',
387
+ 415 => 'TWEN',
388
+ 448 => 'Delete EOL',
389
+ 449 => 'Delete EOS',
390
+ 450 => 'Insert line',
391
+ 451 => 'Delete line',
392
+ },
393
+
394
+ EV_REL => {
395
+ 0 => 'X',
396
+ 1 => 'Y',
397
+ 2 => 'Z',
398
+ 6 => 'HWheel',
399
+ 7 => 'Dial',
400
+ 8 => 'Wheel',
401
+ 9 => 'Misc',
402
+ },
403
+
404
+ EV_ABS => {
405
+ 0 => 'X',
406
+ 1 => 'Y',
407
+ 2 => 'Z',
408
+ 3 => 'Rx',
409
+ 4 => 'Ry',
410
+ 5 => 'Rz',
411
+ 6 => 'Throttle',
412
+ 7 => 'Rudder',
413
+ 8 => 'Wheel',
414
+ 9 => 'Gas',
415
+ 10 => 'Brake',
416
+ 16 => 'Hat0X',
417
+ 17 => 'Hat0Y',
418
+ 18 => 'Hat1X',
419
+ 19 => 'Hat1Y',
420
+ 20 => 'Hat2X',
421
+ 21 => 'Hat2Y',
422
+ 22 => 'Hat3X',
423
+ 23 => 'Hat 3Y',
424
+ 24 => 'Pressure',
425
+ 25 => 'Distance',
426
+ 26 => 'XTilt',
427
+ 27 => 'YTilt',
428
+ 28 => 'Tool Width',
429
+ 32 => 'Volume',
430
+ 40 => 'Misc',
431
+ },
432
+
433
+ EV_MSC => {
434
+ 0 => 'Serial',
435
+ 1 => 'Pulseled',
436
+ 2 => 'Gesture',
437
+ 3 => 'RawData',
438
+ 4 => 'ScanCode',
439
+ },
440
+
441
+ EV_LED => {
442
+ 0 => 'NumLock',
443
+ 1 => 'CapsLock',
444
+ 2 => 'ScrollLock',
445
+ 3 => 'Compose',
446
+ 4 => 'Kana',
447
+ 5 => 'Sleep',
448
+ 6 => 'Suspend',
449
+ 7 => 'Mute',
450
+ 8 => 'Misc',
451
+ },
452
+
453
+ EV_SND => {
454
+ 0 => 'Click',
455
+ 1 => 'Bell',
456
+ 2 => 'Tone',
457
+ },
458
+
459
+ EV_REP => {
460
+ 0 => 'Delay',
461
+ 1 => 'Period',
462
+ },
463
+ }
464
+ end
465
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: device_input
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.1
4
+ version: 0.1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rick Hull
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-24 00:00:00.000000000 Z
11
+ date: 2017-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: buildar
@@ -34,9 +34,10 @@ extensions: []
34
34
  extra_rdoc_files: []
35
35
  files:
36
36
  - README.md
37
+ - VERSION
37
38
  - bin/devsniff
38
39
  - lib/device_input.rb
39
- - lib/device_input/codes.rb
40
+ - lib/device_input/labels.rb
40
41
  homepage: https://github.com/rickhull/device_input
41
42
  licenses:
42
43
  - GPL-3.0
@@ -1,438 +0,0 @@
1
- module DeviceInput
2
- CODES = {}
3
-
4
- # type = Sync
5
- CODES[0] = {
6
- 0 => ['SYN_REPORT', 'Report'],
7
- 1 => ['SYN_CONFIG', 'Config'],
8
- 2 => ['SYN_MT_REPORT', 'Multitouch'],
9
- 3 => ['SYN_DROPPED', 'Desync'],
10
- }
11
-
12
- # type = Key
13
- CODES[1] = {
14
- 0 => 'Reserved',
15
- 1 => 'Esc',
16
- 2 => '1',
17
- 3 => '2',
18
- 4 => '3',
19
- 5 => '4',
20
- 6 => '5',
21
- 7 => '6',
22
- 8 => '7',
23
- 9 => '8',
24
- 10 => '9',
25
- 11 => '0',
26
- 12 => 'Minus',
27
- 13 => 'Equal',
28
- 14 => 'Backspace',
29
- 15 => 'Tab',
30
- 16 => 'Q',
31
- 17 => 'W',
32
- 18 => 'E',
33
- 19 => 'R',
34
- 20 => 'T',
35
- 21 => 'Y',
36
- 22 => 'U',
37
- 23 => 'I',
38
- 24 => 'O',
39
- 25 => 'P',
40
- 26 => 'LeftBrace',
41
- 27 => 'RightBrace',
42
- 28 => 'Enter',
43
- 29 => 'LeftControl',
44
- 30 => 'A',
45
- 31 => 'S',
46
- 32 => 'D',
47
- 33 => 'F',
48
- 34 => 'G',
49
- 35 => 'H',
50
- 36 => 'J',
51
- 37 => 'K',
52
- 38 => 'L',
53
- 39 => 'Semicolon',
54
- 40 => 'Apostrophe',
55
- 41 => 'Grave',
56
- 42 => 'LeftShift',
57
- 43 => 'BackSlash',
58
- 44 => 'Z',
59
- 45 => 'X',
60
- 46 => 'C',
61
- 47 => 'V',
62
- 48 => 'B',
63
- 49 => 'N',
64
- 50 => 'M',
65
- 51 => 'Comma',
66
- 52 => 'Dot',
67
- 53 => 'Slash',
68
- 54 => 'RightShift',
69
- 55 => 'KPAsterisk',
70
- 56 => 'LeftAlt',
71
- 57 => 'Space',
72
- 58 => 'CapsLock',
73
- 59 => 'F1',
74
- 60 => 'F2',
75
- 61 => 'F3',
76
- 62 => 'F4',
77
- 63 => 'F5',
78
- 64 => 'F6',
79
- 65 => 'F7',
80
- 66 => 'F8',
81
- 67 => 'F9',
82
- 68 => 'F10',
83
- 69 => 'NumLock',
84
- 70 => 'ScrollLock',
85
- 71 => 'KP7',
86
- 72 => 'KP8',
87
- 73 => 'KP9',
88
- 74 => 'KPMinus',
89
- 75 => 'KP4',
90
- 76 => 'KP5',
91
- 77 => 'KP6',
92
- 78 => 'KPPlus',
93
- 79 => 'KP1',
94
- 80 => 'KP2',
95
- 81 => 'KP3',
96
- 82 => 'KP0',
97
- 83 => 'KPDot',
98
- 85 => 'Zenkaku/Hankaku',
99
- 86 => '102nd',
100
- 87 => 'F11',
101
- 88 => 'F12',
102
- 89 => 'RO',
103
- 90 => 'Katakana',
104
- 91 => 'HIRAGANA',
105
- 92 => 'Henkan',
106
- 93 => 'Katakana/Hiragana',
107
- 94 => 'Muhenkan',
108
- 95 => 'KPJpComma',
109
- 96 => 'KPEnter',
110
- 97 => 'RightCtrl',
111
- 98 => 'KPSlash',
112
- 99 => 'SysRq',
113
- 100 => 'RightAlt',
114
- 101 => 'LineFeed',
115
- 102 => 'Home',
116
- 103 => 'Up',
117
- 104 => 'PageUp',
118
- 105 => 'Left',
119
- 106 => 'Right',
120
- 107 => 'End',
121
- 108 => 'Down',
122
- 109 => 'PageDown',
123
- 110 => 'Insert',
124
- 111 => 'Delete',
125
- 112 => 'Macro',
126
- 113 => 'Mute',
127
- 114 => 'VolumeDown',
128
- 115 => 'VolumeUp',
129
- 116 => 'Power',
130
- 117 => 'KPEqual',
131
- 118 => 'KPPlusMinus',
132
- 119 => 'Pause',
133
- 121 => 'KPComma',
134
- 122 => 'Hanguel',
135
- 123 => 'Hanja',
136
- 124 => 'Yen',
137
- 125 => 'LeftMeta',
138
- 126 => 'RightMeta',
139
- 127 => 'Compose',
140
- 128 => 'Stop',
141
- 129 => 'Again',
142
- 130 => 'Props',
143
- 131 => 'Undo',
144
- 132 => 'Front',
145
- 133 => 'Copy',
146
- 134 => 'Open',
147
- 135 => 'Paste',
148
- 136 => 'Find',
149
- 137 => 'Cut',
150
- 138 => 'Help',
151
- 139 => 'Menu',
152
- 140 => 'Calc',
153
- 141 => 'Setup',
154
- 142 => 'Sleep',
155
- 143 => 'WakeUp',
156
- 144 => 'File',
157
- 145 => 'SendFile',
158
- 146 => 'DeleteFile',
159
- 147 => 'X-fer',
160
- 148 => 'Prog1',
161
- 149 => 'Prog2',
162
- 150 => 'WWW',
163
- 151 => 'MSDOS',
164
- 152 => 'Coffee',
165
- 153 => 'Direction',
166
- 154 => 'CycleWindows',
167
- 155 => 'Mail',
168
- 156 => 'Bookmarks',
169
- 157 => 'Computer',
170
- 158 => 'Back',
171
- 159 => 'Forward',
172
- 160 => 'CloseCD',
173
- 161 => 'EjectCD',
174
- 162 => 'EjectCloseCD',
175
- 163 => 'NextSong',
176
- 164 => 'PlayPause',
177
- 165 => 'PreviousSong',
178
- 166 => 'StopCD',
179
- 167 => 'Record',
180
- 168 => 'Rewind',
181
- 169 => 'Phone',
182
- 170 => 'ISOKey',
183
- 171 => 'Config',
184
- 172 => 'HomePage',
185
- 173 => 'Refresh',
186
- 174 => 'Exit',
187
- 175 => 'Move',
188
- 176 => 'Edit',
189
- 177 => 'ScrollUp',
190
- 178 => 'ScrollDown',
191
- 179 => 'KPLeftParenthesis',
192
- 180 => 'KPRightParenthesis',
193
- 183 => 'F13',
194
- 184 => 'F14',
195
- 185 => 'F15',
196
- 186 => 'F16',
197
- 187 => 'F17',
198
- 188 => 'F18',
199
- 189 => 'F19',
200
- 190 => 'F20',
201
- 191 => 'F21',
202
- 192 => 'F22',
203
- 193 => 'F23',
204
- 194 => 'F24',
205
- 200 => 'PlayCD',
206
- 201 => 'PauseCD',
207
- 202 => 'Prog3',
208
- 203 => 'Prog4',
209
- 205 => 'Suspend',
210
- 206 => 'Close',
211
- 207 => 'Play',
212
- 208 => 'Fast Forward',
213
- 209 => 'Bass Boost',
214
- 210 => 'Print',
215
- 211 => 'HP',
216
- 212 => 'Camera',
217
- 213 => 'Sound',
218
- 214 => 'Question',
219
- 215 => 'Email',
220
- 216 => 'Chat',
221
- 217 => 'Search',
222
- 218 => 'Connect',
223
- 219 => 'Finance',
224
- 220 => 'Sport',
225
- 221 => 'Shop',
226
- 222 => 'Alternate Erase',
227
- 223 => 'Cancel',
228
- 224 => 'Brightness down',
229
- 225 => 'Brightness up',
230
- 226 => 'Media',
231
- 240 => 'Unknown',
232
- 256 => 'Btn0',
233
- 257 => 'Btn1',
234
- 258 => 'Btn2',
235
- 259 => 'Btn3',
236
- 260 => 'Btn4',
237
- 261 => 'Btn5',
238
- 262 => 'Btn6',
239
- 263 => 'Btn7',
240
- 264 => 'Btn8',
241
- 265 => 'Btn9',
242
- 272 => 'LeftBtn',
243
- 273 => 'RightBtn',
244
- 274 => 'MiddleBtn',
245
- 275 => 'SideBtn',
246
- 276 => 'ExtraBtn',
247
- 277 => 'ForwardBtn',
248
- 278 => 'BackBtn',
249
- 279 => 'TaskBtn',
250
- 288 => 'Trigger',
251
- 289 => 'ThumbBtn',
252
- 290 => 'ThumbBtn2',
253
- 291 => 'TopBtn',
254
- 292 => 'TopBtn2',
255
- 293 => 'PinkieBtn',
256
- 294 => 'BaseBtn',
257
- 295 => 'BaseBtn2',
258
- 296 => 'BaseBtn3',
259
- 297 => 'BaseBtn4',
260
- 298 => 'BaseBtn5',
261
- 299 => 'BaseBtn6',
262
- 303 => 'BtnDead',
263
- 304 => 'BtnA',
264
- 305 => 'BtnB',
265
- 306 => 'BtnC',
266
- 307 => 'BtnX',
267
- 308 => 'BtnY',
268
- 309 => 'BtnZ',
269
- 310 => 'BtnTL',
270
- 311 => 'BtnTR',
271
- 312 => 'BtnTL2',
272
- 313 => 'BtnTR2',
273
- 314 => 'BtnSelect',
274
- 315 => 'BtnStart',
275
- 316 => 'BtnMode',
276
- 317 => 'BtnThumbL',
277
- 318 => 'BtnThumbR',
278
- 320 => 'ToolPen',
279
- 321 => 'ToolRubber',
280
- 322 => 'ToolBrush',
281
- 323 => 'ToolPencil',
282
- 324 => 'ToolAirbrush',
283
- 325 => 'ToolFinger',
284
- 326 => 'ToolMouse',
285
- 327 => 'ToolLens',
286
- 330 => 'Touch',
287
- 331 => 'Stylus',
288
- 332 => 'Stylus2',
289
- 333 => 'Tool Doubletap',
290
- 334 => 'Tool Tripletap',
291
- 336 => 'WheelBtn',
292
- 337 => 'Gear up',
293
- 352 => 'Ok',
294
- 353 => 'Select',
295
- 354 => 'Goto',
296
- 355 => 'Clear',
297
- 356 => 'Power2',
298
- 357 => 'Option',
299
- 358 => 'Info',
300
- 359 => 'Time',
301
- 360 => 'Vendor',
302
- 361 => 'Archive',
303
- 362 => 'Program',
304
- 363 => 'Channel',
305
- 364 => 'Favorites',
306
- 365 => 'EPG',
307
- 366 => 'PVR',
308
- 367 => 'MHP',
309
- 368 => 'Language',
310
- 369 => 'Title',
311
- 370 => 'Subtitle',
312
- 371 => 'Angle',
313
- 372 => 'Zoom',
314
- 373 => 'Mode',
315
- 374 => 'Keyboard',
316
- 375 => 'Screen',
317
- 376 => 'PC',
318
- 377 => 'TV',
319
- 378 => 'TV2',
320
- 379 => 'VCR',
321
- 380 => 'VCR2',
322
- 381 => 'Sat',
323
- 382 => 'Sat2',
324
- 383 => 'CD',
325
- 384 => 'Tape',
326
- 385 => 'Radio',
327
- 386 => 'Tuner',
328
- 387 => 'Player',
329
- 388 => 'Text',
330
- 389 => 'DVD',
331
- 390 => 'Aux',
332
- 391 => 'MP3',
333
- 392 => 'Audio',
334
- 393 => 'Video',
335
- 394 => 'Directory',
336
- 395 => 'List',
337
- 396 => 'Memo',
338
- 397 => 'Calendar',
339
- 398 => 'Red',
340
- 399 => 'Green',
341
- 400 => 'Yellow',
342
- 401 => 'Blue',
343
- 402 => 'ChannelUp',
344
- 403 => 'ChannelDown',
345
- 404 => 'First',
346
- 405 => 'Last',
347
- 406 => 'AB',
348
- 407 => 'Next',
349
- 408 => 'Restart',
350
- 409 => 'Slow',
351
- 410 => 'Shuffle',
352
- 411 => 'Break',
353
- 412 => 'Previous',
354
- 413 => 'Digits',
355
- 414 => 'TEEN',
356
- 415 => 'TWEN',
357
- 448 => 'Delete EOL',
358
- 449 => 'Delete EOS',
359
- 450 => 'Insert line',
360
- 451 => 'Delete line',
361
- }
362
-
363
- # type = Relative
364
- CODES[2] = {
365
- 0 => 'X',
366
- 1 => 'Y',
367
- 2 => 'Z',
368
- 6 => 'HWheel',
369
- 7 => 'Dial',
370
- 8 => 'Wheel',
371
- 9 => 'Misc',
372
- }
373
-
374
- # type = Absolute
375
- CODES[3] = {
376
- 0 => 'X',
377
- 1 => 'Y',
378
- 2 => 'Z',
379
- 3 => 'Rx',
380
- 4 => 'Ry',
381
- 5 => 'Rz',
382
- 6 => 'Throttle',
383
- 7 => 'Rudder',
384
- 8 => 'Wheel',
385
- 9 => 'Gas',
386
- 10 => 'Brake',
387
- 16 => 'Hat0X',
388
- 17 => 'Hat0Y',
389
- 18 => 'Hat1X',
390
- 19 => 'Hat1Y',
391
- 20 => 'Hat2X',
392
- 21 => 'Hat2Y',
393
- 22 => 'Hat3X',
394
- 23 => 'Hat 3Y',
395
- 24 => 'Pressure',
396
- 25 => 'Distance',
397
- 26 => 'XTilt',
398
- 27 => 'YTilt',
399
- 28 => 'Tool Width',
400
- 32 => 'Volume',
401
- 40 => 'Misc',
402
- }
403
-
404
- # type = Misc
405
- CODES[4] = {
406
- 0 => 'Serial',
407
- 1 => 'Pulseled',
408
- 2 => 'Gesture',
409
- 3 => 'RawData',
410
- 4 => 'ScanCode',
411
- }
412
-
413
- # type = LED
414
- CODES[17] = {
415
- 0 => 'NumLock',
416
- 1 => 'CapsLock',
417
- 2 => 'ScrollLock',
418
- 3 => 'Compose',
419
- 4 => 'Kana',
420
- 5 => 'Sleep',
421
- 6 => 'Suspend',
422
- 7 => 'Mute',
423
- 8 => 'Misc',
424
- }
425
-
426
- # type = Sound
427
- CODES[18] = {
428
- 0 => 'Click',
429
- 1 => 'Bell',
430
- 2 => 'Tone',
431
- }
432
-
433
- # type = Repeat
434
- CODES[20] = {
435
- 0 => 'Delay',
436
- 1 => 'Period',
437
- }
438
- end