Mercurial > sdl-ios-xcode
comparison 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 |
comparison
equal
deleted
inserted
replaced
2545:0e63e7e4a986 | 2546:daf40497dcd4 |
---|---|
199 static int | 199 static int |
200 HIDGetDeviceProduct(io_service_t dev, char *name) | 200 HIDGetDeviceProduct(io_service_t dev, char *name) |
201 { | 201 { |
202 CFMutableDictionaryRef hidProperties, usbProperties; | 202 CFMutableDictionaryRef hidProperties, usbProperties; |
203 io_registry_entry_t parent1, parent2; | 203 io_registry_entry_t parent1, parent2; |
204 kern_return_t ret; | |
204 | 205 |
205 hidProperties = usbProperties = 0; | 206 hidProperties = usbProperties = 0; |
207 | |
208 ret = IORegistryEntryCreateCFProperties(hidDevice, &hidProperties, | |
209 kCFAllocatorDefault, | |
210 kNilOptions); | |
211 if ((ret != KERN_SUCCESS) || !hidProperties) { | |
212 SDL_SetError("Haptic: Unable to create CFProperties."); | |
213 return -1; | |
214 } | |
206 | 215 |
207 /* Mac OS X currently is not mirroring all USB properties to HID page so need to look at USB device page also | 216 /* Mac OS X currently is not mirroring all USB properties to HID page so need to look at USB device page also |
208 * get dictionary for usb properties: step up two levels and get CF dictionary for USB properties | 217 * get dictionary for usb properties: step up two levels and get CF dictionary for USB properties |
209 */ | 218 */ |
210 if ((KERN_SUCCESS == | 219 if ((KERN_SUCCESS == |
211 IORegistryEntryGetParentEntry(dev, kIOServicePlane, &parent1)) | 220 IORegistryEntryGetParentEntry(dev, kIOServicePlane, &parent1)) |
212 && (KERN_SUCCESS == | 221 && (KERN_SUCCESS == |
213 IORegistryEntryGetParentEntry(parent1, kIOServicePlane, &parent2)) | 222 IORegistryEntryGetParentEntry(parent1, kIOServicePlane, &parent2)) |
214 && (KERN_SUCCESS == | 223 && (KERN_SUCCESS == |
215 IORegistryEntryCreateCFProperties(parent2, &usbProperties, | 224 IORegistryEntryCreateCFProperties(parent2, &usbProperties, |
216 kCFAllocatorDefault, | 225 kCFAllocatorDefault, |
217 kNilOptions))) { | 226 kNilOptions))) { |
218 if (usbProperties) { | 227 if (usbProperties) { |
219 CFTypeRef refCF = 0; | 228 CFTypeRef refCF = 0; |
220 /* get device info | 229 /* get device info |
221 * try hid dictionary first, if fail then go to usb dictionary | 230 * try hid dictionary first, if fail then go to usb dictionary |
222 */ | 231 */ |
223 | 232 |
224 | 233 |
225 /* Get product name */ | 234 /* Get product name */ |
226 refCF = | 235 refCF = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDProductKey)); |
227 CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDProductKey)); | |
228 if (!refCF) | 236 if (!refCF) |
229 refCF = | 237 refCF = |
230 CFDictionaryGetValue(usbProperties, CFSTR("USB Product Name")); | 238 CFDictionaryGetValue(usbProperties, CFSTR("USB Product Name")); |
231 if (refCF) { | 239 if (refCF) { |
232 if (!CFStringGetCString(refCF, name, 256, | 240 if (!CFStringGetCString(refCF, name, 256, |
249 } | 257 } |
250 if (kIOReturnSuccess != IOObjectRelease(parent1)) { | 258 if (kIOReturnSuccess != IOObjectRelease(parent1)) { |
251 SDL_SetError("IOObjectRelease error with parent1."); | 259 SDL_SetError("IOObjectRelease error with parent1."); |
252 } | 260 } |
253 } | 261 } |
262 else { | |
263 SDL_SetError("Haptic: Error getting registry entries."); | |
264 return -1; | |
265 } | |
266 | |
254 return 0; | 267 return 0; |
255 } | 268 } |
256 | 269 |
257 | 270 |
258 #define FF_TEST(ff, s) \ | 271 #define FF_TEST(ff, s) \ |