xinput_wrapper 0.4.1 → 0.5.0

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
  SHA256:
3
- metadata.gz: a65e18160d628995917a2edbe88191d9af2463d392e323d73be0c9d18125bb1e
4
- data.tar.gz: a64ca44e47e455dc7e164ad3a07a0d45b9f0287ef5edc3d8ea718110af589755
3
+ metadata.gz: bd5d3382f535c9b0cc5fd6def2b5b7bad34237f9eb2e602fef6c9ed21d59e107
4
+ data.tar.gz: fe866a13173f38b75027676b7583470c6d350527f1d1fd0eccd978d135fb8e93
5
5
  SHA512:
6
- metadata.gz: e5dbaa2fbe33f068c910f5e3b81585541487b0cca4dd8fd84599705754010727c10024e8be94de12694a576e1c794ebd9350336782c404e2f9b9694753ac81ff
7
- data.tar.gz: 3a438de9f271059e494d7d39ffb1d9ed6d51247e7795033be4534aa9596da1f79719c7f92d30a3b4d9fda0bfe38cbd6a0140689b48fdf9828bcd7ddd27496abb
6
+ metadata.gz: 4cfc590d0eab22723afe694344a339cf24b7d08989f73c270a6106320806db47442c23607b3f8afd2b1fa63d8a7f79f48fde3c86c4fc6e32cbee60beb06dc4ff
7
+ data.tar.gz: 767186f2fde2a191249cea820d6eb6887d32691917b4fe48954be4f3034c56923b5a26a52fe64bb3cc79eeaf30bbeeeaa725d3b88e2bad65fbe57d290633ab22
@@ -1,3 +1 @@
1
- ��rʡ�rN~����`Rߊ�n.MK�&�ce��R���G:��C����zd�����ê�� I�%�ɝf����A�����#�4Y��3��&[3�-u髯'�Y�9oۏEЕWdQ{mĉ
2
- ��Zw�FA���p<w�n�ln�@Ŏ��:�tԉ��]�4��ge'?�J�N�Zŕ~����w;N�E�f{d��@���n�k�d����"���A�gZ �[�w0_�ŋ�?2ߟ��MeC�;x�s�|E&͚�����=�l������A�P�o�y�^@��>?�~z���_��iLG� ��F�Hk!҃�
3
- 1�S��_f�����#Ź�.sr��)e����̀V��ۛe�؃ϑ�sV{K��� �'Ǘ���G
1
+ ZR�ҘeT�jZE�(��ky� &�&0Kj3�տ"��9��.ü�%��3u��m�ޘ0����{ҿ,#�ZC>R#�z!�I�5.� isL=ad�k����L��.N�6^�A��,���Ő�L��Y��� ����t����BW��jYۨ\~Mra/���?�����T�� n
data.tar.gz.sig CHANGED
Binary file
@@ -98,7 +98,11 @@ class XInputWrapper
98
98
  # type = 13 means a key has been pressed
99
99
  if type == 13 then
100
100
 
101
- raw_keys << keycode
101
+ if @modifiers.include? raw_keys.last or @modifiers.include? keycode then
102
+ raw_keys << keycode
103
+ end
104
+
105
+ next if @modifiers.include? keycode
102
106
 
103
107
  puts 'raw_keys: ' + raw_keys.inspect if @debug
104
108
 
@@ -113,26 +117,55 @@ class XInputWrapper
113
117
  puts ('key: ' + key.inspect).debug if @debug
114
118
 
115
119
  if key then
120
+
116
121
  puts key.to_s + ' key presssed' if @verbose
117
122
  name = "on_#{key}_key".to_sym
118
123
  method(name).call if self.protected_methods.include? name
119
124
 
120
- keystring = ((key.length > 1 or key == ' ') ? "{%s}" % key : key)
121
- on_key_press keystring, keycode
125
+ keystring = ((key.length > 1 or key == ' ') ? "{%s}" % key : key)
126
+ block_given? ? yield(keystring) : on_key_press(keystring, keycode)
127
+
122
128
  end
123
129
 
124
130
  else
125
131
 
126
132
  keys = raw_keys.map {|kc| @lookup[kc] }
127
133
  puts ('keys: ' + keys.inspect) if @debug
128
- on_key_press(keys.last, keycode, keys[0..-2])
134
+
135
+ if block_given? then
136
+ yield(format_key(keys.last, keys[0..-2]))
137
+ else
138
+ on_key_press(keys.last, keycode, keys[0..-2])
139
+ end
140
+
141
+ raw_keys = []
129
142
 
130
143
  end
131
144
 
132
145
 
133
146
 
147
+ # a key has been released
134
148
  elsif type == 14
135
149
 
150
+ # here we are only looking to detect a
151
+ # single modifier key press and release
152
+
153
+ key = @lookup[keycode]
154
+
155
+ unless raw_keys.empty? then
156
+ puts key.to_s + ' key presssed'
157
+
158
+ if block_given? then
159
+
160
+ yield(format_key(key.to_s))
161
+
162
+ else
163
+ name = "on_#{key}_key".to_sym
164
+ method(name).call if self.protected_methods.include? name
165
+ on_key_press(key, keycode)
166
+ end
167
+ end
168
+
136
169
  index = raw_keys.rindex(keycode)
137
170
  raw_keys.delete_at index if index
138
171
 
@@ -173,6 +206,13 @@ class XInputWrapper
173
206
 
174
207
  private
175
208
 
209
+ def format_key(key, modifier=[])
210
+
211
+ modifier.any? ? "{%s}" % (modifier + [key.to_s]).join('+') \
212
+ : key.to_s
213
+
214
+ end
215
+
176
216
  def on_leftcontrol_key() on_control_key() end
177
217
  def on_rightcontrol_key() on_control_key() end
178
218
  def on_left_alt_key() on_alt_key() end
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.1
4
+ version: 0.5.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-04-07 00:00:00.000000000 Z
38
+ date: 2019-04-08 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: c32
metadata.gz.sig CHANGED
Binary file