[v1 1/2] winejoystick.drv/joystick_osx.c: debugstr_device prints location ID

David Lawrie david.dljunk at gmail.com
Fri Jun 24 20:33:15 CDT 2016


Tested on OS X 10.10.5.

Signed-off-by: David Lawrie <david.dljunk at gmail.com>
---
 dlls/winejoystick.drv/joystick_osx.c | 32 ++++++++++++++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)

diff --git a/dlls/winejoystick.drv/joystick_osx.c b/dlls/winejoystick.drv/joystick_osx.c
index 12ccff7..4ef30cc 100644
--- a/dlls/winejoystick.drv/joystick_osx.c
+++ b/dlls/winejoystick.drv/joystick_osx.c
@@ -121,6 +121,33 @@ typedef struct {
 static joystick_t joysticks[MAXJOYSTICK];
 static CFMutableArrayRef device_main_elements = NULL;
 
+static Boolean IOHIDDevice_GetLongProperty(IOHIDDeviceRef inIOHIDDeviceRef, CFStringRef inKey, long * outValue)
+{
+    Boolean result = FALSE;
+    CFTypeRef tCFTypeRef;
+
+    if (inIOHIDDeviceRef) {
+        assert(IOHIDDeviceGetTypeID() == CFGetTypeID(inIOHIDDeviceRef));
+
+        tCFTypeRef = IOHIDDeviceGetProperty(inIOHIDDeviceRef, inKey);
+
+        if ( tCFTypeRef ) {
+            /* if this is a number */
+            if (CFNumberGetTypeID() == CFGetTypeID(tCFTypeRef)) {
+                /* get it's value */
+                result = CFNumberGetValue((CFNumberRef)tCFTypeRef, kCFNumberSInt32Type, outValue);
+            }
+        }
+    }
+    return result;
+}
+
+long IOHIDDevice_GetLocationID(IOHIDDeviceRef inIOHIDDeviceRef)
+{
+    long result = 0;
+    (void)IOHIDDevice_GetLongProperty(inIOHIDDeviceRef, CFSTR(kIOHIDLocationIDKey), &result);
+    return result;
+}
 
 static const char* debugstr_cf(CFTypeRef t)
 {
@@ -154,8 +181,9 @@ static const char* debugstr_cf(CFTypeRef t)
 
 static const char* debugstr_device(IOHIDDeviceRef device)
 {
-    return wine_dbg_sprintf("<IOHIDDevice %p product %s>", device,
-                            debugstr_cf(IOHIDDeviceGetProperty(device, CFSTR(kIOHIDProductKey))));
+    return wine_dbg_sprintf("<IOHIDDevice %p product %s IOHIDLocationID %lu>", device,
+                            debugstr_cf(IOHIDDeviceGetProperty(device, CFSTR(kIOHIDProductKey))),
+                            IOHIDDevice_GetLocationID(device));
 }
 
 static const char* debugstr_element(IOHIDElementRef element)
-- 
1.7.12.4 (Apple Git-37)




More information about the wine-patches mailing list