xinput_wrapper 0.1.3 → 0.2.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
  SHA1:
3
- metadata.gz: d2487ccda5f3bb7af5fa098b2e521edf98c7d1e4
4
- data.tar.gz: d8c547a5da867932cc4cf8611bb2efb0e1d59dbe
3
+ metadata.gz: b6e1b5f2e6105f33b76431173f63596ae7e96461
4
+ data.tar.gz: 19ff16d496d5f940ae43fe37d839ae84b6dfbe50
5
5
  SHA512:
6
- metadata.gz: 37f5a0d2175879a3797bfc7b4bccf4070982b08cb01c99d73da62ea1b7ca1ee93a597ff1a43fe5a463d09110a0db6b210a36903030f0cda9ad3f54f07052b711
7
- data.tar.gz: 9a3efa111712126a516d19220d31254e259536079ecf474ffea5a160161de59c2cc616de83eb376f5345d4055712c6f3359b42ab65fa391cb47a0e931042e187
6
+ metadata.gz: bf611312a0c7b010621c6b3505afce6816370798f92f069e3d76eb60635610e38e9a1ce9b3753d112fe9816f9096a8603325f4cfb66b0701532dc70e3b83fc1b
7
+ data.tar.gz: 9af14598e6af1c75d4c22d610c7a6c950480eb27e81e4513da42a5e4020e50e81cbf6c3f181ad0a475b57f39eec46451bf2d8fa51e4519e40316102be0badc7a
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -3,49 +3,40 @@
3
3
  # file: xinput_wrapper.rb
4
4
 
5
5
 
6
- require 'sps-pub'
7
- require 'secret_knock'
8
-
9
6
 
10
7
  class XInputWrapper
11
8
 
12
- def initialize(device: '3', host: 'sps', port: '59000',
13
- topic: 'input/keyboard', verbose: true, lookup: {},
14
- interval: nil, debug: false)
9
+ def initialize(device: '3', verbose: true, lookup: {}, debug: false )
15
10
 
16
11
  @lookup = {
17
- 37 => :control,
18
- 50 => :lshift,
19
- 133 => :super
12
+ 37 => :control,
13
+ 50 => :shift,
14
+ 62 => :shift,
15
+ 67 => :f1,
16
+ 68 => :f2,
17
+ 69 => :f3,
18
+ 70 => :f4,
19
+ 71 => :f5,
20
+ 72 => :f6,
21
+ 73 => :f7,
22
+ 74 => :f8,
23
+ 75 => :f9,
24
+ 76 => :f10,
25
+ 95 => :f11,
26
+ 96 => :f12,
27
+ 105 => :control,
28
+ 133 => :super,
29
+ 134 => :super
20
30
  }.merge(lookup)
21
-
22
- @device, @topic, @verbose, @debug = device, topic, verbose, debug
23
- @sps = SPSPub.new host: host, port: port
24
- @sk = SecretKnock.new short_delay: 0.25, long_delay: 0.5,
25
- external: self, verbose: verbose, debug: debug
26
- @interval = interval
27
- @time = Time.now if interval
28
-
29
- end
30
-
31
- def knock()
32
- puts 'knock' if @verbose
33
- end
34
-
35
- def message(msg)
36
31
 
37
- puts ':: ' + msg.inspect if @verbose
32
+ @device, @verbose, @debug = device, verbose, debug
38
33
 
39
- return if msg.strip.empty?
40
-
41
- @sps.notice "%s: %s" % [@topic, msg]
42
34
  end
43
35
 
44
36
  def listen()
45
37
 
46
38
  command = "xinput test-xi2 --root #{@device}"
47
- @sk.detect timeout: 0.7
48
- sk = @sk
39
+
49
40
  type = 0
50
41
 
51
42
  IO.popen(command).each_line do |x|
@@ -64,28 +55,39 @@ class XInputWrapper
64
55
  puts 'keycode: ' + keycode.to_s if keycode > 0 and @verbose
65
56
  puts '>keycode: ' + keycode.to_s if @debug
66
57
 
67
- if @interval then
68
-
69
- if Time.now > @time + @interval then
70
- @sps.notice "%s: key pressed" % [@topic]
71
- @time = Time.now
72
- end
73
- end
74
-
75
- case @lookup[keycode]
76
- when :lshift
77
- puts 'left shift' if @verbose
78
- when :control
79
- puts 'control' if @verbose
80
- sk.knock
81
- when :super
82
- puts 'super key pressed' if @verbose
83
- message 'super key pressed'
84
- end
85
-
86
- sk.reset if @lookup[keycode] != :control
58
+ on_key_press(keycode)
59
+
60
+ key = @lookup[keycode]
61
+ puts 'key: ' + key.inspect if @debug
62
+
63
+ if key then
64
+ puts key.to_s + ' key presssed' if @verbose
65
+ method("on_#{key}_key".to_sym).call
66
+ end
87
67
 
88
68
  end
89
69
  end
90
70
  end
71
+
72
+ protected
73
+
74
+ def on_control_key() end
75
+ def on_key_press(keycode) end
76
+
77
+ def on_shift_key() end
78
+ def on_super_key() end
79
+
80
+ def on_f1_key() end
81
+ def on_f2_key() end
82
+ def on_f3_key() end
83
+ def on_f4_key() end
84
+ def on_f5_key() end
85
+ def on_f6_key() end
86
+ def on_f7_key() end
87
+ def on_f8_key() end
88
+ def on_f9_key() end
89
+ def on_f10_key() end
90
+ def on_f11_key() end
91
+ def on_f12_key() end
92
+
91
93
  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.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -32,47 +32,7 @@ cert_chain:
32
32
  5bdH23akkNF4CA==
33
33
  -----END CERTIFICATE-----
34
34
  date: 2018-08-05 00:00:00.000000000 Z
35
- dependencies:
36
- - !ruby/object:Gem::Dependency
37
- name: sps-pub
38
- requirement: !ruby/object:Gem::Requirement
39
- requirements:
40
- - - "~>"
41
- - !ruby/object:Gem::Version
42
- version: '0.5'
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- version: 0.5.5
46
- type: :runtime
47
- prerelease: false
48
- version_requirements: !ruby/object:Gem::Requirement
49
- requirements:
50
- - - "~>"
51
- - !ruby/object:Gem::Version
52
- version: '0.5'
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- version: 0.5.5
56
- - !ruby/object:Gem::Dependency
57
- name: secret_knock
58
- requirement: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - "~>"
61
- - !ruby/object:Gem::Version
62
- version: '0.3'
63
- - - ">="
64
- - !ruby/object:Gem::Version
65
- version: 0.3.0
66
- type: :runtime
67
- prerelease: false
68
- version_requirements: !ruby/object:Gem::Requirement
69
- requirements:
70
- - - "~>"
71
- - !ruby/object:Gem::Version
72
- version: '0.3'
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: 0.3.0
35
+ dependencies: []
76
36
  description:
77
37
  email: james@jamesrobertson.eu
78
38
  executables: []
@@ -103,7 +63,5 @@ rubyforge_project:
103
63
  rubygems_version: 2.6.13
104
64
  signing_key:
105
65
  specification_version: 4
106
- summary: A wrapper for the Linux utility xinput. Publishes an SPS message whenever
107
- the super key is pressed as well as publishing a deciphered message when the control
108
- key is pressed more than once
66
+ summary: A wrapper for the Linux utility xinput.
109
67
  test_files: []
metadata.gz.sig CHANGED
Binary file