Mercurial > sdl-ios-xcode
diff src/haptic/darwin/SDL_syshaptic.c @ 2546:daf40497dcd4 gsoc2008_force_feedback
Attempt to fix HIDGetDeviceProduct.
author | Edgar Simo <bobbens@gmail.com> |
---|---|
date | Tue, 22 Jul 2008 11:40:43 +0000 |
parents | 3544a632064c |
children | 3cfe0ae232c0 |
line wrap: on
line diff
--- 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; }