Skip to content

Commit 6b05e8a

Browse files
committed
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
1 parent 404ee2e commit 6b05e8a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

qubes-rpc/qubes-input-trigger

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,25 @@ def get_args():
3636

3737
def get_service_name(udevreturn, input_dev):
3838
service = None
39+
try:
40+
devpath = [line.split("=", 1)[1] for line in udevreturn.splitlines()
41+
if line.startswith("DEVPATH=")][0]
42+
with open(f"/sys/{devpath}/device/capabilities/abs", "rb") as f:
43+
abs_bytes = f.read()
44+
# we care about only the first byte - that's where X,Y axies are
45+
abs_caps = abs_bytes[0]
46+
except (IndexError, FileNotFoundError):
47+
abs_caps = 0
3948
if (
4049
('ID_INPUT_TABLET' in udevreturn) or
4150
('ID_INPUT_TOUCHSCREEN' in udevreturn) or
4251
('ID_INPUT_TOUCHPAD' in udevreturn) or
4352
('QEMU_USB_Tablet' in udevreturn)
4453
) and 'ID_INPUT_KEY' not in udevreturn:
4554
service = 'qubes-input-sender-tablet'
46-
# PiKVM "mouse" is special, as it sends absolute events
47-
elif 'ID_INPUT_MOUSE' in udevreturn and 'ID_USB_VENDOR=PiKVM' in udevreturn:
55+
# if mouse report absolute events, prefer tablet service
56+
# (0x3 is ABS_X | ABS_Y)
57+
elif 'ID_INPUT_MOUSE' in udevreturn and abs_caps & 0x3:
4858
service = 'qubes-input-sender-tablet'
4959
elif 'ID_INPUT_MOUSE' in udevreturn and 'ID_INPUT_KEY' not in udevreturn:
5060
service = 'qubes-input-sender-mouse'

0 commit comments

Comments
 (0)