http://bugs.winehq.org/show_bug.cgi?id=18424
--- Comment #75 from david.dljunk@gmail.com 2013-02-06 20:05:26 CST --- Here's a summary of what I've found looking at dinput and winmm:
------------ dinput
1. Linux has two dinput joystick implementations: 1) for regular joysticks, 2) for force-feedback joysticks. The list of items at the end of each program give away which functionalities have been implemented and which haven't. For instance, in joystick_linux.c "JoystickAGenericImpl_Poll" indicates that polling the joystick has been implemented but "IDirectInputDevice2AImpl_GetForceFeedbackState" indicates getting the force feedback information has not. Whereas in joystick_linuxinput, instead of "IDirectInputDevice2AImpl_GetForceFeedbackState" it has "JoystickAImpl_GetForceFeedbackState". OS X does not have force-feedback joystick code implemented.
2. Interestingly joystick_osx.c does not have the acquire or release functions implemented while both linux.c and linux_input.c do ("JoystickLinuxAImpl_Acquire","JoystickLinuxAImpl_Unacquire"). In keeping with this the Linux programs have the purely internal functions IDirectInputDevice8W_from_impl (and 8A) used in the acquire function implemented in Linux joystick files but not OS X. I've not experienced any bugs or problems so far in dinput games using wine-OS X, though I see bug reports and patches associated with the acquire/unacquire functions on the Linux side. Is there something about the OS X implementation that doesn't need this, or are we missing some dinput functionality that I'm simply not aware of on the OS X side?
As an aside: what's the difference between AINSII type A and UNICODE type W devices and why do some functions need to be written for each but others don't? I assume it is the type of messages being sent and received. Are they all joysticks or do gamepads use one and joysticks the other?
------------ winmm
winmm is looks easier to understand and shorter than dinput. :) I think I have a basic grip of the functions. Within the winmm folder, we have joystick.c. It seems some winmm functions were not truly implemented like ConfigChanged, but otherwise everything seems there. I'm not sure if the "messages" were implemented (http://msdn.microsoft.com/en-us/library/dd743594(v=vs.85).aspx) as I don't see any reference to them but also not sure if that's actually important as even possible as we have to communicate through the Linux/OS X layer anyway and they seem very limited in their functionality/age.
1. As aforementioned it calls a Linux-only driver named "winejoystick.drv".
static BOOL JOY_LoadDriver(DWORD dwJoyID) { if (dwJoyID >= MAXJOYSTICK) return FALSE; if (JOY_Sticks[dwJoyID].hDriver) return TRUE;
JOY_Sticks[dwJoyID].hDriver = OpenDriverA("winejoystick.drv", 0, dwJoyID); return (JOY_Sticks[dwJoyID].hDriver != 0); }
should probably be changed to:
static BOOL JOY_LoadDriver(DWORD dwJoyID) { if (dwJoyID >= MAXJOYSTICK) return FALSE; if (JOY_Sticks[dwJoyID].hDriver) return TRUE;
#if defined(HAVE_IOKIT_HID_IOHIDLIB_H) JOY_Sticks[dwJoyID].hDriver = OpenDriverA("wine_osxjoystick.drv", 0, dwJoyID); #else JOY_Sticks[dwJoyID].hDriver = OpenDriverA("wine_linuxjoystick.drv", 0, dwJoyID); #endif return (JOY_Sticks[dwJoyID].hDriver != 0); }
check if have the OSX type interface, then load the OS X driver, if not load the linux one (with the consequent change in the name of the current linux driver).
2. I noticed in the the current linux driver code (and winmm.c) reference to changes the authors wanted to make. Some I think were made (inclusion of new Linux 2.2 APIs), but others talk about folding all the joystick code in with the rest of the Winmm code and making the joystick driver part of the lolvl driver code. This was never done and exists outside the scope of my knowledge base. So I'm dealing with this as though the plan is to create a mac version of the linux driver that currently exists.
3. In winejoystick.drv, there is "joystick.c", the functions and structs are as follows:
- tagWINE_JSTCK (needs some modification for OS X)
- JSTCK_drvGet (I think no changes needed)
- JSTCK_drvOpen (I think no changes needed)
- JSTCK_drvClose (needs to be changed for OS X, close the OS X device manager)
- JSTCK_OpenDevice (can be folded into JSTCK_GetDevCaps or rewritten, find the requested OS X joystick/gamepad)
- JSTCK_GetDevCaps (needs to find the requested joystick/gamepad and return its properties - number of axes, buttons, etc ... - to lpCaps)
- JSTCK_GetPosEx (needs to be written for OS X, get the current state of all buttons, axes, etc ... of the requested device and return that information to lpInfo)
- JSTCK_GetPos (no changes needed, simply calls JSTCK_GetPosEx)
- JSTCK_DriverProc (no changes needed, simply calls the above functions)
------------
Anyway that's the summary so far of everything I think I know. :)