diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2018-08-29 13:55:39 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2018-08-29 22:17:33 +0000 |
commit | a661d7b7177d444e7fa444c81d619a1dced965fb (patch) | |
tree | 6220a5e58772f9099b181262e0db686eddfe565b /tools | |
parent | 27c42990d85dcffe0114a52bcf5ff66d0f730c7b (diff) |
tools: handle a finger down at startup for measure pressure/touch-size
Fixes #117
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/libinput-measure-touch-size.py | 23 | ||||
-rwxr-xr-x | tools/libinput-measure-touchpad-pressure.py | 20 |
2 files changed, 29 insertions, 14 deletions
diff --git a/tools/libinput-measure-touch-size.py b/tools/libinput-measure-touch-size.py index 3997c038..957e6052 100755 --- a/tools/libinput-measure-touch-size.py +++ b/tools/libinput-measure-touch-size.py @@ -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: diff --git a/tools/libinput-measure-touchpad-pressure.py b/tools/libinput-measure-touchpad-pressure.py index 892b5e66..c04d8d6d 100755 --- a/tools/libinput-measure-touchpad-pressure.py +++ b/tools/libinput-measure-touchpad-pressure.py @@ -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): |