[v4 2/4] winejoystick.drv/joystick_osx.c: fixes Slider mapping

David Lawrie david.dljunk at gmail.com
Mon Jun 13 00:11:18 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.

v2: whitespace fixes
v3: split patch up
v4: sign-off statement correction

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

diff --git a/dlls/winejoystick.drv/joystick_osx.c b/dlls/winejoystick.drv/joystick_osx.c
index 77dbef8..4e59ca3 100644
--- a/dlls/winejoystick.drv/joystick_osx.c
+++ b/dlls/winejoystick.drv/joystick_osx.c
@@ -442,8 +442,26 @@ 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;
+                        TRACE("kIOHIDElementTypeInput_Misc / kHIDUsage_GD_<axis> (%d)", usage);
+                        while(axis < 3 && joystick->axes[possible_axes[axis]].element)
+                            axis++;
+                        if (axis == 3)
+                            TRACE("    ignoring\n");
+                        else
+                        {
+                            TRACE(" axis %d\n", 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;
-- 
2.5.4 (Apple Git-61)




More information about the wine-patches mailing list