Class: Fusuma::Plugin::Detectors::TouchDetectors::TapDetector

Inherits:
TapHoldBase
  • Object
show all
Defined in:
lib/fusuma/plugin/detectors/touch_detectors/tap_detector.rb

Instance Method Summary collapse

Instance Method Details

#detect(touch_buffer) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/fusuma/plugin/detectors/touch_detectors/tap_detector.rb', line 9

def detect(touch_buffer)
  MultiLogger.debug('> tap detector')

  MultiLogger.debug('  no movement?')
  return if touch_buffer.moved?

  MultiLogger.debug('  began?')
  return unless touch_buffer.began?

  MultiLogger.debug('  ended?')
  return unless touch_buffer.ended?

  MultiLogger.debug("  tap / hold threshold? (duration #{touch_buffer.duration})")
  return unless touch_buffer.duration <= tap_hold_threshold

  MultiLogger.debug("  tap (#{touch_buffer.finger}) detected!")
  Plugin::Events::Records::TouchRecords::TapRecord.new(finger: touch_buffer.finger)
end