hidg0 0.2.1 → 0.2.2
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/hidg0.rb +27 -7
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '018c9573356c84859eaf2a522b4840478b458ddc258a1920c31ff2fea9499722'
|
4
|
+
data.tar.gz: f849f0d82643cca5c7b4af69fae8c9a5d32af9592c46c7fa746cd236b815cf58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 922e0c4c43e6eba5f8ccfe40c52bd7760d439f58c75265ceb6caca8952c18ed9cde4e3587636ff78990101c66951bcaecdb7c1d7f92fdba7023db1935bd7a98f
|
7
|
+
data.tar.gz: 7cab3968f0a11f4c6ce54eaaeea93e79621e146ae06bba8370a296f19a773cee8fd567b67659143c5921dc951f55efb30ba62f6f27140692e08eb126048508ab
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/hidg0.rb
CHANGED
@@ -50,6 +50,7 @@ copied from: https://forum.micropython.org/viewtopic.php?t=2021
|
|
50
50
|
|
51
51
|
h = %i(right_gui rightalt rightshift rightctrl left_gui left_alt leftshift leftctrl).\
|
52
52
|
reverse.map.with_index {|x,i| [x, (2 ** i)]}.to_h
|
53
|
+
|
53
54
|
MODIFIERS = h.merge({shift: h[:leftshift], alt: h[:left_alt],
|
54
55
|
ctrl: h[:leftctrl], control: h[:leftctrl]})
|
55
56
|
|
@@ -100,22 +101,35 @@ KEYS = {
|
|
100
101
|
:'9' => 38, # Keyboard 9 and (
|
101
102
|
:'0' => 39, # Keyboard 0 and )
|
102
103
|
enter: 40, # Keyboard Return (ENTER)
|
104
|
+
:"\n" => 40,
|
103
105
|
esc: 41, # Keyboard ESCAPE
|
104
106
|
backspace: 42, # Keyboard DELETE (Backspace)
|
105
107
|
tab: 43, # Keyboard Tab
|
106
108
|
space: 44, # Keyboard Spacebar
|
109
|
+
:' ' => 44, # Keyboard Spacebar
|
107
110
|
minus: 45, # Keyboard - and _
|
111
|
+
:'-' => 45,
|
108
112
|
equal: 46, # Keyboard = and +
|
113
|
+
:'=' => 46,
|
109
114
|
leftbrace: 47, # Keyboard [ and {
|
115
|
+
:'[' => 47,
|
110
116
|
rightbrace: 48, # Keyboard ] and }
|
117
|
+
:']' => 48,
|
111
118
|
backslash: 49, # Keyboard and |
|
112
119
|
hashtilde: 50, # Keyboard Non-US # and ~
|
120
|
+
:'#' => 50,
|
113
121
|
semicolon: 51, # Keyboard ; and :
|
122
|
+
:';' => 51,
|
114
123
|
apostrophe: 52, # Keyboard ' and "
|
124
|
+
:"'" => 52,
|
115
125
|
grave: 53, # Keyboard ` and ~
|
126
|
+
:'`' => 53,
|
116
127
|
comma: 54, # Keyboard , and <
|
128
|
+
:',' => 54, # Keyboard , and <
|
117
129
|
dot: 55, # Keyboard . and >
|
130
|
+
:'.' => 55,
|
118
131
|
slash: 56, # Keyboard / and ?
|
132
|
+
:'/' => 56,
|
119
133
|
capslock: 57, # Keyboard Caps Lock
|
120
134
|
f1: 58, # Keyboard F1
|
121
135
|
f2: 59, # Keyboard F2
|
@@ -256,10 +270,9 @@ KEYS = {
|
|
256
270
|
W: :w,
|
257
271
|
X: :x,
|
258
272
|
Y: :y,
|
259
|
-
Z: :z,
|
273
|
+
Z: :z,
|
260
274
|
:'!' => :'1',
|
261
275
|
:'@' => :'2',
|
262
|
-
:'#' => :'3',
|
263
276
|
:'$' => :'4',
|
264
277
|
:'%' => :'5',
|
265
278
|
:'^' => :'6',
|
@@ -290,8 +303,9 @@ KEYS = {
|
|
290
303
|
class HidG0
|
291
304
|
using ColouredText
|
292
305
|
|
293
|
-
def initialize(dev='/dev/hidg0', debug: false)
|
306
|
+
def initialize(dev='/dev/hidg0', debug: false, humanspeed: true)
|
294
307
|
@dev, @debug = dev, debug
|
308
|
+
@duration = 0.3 if humanspeed
|
295
309
|
end
|
296
310
|
|
297
311
|
def keypress(key, duration: 0)
|
@@ -302,11 +316,17 @@ class HidG0
|
|
302
316
|
|
303
317
|
def sendkeys(s)
|
304
318
|
|
305
|
-
|
319
|
+
# current keymapping is for en-gb
|
320
|
+
|
321
|
+
# £ is "\u{00A3}" in unicode
|
322
|
+
[["\n",'{enter}'],["\u{00A3}","{shift+3}"],['"','{shift+2}']]\
|
323
|
+
.map {|x,y| s.gsub!(x,y) }
|
324
|
+
|
325
|
+
s.scan(/\{[^\}]+\}|./).each do |x|
|
306
326
|
|
307
327
|
if x.length == 1 and x[0] != '{' then
|
308
328
|
|
309
|
-
keypress x
|
329
|
+
keypress x, duration: @duration
|
310
330
|
|
311
331
|
else
|
312
332
|
|
@@ -329,7 +349,7 @@ class HidG0
|
|
329
349
|
release_keys()
|
330
350
|
|
331
351
|
else
|
332
|
-
keypress keys.first
|
352
|
+
keypress keys.first, duration: @duration
|
333
353
|
end
|
334
354
|
|
335
355
|
end
|
@@ -350,7 +370,7 @@ class HidG0
|
|
350
370
|
else
|
351
371
|
|
352
372
|
# the key can be reproduced by combining tke key press with the shift key
|
353
|
-
|
373
|
+
puts ('KEYS[key.to_sym]: ' + KEYS[key.to_sym].inspect).debug if @debug
|
354
374
|
write_report(MODIFIERS[:shift].chr + NULL_CHAR + \
|
355
375
|
KEYS[KEYS[key.to_sym]].chr + NULL_CHAR*5)
|
356
376
|
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hidg0
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
PwTg5+TqjQvWRfpf4tDWra3/fS6sXSuA4aoh28J3YpuAS2upGYuCk61X4iEDYerh
|
36
36
|
INwakAqcXQ4/4DC0SoRunSvJ
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2019-03-
|
38
|
+
date: 2019-03-20 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: c32
|
metadata.gz.sig
CHANGED
Binary file
|