hidg0 0.3.0 → 0.4.0
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 +88 -6
- data.tar.gz.sig +0 -0
- metadata +1 -1
- 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: 18bb1d1ce3cc1772d08c9174f3b74fa72854063298be6ff49179dfea00f60dc5
|
4
|
+
data.tar.gz: 44c366862cf4516459158d628b1ef2e7fc4e68fa48ca37dfec2cc60b0f9abfa8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 459c736b804d8b8c061fb85a8d5bb322c5dd6b246890dc7f9caf535d2dccfc15ffc2fc375e543e5baf72161b042747760065e0e589ed0caf6108547621781fd6
|
7
|
+
data.tar.gz: c104f3d0ec5e172a9c7c996f2e65e83b236cd840d1ed26105457bc70e9f62d27f7baf19ca9e7e04c6526fa34f2102a466601b0dd71d0adc32fa3cb7efeac242d
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/hidg0.rb
CHANGED
@@ -311,9 +311,10 @@ class HidG0
|
|
311
311
|
@duration = humanspeed ? 0.3 : 0
|
312
312
|
end
|
313
313
|
|
314
|
-
def keypress(
|
314
|
+
def keypress(raw_key, duration: 0)
|
315
315
|
|
316
|
-
|
316
|
+
key = raw_key.strip.empty? ? raw_key : raw_key.strip
|
317
|
+
keydown(key); sleep(duration); release_keys()
|
317
318
|
|
318
319
|
end
|
319
320
|
|
@@ -322,10 +323,7 @@ class HidG0
|
|
322
323
|
# current keymapping is for en-gb
|
323
324
|
|
324
325
|
# £ is "\u{00A3}" in unicode
|
325
|
-
|
326
|
-
.map {|x,y| s.gsub!(x,y) }
|
327
|
-
|
328
|
-
s.gsub(/\s*(?=\{)|(?<=\})\s*/,'').scan(/\{[^\}]+\}|./).each do |x|
|
326
|
+
parse_keys(s).each do |x|
|
329
327
|
|
330
328
|
puts ('x: ' + x.inspect).debug if @debug
|
331
329
|
|
@@ -339,6 +337,12 @@ class HidG0
|
|
339
337
|
|
340
338
|
x[1..-2].split(/\s*;\s*/).each do |instruction|
|
341
339
|
|
340
|
+
if instruction =~ /\*\s*\d+/ then
|
341
|
+
key, n = instruction.split('*',2)
|
342
|
+
n.to_i.times {keypress(key, duration: @duration) }
|
343
|
+
next
|
344
|
+
end
|
345
|
+
|
342
346
|
keys = instruction.split('+')
|
343
347
|
|
344
348
|
|
@@ -379,6 +383,19 @@ class HidG0
|
|
379
383
|
end
|
380
384
|
|
381
385
|
end
|
386
|
+
|
387
|
+
protected
|
388
|
+
|
389
|
+
def parse_keys(raw_s)
|
390
|
+
|
391
|
+
s = raw_s.clone
|
392
|
+
|
393
|
+
[["\u{00A3}","{shift+3}"],['"','{shift+2}']]\
|
394
|
+
.map {|x,y| s.gsub!(x,y) }
|
395
|
+
|
396
|
+
s.gsub(/\s*(?=\{)|(?<=\})\s*/,'').scan(/\{[^\}]+\}|./)
|
397
|
+
|
398
|
+
end
|
382
399
|
|
383
400
|
private
|
384
401
|
|
@@ -412,3 +429,68 @@ class HidG0
|
|
412
429
|
end
|
413
430
|
end
|
414
431
|
|
432
|
+
class HidG0Plus < HidG0
|
433
|
+
|
434
|
+
def initialize(instructions='', dev: '/dev/hidg0', debug: false)
|
435
|
+
|
436
|
+
super(dev, debug: debug, humanspeed: false)
|
437
|
+
@index= 0
|
438
|
+
|
439
|
+
@keys = parse_keys(instructions).map do |x|
|
440
|
+
|
441
|
+
puts 'x: ' + x.inspect if @debug
|
442
|
+
|
443
|
+
if x[0] == '{' then
|
444
|
+
|
445
|
+
x[1..-2].strip.split(/[;,]/).map do |item|
|
446
|
+
|
447
|
+
if item.strip =~ /^sleep /
|
448
|
+
|
449
|
+
next
|
450
|
+
|
451
|
+
elsif item =~ /\w+\s*\*\s*\d+/
|
452
|
+
|
453
|
+
key, n = item.split(/\*/,2)
|
454
|
+
[key] * n.to_i
|
455
|
+
|
456
|
+
else
|
457
|
+
"{%s}" % item.strip
|
458
|
+
end
|
459
|
+
|
460
|
+
end.compact
|
461
|
+
|
462
|
+
else
|
463
|
+
x
|
464
|
+
end
|
465
|
+
|
466
|
+
end.flatten
|
467
|
+
|
468
|
+
end
|
469
|
+
|
470
|
+
def index()
|
471
|
+
@index
|
472
|
+
end
|
473
|
+
|
474
|
+
def keys()
|
475
|
+
|
476
|
+
@keys
|
477
|
+
|
478
|
+
end
|
479
|
+
|
480
|
+
def sendkey()
|
481
|
+
|
482
|
+
key = @keys[@index]
|
483
|
+
key[0] == '{' ? sendkeys(key) : keypress(key)
|
484
|
+
@index+=1
|
485
|
+
|
486
|
+
end
|
487
|
+
|
488
|
+
def next_key()
|
489
|
+
@keys[@index]
|
490
|
+
end
|
491
|
+
|
492
|
+
def prev_key()
|
493
|
+
@keys[@index-1] unless @index == 0
|
494
|
+
end
|
495
|
+
|
496
|
+
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|