Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/joystick_hid.c | 63 +++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index ac67625cddc..a43ecde0e9c 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -818,10 +818,71 @@ static HRESULT WINAPI hid_joystick_CreateEffect( IDirectInputDevice8W *iface, co static HRESULT WINAPI hid_joystick_EnumEffects( IDirectInputDevice8W *iface, LPDIENUMEFFECTSCALLBACKW callback, void *context, DWORD type ) { - FIXME( "iface %p, callback %p, context %p, type %#x stub!\n", iface, callback, context, type ); + DIEFFECTINFOW info = {.dwSize = sizeof(info)}; + HRESULT hr; + + TRACE( "iface %p, callback %p, context %p, type %#x.\n", iface, callback, context, type );
if (!callback) return DIERR_INVALIDPARAM;
+ type = DIEFT_GETTYPE( type ); + + if (type == DIEFT_ALL || type == DIEFT_CONSTANTFORCE) + { + hr = IDirectInputDevice8_GetEffectInfo( iface, &info, &GUID_ConstantForce ); + if (FAILED(hr) && hr != DIERR_DEVICENOTREG) return hr; + if (hr == DI_OK && callback( &info, context ) == DIENUM_STOP) return DI_OK; + } + + if (type == DIEFT_ALL || type == DIEFT_RAMPFORCE) + { + hr = IDirectInputDevice8_GetEffectInfo( iface, &info, &GUID_RampForce ); + if (FAILED(hr) && hr != DIERR_DEVICENOTREG) return hr; + if (hr == DI_OK && callback( &info, context ) == DIENUM_STOP) return DI_OK; + } + + if (type == DIEFT_ALL || type == DIEFT_PERIODIC) + { + hr = IDirectInputDevice8_GetEffectInfo( iface, &info, &GUID_Square ); + if (FAILED(hr) && hr != DIERR_DEVICENOTREG) return hr; + if (hr == DI_OK && callback( &info, context ) == DIENUM_STOP) return DI_OK; + + hr = IDirectInputDevice8_GetEffectInfo( iface, &info, &GUID_Sine ); + if (FAILED(hr) && hr != DIERR_DEVICENOTREG) return hr; + if (hr == DI_OK && callback( &info, context ) == DIENUM_STOP) return DI_OK; + + hr = IDirectInputDevice8_GetEffectInfo( iface, &info, &GUID_Triangle ); + if (FAILED(hr) && hr != DIERR_DEVICENOTREG) return hr; + if (hr == DI_OK && callback( &info, context ) == DIENUM_STOP) return DI_OK; + + hr = IDirectInputDevice8_GetEffectInfo( iface, &info, &GUID_SawtoothUp ); + if (FAILED(hr) && hr != DIERR_DEVICENOTREG) return hr; + if (hr == DI_OK && callback( &info, context ) == DIENUM_STOP) return DI_OK; + + hr = IDirectInputDevice8_GetEffectInfo( iface, &info, &GUID_SawtoothDown ); + if (FAILED(hr) && hr != DIERR_DEVICENOTREG) return hr; + if (hr == DI_OK && callback( &info, context ) == DIENUM_STOP) return DI_OK; + } + + if (type == DIEFT_ALL || type == DIEFT_CONDITION) + { + hr = IDirectInputDevice8_GetEffectInfo( iface, &info, &GUID_Spring ); + if (FAILED(hr) && hr != DIERR_DEVICENOTREG) return hr; + if (hr == DI_OK && callback( &info, context ) == DIENUM_STOP) return DI_OK; + + hr = IDirectInputDevice8_GetEffectInfo( iface, &info, &GUID_Damper ); + if (FAILED(hr) && hr != DIERR_DEVICENOTREG) return hr; + if (hr == DI_OK && callback( &info, context ) == DIENUM_STOP) return DI_OK; + + hr = IDirectInputDevice8_GetEffectInfo( iface, &info, &GUID_Inertia ); + if (FAILED(hr) && hr != DIERR_DEVICENOTREG) return hr; + if (hr == DI_OK && callback( &info, context ) == DIENUM_STOP) return DI_OK; + + hr = IDirectInputDevice8_GetEffectInfo( iface, &info, &GUID_Friction ); + if (FAILED(hr) && hr != DIERR_DEVICENOTREG) return hr; + if (hr == DI_OK && callback( &info, context ) == DIENUM_STOP) return DI_OK; + } + return DI_OK; }