From fa5f61f59d6cbd0bbcd12ae7ebdc4098729065bb Mon Sep 17 00:00:00 2001 From: Zach Smith Date: Mon, 20 Sep 2010 22:25:27 -0400 Subject: [PATCH] dinput: OSX joystick driver separate device for each top level HID collection. --- dlls/dinput/joystick_osx.c | 123 +++++++++++++++++++++++++++++++------ 1 file changed, 103 insertions(+), 20 deletions(-) diff --git a/dlls/dinput/joystick_osx.c b/dlls/dinput/joystick_osx.c index bc6908b0119..fc218d3f722 100644 --- a/dlls/dinput/joystick_osx.c +++ b/dlls/dinput/joystick_osx.c @@ -119,7 +119,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(dinput); #ifdef HAVE_IOHIDMANAGERCREATE static IOHIDManagerRef gIOHIDManagerRef = NULL; -static CFArrayRef gDevices = NULL; +static CFArrayRef gCollections = NULL; typedef struct JoystickImpl JoystickImpl; static const IDirectInputDevice8AVtbl JoystickAvt; @@ -194,6 +194,64 @@ static CFMutableDictionaryRef creates_osx_device_match(int usage) return result; } +static CFIndex find_top_level(IOHIDDeviceRef tIOHIDDeviceRef, CFArrayRef topLevels) +{ + CFArrayRef gElementCFArrayRef; + CFIndex numTops = 0; + + if (!tIOHIDDeviceRef) + return 0; + + gElementCFArrayRef = IOHIDDeviceCopyMatchingElements(tIOHIDDeviceRef, NULL, 0); + + if (gElementCFArrayRef) + { + CFIndex idx, cnt = CFArrayGetCount(gElementCFArrayRef); + for (idx=0; idxelementCFArrayRef = NULL; - if (!gDevices) + if (!gCollections) return; - tIOHIDDeviceRef = ( IOHIDDeviceRef ) CFArrayGetValueAtIndex( gDevices, device->id ); + tIOHIDElementRef = (IOHIDElementRef)CFArrayGetValueAtIndex(gCollections, device->id); - if (!tIOHIDDeviceRef) + if (!tIOHIDElementRef) return; - gElementCFArrayRef = IOHIDDeviceCopyMatchingElements( tIOHIDDeviceRef, - NULL, 0 ); + gElementCFArrayRef = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); + get_element_children(tIOHIDElementRef, gElementCFArrayRef); if (gElementCFArrayRef) { @@ -439,15 +520,17 @@ static void get_osx_device_elements_props(JoystickImpl *device) static void poll_osx_device_state(JoystickGenericImpl *device_in) { JoystickImpl *device = (JoystickImpl*)device_in; + IOHIDElementRef tIOHIDTopElementRef; IOHIDDeviceRef tIOHIDDeviceRef; CFArrayRef gElementCFArrayRef = device->elementCFArrayRef; TRACE("polling device %i\n",device->id); - if (!gDevices) + if (!gCollections) return; - tIOHIDDeviceRef = ( IOHIDDeviceRef ) CFArrayGetValueAtIndex( gDevices, device->id ); + tIOHIDTopElementRef = (IOHIDElementRef) CFArrayGetValueAtIndex(gCollections, device->id); + tIOHIDDeviceRef = IOHIDElementGetDevice(tIOHIDTopElementRef); if (!tIOHIDDeviceRef) return;