Class: Fusuma::Plugin::Inputs::RemapKeyboardInput

Inherits:
Input
  • Object
show all
Includes:
CustomProcess
Defined in:
lib/fusuma/plugin/inputs/remap_keyboard_input.rb

Overview

Get keyboard events from remapper

Defined Under Namespace

Classes: KeyboardSelector, TouchpadSelector

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRemapKeyboardInput

Returns a new instance of RemapKeyboardInput.



23
24
25
26
# File 'lib/fusuma/plugin/inputs/remap_keyboard_input.rb', line 23

def initialize
  super
  setup_remapper
end

Instance Attribute Details

#pidObject (readonly)

Returns the value of attribute pid.



21
22
23
# File 'lib/fusuma/plugin/inputs/remap_keyboard_input.rb', line 21

def pid
  @pid
end

Instance Method Details

#config_param_typesObject



14
15
16
17
18
19
# File 'lib/fusuma/plugin/inputs/remap_keyboard_input.rb', line 14

def config_param_types
  {
    keyboard_name_patterns: [Array, String],
    touchpad_name_patterns: [Array, String]
  }
end

#create_event(record:) ⇒ Event

Parameters:

  • record (String)

Returns:

  • (Event)


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/fusuma/plugin/inputs/remap_keyboard_input.rb', line 34

def create_event(record:)
  data = MessagePack.unpack(record) # => {"key"=>"J", "status"=>1}

  unless data.is_a? Hash
    MultiLogger.error("Invalid record: #{record}", data: data)
    return
  end

  code = data["key"]
  status = (data["status"] == 1) ? "pressed" : "released"
  record = Events::Records::KeypressRecord.new(status: status, code: code)

  e = Events::Event.new(tag: tag, record: record)
  MultiLogger.debug(input_event: e)
  e
end

#ioObject



28
29
30
# File 'lib/fusuma/plugin/inputs/remap_keyboard_input.rb', line 28

def io
  @keyboard_reader
end