mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-30 11:50:08 +01:00
tools: handle a finger down at startup for measure pressure/touch-size
Fixes #117 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
27c42990d8
commit
a661d7b717
2 changed files with 29 additions and 14 deletions
|
|
@ -268,9 +268,13 @@ class Device(object):
|
|||
if event.value > -1:
|
||||
self.start_new_sequence(event.value)
|
||||
else:
|
||||
s = self.current_sequence()
|
||||
s.finalize()
|
||||
print("\r{}".format(s))
|
||||
try:
|
||||
s = self.current_sequence()
|
||||
s.finalize()
|
||||
print("\r{}".format(s))
|
||||
except IndexError:
|
||||
# If the finger was down during start
|
||||
pass
|
||||
elif event.code == evdev.ecodes.ABS_MT_TOUCH_MAJOR:
|
||||
self.touch.major = event.value
|
||||
elif event.code == evdev.ecodes.ABS_MT_TOUCH_MINOR:
|
||||
|
|
@ -280,11 +284,14 @@ class Device(object):
|
|||
|
||||
def handle_syn(self, event):
|
||||
if self.touch.dirty:
|
||||
self.current_sequence().append(self.touch)
|
||||
print("\r{}".format(self.current_sequence()), end="")
|
||||
self.touch = Touch(major=self.touch.major,
|
||||
minor=self.touch.minor,
|
||||
orientation=self.touch.orientation)
|
||||
try:
|
||||
self.current_sequence().append(self.touch)
|
||||
print("\r{}".format(self.current_sequence()), end="")
|
||||
self.touch = Touch(major=self.touch.major,
|
||||
minor=self.touch.minor,
|
||||
orientation=self.touch.orientation)
|
||||
except IndexError:
|
||||
pass
|
||||
|
||||
def handle_event(self, event):
|
||||
if event.type == evdev.ecodes.EV_ABS:
|
||||
|
|
|
|||
|
|
@ -240,13 +240,21 @@ def handle_abs(device, event):
|
|||
if event.value > -1:
|
||||
device.start_new_sequence(event.value)
|
||||
else:
|
||||
s = device.current_sequence()
|
||||
s.finalize()
|
||||
print("\r{}".format(s))
|
||||
try:
|
||||
s = device.current_sequence()
|
||||
s.finalize()
|
||||
print("\r{}".format(s))
|
||||
except IndexError:
|
||||
# If the finger was down at startup
|
||||
pass
|
||||
elif event.code == evdev.ecodes.ABS_MT_PRESSURE:
|
||||
s = device.current_sequence()
|
||||
s.append(Touch(pressure=event.value))
|
||||
print("\r{}".format(s), end="")
|
||||
try:
|
||||
s = device.current_sequence()
|
||||
s.append(Touch(pressure=event.value))
|
||||
print("\r{}".format(s), end="")
|
||||
except IndexError:
|
||||
# If the finger was down at startup
|
||||
pass
|
||||
|
||||
|
||||
def handle_event(device, event):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue