From 6b05e8acd80c9e9a3a9c301e93db2bccaeac92a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Thu, 7 Nov 2024 15:54:54 +0100 Subject: [PATCH] Replace PiKVM special handling with more generic one Check if a "mouse" report absolute capabilities - if so try to connect it as a tablet first. If that doesn't work, tablet service has a fallback to mouse. Fixes QubesOS/qubes-issues#9563 --- qubes-rpc/qubes-input-trigger | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/qubes-rpc/qubes-input-trigger b/qubes-rpc/qubes-input-trigger index 5fa0e5a..264788e 100755 --- a/qubes-rpc/qubes-input-trigger +++ b/qubes-rpc/qubes-input-trigger @@ -36,6 +36,15 @@ def get_args(): def get_service_name(udevreturn, input_dev): service = None + try: + devpath = [line.split("=", 1)[1] for line in udevreturn.splitlines() + if line.startswith("DEVPATH=")][0] + with open(f"/sys/{devpath}/device/capabilities/abs", "rb") as f: + abs_bytes = f.read() + # we care about only the first byte - that's where X,Y axies are + abs_caps = abs_bytes[0] + except (IndexError, FileNotFoundError): + abs_caps = 0 if ( ('ID_INPUT_TABLET' in udevreturn) or ('ID_INPUT_TOUCHSCREEN' in udevreturn) or @@ -43,8 +52,9 @@ def get_service_name(udevreturn, input_dev): ('QEMU_USB_Tablet' in udevreturn) ) and 'ID_INPUT_KEY' not in udevreturn: service = 'qubes-input-sender-tablet' - # PiKVM "mouse" is special, as it sends absolute events - elif 'ID_INPUT_MOUSE' in udevreturn and 'ID_USB_VENDOR=PiKVM' in udevreturn: + # if mouse report absolute events, prefer tablet service + # (0x3 is ABS_X | ABS_Y) + elif 'ID_INPUT_MOUSE' in udevreturn and abs_caps & 0x3: service = 'qubes-input-sender-tablet' elif 'ID_INPUT_MOUSE' in udevreturn and 'ID_INPUT_KEY' not in udevreturn: service = 'qubes-input-sender-mouse'