Class: Gyruby::Remote
- Inherits:
-
Object
- Object
- Gyruby::Remote
- Defined in:
- lib/gyruby/remote.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize ⇒ Remote
constructor
A new instance of Remote.
- #listen ⇒ Object
- #record(&block) ⇒ Object
- #subscribe(button, release = false, frequency = 10, &block) ⇒ Object
Constructor Details
#initialize ⇒ Remote
Returns a new instance of Remote.
22 23 24 25 26 27 |
# File 'lib/gyruby/remote.rb', line 22 def initialize = {} = {} = {} @listening = false end |
Instance Method Details
#listen ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/gyruby/remote.rb', line 52 def listen claim_device unless claimed_device? loop do handle_usb_event if claimed_device? handle_mouse_event if grabbed_mouse? sleep(0.001) end end |
#record(&block) ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/gyruby/remote.rb', line 43 def record(&block) claim_device unless claimed_device? loop do event = fetch_usb_event yield event unless event.nil? sleep(0.001) end end |
#subscribe(button, release = false, frequency = 10, &block) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/gyruby/remote.rb', line 29 def subscribe(, release = false, frequency = 10, &block) if release [] = { :action => :press, :block => block, :frequency => frequency, :last => nil } [release] = {:action => :release, :press => } else [] = block end end |