From 3b41be94198fc3f8645407bd86c0b119fc1d1e98 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 19 Jun 2018 17:33:01 +1000 Subject: [PATCH] tools: touchpad-pressure: add thumb pressure handling Fixes https://gitlab.freedesktop.org/libinput/libinput/issues/49 Signed-off-by: Peter Hutterer --- tools/libinput-measure-touchpad-pressure | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tools/libinput-measure-touchpad-pressure b/tools/libinput-measure-touchpad-pressure index a9ad1c46..765e7997 100755 --- a/tools/libinput-measure-touchpad-pressure +++ b/tools/libinput-measure-touchpad-pressure @@ -70,6 +70,8 @@ class TouchSequence(object): self.was_down = False self.is_palm = False self.was_palm = False + self.is_thumb = False + self.was_thumb = False self.prange = Range() @@ -88,6 +90,10 @@ class TouchSequence(object): if self.is_palm: self.was_palm = True + self.is_thumb = touch.pressure > self.device.thumb + if self.is_thumb: + self.was_thumb = True + def finalize(self): """Mark the TouchSequence as complete (finger is up)""" self.is_active = False @@ -122,17 +128,20 @@ class TouchSequence(object): s += " down" if self.was_palm: s += " palm" + if self.was_thumb: + s += " thumb" return s def _str_state(self): - s = "Touchpad pressure: {:3d} min: {:3d} max: {:3d} tags: {} {}" \ + s = "Touchpad pressure: {:3d} min: {:3d} max: {:3d} tags: {} {} {}" \ .format( self.points[-1].pressure, self.prange.min, self.prange.max, "down" if self.is_down else " ", - "palm" if self.is_palm else " " + "palm" if self.is_palm else " ", + "thumb" if self.is_thumb else " " ) return s @@ -170,6 +179,7 @@ class Device(object): self.down = int(p.min + 0.12 * prange) self.up = int(p.min + 0.10 * prange) self.palm = 130 # the libinput default + self.thumb = p.max self._init_thresholds_from_quirks() self.sequences = [] @@ -206,6 +216,8 @@ class Device(object): self.palm = int(q[1]) elif q[0] == 'AttrPressureRange': self.down, self.up = colon_tuple(q[1]) + elif q[0] == 'AttrThumbPressureThreshold': + self.thumb = int(q[1]) def start_new_sequence(self, tracking_id): self.sequences.append(TouchSequence(self, tracking_id)) @@ -251,6 +263,7 @@ def loop(device): print("Ready for recording data.") print("Pressure range used: {}:{}".format(device.down, device.up)) print("Palm pressure range used: {}".format(device.palm)) + print("Thumb pressure range used: {}".format(device.thumb)) print("Place a single finger on the touchpad to measure pressure values.\n" "Ctrl+C to exit\n")