Class: Fusuma::Plugin::Inputs::RemapTouchpadInput

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

Overview

Get touchpad events from remapper

Defined Under Namespace

Classes: TouchpadSelector

Instance Method Summary collapse

Constructor Details

#initializeRemapTouchpadInput

Returns a new instance of RemapTouchpadInput.



18
19
20
21
# File 'lib/fusuma/plugin/inputs/remap_touchpad_input.rb', line 18

def initialize
  super
  setup_remapper
end

Instance Method Details

#config_param_typesObject



12
13
14
15
16
# File 'lib/fusuma/plugin/inputs/remap_touchpad_input.rb', line 12

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

#ioObject



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

def io
  @fusuma_reader
end

#read_from_ioRecord

override Input#read_from_io

Returns:

  • (Record)


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/fusuma/plugin/inputs/remap_touchpad_input.rb', line 29

def read_from_io
  @unpacker ||= MessagePack::Unpacker.new(io)
  data = @unpacker.unpack

  raise "data is not Hash : #{data}" unless data.is_a? Hash

  gesture = "touch"
  finger = data["finger"]
  status = data["status"]

  Events::Records::GestureRecord.new(gesture: gesture, status: status, finger: finger, delta: nil)
rescue EOFError => e
  MultiLogger.error "#{self.class.name}: #{e}"
  MultiLogger.error "Shutdown fusuma process..."
  Process.kill("TERM", Process.pid)
end