Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/device.c | 41 +++++++++++++++++++++++++----------- dlls/dinput/device_private.h | 1 + dlls/dinput/joystick_hid.c | 41 +++++------------------------------- dlls/dinput/keyboard.c | 1 + dlls/dinput/mouse.c | 1 + 5 files changed, 37 insertions(+), 48 deletions(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index 2a9b9aa596e..e0aa5141067 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -1645,20 +1645,37 @@ HRESULT WINAPI IDirectInputDevice2WImpl_Initialize(LPDIRECTINPUTDEVICE8W iface, return DI_OK; }
-/****************************************************************************** - * IDirectInputDevice2A - */ - -HRESULT WINAPI IDirectInputDevice2WImpl_CreateEffect(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPCDIEFFECT lpeff, - LPDIRECTINPUTEFFECT *ppdef, LPUNKNOWN pUnkOuter) +HRESULT WINAPI IDirectInputDevice2WImpl_CreateEffect( IDirectInputDevice8W *iface, const GUID *guid, + const DIEFFECT *params, IDirectInputEffect **out, + IUnknown *outer ) { - IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface); - FIXME("(%p)->(%s,%p,%p,%p): stub!\n", This, debugstr_guid(rguid), lpeff, ppdef, pUnkOuter); - if (!ppdef) return E_POINTER; + IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8W( iface ); + DWORD flags = DIEP_ALLPARAMS; + HRESULT hr;
- FIXME("not available in the generic implementation\n"); - *ppdef = NULL; - return DIERR_UNSUPPORTED; + TRACE( "iface %p, guid %s, params %p, out %p, outer %p\n", iface, debugstr_guid( guid ), + params, out, outer ); + + if (!out) return E_POINTER; + *out = NULL; + + if (!(impl->caps.dwFlags & DIDC_FORCEFEEDBACK)) return DIERR_UNSUPPORTED; + if (!impl->vtbl->create_effect) return DIERR_UNSUPPORTED; + if (FAILED(hr = impl->vtbl->create_effect( iface, out ))) return hr; + + hr = IDirectInputEffect_Initialize( *out, DINPUT_instance, impl->dinput->dwVersion, guid ); + if (FAILED(hr)) goto failed; + + if (!params) return DI_OK; + if (!impl->acquired || !(impl->dwCoopLevel & DISCL_EXCLUSIVE)) flags |= DIEP_NODOWNLOAD; + hr = IDirectInputEffect_SetParameters( *out, params, flags ); + if (FAILED(hr)) goto failed; + return hr; + +failed: + IDirectInputEffect_Release( *out ); + *out = NULL; + return hr; }
HRESULT WINAPI IDirectInputDevice2WImpl_EnumEffects( IDirectInputDevice8W *iface, LPDIENUMEFFECTSCALLBACKW callback, diff --git a/dlls/dinput/device_private.h b/dlls/dinput/device_private.h index 0b5919c7ec6..66c51f1672a 100644 --- a/dlls/dinput/device_private.h +++ b/dlls/dinput/device_private.h @@ -69,6 +69,7 @@ struct dinput_device_vtbl HRESULT (*set_property)( IDirectInputDevice8W *iface, DWORD property, const DIPROPHEADER *header, const DIDEVICEOBJECTINSTANCEW *instance ); HRESULT (*get_effect_info)( IDirectInputDevice8W *iface, DIEFFECTINFOW *info, const GUID *guid ); + HRESULT (*create_effect)( IDirectInputDevice8W *iface, IDirectInputEffect **out ); };
#define DEVICE_STATE_MAX_SIZE 1024 diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index 2788f138216..c7e9700ed7c 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -803,40 +803,7 @@ static HRESULT hid_joystick_internal_unacquire( IDirectInputDevice8W *iface ) return DI_OK; }
-static HRESULT hid_joystick_effect_create( struct hid_joystick *joystick, IDirectInputEffect **out ); - -static HRESULT WINAPI hid_joystick_CreateEffect( IDirectInputDevice8W *iface, const GUID *guid, - const DIEFFECT *params, IDirectInputEffect **out, - IUnknown *outer ) -{ - struct hid_joystick *impl = impl_from_IDirectInputDevice8W( iface ); - DWORD flags = DIEP_ALLPARAMS; - HRESULT hr; - - TRACE( "iface %p, guid %s, params %p, out %p, outer %p\n", iface, debugstr_guid( guid ), - params, out, outer ); - - if (!out) return E_POINTER; - *out = NULL; - - if (!(impl->base.caps.dwFlags & DIDC_FORCEFEEDBACK)) return DIERR_UNSUPPORTED; - if (FAILED(hr = hid_joystick_effect_create( impl, out ))) return hr; - - hr = IDirectInputEffect_Initialize( *out, DINPUT_instance, impl->base.dinput->dwVersion, guid ); - if (FAILED(hr)) goto failed; - - if (!params) return DI_OK; - if (!impl->base.acquired || !(impl->base.dwCoopLevel & DISCL_EXCLUSIVE)) - flags |= DIEP_NODOWNLOAD; - hr = IDirectInputEffect_SetParameters( *out, params, flags ); - if (FAILED(hr)) goto failed; - return hr; - -failed: - IDirectInputEffect_Release( *out ); - *out = NULL; - return hr; -} +static HRESULT hid_joystick_internal_create_effect( IDirectInputDevice8W *iface, IDirectInputEffect **out );
static HRESULT hid_joystick_internal_get_effect_info( IDirectInputDevice8W *iface, DIEFFECTINFOW *info, const GUID *guid ) @@ -1068,7 +1035,7 @@ static const IDirectInputDevice8WVtbl hid_joystick_vtbl = IDirectInputDevice2WImpl_RunControlPanel, IDirectInputDevice2WImpl_Initialize, /*** IDirectInputDevice2 methods ***/ - hid_joystick_CreateEffect, + IDirectInputDevice2WImpl_CreateEffect, IDirectInputDevice2WImpl_EnumEffects, IDirectInputDevice2WImpl_GetEffectInfo, IDirectInputDevice2WImpl_GetForceFeedbackState, @@ -1312,6 +1279,7 @@ static const struct dinput_device_vtbl hid_joystick_internal_vtbl = hid_joystick_internal_get_property, hid_joystick_internal_set_property, hid_joystick_internal_get_effect_info, + hid_joystick_internal_create_effect, };
static DWORD device_type_for_version( DWORD type, DWORD version ) @@ -2826,8 +2794,9 @@ static IDirectInputEffectVtbl hid_joystick_effect_vtbl = hid_joystick_effect_Escape, };
-static HRESULT hid_joystick_effect_create( struct hid_joystick *joystick, IDirectInputEffect **out ) +static HRESULT hid_joystick_internal_create_effect( IDirectInputDevice8W *iface, IDirectInputEffect **out ) { + struct hid_joystick *joystick = impl_from_IDirectInputDevice8W( iface ); struct hid_joystick_effect *impl; ULONG report_len;
diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c index 1127ec2aaea..8e1b752f016 100644 --- a/dlls/dinput/keyboard.c +++ b/dlls/dinput/keyboard.c @@ -339,6 +339,7 @@ static const struct dinput_device_vtbl keyboard_internal_vtbl = keyboard_internal_get_property, keyboard_internal_set_property, NULL, + NULL, };
static const IDirectInputDevice8WVtbl SysKeyboardWvt = diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c index 69348ad2c7f..ec3282b267f 100644 --- a/dlls/dinput/mouse.c +++ b/dlls/dinput/mouse.c @@ -652,6 +652,7 @@ static const struct dinput_device_vtbl mouse_internal_vtbl = mouse_internal_get_property, mouse_internal_set_property, NULL, + NULL, };
static const IDirectInputDevice8WVtbl SysMouseWvt =