xinput_wrapper 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +2 -2
- data/lib/xinput_wrapper.rb +60 -26
- 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: 290701cfce88a11462cb860805bf014f6a6d0d366c7efaa4f2516423f1da87e1
|
4
|
+
data.tar.gz: e82be2d004f3cfa0e358b162741c63058f9db8717e20d23e86c40e5e0ed5c179
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 429ce14f3defe07737301513180730f9c406fb163cde5d9d0a064170f5b184ce64776c798b151fa049c33fb9a8d0d7eab2e72d92a48e7d248e3a792643be308f
|
7
|
+
data.tar.gz: e67b773e97c10adfeb940e7e000f480c782ef975151526efaf6dfd6cce93f6f51008a40aa3b4d147501c64e2ce5f1122d42b503805336d6e722f19711287abbe
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
���l�z�1����SĖ����8�n�tT�D�,*t�������ښ��8�,��=��{�>"6F�X�&����v�8b��I����t�6��8���1jL[l�t�kl�`���ivR�A"
|
2
|
+
��%��uO*d#9�־�c����v�vpS͟a�.��OG� յ�?�IJ� ^��T������1�����H������A��be?��%<V���8���"����;��0�1�0?�Y� *h ���C�ŋe�WYѻ��������0��U�/���"�����&����,a$Aa�T]��m<n=X��T@�/��)ur,��bZ�}�m{���3��p�n�o�������������G'�'~���3b���"<W�
|
data/lib/xinput_wrapper.rb
CHANGED
@@ -11,19 +11,25 @@ class XInputWrapper
|
|
11
11
|
def initialize(device: '3', verbose: true, lookup: {}, debug: false )
|
12
12
|
|
13
13
|
# defaults to QWERTY keyboard layout
|
14
|
-
|
14
|
+
@modifiers = {
|
15
|
+
62 => :shift, # right control
|
16
|
+
37 => :ctrl, # left control
|
17
|
+
50 => :shift, # left shift
|
18
|
+
64 => :alt, # alt shift
|
19
|
+
92 => :alt, # right alt
|
20
|
+
105 => :ctrl, # right control
|
21
|
+
133 => :super, # left super (windows key)
|
22
|
+
134 => :super # right super (windows key)
|
23
|
+
}
|
15
24
|
@lookup = {
|
16
25
|
10=>:"1", 11=>:"2", 12=>:"3", 13=>:"4", 14=>:"5", 15=>:"6", 16=>:"7",
|
17
26
|
17=>:"8", 18=>:"9", 19=>:"0", 20=>:-, 21=>:"=", 22=>:backspace,
|
18
27
|
23=>:tab, 24=>:q, 25=>:w, 26=>:e, 27=>:r, 28=>:t, 29=>:y, 30=>:u,
|
19
|
-
31=>:i, 32=>:o, 33=>:p, 34=>:"[", 35=>:"]", 36
|
28
|
+
31=>:i, 32=>:o, 33=>:p, 34=>:"[", 35=>:"]", 36=>:enter, 38=>:a, 39=>:s,
|
20
29
|
40=>:d, 41=>:f, 42=>:g, 43=>:h, 44=>:j, 45=>:k, 46=>:l, 47=>:";",
|
21
30
|
48=>:"'", 49=>nil, 52=>:z, 53=>:x, 54=>:c, 55=>:v, 56=>:b, 57=>:n,
|
22
|
-
58=>:m, 59=>:",", 60=>:".", 61=>:/,
|
31
|
+
58=>:m, 59=>:",", 60=>:".", 61=>:/, 65=>:" ",
|
23
32
|
9 => :escape,
|
24
|
-
37 => :control,
|
25
|
-
50 => :left_shift,
|
26
|
-
64 => :left_alt,
|
27
33
|
66 => :capslock,
|
28
34
|
67 => :f1,
|
29
35
|
68 => :f2,
|
@@ -37,10 +43,8 @@ class XInputWrapper
|
|
37
43
|
76 => :f10,
|
38
44
|
77 => :numlock,
|
39
45
|
78 => :scroll_lock,
|
40
|
-
92 => :right_alt,
|
41
46
|
95 => :f11,
|
42
47
|
96 => :f12,
|
43
|
-
105 => :control,
|
44
48
|
107 => :print_screen,
|
45
49
|
110 => :home,
|
46
50
|
111 => :up_arrow,
|
@@ -54,8 +58,6 @@ class XInputWrapper
|
|
54
58
|
122 => :vol_down,
|
55
59
|
123 => :vol_up,
|
56
60
|
127 => :pause_break,
|
57
|
-
133 => :super,
|
58
|
-
134 => :super,
|
59
61
|
135 => :submenu,
|
60
62
|
148 => :calc,
|
61
63
|
150 => :sleep,
|
@@ -69,7 +71,7 @@ class XInputWrapper
|
|
69
71
|
174 => :stop,
|
70
72
|
179 => :music,
|
71
73
|
180 => :browser
|
72
|
-
}.merge(lookup)
|
74
|
+
}.merge(@modifiers).merge(lookup)
|
73
75
|
|
74
76
|
@device, @verbose, @debug = device, verbose, debug
|
75
77
|
|
@@ -80,6 +82,7 @@ class XInputWrapper
|
|
80
82
|
command = "xinput test-xi2 --root #{@device}"
|
81
83
|
|
82
84
|
type = 0
|
85
|
+
raw_keys = []
|
83
86
|
|
84
87
|
IO.popen(command).each_line do |x|
|
85
88
|
|
@@ -87,29 +90,52 @@ class XInputWrapper
|
|
87
90
|
raw_type = x[/EVENT type (\d+)/,1]
|
88
91
|
|
89
92
|
type = raw_type.to_i unless raw_type.nil?
|
90
|
-
|
93
|
+
next unless type == 13 or type == 14
|
94
|
+
|
95
|
+
keycode = x[/detail: (\d+)/,1].to_i
|
96
|
+
next if keycode == 0
|
97
|
+
|
91
98
|
# type = 13 means a key has been pressed
|
92
99
|
if type == 13 then
|
100
|
+
|
101
|
+
raw_keys << keycode
|
93
102
|
|
94
|
-
|
95
|
-
next if keycode == 0
|
103
|
+
puts 'raw_keys: ' + raw_keys.inspect if @debug
|
96
104
|
|
97
|
-
|
98
|
-
|
105
|
+
if raw_keys.length <= 1 then
|
106
|
+
puts 'keycode: ' + keycode.to_s if keycode > 0 and @verbose
|
107
|
+
puts ('>keycode: ' + keycode.to_s).debug if @debug
|
108
|
+
|
109
|
+
key = @lookup[keycode]
|
110
|
+
|
99
111
|
|
100
|
-
key = @lookup[keycode]
|
101
|
-
on_key_press(key, keycode)
|
102
112
|
|
113
|
+
puts ('key: ' + key.inspect).debug if @debug
|
103
114
|
|
104
|
-
|
115
|
+
if key then
|
116
|
+
puts key.to_s + ' key presssed' if @verbose
|
117
|
+
name = "on_#{key}_key".to_sym
|
118
|
+
method(name).call if self.protected_methods.include? name
|
119
|
+
on_key_press key, keycode
|
120
|
+
end
|
121
|
+
|
122
|
+
else
|
123
|
+
|
124
|
+
keys = raw_keys.map {|kc| @lookup[kc] }
|
125
|
+
puts ('keys: ' + keys.inspect) if @debug
|
126
|
+
on_key_press(keys.last, keycode, keys[0..-2])
|
127
|
+
|
128
|
+
end
|
129
|
+
|
105
130
|
|
106
|
-
if key then
|
107
|
-
puts key.to_s + ' key presssed' if @verbose
|
108
|
-
name = "on_#{key}_key".to_sym
|
109
|
-
method(name).call if self.protected_methods.include? name
|
110
|
-
end
|
111
131
|
|
112
|
-
|
132
|
+
elsif type == 14
|
133
|
+
|
134
|
+
index = raw_keys.rindex(keycode)
|
135
|
+
raw_keys.delete_at index if index
|
136
|
+
|
137
|
+
end
|
138
|
+
|
113
139
|
end
|
114
140
|
end
|
115
141
|
|
@@ -118,7 +144,14 @@ class XInputWrapper
|
|
118
144
|
def on_control_key()
|
119
145
|
puts 'ctrl key pressed'
|
120
146
|
end
|
121
|
-
|
147
|
+
|
148
|
+
def on_key_press(key, keycode, modifier)
|
149
|
+
|
150
|
+
if @debug then
|
151
|
+
puts ('key: ' + key.inspect).debug
|
152
|
+
end
|
153
|
+
|
154
|
+
end
|
122
155
|
|
123
156
|
def on_shift_key() end
|
124
157
|
def on_super_key() end
|
@@ -147,3 +180,4 @@ class XInputWrapper
|
|
147
180
|
|
148
181
|
end
|
149
182
|
|
183
|
+
# puts h.sort.map {|x| "%s => :%s" % x}.join(",\n")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xinput_wrapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
rryowfoo6nLmegcIZjm+zz/gkT/0udwMMVm2gwo0bIRQuQOLmd7IUNzYQKZQOGMA
|
36
36
|
g4ETbI8IEC3VCaoECdunsS3t
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2019-
|
38
|
+
date: 2019-04-07 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: c32
|
metadata.gz.sig
CHANGED
Binary file
|