[2/3] dinput: Add element retrieval for top level collections in OSX joystick driver

Zachary Smith iamsparticle at gmail.com
Sun Sep 19 16:21:39 CDT 2010


Hello again-

This Patch:
Here I add get_element_children() to the driver.  It descends through the
tree rooted at a given collection to return all the element it finds.  This
patch in independent of [1/3] but require for patch [3/3].

-Zach Smith
---
 dlls/dinput/joystick_osx.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20100919/6ed20521/attachment.htm>
-------------- next part --------------
From edf003b54cf0a11d64fd17bfc692125f5ba455ec Mon Sep 17 00:00:00 2001
From: Zach Smith <IAmSparticle at gmail.com>
Date: Fri, 17 Sep 2010 23:59:31 -0400
Subject: dinput: Add element retrieval for top level collections in OSX joystick driver

---
 dlls/dinput/joystick_osx.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/dlls/dinput/joystick_osx.c b/dlls/dinput/joystick_osx.c
index 2e30976..dc2cec5 100644
--- a/dlls/dinput/joystick_osx.c
+++ b/dlls/dinput/joystick_osx.c
@@ -227,6 +227,27 @@ static CFIndex find_top_level(IOHIDDeviceRef tIOHIDDeviceRef, CFArrayRef topLeve
     return numTops;
 }
 
+static void get_element_children( IOHIDElementRef tElement, CFArrayRef childElements )
+{
+    CFIndex idx, cnt;
+    CFArrayRef tElementChildrenArray = IOHIDElementGetChildren(tElement);
+
+    cnt = CFArrayGetCount( tElementChildrenArray );
+    if (cnt < 1)
+        return;
+
+    /* Either add the element to the array or grab its children */
+    for (idx=0; idx<cnt; idx++) {
+        IOHIDElementRef tChildElementRef = CFArrayGetValueAtIndex( tElementChildrenArray, idx);
+
+        if (IOHIDElementGetType( tChildElementRef ) == kIOHIDElementTypeCollection) {
+            get_element_children( tChildElementRef, childElements);
+        } else {
+            CFArrayAppendValue( childElements, tChildElementRef );
+        }
+    }
+}
+
 static int find_osx_devices(void)
 {
     IOReturn tIOReturn;
-- 
1.7.1


More information about the wine-patches mailing list