[v2 2/2] winejoystick.drv: Disable joysticks via wine registry on Mac
David Lawrie
david.dljunk at gmail.com
Mon Aug 29 06:03:09 CDT 2016
Converts device name to char array then looks up name in disabled list
in wine registry
Tested on OS X 10.10.5.
Signed-off-by: David Lawrie <david.dljunk at gmail.com>
---
dlls/winejoystick.drv/joystick_osx.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/dlls/winejoystick.drv/joystick_osx.c b/dlls/winejoystick.drv/joystick_osx.c
index bf82f67..1d6c41b 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));
@@ -451,8 +473,13 @@ static int find_osx_devices(void)
num_main_elements = 0;
for (i = 0; i < num_devices; i++)
{
+ char name[MAX_PATH];
IOHIDDeviceRef hid_device = (IOHIDDeviceRef)CFArrayGetValueAtIndex(devices, i);
+
TRACE("hid_device %s\n", debugstr_device(hid_device));
+ char_device_name_length(hid_device, name, MAX_PATH);
+ if (device_disabled_registry(name))
+ continue;
num_main_elements += find_top_level(hid_device, device_main_elements);
}
--
1.7.12.4 (Apple Git-37)
More information about the wine-patches
mailing list