10000 Put mouse before gamepad due to MacOS being finicky · domdfcoding/circuitpython@8a8deb4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8a8deb4

Browse files
committed
Put mouse before gamepad due to MacOS being finicky
1 parent d0ba75e commit 8a8deb4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tools/gen_usb_descriptor.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717
ALL_DEVICES_SET = frozenset(ALL_DEVICES.split())
1818
DEFAULT_DEVICES = "CDC MSC AUDIO HID"
1919

20+
# This list is in preferred order. MacOS does not like GAMEPAD coming before MOUSE.
2021
ALL_HID_DEVICES = (
2122
"KEYBOARD MOUSE CONSUMER SYS_CONTROL GAMEPAD DIGITIZER XAC_COMPATIBLE_GAMEPAD RAW"
2223
)
24+
ALL_HID_DEVICES_ORDER = dict((name, idx) for (idx, name) in enumerate(ALL_HID_DEVICES.split()))
2325
ALL_HID_DEVICES_SET = frozenset(ALL_HID_DEVICES.split())
2426
# Digitizer works on Linux but conflicts with mouse, so omit it.
2527
DEFAULT_HID_DEVICES = "KEYBOARD MOUSE CONSUMER GAMEPAD"
@@ -352,7 +354,8 @@ def make_cdc_data_interface(name, cdc_ep_num_data_in, cdc_ep_num_data_out):
352354
else:
353355
report_id = 1
354356
concatenated_descriptors = bytearray()
355-
for name in args.hid_devices:
357+
# Sort HID devices by preferred order.
358+
for name in sorted(args.hid_devices, key=ALL_HID_DEVICES_ORDER.get):
356359
concatenated_descriptors.extend(
357360
bytes(hid_report_descriptors.REPORT_DESCRIPTOR_FUNCTIONS[name](report_id))
358361
)

0 commit comments

Comments
 (0)
0