Class: Vigilem::Win32API::DOM::Adapter

Inherits:
Object
  • Object
show all
Includes:
Core::Adapters::BufferedAdapter, Core::EventHandler, Core::Eventable, InputRecordUtils
Defined in:
lib/vigilem/win32_api/dom/adapter.rb

Constant Summary

Constants included from InputRecordUtils

InputRecordUtils::NULL_STR, InputRecordUtils::UNKNOWN_VAL

Constants included from VirtualKeys

VirtualKeys::Map, VirtualKeys::VK

Constants included from CodeValuesTables

CodeValuesTables::ArrowPadSection, CodeValuesTables::ControlPadSection, CodeValuesTables::FunctionSection, CodeValuesTables::FunctionalKeys, CodeValuesTables::LegacyKeysandNon_StandardKeys, CodeValuesTables::MediaKeys, CodeValuesTables::NumpadSection, CodeValuesTables::WritingSystemKeys

Constants included from Constants

Constants::BACKGROUND_BLUE, Constants::BACKGROUND_GREEN, Constants::BACKGROUND_INTENSITY, Constants::BACKGROUND_RED, Constants::CONSOLE_TEXTMODE_BUFFER, Constants::DOUBLE_CLICK, Constants::ENABLE_ECHO_INPUT, Constants::ENABLE_LINE_INPUT, Constants::ENABLE_MOUSE_INPUT, Constants::ENABLE_PROCESSED_INPUT, Constants::ENABLE_PROCESSED_OUTPUT, Constants::ENABLE_WINDOW_INPUT, Constants::ENABLE_WRAP_AT_EOL_OUTPUT, Constants::FILE_SHARE_READ, Constants::FILE_SHARE_WRITE, Constants::FOREGROUND_BLUE, Constants::FOREGROUND_GREEN, Constants::FOREGROUND_INTENSITY, Constants::FOREGROUND_RED, Constants::FROM_LEFT_1ST_BUTTON_PRESSED, Constants::FROM_LEFT_2ND_BUTTON_PRESSED, Constants::FROM_LEFT_3RD_BUTTON_PRESSED, Constants::FROM_LEFT_4TH_BUTTON_PRESSED, Constants::GENERIC_READ, Constants::GENERIC_WRITE, Constants::INVALID_HANDLE_VALUE, Constants::MOUSE_MOVED, Constants::MOUSE_WHEELED, Constants::MapVK, Constants::RIGHTMOST_BUTTON_PRESSED, Constants::STD_ERROR_HANDLE, Constants::STD_INPUT_HANDLE, Constants::STD_OUTPUT_HANDLE

Constants included from Constants::MapType

Constants::MapType::MAPVK, Constants::MapType::MAPVK_VK_TO_CHAR, Constants::MapType::MAPVK_VK_TO_VSC, Constants::MapType::MAPVK_VSC_TO_VK, Constants::MapType::MAPVK_VSC_TO_VK_EX

Constants included from Constants::Events

Constants::Events::CTRL_BREAK_EVENT, Constants::Events::CTRL_CLOSE_EVENT, Constants::Events::CTRL_C_EVENT, Constants::Events::CTRL_LOGOFF_EVENT, Constants::Events::CTRL_SHUTDOWN_EVENT, Constants::Events::FOCUS_EVENT, Constants::Events::KEY_EVENT, Constants::Events::MENU_EVENT, Constants::Events::MOUSE_EVENT, Constants::Events::WINDOW_BUFFER_SIZE_EVENT

Constants included from Constants::DWControlKeys

Constants::DWControlKeys::CAPSLOCK_ON, Constants::DWControlKeys::ENHANCED_KEY, Constants::DWControlKeys::LEFT_ALT_PRESSED, Constants::DWControlKeys::LEFT_CTRL_PRESSED, Constants::DWControlKeys::NUMLOCK_ON, Constants::DWControlKeys::RIGHT_ALT_PRESSED, Constants::DWControlKeys::RIGHT_CTRL_PRESSED, Constants::DWControlKeys::SCROLLLOCK_ON, Constants::DWControlKeys::SHIFT_PRESSED

Instance Method Summary collapse

Methods included from InputRecordUtils

#current_keys, #dom_code, #dom_key, #dom_location, #dom_modifiers, #dw_control_key_state_vks, empty_or_null?, flip_lr_sides, #location_less_vks_map, lr_location_from_name, #lr_not_in_name, #lr_not_in_name!, #shift_scan_code_to_location_vk, #to_dom_key_event, #vk_without_location_info?

Methods included from Utils::Keyboard::ControlPadKeys

#control_pad_key?

Methods included from Utils::Keyboard::NavigationKeys

#arrow_key?, #nav_arrow_key?, #nav_control_key?

Methods included from Utils::Keyboard::NumpadKeys

#numlock?, #numpad?, #numpad_arrow?, #numpad_control_key?, #numpad_number_function?, #numpad_return?

Constructor Details

#initialize(link = InputSystemHandler.new) ⇒ Adapter

Returns a new instance of Adapter.

Parameters:

  • link (defaults to: InputSystemHandler.new)


28
29
30
31
32
# File 'lib/vigilem/win32_api/dom/adapter.rb', line 28

def initialize(link=InputSystemHandler.new)
  initialize_buffered(link)
  self.dom_ir_utils_source = link
  on(Win32API::KEY_EVENT_RECORD) {|event| to_dom_key_event(event) } 
end

Instance Method Details

#has_any?TrueClass || FalseClass

Returns:

  • (TrueClass || FalseClass)


52
53
54
# File 'lib/vigilem/win32_api/dom/adapter.rb', line 52

def has_any?
  not buffer.empty? || link.has_any?
end

#read_many_nonblock(limit = 1) ⇒ Object

Parameters:

  • limit (Integer) (defaults to: 1)

Returns:



39
40
41
42
43
44
45
46
47
48
# File 'lib/vigilem/win32_api/dom/adapter.rb', line 39

def read_many_nonblock(limit=1)
  buffered!(limit) do |len_remainder|
    dom_src_events = link.read_many_nonblock(len_remainder).map do |event| 
      handle(event.event_record)
    end.compact.flatten
    ret, to_buffer = Support::Utils.split_at(dom_src_events, len_remainder)
    buffer.concat([*to_buffer])
    ret
  end
end