hidg0 0.4.0 → 0.4.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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/hidg0.rb +31 -19
- 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: d0c91653b0bfe7b9f36b262a8f7dc434cd97e329a7bf6a63c4c5d027d8ec1e71
|
4
|
+
data.tar.gz: ab1c3db4a4d942e0dcfd75307633642ddb803a81811a69e9a28fd97161d500ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1e85d10a3450298718f0be33857266bb29b9702f4553c927c0475668e79c112ea936a4e1b81ae35f38a98ae70d2394d1adf8b9b35d4e96710abb2f6abb165ec
|
7
|
+
data.tar.gz: 2e9405866f8b02b21d9fa97ee32ac19b6f2aaa945fcb4528862cfd574978fea818045239e721c925708ca7ed8da24588ec3b18c42c910e18be1b6b34c3786134
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/hidg0.rb
CHANGED
@@ -308,7 +308,7 @@ class HidG0
|
|
308
308
|
|
309
309
|
def initialize(dev='/dev/hidg0', debug: false, humanspeed: true)
|
310
310
|
@dev, @debug = dev, debug
|
311
|
-
@duration = humanspeed ? 0.
|
311
|
+
@duration = humanspeed ? 0.22 : 0
|
312
312
|
end
|
313
313
|
|
314
314
|
def keypress(raw_key, duration: 0)
|
@@ -335,7 +335,7 @@ class HidG0
|
|
335
335
|
|
336
336
|
# split by semicolon
|
337
337
|
|
338
|
-
x[1..-2].split(/\s
|
338
|
+
x[1..-2].split(/\s*[;,]\s*/).each do |instruction|
|
339
339
|
|
340
340
|
if instruction =~ /\*\s*\d+/ then
|
341
341
|
key, n = instruction.split('*',2)
|
@@ -425,18 +425,20 @@ class HidG0
|
|
425
425
|
end
|
426
426
|
|
427
427
|
def write_report(report)
|
428
|
-
open(@dev, 'wb+') {|f| f.write report }
|
428
|
+
open(@dev, 'wb+') {|f| f.write report } if @dev
|
429
429
|
end
|
430
430
|
end
|
431
431
|
|
432
432
|
class HidG0Plus < HidG0
|
433
433
|
|
434
|
-
def initialize(instructions='', dev: '/dev/hidg0', debug: false
|
434
|
+
def initialize(instructions='', dev: '/dev/hidg0', debug: false,
|
435
|
+
progress_units: 100, chunk: true)
|
435
436
|
|
436
|
-
|
437
|
-
|
437
|
+
humanspeed = chunk == true
|
438
|
+
super(dev, debug: debug, humanspeed: humanspeed)
|
439
|
+
@index, @progress_units = 0, progress_units
|
438
440
|
|
439
|
-
|
441
|
+
a = parse_keys(instructions).map do |x|
|
440
442
|
|
441
443
|
puts 'x: ' + x.inspect if @debug
|
442
444
|
|
@@ -465,32 +467,42 @@ class HidG0Plus < HidG0
|
|
465
467
|
|
466
468
|
end.flatten
|
467
469
|
|
470
|
+
@keys = chunk ? a.chunk_while {|x| x.length == 1}.map(&:join) : a
|
471
|
+
|
468
472
|
end
|
469
473
|
|
470
474
|
def index()
|
471
475
|
@index
|
472
476
|
end
|
473
477
|
|
474
|
-
def keys()
|
475
|
-
|
476
|
-
@keys
|
477
|
-
|
478
|
+
def keys()
|
479
|
+
@keys
|
478
480
|
end
|
479
|
-
|
480
|
-
def sendkey()
|
481
481
|
|
482
|
-
key = @keys[@index]
|
483
|
-
key[0] == '{' ? sendkeys(key) : keypress(key)
|
484
|
-
@index+=1
|
485
|
-
|
486
|
-
end
|
487
|
-
|
488
482
|
def next_key()
|
489
483
|
@keys[@index]
|
490
484
|
end
|
491
485
|
|
492
486
|
def prev_key()
|
493
487
|
@keys[@index-1] unless @index == 0
|
488
|
+
end
|
489
|
+
|
490
|
+
def progress(units=@progress_units)
|
491
|
+
(units / (@keys.length / @index.to_f)).round
|
492
|
+
end
|
493
|
+
|
494
|
+
def reset()
|
495
|
+
@index = 0
|
494
496
|
end
|
495
497
|
|
498
|
+
def sendkey()
|
499
|
+
|
500
|
+
return if @index >= @keys.length
|
501
|
+
key = @keys[@index]
|
502
|
+
key.length > 1 ? sendkeys(key) : keypress(key)
|
503
|
+
@index+=1
|
504
|
+
progress()
|
505
|
+
|
506
|
+
end
|
507
|
+
|
496
508
|
end
|
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.4.
|
4
|
+
version: 0.4.1
|
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-
|
38
|
+
date: 2019-04-01 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: c32
|
metadata.gz.sig
CHANGED
Binary file
|