dolphin/Externals/hidapi/applied_patches/0001-macOS-Use-unique-IDs-f...

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

63 lines
2.2 KiB
Diff
Raw Normal View History

From 8d5810a1038347b9e56d41334d3f83641c913b3d Mon Sep 17 00:00:00 2001
From: Vincent Duvert <vincent@duvert.net>
Date: Sun, 7 Jan 2018 11:00:01 +0100
Subject: [PATCH 1/2] macOS: Use unique IDs for HID paths
If available, use the system-generated unique ID for HID device paths instead of a transport/vid/pid/location tuple.
The Mayflash Dolphinbar registers four HID devices (regardless of the number of connected Wiimotes) which had the same path with the previous path building method, causing a bit of confusion when detecting and connecting to Wiimotes.
The unique IDs do not change if the computer is suspended and resumed, but do change if the HID device is unplugged/replugged.
---
Externals/hidapi/mac/hid.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/Externals/hidapi/mac/hid.c b/Externals/hidapi/mac/hid.c
index 38bb635af2..46a97886d7 100644
--- a/Externals/hidapi/mac/hid.c
+++ b/Externals/hidapi/mac/hid.c
@@ -217,6 +217,11 @@ static int32_t get_location_id(IOHIDDeviceRef device)
return get_int_property(device, CFSTR(kIOHIDLocationIDKey));
}
+static int32_t get_unique_id(IOHIDDeviceRef device)
+{
+ return get_int_property(device, CFSTR(kIOHIDUniqueIDKey));
+}
+
static int32_t get_max_report_length(IOHIDDeviceRef device)
{
return get_int_property(device, CFSTR(kIOHIDMaxInputReportSizeKey));
@@ -337,6 +342,7 @@ static int make_path(IOHIDDeviceRef device, char *buf, size_t len)
unsigned short vid, pid;
char transport[32];
int32_t location;
+ int32_t unique_id;
buf[0] = '\0';
@@ -347,12 +353,17 @@ static int make_path(IOHIDDeviceRef device, char *buf, size_t len)
if (!res)
return -1;
- location = get_location_id(device);
- vid = get_vendor_id(device);
- pid = get_product_id(device);
+ unique_id = get_unique_id(device);
+ if (unique_id != 0) {
+ res = snprintf(buf, len, "id_%x", unique_id);
+ } else {
+ location = get_location_id(device);
+ vid = get_vendor_id(device);
+ pid = get_product_id(device);
- res = snprintf(buf, len, "%s_%04hx_%04hx_%x",
- transport, vid, pid, location);
+ res = snprintf(buf, len, "%s_%04hx_%04hx_%x",
+ transport, vid, pid, location);
+ }
buf[len-1] = '\0';
--
2.14.3 (Apple Git-98)