Attempt to fix HIDGetDeviceProduct. gsoc2008_force_feedback
authorEdgar Simo <bobbens@gmail.com>
Tue, 22 Jul 2008 11:40:43 +0000
branchgsoc2008_force_feedback
changeset 2546daf40497dcd4
parent 2545 0e63e7e4a986
child 2547 3cfe0ae232c0
Attempt to fix HIDGetDeviceProduct.
src/haptic/darwin/SDL_syshaptic.c
     1.1 --- a/src/haptic/darwin/SDL_syshaptic.c	Tue Jul 22 10:58:27 2008 +0000
     1.2 +++ b/src/haptic/darwin/SDL_syshaptic.c	Tue Jul 22 11:40:43 2008 +0000
     1.3 @@ -201,9 +201,18 @@
     1.4  {
     1.5     CFMutableDictionaryRef hidProperties, usbProperties;
     1.6     io_registry_entry_t parent1, parent2;
     1.7 +   kern_return_t ret;
     1.8  
     1.9     hidProperties = usbProperties = 0;
    1.10  
    1.11 +   ret = IORegistryEntryCreateCFProperties(hidDevice, &hidProperties,
    1.12 +                                           kCFAllocatorDefault,
    1.13 +                                           kNilOptions);
    1.14 +   if ((ret != KERN_SUCCESS) || !hidProperties) {
    1.15 +      SDL_SetError("Haptic: Unable to create CFProperties.");
    1.16 +      return -1;
    1.17 +   }
    1.18 +
    1.19     /* Mac OS X currently is not mirroring all USB properties to HID page so need to look at USB device page also
    1.20      * get dictionary for usb properties: step up two levels and get CF dictionary for USB properties
    1.21      */
    1.22 @@ -213,8 +222,8 @@
    1.23              IORegistryEntryGetParentEntry(parent1, kIOServicePlane, &parent2))
    1.24           && (KERN_SUCCESS ==
    1.25              IORegistryEntryCreateCFProperties(parent2, &usbProperties,
    1.26 -               kCFAllocatorDefault,
    1.27 -               kNilOptions))) {
    1.28 +                                              kCFAllocatorDefault,
    1.29 +                                              kNilOptions))) {
    1.30        if (usbProperties) {
    1.31           CFTypeRef refCF = 0;
    1.32           /* get device info
    1.33 @@ -223,8 +232,7 @@
    1.34  
    1.35  
    1.36           /* Get product name */
    1.37 -         refCF =
    1.38 -            CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDProductKey));
    1.39 +         refCF = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDProductKey));
    1.40           if (!refCF)
    1.41              refCF =
    1.42                 CFDictionaryGetValue(usbProperties, CFSTR("USB Product Name"));
    1.43 @@ -251,6 +259,11 @@
    1.44           SDL_SetError("IOObjectRelease error with parent1.");
    1.45        }
    1.46     }
    1.47 +   else {
    1.48 +      SDL_SetError("Haptic: Error getting registry entries.");
    1.49 +      return -1;
    1.50 +   }
    1.51 +
    1.52     return 0;
    1.53  }
    1.54