tools: touchpad-pressure: switch to using quirks for pre-loading thresholds

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

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

View file

@ -25,6 +25,7 @@
#
import sys
import subprocess
import argparse
try:
import evdev
@ -170,7 +171,7 @@ class Device(object):
self.up = int(p.min + 0.10 * prange)
self.palm = 130 # the libinput default
self._init_thresholds_from_udev()
self._init_thresholds_from_quirks()
self.sequences = []
def find_touchpad_device(self):
@ -187,16 +188,24 @@ class Device(object):
print("Unable to find a touchpad device.", file=sys.stderr)
sys.exit(1)
def _init_thresholds_from_udev(self):
context = pyudev.Context()
ud = pyudev.Devices.from_device_file(context, self.path)
v = ud.get('LIBINPUT_ATTR_PRESSURE_RANGE')
if v:
self.down, self.up = colon_tuple(v)
def _init_thresholds_from_quirks(self):
# FIXME: this uses the system-installed version
# but we should really auto-detect when this is started
# from the builddir
command = ['libinput', 'list-quirks', self.path]
cmd = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if cmd.returncode != 0:
print("Error querying quirks: {}".format(cmd.stderr.decode('utf-8')), file=sys.stderr)
return
v = ud.get('LIBINPUT_ATTR_PALM_PRESSURE_THRESHOLD')
if v:
self.palm = int(v)
stdout = cmd.stdout.decode('utf-8')
quirks = [q.split('=') for q in stdout.split('\n')]
for q in quirks:
if q[0] == 'AttrPalmPressureThreshold':
self.palm = int(q[1])
elif q[0] == 'AttrPressureRange':
self.down, self.up = colon_tuple(q[1])
def start_new_sequence(self, tracking_id):
self.sequences.append(TouchSequence(self, tracking_id))