Class: Fusuma::Plugin::Remap::TouchpadRemapper::PalmDetection

Inherits:
Object
  • Object
show all
Defined in:
lib/fusuma/plugin/remap/touchpad_remapper.rb

Overview

Detect palm touch

Instance Method Summary collapse

Constructor Details

#initialize(touchpad) ⇒ PalmDetection

Returns a new instance of PalmDetection.



163
164
165
166
# File 'lib/fusuma/plugin/remap/touchpad_remapper.rb', line 163

def initialize(touchpad)
  @max_x = touchpad.absinfo_for_axis(Revdev::ABS_MT_POSITION_X)[:absmax]
  @max_y = touchpad.absinfo_for_axis(Revdev::ABS_MT_POSITION_Y)[:absmax]
end

Instance Method Details

#palm?(touch_state) ⇒ Boolean

Returns:

  • (Boolean)


168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/fusuma/plugin/remap/touchpad_remapper.rb', line 168

def palm?(touch_state)
  return false unless touch_state[:X] && touch_state[:Y]

  if 0.8 * @max_y < touch_state[:Y]
    true
  else
    !(
      # Disable 20% of the touch area on the left, right
      (touch_state[:X] < 0.2 * @max_x || touch_state[:X] > 0.8 * @max_x) ||
      # Disable 10% of the touch area on the top edge
      (touch_state[:Y] < 0.1 * @max_y && (touch_state[:X] < 0.2 * @max_x || touch_state[:X] > 0.8 * @max_x)
      )
    )
  end
end