Sha256: 748e88159d4b2247e8fea0a60153282601d120cb209ad92e7272b453097dbee2

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

require 'pi_piper'
require 'tamashii/agent/device/keyboard/base'

module Tamashii
  module Agent
    module Device
      module Keyboard
        class Dummy < Base
          def initialize_hardware
            @last_report = Time.now
            logger.debug "Initialized"
          end
          
          def finalize_hardware
            logger.debug "Finalized"
          end
          
          def default_number_of_keys
            8
          end

          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
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tamashii-agent-0.4.0 lib/tamashii/agent/device/keyboard/dummy.rb
tamashii-agent-0.3.4 lib/tamashii/agent/device/keyboard/dummy.rb
tamashii-agent-0.3.3 lib/tamashii/agent/device/keyboard/dummy.rb