Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Attempt to fix HIDGetDeviceProduct.
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbens committed Jul 22, 2008
1 parent e5a46b4 commit 5a0c7f4
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/haptic/darwin/SDL_syshaptic.c
Expand Up @@ -201,9 +201,18 @@ HIDGetDeviceProduct(io_service_t dev, char *name)
{
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
*/
Expand All @@ -213,8 +222,8 @@ HIDGetDeviceProduct(io_service_t dev, char *name)
IORegistryEntryGetParentEntry(parent1, kIOServicePlane, &parent2))
&& (KERN_SUCCESS ==
IORegistryEntryCreateCFProperties(parent2, &usbProperties,
kCFAllocatorDefault,
kNilOptions))) {
kCFAllocatorDefault,
kNilOptions))) {
if (usbProperties) {
CFTypeRef refCF = 0;
/* get device info
Expand All @@ -223,8 +232,7 @@ HIDGetDeviceProduct(io_service_t dev, char *name)


/* Get product name */
refCF =
CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDProductKey));
refCF = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDProductKey));
if (!refCF)
refCF =
CFDictionaryGetValue(usbProperties, CFSTR("USB Product Name"));
Expand All @@ -251,6 +259,11 @@ HIDGetDeviceProduct(io_service_t dev, char *name)
SDL_SetError("IOObjectRelease error with parent1.");
}
}
else {
SDL_SetError("Haptic: Error getting registry entries.");
return -1;
}

return 0;
}

Expand Down

0 comments on commit 5a0c7f4

Please sign in to comment.