Class: Tamashii::Agent::Device::Keyboard::Dummy

Inherits:
Base show all
Defined in:
lib/tamashii/agent/device/keyboard/dummy.rb

Instance Method Summary collapse

Methods inherited from Base

#add_callback, #default_watch, #initialize, #initialize_watcher, #mark_key_down, #mark_key_up, #number_of_keys, #on_key_down, #on_key_pressed, #on_key_up, #poll_key, #polling_interval, #process_callbacks, #record_key_state, #shutdown, #start_watcher_thread, #stop_watcher_thread, #watcher_loop, #watcher_stopping?

Methods inherited from DeviceBase

#fetch_option, #fetch_option!, #initialize, #shutdown, #unexport_pin

Methods included from Common::Loggable

#display_name, #logger, #progname

Constructor Details

This class inherits a constructor from Tamashii::Agent::Device::Keyboard::Base

Instance Method Details

#default_number_of_keysObject



18
19
20
# File 'lib/tamashii/agent/device/keyboard/dummy.rb', line 18

def default_number_of_keys
  8
end

#finalize_hardwareObject



14
15
16
# File 'lib/tamashii/agent/device/keyboard/dummy.rb', line 14

def finalize_hardware
  logger.debug "Finalized"
end

#initialize_hardwareObject



9
10
11
12
# File 'lib/tamashii/agent/device/keyboard/dummy.rb', line 9

def initialize_hardware
  @last_report = Time.now
  logger.debug "Initialized"
end

#read_keyObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/tamashii/agent/device/keyboard/dummy.rb', line 22

def read_key
  if (Time.now - @last_report) > (3 + rand)
    @last_report = Time.now
    key = rand(@number_of_keys)
    logger.debug "Fake key generated: #{key}"
    @number_of_keys.times do |testing_key|
      if testing_key == key
        mark_key_down(testing_key)
      else
        mark_key_up(testing_key)
      end
    end
    return key
  else
    return nil
  end
end