Class: Fusuma::Plugin::Inputs::RemapKeyboardInput
- Inherits:
-
Input
- Object
- Input
- Fusuma::Plugin::Inputs::RemapKeyboardInput
- Includes:
- CustomProcess
- Defined in:
- lib/fusuma/plugin/inputs/remap_keyboard_input.rb
Overview
Get keyboard events from remapper
Instance Method Summary collapse
- #config_param_types ⇒ Object
-
#initialize ⇒ RemapKeyboardInput
constructor
A new instance of RemapKeyboardInput.
- #io ⇒ Object
-
#read_from_io ⇒ Record
override Input#read_from_io.
Constructor Details
#initialize ⇒ RemapKeyboardInput
Returns a new instance of RemapKeyboardInput.
22 23 24 25 |
# File 'lib/fusuma/plugin/inputs/remap_keyboard_input.rb', line 22 def initialize super setup_remapper end |
Instance Method Details
#config_param_types ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/fusuma/plugin/inputs/remap_keyboard_input.rb', line 14 def config_param_types { emergency_ungrab_keys: [String], keyboard_name_patterns: [Array, String], touchpad_name_patterns: [Array, String] } end |
#io ⇒ Object
27 28 29 |
# File 'lib/fusuma/plugin/inputs/remap_keyboard_input.rb', line 27 def io @fusuma_reader end |
#read_from_io ⇒ Record
override Input#read_from_io
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/fusuma/plugin/inputs/remap_keyboard_input.rb', line 33 def read_from_io @unpacker ||= MessagePack::Unpacker.new(io) data = @unpacker.unpack raise "data is not Hash : #{data}" unless data.is_a? Hash status = (data["status"] == 1) ? "pressed" : "released" Events::Records::KeypressRecord.new(status: status, code: data["key"], layer: data["layer"]) rescue EOFError => e MultiLogger.error "#{self.class.name}: #{e}" MultiLogger.error "Shutdown fusuma process..." Process.kill("TERM", Process.pid) end |