mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-20 03:20:05 +01:00
tools: touch-size: update to use the device quirks
Fixes https://gitlab.freedesktop.org/libinput/libinput/issues/57 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
404990f125
commit
c54d81b9ec
2 changed files with 20 additions and 11 deletions
|
|
@ -25,6 +25,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
import subprocess
|
||||||
import argparse
|
import argparse
|
||||||
try:
|
try:
|
||||||
import evdev
|
import evdev
|
||||||
|
|
@ -199,7 +200,7 @@ class Device(object):
|
||||||
self.down = 0
|
self.down = 0
|
||||||
self.palm = 0
|
self.palm = 0
|
||||||
|
|
||||||
self._init_thresholds_from_udev()
|
self._init_thresholds_from_quirks()
|
||||||
self.sequences = []
|
self.sequences = []
|
||||||
self.touch = Touch(0, 0)
|
self.touch = Touch(0, 0)
|
||||||
|
|
||||||
|
|
@ -219,16 +220,24 @@ class Device(object):
|
||||||
print("Unable to find a touch device.", file=sys.stderr)
|
print("Unable to find a touch device.", file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def _init_thresholds_from_udev(self):
|
def _init_thresholds_from_quirks(self):
|
||||||
context = pyudev.Context()
|
# FIXME: this uses the system-installed version
|
||||||
ud = pyudev.Devices.from_device_file(context, self.path)
|
# but we should really auto-detect when this is started
|
||||||
v = ud.get('LIBINPUT_ATTR_TOUCH_SIZE_RANGE')
|
# from the builddir
|
||||||
if v:
|
command = ['libinput', 'list-quirks', self.path]
|
||||||
self.down, self.up = colon_tuple(v)
|
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')
|
stdout = cmd.stdout.decode('utf-8')
|
||||||
if v:
|
quirks = [q.split('=') for q in stdout.split('\n')]
|
||||||
self.palm = int(v)
|
|
||||||
|
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):
|
def start_new_sequence(self, tracking_id):
|
||||||
self.sequences.append(TouchSequence(self, tracking_id))
|
self.sequences.append(TouchSequence(self, tracking_id))
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ Assume a palm threshold of
|
||||||
The threshold has to be in device-specific pressure values.
|
The threshold has to be in device-specific pressure values.
|
||||||
.PP
|
.PP
|
||||||
If the touch-thresholds or the palm-threshold are not provided,
|
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.
|
built-in defaults.
|
||||||
.SH LIBINPUT
|
.SH LIBINPUT
|
||||||
Part of the
|
Part of the
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue