mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-05-05 06:27:59 +02:00
tools: allow measuring single-touch ABS_PRESSURE
Fixes #173 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
6041d0ba69
commit
27bf3fb2ab
1 changed files with 8 additions and 2 deletions
|
|
@ -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):
|
||||||
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))
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue