Class: Fusuma::Plugin::Buffers::ThumbsenseBuffer

Inherits:
Buffer
  • Object
show all
Defined in:
lib/fusuma/plugin/buffers/thumbsense_buffer.rb

Overview

manage events and generate command

Constant Summary collapse

DEFAULT_SOURCE =
"remap_touchpad_input"
POINTING_STICK_SOURCE =
"pointing_stick_input"

Instance Method Summary collapse

Instance Method Details

#begin?(event) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/fusuma/plugin/buffers/thumbsense_buffer.rb', line 46

def begin?(event)
  event.record.status == "begin"
end

#buffer(event) ⇒ NilClass, ThumbsenseBuffer

Parameters:

  • event (Event)

Returns:



29
30
31
32
33
34
35
# File 'lib/fusuma/plugin/buffers/thumbsense_buffer.rb', line 29

def buffer(event)
  case event.tag
  when source, POINTING_STICK_SOURCE
    @events.push(event)
    self
  end
end

#clear_expiredObject

clear old events



18
19
20
21
22
23
24
25
# File 'lib/fusuma/plugin/buffers/thumbsense_buffer.rb', line 18

def clear_expired(*)
  return if @events.empty?

  # skip palm/begin record
  return if !ended?(@events.last)

  clear
end

#config_param_typesObject



11
12
13
14
15
# File 'lib/fusuma/plugin/buffers/thumbsense_buffer.rb', line 11

def config_param_types
  {
    source: [String]
  }
end

#ended?(event) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/fusuma/plugin/buffers/thumbsense_buffer.rb', line 42

def ended?(event)
  event.record.status == "end"
end

#fingerObject

return [Integer]



38
39
40
# File 'lib/fusuma/plugin/buffers/thumbsense_buffer.rb', line 38

def finger
  @events.map { |e| e.record.finger }.max
end