summaryrefslogtreecommitdiff
path: root/dev-python/pynput/files/patches/uinput.patch
blob: 44d17e803ed13cc64f3db89235cc51faaf582dad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
@@ -72,6 +72,14 @@ class ListenerMixin(object):
             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(