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 +4 -4
- data/lib/uinput/keyboard.rb +17 -21
- data/lib/uinput/keyboard/version.rb +1 -1
- data/test.rb +3 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 055f65c464f1c5f9310cc2d31288a1d36409830f
|
4
|
+
data.tar.gz: 120db4ff5630594825c319fba7d59b1108a20826
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c4e5fb9a2588d4defddae092d735e266e6d153c2893b504f364f9452a5cf90addceac725883ac7979f822d27fa22fa8483d16c589131f73feb192fdf014d08a
|
7
|
+
data.tar.gz: 755ef4927a1d0bdb840e1d0760d04e452502ce4e9568a2898c67b45ba48185c747e41e74cba8275524010e9fb2cc713932c80cf62a447bdebf00e544556f735c
|
data/lib/uinput/keyboard.rb
CHANGED
@@ -20,21 +20,25 @@ module Uinput
|
|
20
20
|
attr_accessor :keymap
|
21
21
|
|
22
22
|
def press(*symbols)
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|
-
|
33
|
-
|
34
|
-
|
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
|
-
|
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
|
data/test.rb
CHANGED
@@ -10,11 +10,11 @@ begin
|
|
10
10
|
puts keyboard.sys_path
|
11
11
|
puts keyboard.dev_path
|
12
12
|
|
13
|
-
|
14
|
-
puts
|
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('Ѣ')
|