tools: only warn once about our lack of support for multiple fingers

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1096>
This commit is contained in:
Peter Hutterer 2024-12-16 11:52:18 +10:00 committed by Marge Bot
parent eef0650759
commit d63689003f
3 changed files with 26 additions and 12 deletions

View file

@ -206,6 +206,8 @@ class Device(libevdev.Device):
self.sequences = []
self.touch = Touch(0, 0)
self.warned = False
def find_touch_device(self):
context = pyudev.Context()
for device in context.list_devices(subsystem="input"):
@ -259,8 +261,11 @@ class Device(libevdev.Device):
libevdev.EV_KEY.BTN_TOOL_QUINTTAP,
]
if event.code in tapcodes and event.value > 0:
if not self.warned:
self.warned = True
print(
"\rThis tool cannot handle multiple fingers, " "output will be invalid",
"\rThis tool cannot handle multiple fingers, "
"output will be invalid",
file=sys.stderr,
)

View file

@ -293,6 +293,11 @@ def handle_key(device, event):
libevdev.EV_KEY.BTN_TOOL_QUINTTAP,
]
if event.code in tapcodes and event.value > 0:
try:
if handle_key.warned:
return
except AttributeError:
handle_key.warned = True
print(
"\r\033[2KThis tool cannot handle multiple fingers, "
"output will be invalid"

View file

@ -100,6 +100,7 @@ class Device(libevdev.Device):
raise InvalidDeviceError("device does not have BTN_TOUCH")
self.touches = []
self.warned = False
def _find_touch_device(self):
context = pyudev.Context()
@ -141,8 +142,11 @@ class Device(libevdev.Device):
libevdev.EV_KEY.BTN_TOOL_QUINTTAP,
]
if event.code in tapcodes and event.value > 0:
if not self.warned:
self.warned = True
error(
"\rThis tool cannot handle multiple fingers, " "output will be invalid"
"\rThis tool cannot handle multiple fingers, "
"output will be invalid"
)
return