[v2 1/2] winejoystick.drv: Print location ID in debugstr_device

David Lawrie david.dljunk at gmail.com
Thu Jun 30 03:40:20 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 | 31 +++++++++++++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/dlls/winejoystick.drv/joystick_osx.c b/dlls/winejoystick.drv/joystick_osx.c
index 12ccff7..111b9c1 100644
--- a/dlls/winejoystick.drv/joystick_osx.c
+++ b/dlls/winejoystick.drv/joystick_osx.c
@@ -121,6 +121,32 @@ typedef struct {
 static joystick_t joysticks[MAXJOYSTICK];
 static CFMutableArrayRef device_main_elements = NULL;
 
+static Boolean get_device_property_long(IOHIDDeviceRef in_device, CFStringRef in_key, long * out_value)
+{
+    Boolean result = FALSE;
+    CFTypeRef type;
+
+    if (in_device)
+    {
+        assert(IOHIDDeviceGetTypeID() == CFGetTypeID(in_device));
+
+        type = IOHIDDeviceGetProperty(in_device, in_key);
+
+        if (type)
+        {
+            if (CFNumberGetTypeID() == CFGetTypeID(type))
+                result = CFNumberGetValue((CFNumberRef)type, kCFNumberLongType, out_value);
+        }
+    }
+    return result;
+}
+
+long get_device_location_ID(IOHIDDeviceRef in_device)
+{
+    long result = 0;
+    get_device_property_long(in_device, CFSTR(kIOHIDLocationIDKey), &result);
+    return result;
+}
 
 static const char* debugstr_cf(CFTypeRef t)
 {
@@ -154,8 +180,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))),
+                            get_device_location_ID(device));
 }
 
 static const char* debugstr_element(IOHIDElementRef element)
-- 
1.7.12.4 (Apple Git-37)




More information about the wine-patches mailing list