diff --git a/tools/libinput-measure-touch-size b/tools/libinput-measure-touch-size index 8387eb67..9ff65eaa 100755 --- a/tools/libinput-measure-touch-size +++ b/tools/libinput-measure-touch-size @@ -25,6 +25,7 @@ # import sys +import subprocess import argparse try: import evdev @@ -199,7 +200,7 @@ class Device(object): self.down = 0 self.palm = 0 - self._init_thresholds_from_udev() + self._init_thresholds_from_quirks() self.sequences = [] self.touch = Touch(0, 0) @@ -219,16 +220,24 @@ class Device(object): print("Unable to find a touch 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_TOUCH_SIZE_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_SIZE_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] == 'AttrPalmSizeThreshold': + self.palm = int(q[1]) + elif q[0] == 'AttrTouchSizeRange': + self.down, self.up = colon_tuple(q[1]) def start_new_sequence(self, tracking_id): self.sequences.append(TouchSequence(self, tracking_id)) diff --git a/tools/libinput-measure-touch-size.man b/tools/libinput-measure-touch-size.man index 5525ec56..7fe042f0 100644 --- a/tools/libinput-measure-touch-size.man +++ b/tools/libinput-measure-touch-size.man @@ -49,7 +49,7 @@ Assume a palm threshold of The threshold has to be in device-specific pressure values. .PP If the touch-thresholds or the palm-threshold are not provided, -this tool uses the thresholds provided by the udev hwdb (if any) or the +this tool uses the thresholds provided by the device quirks (if any) or the built-in defaults. .SH LIBINPUT Part of the