From: Peter Hutterer Date: Tue, 30 Oct 2018 23:55:17 +0000 (+1000) Subject: tools: allow measuring single-touch ABS_PRESSURE X-Git-Tag: 1.12.3~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=27bf3fb2abaaa84fdccefded39b87097a6efab83;p=platform%2Fupstream%2Flibinput.git tools: allow measuring single-touch ABS_PRESSURE Fixes #173 Signed-off-by: Peter Hutterer --- diff --git a/tools/libinput-measure-touchpad-pressure.py b/tools/libinput-measure-touchpad-pressure.py index c04d8d6d..a7a2e34b 100755 --- a/tools/libinput-measure-touchpad-pressure.py +++ b/tools/libinput-measure-touchpad-pressure.py @@ -170,7 +170,12 @@ class Device(object): caps = all_caps.get(evdev.ecodes.EV_ABS, []) p = [cap[1] for cap in caps if cap[0] == evdev.ecodes.ABS_MT_PRESSURE] if not p: - raise InvalidDeviceError("device does not have ABS_MT_PRESSURE") + p = [cap[1] for cap in caps if cap[0] == evdev.ecodes.ABS_PRESSURE] + if not p: + raise InvalidDeviceError("device does not have ABS_PRESSURE/ABS_MT_PRESSURE") + self.has_mt_pressure = False + else: + self.has_mt_pressure = True p = p[0] prange = p.max - p.min @@ -247,7 +252,8 @@ def handle_abs(device, event): except IndexError: # If the finger was down at startup pass - elif event.code == evdev.ecodes.ABS_MT_PRESSURE: + elif ((event.code == evdev.ecodes.ABS_MT_PRESSURE) or + (event.code == evdev.ecodes.ABS_PRESSURE and not device.has_mt_pressure)): try: s = device.current_sequence() s.append(Touch(pressure=event.value))