<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">--- src/hid_osx.c.orig	2023-02-20 16:21:28.000000000 +0800
+++ src/hid_osx.c	2023-06-20 10:42:18.000000000 +0800
@@ -12,7 +12,7 @@
 #include &lt;signal.h&gt;
 #include &lt;unistd.h&gt;
 
-#include &lt;Availability.h&gt;
+#include &lt;AvailabilityMacros.h&gt;
 #include &lt;CoreFoundation/CoreFoundation.h&gt;
 #include &lt;IOKit/IOKitLib.h&gt;
 #include &lt;IOKit/hid/IOHIDKeys.h&gt;
@@ -20,8 +20,9 @@
 
 #include "fido.h"
 
-#if __MAC_OS_X_VERSION_MIN_REQUIRED &lt; 120000
+#if MAC_OS_X_VERSION_MIN_REQUIRED &lt; 120000
 #define kIOMainPortDefault kIOMasterPortDefault
+#define kIOHIDManagerOptionNone 0x0
 #endif
 
 #define IOREG "ioreg://"
@@ -169,25 +170,27 @@
 static char *
 get_path(IOHIDDeviceRef dev)
 {
-	io_service_t	 s;
-	uint64_t	 id;
-	char		*path;
+	io_service_t	s;
+	io_string_t		path;
 
+#if MAC_OS_X_VERSION_MIN_REQUIRED &gt; 1050 &amp;&amp; !defined(__ppc__)
 	if ((s = IOHIDDeviceGetService(dev)) == MACH_PORT_NULL) {
 		fido_log_debug("%s: IOHIDDeviceGetService", __func__);
 		return (NULL);
 	}
+#endif
 
-	if (IORegistryEntryGetRegistryEntryID(s, &amp;id) != KERN_SUCCESS) {
-		fido_log_debug("%s: IORegistryEntryGetRegistryEntryID",
-		    __func__);
+	if (IORegistryEntryGetPath(s, kIOServicePlane, path) != KERN_SUCCESS) {
+		fido_log_debug("%s: IORegistryEntryGetPath", __func__);
 		return (NULL);
 	}
 
+#if MAC_OS_X_VERSION_MIN_REQUIRED &gt; 1050 &amp;&amp; !defined(__ppc__)
 	if (asprintf(&amp;path, "%s%llu", IOREG, (unsigned long long)id) == -1) {
 		fido_log_error(errno, "%s: asprintf", __func__);
 		return (NULL);
 	}
+#endif
 
 	return (path);
 }
@@ -362,6 +365,7 @@
 	return (0);
 }
 
+#if MAC_OS_X_VERSION_MIN_REQUIRED &gt; 1060
 static int
 disable_sigpipe(int fd)
 {
@@ -391,6 +395,7 @@
 	return (IOServiceGetMatchingService(kIOMainPortDefault,
 	    IORegistryEntryIDMatching(id)));
 }
+#endif
 
 void *
 fido_hid_open(const char *path)
@@ -414,6 +419,7 @@
 		goto fail;
 	}
 
+#if MAC_OS_X_VERSION_MIN_REQUIRED &gt; 1060
 	if (set_nonblock(ctx-&gt;report_pipe[0]) &lt; 0 ||
 	    set_nonblock(ctx-&gt;report_pipe[1]) &lt; 0) {
 		fido_log_debug("%s: set_nonblock", __func__);
@@ -429,6 +435,12 @@
 		fido_log_debug("%s: get_ioreg_entry: %s", __func__, path);
 		goto fail;
 	}
+#else
+	if ((entry = IORegistryEntryFromPath(kIOMainPortDefault,path)) == MACH_PORT_NULL) {
+		fido_log_debug("%s: IORegistryEntryFromPath: %s", __func__, path);
+		goto fail;
+	}
+#endif
 
 	if ((ctx-&gt;ref = IOHIDDeviceCreate(kCFAllocatorDefault,
 	    entry)) == NULL) {
</pre></body></html>