Class: Vigilem::Win32API::InputSystemHandler
- Inherits:
-
Object
- Object
- Vigilem::Win32API::InputSystemHandler
- Defined in:
- lib/vigilem/win32_api/input_system_handler.rb
Constant Summary
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
- #demux(*msgs) ⇒ Object
-
#hub ⇒ Object
the hub that sends and receives messages for this buffer.
-
#initialize(lnk = nil) ⇒ InputSystemHandler
constructor
A new instance of InputSystemHandler.
- #MapVirtualKey(uCode, uMapType) ⇒ Object
-
#PeekConsoleInput(hConsoleInput, lpBuffer, nLength, lpNumberOfEventsRead) ⇒ Integer
1 or 0.
-
#ReadConsoleInput(hConsoleInput, lpBuffer, nLength, lpNumberOfEventsRead) ⇒ Integer
1 or 0.
- #win32_api_rubyized_source ⇒ Object
Methods included from Eventable
#has_any?, #read_many, #read_many_nonblock, #read_one, #read_one_nonblock
Methods included from Rubyized
#get_std_handle, #map_virtual_key, #peek_console_input, #read_console_input
Constructor Details
#initialize(lnk = nil) ⇒ InputSystemHandler
Returns a new instance of InputSystemHandler.
29 30 31 |
# File 'lib/vigilem/win32_api/input_system_handler.rb', line 29 def initialize(lnk=nil) initialize_buffered(lnk || Vigilem::Win32API) end |
Instance Method Details
#demux(*msgs) ⇒ Object
98 99 100 |
# File 'lib/vigilem/win32_api/input_system_handler.rb', line 98 def demux(*msgs) hub.demux(self, *msgs) end |
#hub ⇒ Object
the hub that sends and receives messages for this buffer
90 91 92 |
# File 'lib/vigilem/win32_api/input_system_handler.rb', line 90 def hub @hub ||= (Core::Hub.aquire(link()) << self.buffer) end |
#MapVirtualKey(uCode, uMapType) ⇒ Object
79 80 81 82 83 84 |
# File 'lib/vigilem/win32_api/input_system_handler.rb', line 79 def MapVirtualKey(uCode, uMapType) # without this it could fail silently raise ArgumentError, "uCode has to be a Integer not #{uCode.class}:`#{uCode}'" unless uCode.is_a? Integer raise ArgumentError, "uMapType has to be a Integer not #{uMapType.class}:`#{uMapType}'" unless uMapType.is_a? Integer link.MapVirtualKeyW(uCode, uMapType) end |
#PeekConsoleInput(hConsoleInput, lpBuffer, nLength, lpNumberOfEventsRead) ⇒ Integer
Returns 1 or 0.
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/vigilem/win32_api/input_system_handler.rb', line 45 def PeekConsoleInput(hConsoleInput, lpBuffer, nLength, lpNumberOfEventsRead) semaphore.synchronize { events = buffered(nLength) do |len_remainder| ret = link.PeekConsoleInputW(hConsoleInput, lpBuffer, nLength, lpNumberOfEventsRead) lpBuffer end _update_out_args(lpBuffer, lpNumberOfEventsRead, events) ret ||= 1 } end |
#ReadConsoleInput(hConsoleInput, lpBuffer, nLength, lpNumberOfEventsRead) ⇒ Integer
Returns 1 or 0.
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/vigilem/win32_api/input_system_handler.rb', line 62 def ReadConsoleInput(hConsoleInput, lpBuffer, nLength, lpNumberOfEventsRead) semaphore.synchronize { events = buffered!(nLength) do |still_to_get| ret = link.ReadConsoleInputW(hConsoleInput, lpBuffer, still_to_get, lpNumberOfEventsRead) demux(*lpBuffer) unless lpBuffer.empty? lpBuffer end _update_out_args(lpBuffer, lpNumberOfEventsRead, events) ret ||= 1 } end |
#win32_api_rubyized_source ⇒ Object
33 34 35 |
# File 'lib/vigilem/win32_api/input_system_handler.rb', line 33 def win32_api_rubyized_source self end |