Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/device.c | 73 ++++++++++++++++++++++++++++++++++---- dlls/dinput/joystick_hid.c | 73 +------------------------------------- 2 files changed, 67 insertions(+), 79 deletions(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index 8858bfa26bb..e5713f4713d 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -1661,14 +1661,73 @@ HRESULT WINAPI IDirectInputDevice2WImpl_CreateEffect(LPDIRECTINPUTDEVICE8W iface return DIERR_UNSUPPORTED; }
-HRESULT WINAPI IDirectInputDevice2WImpl_EnumEffects( - LPDIRECTINPUTDEVICE8W iface, - LPDIENUMEFFECTSCALLBACKW lpCallback, - LPVOID lpvRef, - DWORD dwFlags) +HRESULT WINAPI IDirectInputDevice2WImpl_EnumEffects( IDirectInputDevice8W *iface, LPDIENUMEFFECTSCALLBACKW callback, + void *context, DWORD type ) { - IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface); - FIXME("(%p)->(%p,%p,0x%08x): stub!\n", This, lpCallback, lpvRef, dwFlags); + 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; } diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index 766e022ebe0..91b6020d1f1 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -838,77 +838,6 @@ failed: return hr; }
-static HRESULT WINAPI hid_joystick_EnumEffects( IDirectInputDevice8W *iface, LPDIENUMEFFECTSCALLBACKW callback, - void *context, DWORD 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; -} - static HRESULT WINAPI hid_joystick_GetEffectInfo( IDirectInputDevice8W *iface, DIEFFECTINFOW *info, const GUID *guid ) { @@ -1155,7 +1084,7 @@ static const IDirectInputDevice8WVtbl hid_joystick_vtbl = IDirectInputDevice2WImpl_Initialize, /*** IDirectInputDevice2 methods ***/ hid_joystick_CreateEffect, - hid_joystick_EnumEffects, + IDirectInputDevice2WImpl_EnumEffects, hid_joystick_GetEffectInfo, hid_joystick_GetForceFeedbackState, hid_joystick_SendForceFeedbackCommand,
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/device.c | 18 +++++++++++------- dlls/dinput/device_private.h | 1 + dlls/dinput/joystick_hid.c | 13 ++++--------- dlls/dinput/keyboard.c | 1 + dlls/dinput/mouse.c | 1 + 5 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index e5713f4713d..ce163660e6c 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -1732,14 +1732,18 @@ HRESULT WINAPI IDirectInputDevice2WImpl_EnumEffects( IDirectInputDevice8W *iface return DI_OK; }
-HRESULT WINAPI IDirectInputDevice2WImpl_GetEffectInfo( - LPDIRECTINPUTDEVICE8W iface, - LPDIEFFECTINFOW lpdei, - REFGUID rguid) +HRESULT WINAPI IDirectInputDevice2WImpl_GetEffectInfo( IDirectInputDevice8W *iface, DIEFFECTINFOW *info, + const GUID *guid ) { - IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface); - FIXME("(%p)->(%p,%s): stub!\n", This, lpdei, debugstr_guid(rguid)); - return DI_OK; + IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8W( iface ); + + TRACE( "iface %p, info %p, guid %s.\n", iface, info, debugstr_guid( guid ) ); + + if (!info) return E_POINTER; + if (info->dwSize != sizeof(DIEFFECTINFOW)) return DIERR_INVALIDPARAM; + if (!(impl->caps.dwFlags & DIDC_FORCEFEEDBACK)) return DIERR_DEVICENOTREG; + if (!impl->vtbl->get_effect_info) return DIERR_UNSUPPORTED; + return impl->vtbl->get_effect_info( iface, info, guid ); }
HRESULT WINAPI IDirectInputDevice2WImpl_GetForceFeedbackState(LPDIRECTINPUTDEVICE8W iface, LPDWORD pdwOut) diff --git a/dlls/dinput/device_private.h b/dlls/dinput/device_private.h index bdac5b4a378..0b5919c7ec6 100644 --- a/dlls/dinput/device_private.h +++ b/dlls/dinput/device_private.h @@ -68,6 +68,7 @@ struct dinput_device_vtbl DIDEVICEOBJECTINSTANCEW *instance ); HRESULT (*set_property)( IDirectInputDevice8W *iface, DWORD property, const DIPROPHEADER *header, const DIDEVICEOBJECTINSTANCEW *instance ); + HRESULT (*get_effect_info)( IDirectInputDevice8W *iface, DIEFFECTINFOW *info, const GUID *guid ); };
#define DEVICE_STATE_MAX_SIZE 1024 diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index 91b6020d1f1..1e1f8c05e3f 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -838,8 +838,8 @@ failed: return hr; }
-static HRESULT WINAPI hid_joystick_GetEffectInfo( IDirectInputDevice8W *iface, DIEFFECTINFOW *info, - const GUID *guid ) +static HRESULT hid_joystick_internal_get_effect_info( IDirectInputDevice8W *iface, DIEFFECTINFOW *info, + const GUID *guid ) { struct hid_joystick *impl = impl_from_IDirectInputDevice8W( iface ); struct pid_effect_update *effect_update = &impl->pid_effect_update; @@ -853,12 +853,6 @@ static HRESULT WINAPI hid_joystick_GetEffectInfo( IDirectInputDevice8W *iface, D USAGE usage = 0; USHORT count;
- TRACE( "iface %p, info %p, guid %s.\n", iface, info, debugstr_guid( guid ) ); - - if (!info) return E_POINTER; - if (info->dwSize != sizeof(DIEFFECTINFOW)) return DIERR_INVALIDPARAM; - if (!(impl->base.caps.dwFlags & DIDC_FORCEFEEDBACK)) return DIERR_DEVICENOTREG; - switch ((usage = effect_guid_to_usage( guid ))) { case PID_USAGE_ET_SQUARE: @@ -1085,7 +1079,7 @@ static const IDirectInputDevice8WVtbl hid_joystick_vtbl = /*** IDirectInputDevice2 methods ***/ hid_joystick_CreateEffect, IDirectInputDevice2WImpl_EnumEffects, - hid_joystick_GetEffectInfo, + IDirectInputDevice2WImpl_GetEffectInfo, hid_joystick_GetForceFeedbackState, hid_joystick_SendForceFeedbackCommand, hid_joystick_EnumCreatedEffectObjects, @@ -1326,6 +1320,7 @@ static const struct dinput_device_vtbl hid_joystick_internal_vtbl = hid_joystick_internal_enum_objects, hid_joystick_internal_get_property, hid_joystick_internal_set_property, + hid_joystick_internal_get_effect_info, };
static DWORD device_type_for_version( DWORD type, DWORD version ) diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c index f17dc89ac16..1127ec2aaea 100644 --- a/dlls/dinput/keyboard.c +++ b/dlls/dinput/keyboard.c @@ -338,6 +338,7 @@ static const struct dinput_device_vtbl keyboard_internal_vtbl = keyboard_internal_enum_objects, keyboard_internal_get_property, keyboard_internal_set_property, + NULL, };
static const IDirectInputDevice8WVtbl SysKeyboardWvt = diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c index 7fafa7696a7..69348ad2c7f 100644 --- a/dlls/dinput/mouse.c +++ b/dlls/dinput/mouse.c @@ -651,6 +651,7 @@ static const struct dinput_device_vtbl mouse_internal_vtbl = mouse_internal_enum_objects, mouse_internal_get_property, mouse_internal_set_property, + NULL, };
static const IDirectInputDevice8WVtbl SysMouseWvt =
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/device.c | 8 ++++---- dlls/dinput/joystick_hid.c | 11 +---------- 2 files changed, 5 insertions(+), 14 deletions(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index ce163660e6c..2a9b9aa596e 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -1746,11 +1746,11 @@ HRESULT WINAPI IDirectInputDevice2WImpl_GetEffectInfo( IDirectInputDevice8W *ifa return impl->vtbl->get_effect_info( iface, info, guid ); }
-HRESULT WINAPI IDirectInputDevice2WImpl_GetForceFeedbackState(LPDIRECTINPUTDEVICE8W iface, LPDWORD pdwOut) +HRESULT WINAPI IDirectInputDevice2WImpl_GetForceFeedbackState( IDirectInputDevice8W *iface, DWORD *out ) { - IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface); - FIXME("(%p)->(%p): stub!\n", This, pdwOut); - return DI_OK; + FIXME( "iface %p, out %p stub!\n", iface, out ); + if (!out) return E_POINTER; + return DIERR_UNSUPPORTED; }
HRESULT WINAPI IDirectInputDevice2WImpl_SendForceFeedbackCommand(LPDIRECTINPUTDEVICE8W iface, DWORD dwFlags) diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index 1e1f8c05e3f..2788f138216 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -973,15 +973,6 @@ static HRESULT hid_joystick_internal_get_effect_info( IDirectInputDevice8W *ifac return DI_OK; }
-static HRESULT WINAPI hid_joystick_GetForceFeedbackState( IDirectInputDevice8W *iface, DWORD *out ) -{ - FIXME( "iface %p, out %p stub!\n", iface, out ); - - if (!out) return E_POINTER; - - return DIERR_UNSUPPORTED; -} - static BOOL CALLBACK unload_effect_object( IDirectInputEffect *effect, void *context ) { IDirectInputEffect_Unload( effect ); @@ -1080,7 +1071,7 @@ static const IDirectInputDevice8WVtbl hid_joystick_vtbl = hid_joystick_CreateEffect, IDirectInputDevice2WImpl_EnumEffects, IDirectInputDevice2WImpl_GetEffectInfo, - hid_joystick_GetForceFeedbackState, + IDirectInputDevice2WImpl_GetForceFeedbackState, hid_joystick_SendForceFeedbackCommand, hid_joystick_EnumCreatedEffectObjects, IDirectInputDevice2WImpl_Escape,
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 =
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/device.c | 30 ++++++++++++++++++++++++++---- dlls/dinput/device_private.h | 1 + dlls/dinput/joystick_hid.c | 35 ++++++++++++----------------------- dlls/dinput/keyboard.c | 1 + dlls/dinput/mouse.c | 1 + 5 files changed, 41 insertions(+), 27 deletions(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index e0aa5141067..b8da627b1ea 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -1770,11 +1770,33 @@ HRESULT WINAPI IDirectInputDevice2WImpl_GetForceFeedbackState( IDirectInputDevic return DIERR_UNSUPPORTED; }
-HRESULT WINAPI IDirectInputDevice2WImpl_SendForceFeedbackCommand(LPDIRECTINPUTDEVICE8W iface, DWORD dwFlags) +HRESULT WINAPI IDirectInputDevice2WImpl_SendForceFeedbackCommand( IDirectInputDevice8W *iface, DWORD command ) { - IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface); - TRACE("(%p)->(0x%08x)\n", This, dwFlags); - return DI_NOEFFECT; + IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8W( iface ); + HRESULT hr; + + TRACE( "iface %p, flags %x.\n", iface, command ); + + switch (command) + { + case DISFFC_RESET: break; + case DISFFC_STOPALL: break; + case DISFFC_PAUSE: break; + case DISFFC_CONTINUE: break; + case DISFFC_SETACTUATORSON: break; + case DISFFC_SETACTUATORSOFF: break; + default: return DIERR_INVALIDPARAM; + } + + if (!(impl->caps.dwFlags & DIDC_FORCEFEEDBACK)) return DIERR_UNSUPPORTED; + if (!impl->vtbl->send_force_feedback_command) return DIERR_UNSUPPORTED; + + EnterCriticalSection( &impl->crit ); + if (!impl->acquired || !(impl->dwCoopLevel & DISCL_EXCLUSIVE)) hr = DIERR_NOTEXCLUSIVEACQUIRED; + else hr = impl->vtbl->send_force_feedback_command( iface, command ); + LeaveCriticalSection( &impl->crit ); + + return hr; }
HRESULT WINAPI IDirectInputDevice2WImpl_EnumCreatedEffectObjects(LPDIRECTINPUTDEVICE8W iface, diff --git a/dlls/dinput/device_private.h b/dlls/dinput/device_private.h index 66c51f1672a..b90c6bf2dcd 100644 --- a/dlls/dinput/device_private.h +++ b/dlls/dinput/device_private.h @@ -70,6 +70,7 @@ struct dinput_device_vtbl const DIDEVICEOBJECTINSTANCEW *instance ); HRESULT (*get_effect_info)( IDirectInputDevice8W *iface, DIEFFECTINFOW *info, const GUID *guid ); HRESULT (*create_effect)( IDirectInputDevice8W *iface, IDirectInputEffect **out ); + HRESULT (*send_force_feedback_command)( IDirectInputDevice8W *iface, DWORD command ); };
#define DEVICE_STATE_MAX_SIZE 1024 diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index c7e9700ed7c..e9bbfa081e8 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -946,7 +946,7 @@ static BOOL CALLBACK unload_effect_object( IDirectInputEffect *effect, void *con return DIENUM_CONTINUE; }
-static HRESULT WINAPI hid_joystick_SendForceFeedbackCommand( IDirectInputDevice8W *iface, DWORD command ) +static HRESULT hid_joystick_internal_send_force_feedback_command( IDirectInputDevice8W *iface, DWORD command ) { struct hid_joystick *impl = impl_from_IDirectInputDevice8W( iface ); struct pid_control_report *report = &impl->pid_device_control; @@ -955,7 +955,6 @@ static HRESULT WINAPI hid_joystick_SendForceFeedbackCommand( IDirectInputDevice8 NTSTATUS status; USAGE usage; ULONG count; - HRESULT hr;
TRACE( "iface %p, flags %x.\n", iface, command );
@@ -967,31 +966,20 @@ static HRESULT WINAPI hid_joystick_SendForceFeedbackCommand( IDirectInputDevice8 case DISFFC_CONTINUE: usage = PID_USAGE_DC_DEVICE_CONTINUE; break; case DISFFC_SETACTUATORSON: usage = PID_USAGE_DC_ENABLE_ACTUATORS; break; case DISFFC_SETACTUATORSOFF: usage = PID_USAGE_DC_DISABLE_ACTUATORS; break; - default: return DIERR_INVALIDPARAM; }
- if (!(impl->base.caps.dwFlags & DIDC_FORCEFEEDBACK)) return DIERR_UNSUPPORTED; + if (command == DISFFC_RESET) IDirectInputDevice8_EnumCreatedEffectObjects( iface, unload_effect_object, NULL, 0 );
- EnterCriticalSection( &impl->base.crit ); - if (!impl->base.acquired || !(impl->base.dwCoopLevel & DISCL_EXCLUSIVE)) - hr = DIERR_NOTEXCLUSIVEACQUIRED; - else - { - if (command == DISFFC_RESET) IDirectInputDevice8_EnumCreatedEffectObjects( iface, unload_effect_object, NULL, 0 ); - - count = 1; - status = HidP_InitializeReportForID( HidP_Output, report->id, impl->preparsed, report_buf, report_len ); - if (status != HIDP_STATUS_SUCCESS) hr = status; - else status = HidP_SetUsages( HidP_Output, HID_USAGE_PAGE_PID, report->control_coll, &usage, - &count, impl->preparsed, report_buf, report_len ); + count = 1; + status = HidP_InitializeReportForID( HidP_Output, report->id, impl->preparsed, report_buf, report_len ); + if (status != HIDP_STATUS_SUCCESS) return status;
- if (status != HIDP_STATUS_SUCCESS) hr = status; - else if (WriteFile( impl->device, report_buf, report_len, NULL, NULL )) hr = DI_OK; - else hr = DIERR_GENERIC; - } - LeaveCriticalSection( &impl->base.crit ); + status = HidP_SetUsages( HidP_Output, HID_USAGE_PAGE_PID, report->control_coll, &usage, + &count, impl->preparsed, report_buf, report_len ); + if (status != HIDP_STATUS_SUCCESS) return status;
- return hr; + if (!WriteFile( impl->device, report_buf, report_len, NULL, NULL )) return DIERR_INPUTLOST; + return DI_OK; }
static HRESULT WINAPI hid_joystick_EnumCreatedEffectObjects( IDirectInputDevice8W *iface, @@ -1039,7 +1027,7 @@ static const IDirectInputDevice8WVtbl hid_joystick_vtbl = IDirectInputDevice2WImpl_EnumEffects, IDirectInputDevice2WImpl_GetEffectInfo, IDirectInputDevice2WImpl_GetForceFeedbackState, - hid_joystick_SendForceFeedbackCommand, + IDirectInputDevice2WImpl_SendForceFeedbackCommand, hid_joystick_EnumCreatedEffectObjects, IDirectInputDevice2WImpl_Escape, IDirectInputDevice2WImpl_Poll, @@ -1280,6 +1268,7 @@ static const struct dinput_device_vtbl hid_joystick_internal_vtbl = hid_joystick_internal_set_property, hid_joystick_internal_get_effect_info, hid_joystick_internal_create_effect, + hid_joystick_internal_send_force_feedback_command, };
static DWORD device_type_for_version( DWORD type, DWORD version ) diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c index 8e1b752f016..a04b59e9c0c 100644 --- a/dlls/dinput/keyboard.c +++ b/dlls/dinput/keyboard.c @@ -340,6 +340,7 @@ static const struct dinput_device_vtbl keyboard_internal_vtbl = keyboard_internal_set_property, NULL, NULL, + NULL, };
static const IDirectInputDevice8WVtbl SysKeyboardWvt = diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c index ec3282b267f..faf093489cf 100644 --- a/dlls/dinput/mouse.c +++ b/dlls/dinput/mouse.c @@ -653,6 +653,7 @@ static const struct dinput_device_vtbl mouse_internal_vtbl = mouse_internal_set_property, NULL, NULL, + NULL, };
static const IDirectInputDevice8WVtbl SysMouseWvt =
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/device.c | 18 +++++++++++++----- dlls/dinput/device_private.h | 2 ++ dlls/dinput/joystick_hid.c | 12 +++++------- dlls/dinput/keyboard.c | 1 + dlls/dinput/mouse.c | 1 + 5 files changed, 22 insertions(+), 12 deletions(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index b8da627b1ea..d9b92e82271 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -1799,12 +1799,20 @@ HRESULT WINAPI IDirectInputDevice2WImpl_SendForceFeedbackCommand( IDirectInputDe return hr; }
-HRESULT WINAPI IDirectInputDevice2WImpl_EnumCreatedEffectObjects(LPDIRECTINPUTDEVICE8W iface, - LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID lpvRef, DWORD dwFlags) +HRESULT WINAPI IDirectInputDevice2WImpl_EnumCreatedEffectObjects( IDirectInputDevice8W *iface, + LPDIENUMCREATEDEFFECTOBJECTSCALLBACK callback, + void *context, DWORD flags ) { - IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface); - FIXME("(%p)0>(%p,%p,0x%08x): stub!\n", This, lpCallback, lpvRef, dwFlags); - return DI_OK; + IDirectInputDeviceImpl *impl = impl_from_IDirectInputDevice8W( iface ); + + TRACE( "iface %p, callback %p, context %p, flags %#x.\n", iface, callback, context, flags ); + + if (!callback) return DIERR_INVALIDPARAM; + if (flags) return DIERR_INVALIDPARAM; + if (!(impl->caps.dwFlags & DIDC_FORCEFEEDBACK)) return DI_OK; + if (!impl->vtbl->enum_created_effect_objects) return DIERR_UNSUPPORTED; + + return impl->vtbl->enum_created_effect_objects( iface, callback, context, flags ); }
HRESULT WINAPI IDirectInputDevice2WImpl_Escape(LPDIRECTINPUTDEVICE8W iface, LPDIEFFESCAPE lpDIEEsc) diff --git a/dlls/dinput/device_private.h b/dlls/dinput/device_private.h index b90c6bf2dcd..16d28323281 100644 --- a/dlls/dinput/device_private.h +++ b/dlls/dinput/device_private.h @@ -71,6 +71,8 @@ struct dinput_device_vtbl HRESULT (*get_effect_info)( IDirectInputDevice8W *iface, DIEFFECTINFOW *info, const GUID *guid ); HRESULT (*create_effect)( IDirectInputDevice8W *iface, IDirectInputEffect **out ); HRESULT (*send_force_feedback_command)( IDirectInputDevice8W *iface, DWORD command ); + HRESULT (*enum_created_effect_objects)( IDirectInputDevice8W *iface, LPDIENUMCREATEDEFFECTOBJECTSCALLBACK callback, + void *context, DWORD flags ); };
#define DEVICE_STATE_MAX_SIZE 1024 diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index e9bbfa081e8..5fb4e9a2de9 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -982,18 +982,15 @@ static HRESULT hid_joystick_internal_send_force_feedback_command( IDirectInputDe return DI_OK; }
-static HRESULT WINAPI hid_joystick_EnumCreatedEffectObjects( IDirectInputDevice8W *iface, - LPDIENUMCREATEDEFFECTOBJECTSCALLBACK callback, - void *context, DWORD flags ) +static HRESULT hid_joystick_internal_enum_created_effect_objects( IDirectInputDevice8W *iface, + LPDIENUMCREATEDEFFECTOBJECTSCALLBACK callback, + void *context, DWORD flags ) { struct hid_joystick *impl = impl_from_IDirectInputDevice8W( iface ); struct hid_joystick_effect *effect, *next;
TRACE( "iface %p, callback %p, context %p, flags %#x.\n", iface, callback, context, flags );
- if (!callback) return DIERR_INVALIDPARAM; - if (flags) return DIERR_INVALIDPARAM; - LIST_FOR_EACH_ENTRY_SAFE(effect, next, &impl->effect_list, struct hid_joystick_effect, entry) if (callback( &effect->IDirectInputEffect_iface, context ) != DIENUM_CONTINUE) break;
@@ -1028,7 +1025,7 @@ static const IDirectInputDevice8WVtbl hid_joystick_vtbl = IDirectInputDevice2WImpl_GetEffectInfo, IDirectInputDevice2WImpl_GetForceFeedbackState, IDirectInputDevice2WImpl_SendForceFeedbackCommand, - hid_joystick_EnumCreatedEffectObjects, + IDirectInputDevice2WImpl_EnumCreatedEffectObjects, IDirectInputDevice2WImpl_Escape, IDirectInputDevice2WImpl_Poll, IDirectInputDevice2WImpl_SendDeviceData, @@ -1269,6 +1266,7 @@ static const struct dinput_device_vtbl hid_joystick_internal_vtbl = hid_joystick_internal_get_effect_info, hid_joystick_internal_create_effect, hid_joystick_internal_send_force_feedback_command, + hid_joystick_internal_enum_created_effect_objects, };
static DWORD device_type_for_version( DWORD type, DWORD version ) diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c index a04b59e9c0c..fb6cf33b911 100644 --- a/dlls/dinput/keyboard.c +++ b/dlls/dinput/keyboard.c @@ -341,6 +341,7 @@ static const struct dinput_device_vtbl keyboard_internal_vtbl = NULL, NULL, NULL, + NULL, };
static const IDirectInputDevice8WVtbl SysKeyboardWvt = diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c index faf093489cf..1b91fa12189 100644 --- a/dlls/dinput/mouse.c +++ b/dlls/dinput/mouse.c @@ -654,6 +654,7 @@ static const struct dinput_device_vtbl mouse_internal_vtbl = NULL, NULL, NULL, + NULL, };
static const IDirectInputDevice8WVtbl SysMouseWvt =