uinput-keyboard 0.2 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0a2456a2d30b81219abee04f64a31da51b170724
4
- data.tar.gz: 9aaf462f74e3b92583babba97c48c9477bf8ae13
3
+ metadata.gz: 055f65c464f1c5f9310cc2d31288a1d36409830f
4
+ data.tar.gz: 120db4ff5630594825c319fba7d59b1108a20826
5
5
  SHA512:
6
- metadata.gz: f473d72d327d7ab7db33e0fb3126b6de19390764459559e608eb583ba9226259e958f0ddef6c5eb4affae0c02e318f71229e67258e47bf4637c2afcfe8ca3e33
7
- data.tar.gz: e8d8a189d12fddd315f936494e02544c94226808dd7abfda4e6b402f6eb898c0bab74c0a7e48312e27d20a6766b606ce9d243020522ed4de7968589904874253
6
+ metadata.gz: 0c4e5fb9a2588d4defddae092d735e266e6d153c2893b504f364f9452a5cf90addceac725883ac7979f822d27fa22fa8483d16c589131f73feb192fdf014d08a
7
+ data.tar.gz: 755ef4927a1d0bdb840e1d0760d04e452502ce4e9568a2898c67b45ba48185c747e41e74cba8275524010e9fb2cc713932c80cf62a447bdebf00e544556f735c
@@ -20,21 +20,25 @@ module Uinput
20
20
  attr_accessor :keymap
21
21
 
22
22
  def press(*symbols)
23
- keys = symbols_to_keys(*symbols)
24
- keys.each do |key|
25
- send_event(:EV_KEY, key.scan_code, 1)
23
+ symbols.flat_map do |symbol|
24
+ symbol(symbol).keys.map do |key|
25
+ send_event(:EV_KEY, key.scan_code, 1)
26
+ key.code
27
+ end.tap do
28
+ send_event(:EV_SYN, :SYN_REPORT)
29
+ end
26
30
  end
27
- send_event(:EV_SYN, :SYN_REPORT)
28
- keys.map(&:code)
29
31
  end
30
32
 
31
33
  def release(*symbols)
32
- keys = symbols_to_keys(*symbols)
33
- keys.each do |key|
34
- send_event(:EV_KEY, key.scan_code, 0)
34
+ symbols.flat_map do |symbol|
35
+ symbol(symbol).keys.map do |key|
36
+ send_event(:EV_KEY, key.scan_code, 0)
37
+ key.code
38
+ end.tap do
39
+ send_event(:EV_SYN, :SYN_REPORT)
40
+ end
35
41
  end
36
- send_event(:EV_SYN, :SYN_REPORT)
37
- keys.map(&:code)
38
42
  end
39
43
 
40
44
  def tap(*symbols)
@@ -54,23 +58,15 @@ module Uinput
54
58
  end
55
59
 
56
60
  def symbols_to_keycodes(*names)
57
- symbols_to_keys(*names).map(&:code)
58
- end
59
-
60
- def string_to_keycodes(string)
61
- string_to_symbols(string).map{ |symbols| symbols_to_keycodes(*symbols) }
62
- end
63
-
64
- private
65
-
66
- def symbols_to_keys(*names)
67
- [*names].flat_map{ |name| symbol(name).keys }
61
+ names.map{ |name| symbol(name).keys.map(&:code) }
68
62
  end
69
63
 
70
64
  def string_to_symbols(string)
71
65
  string.chars.map{ |char| char_to_symbol(char).name }
72
66
  end
73
67
 
68
+ private
69
+
74
70
  def symbol(name)
75
71
  @keymap.symbols[name.to_sym] or raise Device::Error.new("no keysym '#{name}' in keymap")
76
72
  end
@@ -1,3 +1,3 @@
1
1
  module Uinput
2
- Keyboard_VERSION = "0.2"
2
+ Keyboard_VERSION = "0.3"
3
3
  end
data/test.rb CHANGED
@@ -10,11 +10,11 @@ begin
10
10
  puts keyboard.sys_path
11
11
  puts keyboard.dev_path
12
12
 
13
- puts keyboard.string_to_keycodes('DaTe!').inspect
14
- puts keyboard.symbols_to_keycodes(:Shift_L, :d).inspect
13
+ symbols = keyboard.string_to_symbols('DaTe!')
14
+ puts symbols.inspect
15
+ puts keyboard.symbols_to_keycodes(*symbols).inspect
15
16
 
16
17
  puts keyboard.type('date').inspect
17
-
18
18
  puts keyboard.tap(:Return).inspect
19
19
 
20
20
  #keyboard.type('Ѣ')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uinput-keyboard
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.2'
4
+ version: '0.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Aue