Files
guru/dev-python/pynput/files/patches/uinput.patch
T

19 lines
817 B
Diff
Raw Normal View History

2025-09-02 09:10:11 -04:00
diff --git a/lib/pynput/_util/uinput.py b/lib/pynput/_util/uinput.py
index b0a6a78..c891b83 100644
--- a/lib/pynput/_util/uinput.py
+++ b/lib/pynput/_util/uinput.py
2026-06-02 15:34:27 -04:00
@@ -72,6 +72,14 @@ class ListenerMixin(object):
2025-09-02 09:10:11 -04:00
except OSError:
continue
+ # Some programmable mouse devices report each programmable input as
+ # a separate capability, so it is possible for a mouse to exceed
+ # keyboards in capability count; for this reason we will prefer a
+ # device with "keyboard" in its name
+ if 'keyboard' in next_dev.name.lower():
+ dev = next_dev
+ break
+
# Does this device provide more handled event codes?
capabilities = next_dev.capabilities()
next_count = sum(