[3/3] dinput: OSX joystick driver seperate device for each top level HID collection
Zachary Smith
iamsparticle at gmail.com
Sun Sep 19 16:21:51 CDT 2010
Hello Again-
This Patch:
This patch implements treating each HID top-level collection as a separate
device. It requires both patches [1/3] and [2/3] in the series to function
properly.
-Zach Smith
---
dlls/dinput/joystick_osx.c | 64
+++++++++++++++++++++++++++++++-------------
1 files changed, 45 insertions(+), 19 deletions(-)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20100919/13d99858/attachment-0001.htm>
-------------- next part --------------
From 0dbb253101e4fd072899e7be91f4b675f78aa87e Mon Sep 17 00:00:00 2001
From: Zach Smith <IAmSparticle at gmail.com>
Date: Sat, 18 Sep 2010 01:13:17 -0400
Subject: dinput: OSX joystick driver seperate device for each top level HID collection
Fixes button ID collisions for multiple joysticks on one overall HID Descriptor
---
dlls/dinput/joystick_osx.c | 64 +++++++++++++++++++++++++++++++-------------
1 files changed, 45 insertions(+), 19 deletions(-)
diff --git a/dlls/dinput/joystick_osx.c b/dlls/dinput/joystick_osx.c
index dc2cec5..1e7e4f9 100644
--- a/dlls/dinput/joystick_osx.c
+++ b/dlls/dinput/joystick_osx.c
@@ -119,7 +119,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(dinput);
#ifdef HAVE_IOHIDMANAGERCREATE
static IOHIDManagerRef gIOHIDManagerRef = NULL;
-static CFArrayRef gDevices = NULL;
+static CFArrayRef gCollections = NULL;
typedef struct JoystickImpl JoystickImpl;
static const IDirectInputDevice8AVtbl JoystickAvt;
@@ -267,14 +267,14 @@ static int find_osx_devices(void)
&kCFTypeArrayCallBacks );
/* build matching dictionary */
- result = creates_osx_device_match(kHIDPage_Sport);
+ result = creates_osx_device_match(kHIDUsage_GD_Joystick);
if (!result)
{
CFRelease(matching);
return 0;
}
CFArrayAppendValue( ( CFMutableArrayRef )matching, result );
- result = creates_osx_device_match(kHIDPage_Game);
+ result = creates_osx_device_match(kHIDUsage_GD_GamePad);
if (!result)
{
CFRelease(matching);
@@ -286,17 +286,32 @@ static int find_osx_devices(void)
devset = IOHIDManagerCopyDevices( gIOHIDManagerRef );
if (devset)
{
- CFIndex count;
- gDevices = CFArrayCreateMutable( kCFAllocatorDefault, 0,
+ CFIndex countDevices, countCollections, idx;
+ CFArrayRef gDevices = CFArrayCreateMutable( kCFAllocatorDefault, 0,
&kCFTypeArrayCallBacks );
CFSetApplyFunction(devset, CFSetApplierFunctionCopyToCFArray, (void*)gDevices);
- count = CFArrayGetCount( gDevices);
CFRelease( devset);
- count = CFArrayGetCount( gDevices);
+ countDevices = CFArrayGetCount( gDevices);
- TRACE("found %i device(s)\n",(int)count);
- return count;
+ gCollections = CFArrayCreateMutable( kCFAllocatorDefault, 0,
+ &kCFTypeArrayCallBacks );
+ if (!gCollections)
+ return 0;
+ countCollections = 0;
+ for ( idx = 0; idx < countDevices; idx++ ) {
+ CFIndex tTop;
+ IOHIDDeviceRef tDevice;
+
+ tDevice = (IOHIDDeviceRef) CFArrayGetValueAtIndex( gDevices, idx );
+ tTop = find_top_level( tDevice, gCollections);
+ countCollections += tTop;
+ }
+
+ CFRelease(gDevices);
+
+ TRACE("found %i device(s), %i collection(s)\n",(int)countDevices,(int)countCollections);
+ return (int) countCollections;
}
return 0;
}
@@ -304,12 +319,21 @@ static int find_osx_devices(void)
static int get_osx_device_name(int id, char *name, int length)
{
CFStringRef str;
+ IOHIDElementRef tIOHIDElementRef;
IOHIDDeviceRef tIOHIDDeviceRef;
- if (!gDevices)
+ if (!gCollections)
+ return 0;
+
+ tIOHIDElementRef = ( IOHIDElementRef ) CFArrayGetValueAtIndex( gCollections, id );
+
+ if (!tIOHIDElementRef)
+ {
+ ERR("Invalid Element requested %i\n",id);
return 0;
+ }
- tIOHIDDeviceRef = ( IOHIDDeviceRef ) CFArrayGetValueAtIndex( gDevices, id );
+ tIOHIDDeviceRef = IOHIDElementGetDevice( tIOHIDElementRef );
if (name)
name[0] = 0;
@@ -358,7 +382,7 @@ static void insert_sort_button(int header, IOHIDElementRef tIOHIDElementRef,
static void get_osx_device_elements(JoystickImpl *device, int axis_map[8])
{
- IOHIDDeviceRef tIOHIDDeviceRef;
+ IOHIDElementRef tIOHIDElementRef;
CFArrayRef gElementCFArrayRef;
DWORD axes = 0;
DWORD sliders = 0;
@@ -367,16 +391,16 @@ static void get_osx_device_elements(JoystickImpl *device, int axis_map[8])
device->elementCFArrayRef = NULL;
- if (!gDevices)
+ if (!gCollections)
return;
- tIOHIDDeviceRef = ( IOHIDDeviceRef ) CFArrayGetValueAtIndex( gDevices, device->id );
+ tIOHIDElementRef = ( IOHIDElementRef ) CFArrayGetValueAtIndex( gCollections, device->id );
- if (!tIOHIDDeviceRef)
+ if (!tIOHIDElementRef)
return;
- gElementCFArrayRef = IOHIDDeviceCopyMatchingElements( tIOHIDDeviceRef,
- NULL, 0 );
+ gElementCFArrayRef = CFArrayCreateMutable( kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks );
+ get_element_children( tIOHIDElementRef, gElementCFArrayRef );
if (gElementCFArrayRef)
{
@@ -493,15 +517,17 @@ static void get_osx_device_elements_props(JoystickImpl *device)
static void poll_osx_device_state(JoystickGenericImpl *device_in)
{
JoystickImpl *device = (JoystickImpl*)device_in;
+ IOHIDElementRef tIOHIDTopElementRef;
IOHIDDeviceRef tIOHIDDeviceRef;
CFArrayRef gElementCFArrayRef = device->elementCFArrayRef;
TRACE("polling device %i\n",device->id);
- if (!gDevices)
+ if (!gCollections)
return;
- tIOHIDDeviceRef = ( IOHIDDeviceRef ) CFArrayGetValueAtIndex( gDevices, device->id );
+ tIOHIDTopElementRef = ( IOHIDElementRef ) CFArrayGetValueAtIndex( gCollections, device->id );
+ tIOHIDDeviceRef = IOHIDElementGetDevice( tIOHIDTopElementRef );
if (!tIOHIDDeviceRef)
return;
--
1.7.1
More information about the wine-patches
mailing list