[v5 2/5] winejoystick.drv/joystick_osx.c: fixes Slider mapping

David Lawrie david.dljunk at gmail.com
Tue Jun 14 22:33:49 CDT 2016


Sliders, Dials, and Wheels now map to Z, U (Ry), or V (Rx) depending on
availability. Thus, also adds support for up to 3 such HID elements.

Sources:
https://msdn.microsoft.com/en-us/library/windows/hardware/ff538340(v=vs.
85).aspx
https://msdn.microsoft.com/en-us/library/windows/hardware/ff543445(v=vs.
85).aspx
http://opensource.apple.com//source/IOHIDFamily/IOHIDFamily-315.7.16/
IOHIDFamily/IOHIDUsageTables.h

Tested on OS X 10.10.5.

Tested on Red Baron 3D, X-wing vs Tie Fighter, X-wing Alliance,
Independence War deluxe w/ Logitech Extreme 3D pro and ControllerMate
virtual joystick with 5/6 axes.

Signed-off-by: David Lawrie <david.dljunk at gmail.com>
---
 dlls/winejoystick.drv/joystick_osx.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/dlls/winejoystick.drv/joystick_osx.c b/dlls/winejoystick.drv/joystick_osx.c
index 42046a4..1edd8e9 100644
--- a/dlls/winejoystick.drv/joystick_osx.c
+++ b/dlls/winejoystick.drv/joystick_osx.c
@@ -442,8 +442,25 @@ static void collect_joystick_elements(joystick_t* joystick, IOHIDElementRef coll
                         break;
                     }
                     case kHIDUsage_GD_Slider:
-                        TRACE("kIOHIDElementTypeInput_Misc / kHIDUsage_GD_Slider; ignoring\n");
+                    case kHIDUsage_GD_Dial:
+                    case kHIDUsage_GD_Wheel:
+                    {
+                        /* if one axis is taken, fall to the next until axes are filled */
+                        int possible_axes[3] = {AXIS_Z,AXIS_RY,AXIS_RX};
+                        int axis = 0;
+                        while(axis < 3 && joystick->axes[possible_axes[axis]].element)
+                            axis++;
+                        if (axis == 3)
+                            TRACE("kIOHIDElementTypeInput_Misc / kHIDUsage_GD_<axis> (%d)\n    ignoring\n", usage);
+                        else
+                        {
+                            TRACE("kIOHIDElementTypeInput_Misc / kHIDUsage_GD_<axis> (%d) axis %d\n", usage, possible_axes[axis]);
+                            joystick->axes[possible_axes[axis]].element = (IOHIDElementRef)CFRetain(child);
+                            joystick->axes[possible_axes[axis]].min_value = IOHIDElementGetLogicalMin(child);
+                            joystick->axes[possible_axes[axis]].max_value = IOHIDElementGetLogicalMax(child);
+                        }
                         break;
+                    }
                     default:
                         FIXME("kIOHIDElementTypeInput_Misc / Unhandled usage %d\n", usage);
                         break;
-- 
1.7.12.4 (Apple Git-37)




More information about the wine-patches mailing list