Class: XInputWrapperPlus

Inherits:
XInputWrapper
  • Object
show all
Defined in:
lib/xinput_wrapperplus.rb

Instance Method Summary collapse

Constructor Details

#initialize(host: 'sps', port: '59000', topic: 'input', verbose: true, lookup: {}, debug: false, capture_all: false, keys: [], keypress_detection: true, motion_detection: true, window_context: false) ⇒ XInputWrapperPlus

Returns a new instance of XInputWrapperPlus.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/xinput_wrapperplus.rb', line 13

def initialize(host: 'sps', port: '59000', 
               topic: 'input', verbose: true, lookup: {}, 
               debug: false, capture_all: false, keys: [], 
               keypress_detection: true, motion_detection: true, 
               window_context: false)

  puts 'before super'
  super(verbose: verbose, lookup: lookup, 
        debug: debug, keys: keys)
  puts 'after super'
  
  @topic, @capture_all = topic, capture_all
  @keypress_detection = keypress_detection
  @motion_detection = motion_detection
  @window_context = window_context

  @sps = SPSPub.new host: host, port: port

  @sk = SecretKnock.new short_delay: 0.25, long_delay: 0.5, 
                            external: self, verbose: verbose, debug: debug
  @sk.detect timeout: 0.7
  @interval = 120

  @a = [] # Used to store mouse gestures
  @timer, @t2 = nil , Time.now - @interval

end

Instance Method Details

#knockObject



41
42
43
# File 'lib/xinput_wrapperplus.rb', line 41

def knock()
  puts 'knock' if @verbose
end

#message(msg, subtopic = :keyboard) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/xinput_wrapperplus.rb', line 45

def message(msg, subtopic=:keyboard)
  
  puts ':: ' + msg.inspect if @verbose        
  
  return if msg.strip.empty?
  
  topic = [@topic, subtopic].compact.join('/')
  
  if @window_context then      

    wm = WMCtrl.display
    win = wm.windows.find {|x| x.active}
    
    @sps.notice "%s: %s in %s" % [topic, msg, win.title]
    
  else
    
    @sps.notice "%s: %s" % [topic, msg]
    
  end
  
end