tools: touchpad-pressure: add thumb pressure handling

Fixes https://gitlab.freedesktop.org/libinput/libinput/issues/49

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2018-06-19 17:33:01 +10:00
parent ecc406ee53
commit 3b41be9419

View file

@ -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")