summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2018-06-19 17:17:31 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2018-06-20 14:01:17 +1000
commitecc406ee53d7c0be3983ca3d7da62befc3bee99b (patch)
tree95b3cae3cd1ec4123b809c49d7ec7bb1669e1668 /tools
parentefe954aea8015002d0966944c5d31ce8c2bfa60c (diff)
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>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/libinput-measure-touchpad-pressure31
1 files changed, 20 insertions, 11 deletions
diff --git a/tools/libinput-measure-touchpad-pressure b/tools/libinput-measure-touchpad-pressure
index 25be07b5..a9ad1c46 100755
--- a/tools/libinput-measure-touchpad-pressure
+++ b/tools/libinput-measure-touchpad-pressure
@@ -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)
-
- v = ud.get('LIBINPUT_ATTR_PALM_PRESSURE_THRESHOLD')
- if v:
- self.palm = int(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
+
+ 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))