xinput_wrapper 0.5.1 → 0.6.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: 8f4e856f73b9e7dd55af1a5b49118539aa67816d22efedb6e0a413628d7eef55
4
- data.tar.gz: d38a486aca20bfe0a41f20236f0ec998d7216c4dc78c00fda115f03a85247029
3
+ metadata.gz: 9e4522c710fedfbd87d06378e9e3833ac5c1ed33ea8f39b2f7626b028c81e787
4
+ data.tar.gz: a5cabb6c182af563bb98dc1dce22b56ddda54c22552ac0a20b2e0b9e83b90f3e
5
5
  SHA512:
6
- metadata.gz: 4df624c748de48612aebc920ad2e9788159570ba294f70113dfe6fcc528db7716cdbafa11230e4e087bde2e4cee1d71e68ae426f48c1b486c1ba7cf491e03742
7
- data.tar.gz: 5edec0ee6f3df041053db4a1289ea032b8094da8541b997c1758dcb81cc14d1973521c7f2d1c67b77e8ee72ed6927b96f5c740932cf7d6cedec499ba23c7b791
6
+ metadata.gz: d824a72ef9e9752631513d260204c81e397036e5e1c99822c2ea95a02375f059191cc89021e9999ef52db4d969b2a65ff85f5fbc6fa0344cf4a0d48cf26314a7
7
+ data.tar.gz: 6d9528dd576ba565fec74bcf2d305304a882785b336d8e85b2b44df657b697a0cd3ee45c4fb914e1b0a4d2587b3075b5d3bc2d37edb0267995bf4df65edd76e6
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -5,6 +5,11 @@
5
5
  require 'c32'
6
6
 
7
7
 
8
+ MOTION = 6
9
+ RAWKEY_PRESS = 13
10
+ RAWKEY_RELEASE = 14
11
+
12
+
8
13
  class XInputWrapper
9
14
  using ColouredText
10
15
 
@@ -83,20 +88,73 @@ class XInputWrapper
83
88
 
84
89
  type = 0
85
90
  raw_keys = []
91
+ t1 = Time.now
92
+ lines = []
86
93
 
87
94
  IO.popen(command).each_line do |x|
88
95
 
89
96
  #print "GOT ", x
90
- raw_type = x[/EVENT type (\d+)/,1]
97
+ if x[/EVENT type \d \(Motion\)/] and (Time.now > (t1 + 0.06125)) then
98
+
99
+ type = x[/EVENT type (\d+)/,1].to_i
100
+
101
+ r = lines.join[/^\s+root: (\d+\.\d{2}\/\d+\.\d{2})/,1]
102
+
103
+ if r then
104
+
105
+ x1, y1 = r.split('/').map(&:to_f)
106
+ puts "x1: %s y1: %s" % [x1, y1] if @debug
107
+ on_mousemove(x1, y1)
108
+ t1 = Time.now
109
+
110
+ end
111
+
112
+ lines = [x]
113
+
114
+ elsif x[/EVENT type \d+ \(RawKey(?:Release|Press)\)/]
115
+
116
+ type = x[/EVENT type (\d+)/,1].to_i
117
+
118
+ lines = [x]
119
+
120
+ elsif type == MOTION or type == RAWKEY_PRESS or type == RAWKEY_RELEASE
121
+
122
+ lines << x
123
+
124
+ if x == "\n" then
125
+ case lines.first[/(?<=EVENT type )\d+/].to_i
126
+ when RAWKEY_PRESS
127
+
128
+ r = lines.join[/detail: (\d+)/,1]
129
+
130
+ keycode = r.to_i if r
91
131
 
92
- type = raw_type.to_i unless raw_type.nil?
93
- next unless type == 13 or type == 14
132
+ type = lines.join[/EVENT type (\d+)/,1] .to_i
133
+
134
+ when RAWKEY_RELEASE
135
+
136
+ r = lines.join[/detail: (\d+)/,1]
137
+
138
+ keycode = r.to_i if r
139
+
140
+ type = lines.join[/EVENT type (\d+)/,1] .to_i
141
+
142
+ end
143
+
144
+
145
+ else
146
+ next
147
+ end
148
+
149
+ else
150
+ next
151
+ end
94
152
 
95
- keycode = x[/detail: (\d+)/,1].to_i
96
- next if keycode == 0
153
+ next unless keycode
154
+ puts 'keycode: ' + keycode.inspect if @debug
97
155
 
98
156
  # type = 13 means a key has been pressed
99
- if type == 13 then
157
+ if type == RAWKEY_PRESS then
100
158
 
101
159
  if @modifiers.include? raw_keys.last or @modifiers.include? keycode then
102
160
  raw_keys << keycode
@@ -145,7 +203,7 @@ class XInputWrapper
145
203
 
146
204
 
147
205
  # a key has been released
148
- elsif type == 14
206
+ elsif type == RAWKEY_RELEASE
149
207
 
150
208
  # here we are only looking to detect a
151
209
  # single modifier key press and release
@@ -187,6 +245,14 @@ class XInputWrapper
187
245
  end
188
246
 
189
247
  end
248
+
249
+ def on_mousemove(x,y)
250
+
251
+ if @debug then
252
+ puts "on_mousemove() x: %s y: %s" % [x, y]
253
+ end
254
+
255
+ end
190
256
 
191
257
  def on_shift_key() end
192
258
  def on_super_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.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,28 +35,28 @@ cert_chain:
35
35
  rryowfoo6nLmegcIZjm+zz/gkT/0udwMMVm2gwo0bIRQuQOLmd7IUNzYQKZQOGMA
36
36
  g4ETbI8IEC3VCaoECdunsS3t
37
37
  -----END CERTIFICATE-----
38
- date: 2019-04-08 00:00:00.000000000 Z
38
+ date: 2019-05-08 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: c32
42
42
  requirement: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - "~>"
45
- - !ruby/object:Gem::Version
46
- version: '0.1'
47
44
  - - ">="
48
45
  - !ruby/object:Gem::Version
49
- version: 0.1.2
46
+ version: 0.2.0
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '0.2'
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
- - - "~>"
55
- - !ruby/object:Gem::Version
56
- version: '0.1'
57
54
  - - ">="
58
55
  - !ruby/object:Gem::Version
59
- version: 0.1.2
56
+ version: 0.2.0
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '0.2'
60
60
  description:
61
61
  email: james@jamesrobertson.eu
62
62
  executables: []
metadata.gz.sig CHANGED
Binary file