David Lawrie : dinput: Sort devices by location ID on the Mac.
Alexandre Julliard
julliard at winehq.org
Thu Jul 14 08:58:04 CDT 2016
Module: wine
Branch: master
Commit: 33c43473c0a5d1a872b50757a9bace654a6502c8
URL: http://source.winehq.org/git/wine.git/?a=commit;h=33c43473c0a5d1a872b50757a9bace654a6502c8
Author: David Lawrie <david.dljunk at gmail.com>
Date: Mon Jul 11 04:06:01 2016 -0700
dinput: Sort devices by location ID on the Mac.
Signed-off-by: David Lawrie <david.dljunk at gmail.com>
Signed-off-by: Ken Thomases <ken at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/dinput/joystick_osx.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/dlls/dinput/joystick_osx.c b/dlls/dinput/joystick_osx.c
index 21d8d51..e937647 100644
--- a/dlls/dinput/joystick_osx.c
+++ b/dlls/dinput/joystick_osx.c
@@ -204,6 +204,18 @@ static void CFSetApplierFunctionCopyToCFArray(const void *value, void *context)
CFArrayAppendValue( ( CFMutableArrayRef ) context, value );
}
+static CFComparisonResult device_location_comparator(const void *val1, const void *val2, void *context)
+{
+ IOHIDDeviceRef device1 = (IOHIDDeviceRef)val1, device2 = (IOHIDDeviceRef)val2;
+ long loc1 = get_device_location_ID(device1), loc2 = get_device_location_ID(device2);
+
+ if (loc1 < loc2)
+ return kCFCompareLessThan;
+ else if (loc1 > loc2)
+ return kCFCompareGreaterThan;
+ return kCFCompareEqualTo;
+}
+
static const char* debugstr_cf(CFTypeRef t)
{
CFStringRef s;
@@ -478,6 +490,7 @@ static int find_osx_devices(void)
CFSetApplyFunction(devset, CFSetApplierFunctionCopyToCFArray, devices);
CFRelease( devset);
num_devices = CFArrayGetCount(devices);
+ CFArraySortValues(devices, CFRangeMake(0, num_devices), device_location_comparator, NULL);
device_main_elements = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
if (!device_main_elements)
More information about the wine-cvs
mailing list