Commit 27bf3fb2 authored by Peter Hutterer's avatar Peter Hutterer

tools: allow measuring single-touch ABS_PRESSURE

Fixes #173
Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
parent 6041d0ba
Pipeline #7681 passed with stages
in 5 minutes and 2 seconds
...@@ -170,7 +170,12 @@ class Device(object): ...@@ -170,7 +170,12 @@ class Device(object):
caps = all_caps.get(evdev.ecodes.EV_ABS, []) caps = all_caps.get(evdev.ecodes.EV_ABS, [])
p = [cap[1] for cap in caps if cap[0] == evdev.ecodes.ABS_MT_PRESSURE] p = [cap[1] for cap in caps if cap[0] == evdev.ecodes.ABS_MT_PRESSURE]
if not p: 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] p = p[0]
prange = p.max - p.min prange = p.max - p.min
...@@ -247,7 +252,8 @@ def handle_abs(device, event): ...@@ -247,7 +252,8 @@ def handle_abs(device, event):
except IndexError: except IndexError:
# If the finger was down at startup # If the finger was down at startup
pass 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: try:
s = device.current_sequence() s = device.current_sequence()
s.append(Touch(pressure=event.value)) s.append(Touch(pressure=event.value))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment