Commit 5135f80a authored by Andrew Eikum's avatar Andrew Eikum Committed by Alexandre Julliard

dinput: Debug print DIEFFECT structure.

parent 44a2d36f
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include "dinput.h" #include "dinput.h"
#include "device_private.h" #include "device_private.h"
#include "joystick_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(dinput); WINE_DEFAULT_DEBUG_CHANNEL(dinput);
...@@ -67,194 +68,6 @@ static inline LinuxInputEffectImpl *impl_from_IDirectInputEffect(IDirectInputEff ...@@ -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 * LinuxInputEffectImpl
*/ */
...@@ -546,12 +359,12 @@ static HRESULT WINAPI LinuxInputEffectImpl_SetParameters( ...@@ -546,12 +359,12 @@ static HRESULT WINAPI LinuxInputEffectImpl_SetParameters(
DWORD dwFlags) DWORD dwFlags)
{ {
LinuxInputEffectImpl *This = impl_from_IDirectInputEffect(iface); LinuxInputEffectImpl *This = impl_from_IDirectInputEffect(iface);
DWORD type = _typeFromGUID(&This->guid); DWORD type = typeFromGUID(&This->guid);
HRESULT retval = DI_OK; HRESULT retval = DI_OK;
TRACE("(this=%p,%p,%d)\n", This, peff, dwFlags); 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) { if ((dwFlags & ~DIEP_NORESTART & ~DIEP_NODOWNLOAD & ~DIEP_START) == 0) {
/* set everything */ /* set everything */
...@@ -800,7 +613,7 @@ DECLSPEC_HIDDEN HRESULT linuxinput_create_effect( ...@@ -800,7 +613,7 @@ DECLSPEC_HIDDEN HRESULT linuxinput_create_effect(
{ {
LinuxInputEffectImpl* newEffect = HeapAlloc(GetProcessHeap(), LinuxInputEffectImpl* newEffect = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY, sizeof(LinuxInputEffectImpl)); HEAP_ZERO_MEMORY, sizeof(LinuxInputEffectImpl));
DWORD type = _typeFromGUID(rguid); DWORD type = typeFromGUID(rguid);
newEffect->IDirectInputEffect_iface.lpVtbl = &LinuxInputEffectVtbl; newEffect->IDirectInputEffect_iface.lpVtbl = &LinuxInputEffectVtbl;
newEffect->ref = 1; newEffect->ref = 1;
...@@ -869,7 +682,7 @@ DECLSPEC_HIDDEN HRESULT linuxinput_get_info_A( ...@@ -869,7 +682,7 @@ DECLSPEC_HIDDEN HRESULT linuxinput_get_info_A(
REFGUID rguid, REFGUID rguid,
LPDIEFFECTINFOA info) LPDIEFFECTINFOA info)
{ {
DWORD type = _typeFromGUID(rguid); DWORD type = typeFromGUID(rguid);
TRACE("(%d, %s, %p) type=%d\n", fd, _dump_dinput_GUID(rguid), info, type); 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( ...@@ -903,7 +716,7 @@ DECLSPEC_HIDDEN HRESULT linuxinput_get_info_W(
REFGUID rguid, REFGUID rguid,
LPDIEFFECTINFOW info) LPDIEFFECTINFOW info)
{ {
DWORD type = _typeFromGUID(rguid); DWORD type = typeFromGUID(rguid);
TRACE("(%d, %s, %p) type=%d\n", fd, _dump_dinput_GUID(rguid), info, type); TRACE("(%d, %s, %p) type=%d\n", fd, _dump_dinput_GUID(rguid), info, type);
......
...@@ -49,6 +49,184 @@ static inline IDirectInputDevice8W *IDirectInputDevice8W_from_impl(JoystickGener ...@@ -49,6 +49,184 @@ static inline IDirectInputDevice8W *IDirectInputDevice8W_from_impl(JoystickGener
return &This->base.IDirectInputDevice8W_iface; 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) BOOL device_disabled_registry(const char* name)
{ {
static const char disabled_str[] = "disabled"; static const char disabled_str[] = "disabled";
......
...@@ -1118,6 +1118,7 @@ static HRESULT WINAPI JoystickWImpl_CreateEffect(IDirectInputDevice8W *iface, ...@@ -1118,6 +1118,7 @@ static HRESULT WINAPI JoystickWImpl_CreateEffect(IDirectInputDevice8W *iface,
HRESULT hr; HRESULT hr;
TRACE("%p %s %p %p %p\n", iface, debugstr_guid(type), params, out, outer); TRACE("%p %s %p %p %p\n", iface, debugstr_guid(type), params, out, outer);
dump_DIEFFECT(params, type, 0);
if(!This->ff){ if(!This->ff){
TRACE("No force feedback support\n"); TRACE("No force feedback support\n");
...@@ -1310,6 +1311,7 @@ static HRESULT WINAPI effect_SetParameters(IDirectInputEffect *iface, ...@@ -1310,6 +1311,7 @@ static HRESULT WINAPI effect_SetParameters(IDirectInputEffect *iface,
{ {
EffectImpl *This = impl_from_IDirectInputEffect(iface); EffectImpl *This = impl_from_IDirectInputEffect(iface);
TRACE("%p %p 0x%x\n", This, effect, flags); TRACE("%p %p 0x%x\n", This, effect, flags);
dump_DIEFFECT(effect, &This->guid, flags);
return osx_to_win32_hresult(FFEffectSetParameters(This->effect, (FFEFFECT*)effect, flags)); return osx_to_win32_hresult(FFEffectSetParameters(This->effect, (FFEFFECT*)effect, flags));
} }
......
...@@ -94,4 +94,7 @@ HRESULT WINAPI JoystickWGenericImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface, ...@@ -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 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; 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 */ #endif /* __WINE_DLLS_DINPUT_JOYSTICK_PRIVATE_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment