[PATCH 1/5] dinput: Debug print DIEFFECT structure

Andrew Eikum aeikum at codeweavers.com
Tue May 21 14:34:26 CDT 2013


---
 dlls/dinput/effect_linuxinput.c | 199 ++--------------------------------------
 dlls/dinput/joystick.c          | 178 +++++++++++++++++++++++++++++++++++
 dlls/dinput/joystick_osx.c      |   2 +
 dlls/dinput/joystick_private.h  |   3 +
 4 files changed, 189 insertions(+), 193 deletions(-)

diff --git a/dlls/dinput/effect_linuxinput.c b/dlls/dinput/effect_linuxinput.c
index 0fb183f..da1fb85 100644
--- a/dlls/dinput/effect_linuxinput.c
+++ b/dlls/dinput/effect_linuxinput.c
@@ -43,6 +43,7 @@
 #include "dinput.h"
 
 #include "device_private.h"
+#include "joystick_private.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(dinput);
 
@@ -67,194 +68,6 @@ static inline LinuxInputEffectImpl *impl_from_IDirectInputEffect(IDirectInputEff
 }
 
 /******************************************************************************
- *      DirectInputEffect Functional Helper
- */
-
-static DWORD _typeFromGUID(REFGUID guid)
-{
-    if (IsEqualGUID(guid, &GUID_ConstantForce)) {
-	return DIEFT_CONSTANTFORCE;
-    } else if (IsEqualGUID(guid, &GUID_Square)
-            || IsEqualGUID(guid, &GUID_Sine)
-            || IsEqualGUID(guid, &GUID_Triangle)
-            || IsEqualGUID(guid, &GUID_SawtoothUp)
-            || IsEqualGUID(guid, &GUID_SawtoothDown)) {
-	return DIEFT_PERIODIC;
-    } else if (IsEqualGUID(guid, &GUID_RampForce)) {
-	return DIEFT_RAMPFORCE;
-    } else if (IsEqualGUID(guid, &GUID_Spring)
-            || IsEqualGUID(guid, &GUID_Damper)
-            || IsEqualGUID(guid, &GUID_Inertia)
-            || IsEqualGUID(guid, &GUID_Friction)) {
-	return DIEFT_CONDITION;
-    } else if (IsEqualGUID(guid, &GUID_CustomForce)) {
-	return DIEFT_CUSTOMFORCE;
-    } else {
-        WARN("GUID (%s) is not a known force type\n", _dump_dinput_GUID(guid));
-	return 0;
-    }
-}
-
-
-/******************************************************************************
- *      DirectInputEffect debug helpers 
- */
-
-static void _dump_DIEFFECT_flags(DWORD dwFlags)
-{
-    if (TRACE_ON(dinput)) {
-        unsigned int   i;
-        static const struct {
-            DWORD       mask;
-            const char  *name;
-        } flags[] = {
-#define FE(x) { x, #x}
-            FE(DIEFF_CARTESIAN),
-            FE(DIEFF_OBJECTIDS),
-            FE(DIEFF_OBJECTOFFSETS),
-            FE(DIEFF_POLAR),
-            FE(DIEFF_SPHERICAL)
-#undef FE
-        };
-        for (i = 0; i < (sizeof(flags) / sizeof(flags[0])); i++)
-            if (flags[i].mask & dwFlags)
-                TRACE("%s ", flags[i].name);
-        TRACE("\n");
-    }       
-}
-
-static void _dump_DIENVELOPE(LPCDIENVELOPE env)
-{
-    if (env->dwSize != sizeof(DIENVELOPE)) {
-        WARN("Non-standard DIENVELOPE structure size %d.\n", env->dwSize);
-    }
-    TRACE("Envelope has attack (level: %d time: %d), fade (level: %d time: %d)\n",
-	  env->dwAttackLevel, env->dwAttackTime, env->dwFadeLevel, env->dwFadeTime);
-} 
-
-static void _dump_DICONSTANTFORCE(LPCDICONSTANTFORCE frc)
-{
-    TRACE("Constant force has magnitude %d\n", frc->lMagnitude);
-}
-
-static void _dump_DIPERIODIC(LPCDIPERIODIC frc)
-{
-    TRACE("Periodic force has magnitude %d, offset %d, phase %d, period %d\n",
-	  frc->dwMagnitude, frc->lOffset, frc->dwPhase, frc->dwPeriod);
-}
-
-static void _dump_DIRAMPFORCE(LPCDIRAMPFORCE frc)
-{
-    TRACE("Ramp force has start %d, end %d\n",
-	  frc->lStart, frc->lEnd);
-}
-
-static void _dump_DICONDITION(LPCDICONDITION frc)
-{
-    TRACE("Condition has offset %d, pos/neg coefficients %d and %d, pos/neg saturations %d and %d, deadband %d\n",
-	  frc->lOffset, frc->lPositiveCoefficient, frc->lNegativeCoefficient,
-	  frc->dwPositiveSaturation, frc->dwNegativeSaturation, frc->lDeadBand);
-}
-
-static void _dump_DICUSTOMFORCE(LPCDICUSTOMFORCE frc)
-{
-    unsigned int i;
-    TRACE("Custom force uses %d channels, sample period %d.  Has %d samples at %p.\n",
-	  frc->cChannels, frc->dwSamplePeriod, frc->cSamples, frc->rglForceData);
-    if (frc->cSamples % frc->cChannels != 0)
-	WARN("Custom force has a non-integral samples-per-channel count!\n");
-    if (TRACE_ON(dinput)) {
-	TRACE("Custom force data (time aligned, axes in order):\n");
-	for (i = 1; i <= frc->cSamples; ++i) {
-	    TRACE("%d ", frc->rglForceData[i]);
-	    if (i % frc->cChannels == 0)
-		TRACE("\n");
-	}	
-    }
-}
-
-static void _dump_DIEFFECT(LPCDIEFFECT eff, REFGUID guid, DWORD dwFlags)
-{
-    unsigned int i;
-    DWORD type = _typeFromGUID(guid);
-
-    TRACE("Dumping DIEFFECT structure:\n");
-    TRACE("  - dwSize: %d\n", eff->dwSize);
-    if ((eff->dwSize != sizeof(DIEFFECT)) && (eff->dwSize != sizeof(DIEFFECT_DX5))) {
-        WARN("Non-standard DIEFFECT structure size %d\n", eff->dwSize);
-    }
-    TRACE("  - dwFlags: %d\n", eff->dwFlags);
-    TRACE("    ");
-    _dump_DIEFFECT_flags(eff->dwFlags); 
-    TRACE("  - dwDuration: %d\n", eff->dwDuration);
-    TRACE("  - dwGain: %d\n", eff->dwGain);
-
-    if (eff->dwGain > 10000)
-        WARN("dwGain is out of range (>10,000)\n");
-
-    TRACE("  - dwTriggerButton: %d\n", eff->dwTriggerButton);
-    TRACE("  - dwTriggerRepeatInterval: %d\n", eff->dwTriggerRepeatInterval);
-    TRACE("  - rglDirection: %p\n", eff->rglDirection);
-    TRACE("  - cbTypeSpecificParams: %d\n", eff->cbTypeSpecificParams);
-    TRACE("  - lpvTypeSpecificParams: %p\n", eff->lpvTypeSpecificParams);
-
-    /* Only trace some members if dwFlags indicates they have data */
-    if (dwFlags & DIEP_AXES) {
-        TRACE("  - cAxes: %d\n", eff->cAxes);
-        TRACE("  - rgdwAxes: %p\n", eff->rgdwAxes);
-
-        if (TRACE_ON(dinput) && eff->rgdwAxes) {
-            TRACE("    ");
-            for (i = 0; i < eff->cAxes; ++i)
-                TRACE("%d ", eff->rgdwAxes[i]);
-            TRACE("\n");
-        }
-    }
-
-    if (dwFlags & DIEP_ENVELOPE) {
-        TRACE("  - lpEnvelope: %p\n", eff->lpEnvelope);
-        if (eff->lpEnvelope != NULL)
-            _dump_DIENVELOPE(eff->lpEnvelope);
-    }
-
-    if (eff->dwSize > sizeof(DIEFFECT_DX5))
-        TRACE("  - dwStartDelay: %d\n", eff->dwStartDelay);
-
-    if (type == DIEFT_CONSTANTFORCE) {
-	if (eff->cbTypeSpecificParams != sizeof(DICONSTANTFORCE)) {
-	    WARN("Effect claims to be a constant force but the type-specific params are the wrong size!\n"); 
-	} else {
-	    _dump_DICONSTANTFORCE(eff->lpvTypeSpecificParams);
-	}
-    } else if (type == DIEFT_PERIODIC) { 
-        if (eff->cbTypeSpecificParams != sizeof(DIPERIODIC)) {
-            WARN("Effect claims to be a periodic force but the type-specific params are the wrong size!\n");
-        } else {
-            _dump_DIPERIODIC(eff->lpvTypeSpecificParams);
-        }
-    } else if (type == DIEFT_RAMPFORCE) {
-        if (eff->cbTypeSpecificParams != sizeof(DIRAMPFORCE)) {
-            WARN("Effect claims to be a ramp force but the type-specific params are the wrong size!\n");
-        } else {
-            _dump_DIRAMPFORCE(eff->lpvTypeSpecificParams);
-        }
-    } else if (type == DIEFT_CONDITION) { 
-        if (eff->cbTypeSpecificParams != sizeof(DICONDITION)) {
-            WARN("Effect claims to be a condition but the type-specific params are the wrong size!\n");
-        } else {
-            _dump_DICONDITION(eff->lpvTypeSpecificParams);
-        }
-    } else if (type == DIEFT_CUSTOMFORCE) {
-        if (eff->cbTypeSpecificParams != sizeof(DICUSTOMFORCE)) {
-            WARN("Effect claims to be a custom force but the type-specific params are the wrong size!\n");
-        } else {
-            _dump_DICUSTOMFORCE(eff->lpvTypeSpecificParams);
-        }
-    }
-}
-
-
-/******************************************************************************
  *      LinuxInputEffectImpl 
  */
 
@@ -546,12 +359,12 @@ static HRESULT WINAPI LinuxInputEffectImpl_SetParameters(
         DWORD dwFlags)
 {
     LinuxInputEffectImpl *This = impl_from_IDirectInputEffect(iface);
-    DWORD type = _typeFromGUID(&This->guid);
+    DWORD type = typeFromGUID(&This->guid);
     HRESULT retval = DI_OK;
 
     TRACE("(this=%p,%p,%d)\n", This, peff, dwFlags);
 
-    _dump_DIEFFECT(peff, &This->guid, dwFlags);
+    dump_DIEFFECT(peff, &This->guid, dwFlags);
 
     if ((dwFlags & ~DIEP_NORESTART & ~DIEP_NODOWNLOAD & ~DIEP_START) == 0) {
 	/* set everything */
@@ -800,7 +613,7 @@ DECLSPEC_HIDDEN HRESULT linuxinput_create_effect(
 {
     LinuxInputEffectImpl* newEffect = HeapAlloc(GetProcessHeap(), 
 	HEAP_ZERO_MEMORY, sizeof(LinuxInputEffectImpl));
-    DWORD type = _typeFromGUID(rguid);
+    DWORD type = typeFromGUID(rguid);
 
     newEffect->IDirectInputEffect_iface.lpVtbl = &LinuxInputEffectVtbl;
     newEffect->ref = 1;
@@ -869,7 +682,7 @@ DECLSPEC_HIDDEN HRESULT linuxinput_get_info_A(
 	REFGUID rguid,
 	LPDIEFFECTINFOA info)
 {
-    DWORD type = _typeFromGUID(rguid);
+    DWORD type = typeFromGUID(rguid);
 
     TRACE("(%d, %s, %p) type=%d\n", fd, _dump_dinput_GUID(rguid), info, type);
 
@@ -903,7 +716,7 @@ DECLSPEC_HIDDEN HRESULT linuxinput_get_info_W(
 	REFGUID rguid,
 	LPDIEFFECTINFOW info)
 {
-    DWORD type = _typeFromGUID(rguid);
+    DWORD type = typeFromGUID(rguid);
 
     TRACE("(%d, %s, %p) type=%d\n", fd, _dump_dinput_GUID(rguid), info, type);
 
diff --git a/dlls/dinput/joystick.c b/dlls/dinput/joystick.c
index 7da8aac..b929c05 100644
--- a/dlls/dinput/joystick.c
+++ b/dlls/dinput/joystick.c
@@ -49,6 +49,184 @@ static inline IDirectInputDevice8W *IDirectInputDevice8W_from_impl(JoystickGener
     return &This->base.IDirectInputDevice8W_iface;
 }
 
+DWORD typeFromGUID(REFGUID guid)
+{
+    if (IsEqualGUID(guid, &GUID_ConstantForce)) {
+        return DIEFT_CONSTANTFORCE;
+    } else if (IsEqualGUID(guid, &GUID_Square)
+            || IsEqualGUID(guid, &GUID_Sine)
+            || IsEqualGUID(guid, &GUID_Triangle)
+            || IsEqualGUID(guid, &GUID_SawtoothUp)
+            || IsEqualGUID(guid, &GUID_SawtoothDown)) {
+        return DIEFT_PERIODIC;
+    } else if (IsEqualGUID(guid, &GUID_RampForce)) {
+        return DIEFT_RAMPFORCE;
+    } else if (IsEqualGUID(guid, &GUID_Spring)
+            || IsEqualGUID(guid, &GUID_Damper)
+            || IsEqualGUID(guid, &GUID_Inertia)
+            || IsEqualGUID(guid, &GUID_Friction)) {
+        return DIEFT_CONDITION;
+    } else if (IsEqualGUID(guid, &GUID_CustomForce)) {
+        return DIEFT_CUSTOMFORCE;
+    } else {
+        WARN("GUID (%s) is not a known force type\n", _dump_dinput_GUID(guid));
+        return 0;
+    }
+}
+
+static void _dump_DIEFFECT_flags(DWORD dwFlags)
+{
+    if (TRACE_ON(dinput)) {
+        unsigned int   i;
+        static const struct {
+            DWORD       mask;
+            const char  *name;
+        } flags[] = {
+#define FE(x) { x, #x}
+            FE(DIEFF_CARTESIAN),
+            FE(DIEFF_OBJECTIDS),
+            FE(DIEFF_OBJECTOFFSETS),
+            FE(DIEFF_POLAR),
+            FE(DIEFF_SPHERICAL)
+#undef FE
+        };
+        for (i = 0; i < (sizeof(flags) / sizeof(flags[0])); i++)
+            if (flags[i].mask & dwFlags)
+                TRACE("%s ", flags[i].name);
+        TRACE("\n");
+    }
+}
+
+static void _dump_DIENVELOPE(LPCDIENVELOPE env)
+{
+    if (env->dwSize != sizeof(DIENVELOPE)) {
+        WARN("Non-standard DIENVELOPE structure size %d.\n", env->dwSize);
+    }
+    TRACE("Envelope has attack (level: %d time: %d), fade (level: %d time: %d)\n",
+          env->dwAttackLevel, env->dwAttackTime, env->dwFadeLevel, env->dwFadeTime);
+}
+
+static void _dump_DICONSTANTFORCE(LPCDICONSTANTFORCE frc)
+{
+    TRACE("Constant force has magnitude %d\n", frc->lMagnitude);
+}
+
+static void _dump_DIPERIODIC(LPCDIPERIODIC frc)
+{
+    TRACE("Periodic force has magnitude %d, offset %d, phase %d, period %d\n",
+          frc->dwMagnitude, frc->lOffset, frc->dwPhase, frc->dwPeriod);
+}
+
+static void _dump_DIRAMPFORCE(LPCDIRAMPFORCE frc)
+{
+    TRACE("Ramp force has start %d, end %d\n",
+          frc->lStart, frc->lEnd);
+}
+
+static void _dump_DICONDITION(LPCDICONDITION frc)
+{
+    TRACE("Condition has offset %d, pos/neg coefficients %d and %d, pos/neg saturations %d and %d, deadband %d\n",
+          frc->lOffset, frc->lPositiveCoefficient, frc->lNegativeCoefficient,
+          frc->dwPositiveSaturation, frc->dwNegativeSaturation, frc->lDeadBand);
+}
+
+static void _dump_DICUSTOMFORCE(LPCDICUSTOMFORCE frc)
+{
+    unsigned int i;
+    TRACE("Custom force uses %d channels, sample period %d.  Has %d samples at %p.\n",
+          frc->cChannels, frc->dwSamplePeriod, frc->cSamples, frc->rglForceData);
+    if (frc->cSamples % frc->cChannels != 0)
+        WARN("Custom force has a non-integral samples-per-channel count!\n");
+    if (TRACE_ON(dinput)) {
+        TRACE("Custom force data (time aligned, axes in order):\n");
+        for (i = 1; i <= frc->cSamples; ++i) {
+            TRACE("%d ", frc->rglForceData[i]);
+            if (i % frc->cChannels == 0)
+                TRACE("\n");
+        }
+    }
+}
+
+void dump_DIEFFECT(LPCDIEFFECT eff, REFGUID guid, DWORD dwFlags)
+{
+    DWORD type = typeFromGUID(guid);
+    unsigned int i;
+
+    TRACE("Dumping DIEFFECT structure:\n");
+    TRACE("  - dwSize: %d\n", eff->dwSize);
+    if ((eff->dwSize != sizeof(DIEFFECT)) && (eff->dwSize != sizeof(DIEFFECT_DX5))) {
+        WARN("Non-standard DIEFFECT structure size %d\n", eff->dwSize);
+    }
+    TRACE("  - dwFlags: %d\n", eff->dwFlags);
+    TRACE("    ");
+    _dump_DIEFFECT_flags(eff->dwFlags);
+    TRACE("  - dwDuration: %d\n", eff->dwDuration);
+    TRACE("  - dwGain: %d\n", eff->dwGain);
+
+    if (eff->dwGain > 10000)
+        WARN("dwGain is out of range (>10,000)\n");
+
+    TRACE("  - dwTriggerButton: %d\n", eff->dwTriggerButton);
+    TRACE("  - dwTriggerRepeatInterval: %d\n", eff->dwTriggerRepeatInterval);
+    TRACE("  - rglDirection: %p\n", eff->rglDirection);
+    TRACE("  - cbTypeSpecificParams: %d\n", eff->cbTypeSpecificParams);
+    TRACE("  - lpvTypeSpecificParams: %p\n", eff->lpvTypeSpecificParams);
+
+    /* Only trace some members if dwFlags indicates they have data */
+    if (dwFlags & DIEP_AXES) {
+        TRACE("  - cAxes: %d\n", eff->cAxes);
+        TRACE("  - rgdwAxes: %p\n", eff->rgdwAxes);
+
+        if (TRACE_ON(dinput) && eff->rgdwAxes) {
+            TRACE("    ");
+            for (i = 0; i < eff->cAxes; ++i)
+                TRACE("%d ", eff->rgdwAxes[i]);
+            TRACE("\n");
+        }
+    }
+
+    if (dwFlags & DIEP_ENVELOPE) {
+        TRACE("  - lpEnvelope: %p\n", eff->lpEnvelope);
+        if (eff->lpEnvelope != NULL)
+            _dump_DIENVELOPE(eff->lpEnvelope);
+    }
+
+    if (eff->dwSize > sizeof(DIEFFECT_DX5))
+        TRACE("  - dwStartDelay: %d\n", eff->dwStartDelay);
+
+    if (type == DIEFT_CONSTANTFORCE) {
+        if (eff->cbTypeSpecificParams != sizeof(DICONSTANTFORCE)) {
+            WARN("Effect claims to be a constant force but the type-specific params are the wrong size!\n");
+        } else {
+            _dump_DICONSTANTFORCE(eff->lpvTypeSpecificParams);
+        }
+    } else if (type == DIEFT_PERIODIC) {
+        if (eff->cbTypeSpecificParams != sizeof(DIPERIODIC)) {
+            WARN("Effect claims to be a periodic force but the type-specific params are the wrong size!\n");
+        } else {
+            _dump_DIPERIODIC(eff->lpvTypeSpecificParams);
+        }
+    } else if (type == DIEFT_RAMPFORCE) {
+        if (eff->cbTypeSpecificParams != sizeof(DIRAMPFORCE)) {
+            WARN("Effect claims to be a ramp force but the type-specific params are the wrong size!\n");
+        } else {
+            _dump_DIRAMPFORCE(eff->lpvTypeSpecificParams);
+        }
+    } else if (type == DIEFT_CONDITION) {
+        if (eff->cbTypeSpecificParams != sizeof(DICONDITION)) {
+            WARN("Effect claims to be a condition but the type-specific params are the wrong size!\n");
+        } else {
+            _dump_DICONDITION(eff->lpvTypeSpecificParams);
+        }
+    } else if (type == DIEFT_CUSTOMFORCE) {
+        if (eff->cbTypeSpecificParams != sizeof(DICUSTOMFORCE)) {
+            WARN("Effect claims to be a custom force but the type-specific params are the wrong size!\n");
+        } else {
+            _dump_DICUSTOMFORCE(eff->lpvTypeSpecificParams);
+        }
+    }
+}
+
 BOOL device_disabled_registry(const char* name)
 {
     static const char disabled_str[] = "disabled";
diff --git a/dlls/dinput/joystick_osx.c b/dlls/dinput/joystick_osx.c
index 0d3927a..94398e7 100644
--- a/dlls/dinput/joystick_osx.c
+++ b/dlls/dinput/joystick_osx.c
@@ -1089,6 +1089,7 @@ static HRESULT WINAPI JoystickWImpl_CreateEffect(IDirectInputDevice8W *iface,
     HRESULT hr;
 
     TRACE("%p %s %p %p %p\n", iface, debugstr_guid(type), params, out, outer);
+    dump_DIEFFECT(params, type, 0);
 
     if(!This->ff){
         TRACE("No force feedback support\n");
@@ -1281,6 +1282,7 @@ static HRESULT WINAPI effect_SetParameters(IDirectInputEffect *iface,
 {
     EffectImpl *This = impl_from_IDirectInputEffect(iface);
     TRACE("%p %p 0x%x\n", This, effect, flags);
+    dump_DIEFFECT(effect, &This->guid, flags);
     return FFEffectSetParameters(This->effect, (FFEFFECT*)effect, flags);
 }
 
diff --git a/dlls/dinput/joystick_private.h b/dlls/dinput/joystick_private.h
index 483db66..e758cac 100644
--- a/dlls/dinput/joystick_private.h
+++ b/dlls/dinput/joystick_private.h
@@ -94,4 +94,7 @@ HRESULT WINAPI JoystickWGenericImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface,
 HRESULT WINAPI JoystickAGenericImpl_SetActionMap(LPDIRECTINPUTDEVICE8A iface, LPDIACTIONFORMATA lpdiaf, LPCSTR lpszUserName, DWORD dwFlags) DECLSPEC_HIDDEN;
 HRESULT WINAPI JoystickWGenericImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags) DECLSPEC_HIDDEN;
 
+DWORD typeFromGUID(REFGUID guid) DECLSPEC_HIDDEN;
+void dump_DIEFFECT(LPCDIEFFECT eff, REFGUID guid, DWORD dwFlags) DECLSPEC_HIDDEN;
+
 #endif /* __WINE_DLLS_DINPUT_JOYSTICK_PRIVATE_H */
-- 
1.8.2.3





More information about the wine-patches mailing list