Fixed SDL_HapticNewEffect() failing on various DirectInput devices.
authorRyan C. Gordon <icculus@icculus.org>
Tue, 18 Mar 2014 17:16:28 -0400
changeset 8634 a60eaa04d3fb
parent 8633 05237b5e8366
child 8635 f1076ec9e707
Fixed SDL_HapticNewEffect() failing on various DirectInput devices.
src/haptic/windows/SDL_syshaptic.c
--- a/src/haptic/windows/SDL_syshaptic.c	Tue Mar 18 12:53:01 2014 -0400
+++ b/src/haptic/windows/SDL_syshaptic.c	Tue Mar 18 17:16:28 2014 -0400
@@ -507,8 +507,25 @@
     SDL_Haptic *haptic = (SDL_Haptic *) pvRef;
 
     if ((dev->dwType & DIDFT_AXIS) && (dev->dwFlags & DIDOI_FFACTUATOR)) {
+        const GUID *guid = &dev->guidType;
+        DWORD offset = 0;
+        if (DI_GUIDIsSame(guid, &GUID_XAxis)) {
+            offset = DIJOFS_X;
+        } else if (DI_GUIDIsSame(guid, &GUID_YAxis)) {
+            offset = DIJOFS_Y;
+        } else if (DI_GUIDIsSame(guid, &GUID_ZAxis)) {
+            offset = DIJOFS_Z;
+        } else if (DI_GUIDIsSame(guid, &GUID_RxAxis)) {
+            offset = DIJOFS_RX;
+        } else if (DI_GUIDIsSame(guid, &GUID_RyAxis)) {
+            offset = DIJOFS_RY;
+        } else if (DI_GUIDIsSame(guid, &GUID_RzAxis)) {
+            offset = DIJOFS_RZ;
+        } else {
+            return DIENUM_CONTINUE;   /* can't use this, go on. */
+        }
 
-        haptic->hwdata->axes[haptic->naxes] = dev->dwOfs;
+        haptic->hwdata->axes[haptic->naxes] = offset;
         haptic->naxes++;
 
         /* Currently using the artificial limit of 3 axes. */