mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-05-07 11:58:04 +02:00
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:
parent
eef0650759
commit
d63689003f
3 changed files with 26 additions and 12 deletions
|
|
@ -206,6 +206,8 @@ class Device(libevdev.Device):
|
||||||
self.sequences = []
|
self.sequences = []
|
||||||
self.touch = Touch(0, 0)
|
self.touch = Touch(0, 0)
|
||||||
|
|
||||||
|
self.warned = False
|
||||||
|
|
||||||
def find_touch_device(self):
|
def find_touch_device(self):
|
||||||
context = pyudev.Context()
|
context = pyudev.Context()
|
||||||
for device in context.list_devices(subsystem="input"):
|
for device in context.list_devices(subsystem="input"):
|
||||||
|
|
@ -259,10 +261,13 @@ class Device(libevdev.Device):
|
||||||
libevdev.EV_KEY.BTN_TOOL_QUINTTAP,
|
libevdev.EV_KEY.BTN_TOOL_QUINTTAP,
|
||||||
]
|
]
|
||||||
if event.code in tapcodes and event.value > 0:
|
if event.code in tapcodes and event.value > 0:
|
||||||
print(
|
if not self.warned:
|
||||||
"\rThis tool cannot handle multiple fingers, " "output will be invalid",
|
self.warned = True
|
||||||
file=sys.stderr,
|
print(
|
||||||
)
|
"\rThis tool cannot handle multiple fingers, "
|
||||||
|
"output will be invalid",
|
||||||
|
file=sys.stderr,
|
||||||
|
)
|
||||||
|
|
||||||
def handle_abs(self, event):
|
def handle_abs(self, event):
|
||||||
if event.matches(libevdev.EV_ABS.ABS_MT_TRACKING_ID):
|
if event.matches(libevdev.EV_ABS.ABS_MT_TRACKING_ID):
|
||||||
|
|
|
||||||
|
|
@ -293,10 +293,15 @@ def handle_key(device, event):
|
||||||
libevdev.EV_KEY.BTN_TOOL_QUINTTAP,
|
libevdev.EV_KEY.BTN_TOOL_QUINTTAP,
|
||||||
]
|
]
|
||||||
if event.code in tapcodes and event.value > 0:
|
if event.code in tapcodes and event.value > 0:
|
||||||
print(
|
try:
|
||||||
"\r\033[2KThis tool cannot handle multiple fingers, "
|
if handle_key.warned:
|
||||||
"output will be invalid"
|
return
|
||||||
)
|
except AttributeError:
|
||||||
|
handle_key.warned = True
|
||||||
|
print(
|
||||||
|
"\r\033[2KThis tool cannot handle multiple fingers, "
|
||||||
|
"output will be invalid"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def handle_abs(device, event):
|
def handle_abs(device, event):
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,7 @@ class Device(libevdev.Device):
|
||||||
raise InvalidDeviceError("device does not have BTN_TOUCH")
|
raise InvalidDeviceError("device does not have BTN_TOUCH")
|
||||||
|
|
||||||
self.touches = []
|
self.touches = []
|
||||||
|
self.warned = False
|
||||||
|
|
||||||
def _find_touch_device(self):
|
def _find_touch_device(self):
|
||||||
context = pyudev.Context()
|
context = pyudev.Context()
|
||||||
|
|
@ -141,10 +142,13 @@ class Device(libevdev.Device):
|
||||||
libevdev.EV_KEY.BTN_TOOL_QUINTTAP,
|
libevdev.EV_KEY.BTN_TOOL_QUINTTAP,
|
||||||
]
|
]
|
||||||
if event.code in tapcodes and event.value > 0:
|
if event.code in tapcodes and event.value > 0:
|
||||||
error(
|
if not self.warned:
|
||||||
"\rThis tool cannot handle multiple fingers, " "output will be invalid"
|
self.warned = True
|
||||||
)
|
error(
|
||||||
return
|
"\rThis tool cannot handle multiple fingers, "
|
||||||
|
"output will be invalid"
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
if event.matches(libevdev.EV_KEY.BTN_TOUCH):
|
if event.matches(libevdev.EV_KEY.BTN_TOUCH):
|
||||||
self.handle_btn_touch(event)
|
self.handle_btn_touch(event)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue