[v1 4/5] winejoystick.drv: Convert device name to char array on Mac

David Lawrie david.dljunk at gmail.com
Sun Aug 28 01:18: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 | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/dlls/winejoystick.drv/joystick_osx.c b/dlls/winejoystick.drv/joystick_osx.c
index bf82f67..131f1a1 100644
--- a/dlls/winejoystick.drv/joystick_osx.c
+++ b/dlls/winejoystick.drv/joystick_osx.c
@@ -171,6 +171,28 @@ static CFStringRef copy_device_name(IOHIDDeviceRef device)
     return name;
 }
 
+static void char_device_name_length(IOHIDDeviceRef device, char *name, int max_length)
+{
+    CFStringRef str = copy_device_name(device);
+    CFIndex len = CFStringGetLength(str);
+
+    if (name)
+        name[0] = 0;
+
+    if (max_length >= len)
+    {
+        CFStringGetCString(str,name,max_length,kCFStringEncodingASCII);
+        CFRelease(str);
+    }
+    else
+    {
+        CFStringRef substr = CFStringCreateWithSubstring(kCFAllocatorDefault, str, CFRangeMake(0, max_length));
+        CFRelease(str);
+        CFStringGetCString(substr,name,max_length,kCFStringEncodingASCII);
+        CFRelease(substr);
+    }
+}
+
 static long get_device_location_ID(IOHIDDeviceRef device)
 {
     return get_device_property_long(device, CFSTR(kIOHIDLocationIDKey));
-- 
1.7.12.4 (Apple Git-37)




More information about the wine-patches mailing list