Added some fallbacks if the HID Manager can't provide an actual device name.
authorRyan C. Gordon <icculus@icculus.org>
Sat, 15 Oct 2011 13:44:16 -0400
changeset 115 00ccb93a8e38
parent 114 039143fcea3b
child 116 b10b5fb6d8e0
Added some fallbacks if the HID Manager can't provide an actual device name.
macosx_hidmanager.c
--- a/macosx_hidmanager.c	Sun Aug 21 09:43:38 2011 -0400
+++ b/macosx_hidmanager.c	Sat Oct 15 13:44:16 2011 -0400
@@ -47,7 +47,14 @@
     CFStringRef cfstr = (CFStringRef) IOHIDDeviceGetProperty(device,
                                                     CFSTR(kIOHIDProductKey));
     if (!cfstr)
-        return NULL;
+    {
+        /* Maybe we can't get "AwesomeMouse2000", but we can get "Logitech"? */
+        cfstr = (CFStringRef) IOHIDDeviceGetProperty(device,
+                                                 CFSTR(kIOHIDManufacturerKey));
+    } /* if */
+
+    if (!cfstr)
+        return strdup("Unidentified mouse device");  /* oh well. */
 
     CFRetain(cfstr);
     len = (CFStringGetLength(cfstr)+1) * 12; /* 12 is overkill, but oh well. */