Class: Tamashii::Agent::KeyboardLogger

Inherits:
Component
  • Object
show all
Defined in:
lib/tamashii/agent/keyboard_logger.rb

Instance Method Summary collapse

Methods inherited from Component

#check_new_event, #display_name, #get_device_instance, #handle_new_event, #initialize_device, #load_default_device, #restart_current_component_async, #run, #run!, #run_worker_loop, #send_event, #stop, #stop_threads, #worker_loop

Methods included from Common::Loggable

#display_name, #logger, #progname

Constructor Details

#initialize(name, master, options = {}) ⇒ KeyboardLogger

Returns a new instance of KeyboardLogger.



7
8
9
10
11
12
13
14
15
# File 'lib/tamashii/agent/keyboard_logger.rb', line 7

def initialize(name, master, options = {})
  options[:watch] = true # Force enable watch mode
  super
  @kb = initialize_device
  @kb.on_key_down do |key|
    logger.debug "Key down: #{key+1}"
    @master.send_event(Event.new(Event::LCD_MESSAGE, "Key pressed: #{key+1} "))
  end
end

Instance Method Details

#clean_upObject



30
31
32
33
# File 'lib/tamashii/agent/keyboard_logger.rb', line 30

def clean_up
  super
  @kb.shutdown
end

#default_device_nameObject



17
18
19
# File 'lib/tamashii/agent/keyboard_logger.rb', line 17

def default_device_name
  'Dummy'
end

#get_device_class_name(device_name) ⇒ Object



21
22
23
# File 'lib/tamashii/agent/keyboard_logger.rb', line 21

def get_device_class_name(device_name)
  "Keyboard::#{device_name}"
end

#process_event(event) ⇒ Object

override



26
27
28
# File 'lib/tamashii/agent/keyboard_logger.rb', line 26

def process_event(event)
  # silent is gold
end