# HG changeset patch # User Edgar Simo # Date 1216726843 0 # Node ID daf40497dcd42c7e26519883069fcacd02bb5a30 # Parent 0e63e7e4a986c0728e850b423479d30d816b49bb Attempt to fix HIDGetDeviceProduct. diff -r 0e63e7e4a986 -r daf40497dcd4 src/haptic/darwin/SDL_syshaptic.c --- a/src/haptic/darwin/SDL_syshaptic.c Tue Jul 22 10:58:27 2008 +0000 +++ b/src/haptic/darwin/SDL_syshaptic.c Tue Jul 22 11:40:43 2008 +0000 @@ -201,9 +201,18 @@ { CFMutableDictionaryRef hidProperties, usbProperties; io_registry_entry_t parent1, parent2; + kern_return_t ret; hidProperties = usbProperties = 0; + ret = IORegistryEntryCreateCFProperties(hidDevice, &hidProperties, + kCFAllocatorDefault, + kNilOptions); + if ((ret != KERN_SUCCESS) || !hidProperties) { + SDL_SetError("Haptic: Unable to create CFProperties."); + return -1; + } + /* Mac OS X currently is not mirroring all USB properties to HID page so need to look at USB device page also * get dictionary for usb properties: step up two levels and get CF dictionary for USB properties */ @@ -213,8 +222,8 @@ IORegistryEntryGetParentEntry(parent1, kIOServicePlane, &parent2)) && (KERN_SUCCESS == IORegistryEntryCreateCFProperties(parent2, &usbProperties, - kCFAllocatorDefault, - kNilOptions))) { + kCFAllocatorDefault, + kNilOptions))) { if (usbProperties) { CFTypeRef refCF = 0; /* get device info @@ -223,8 +232,7 @@ /* Get product name */ - refCF = - CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDProductKey)); + refCF = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDProductKey)); if (!refCF) refCF = CFDictionaryGetValue(usbProperties, CFSTR("USB Product Name")); @@ -251,6 +259,11 @@ SDL_SetError("IOObjectRelease error with parent1."); } } + else { + SDL_SetError("Haptic: Error getting registry entries."); + return -1; + } + return 0; }