Commit a661d7b7 authored by Peter Hutterer's avatar Peter Hutterer

tools: handle a finger down at startup for measure pressure/touch-size

Fixes #117
Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
parent 27c42990
Pipeline #3742 failed with stages
in 98 minutes and 52 seconds
......@@ -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):
......
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