From 7a82be5d977154bca942dbcd0de3ad537bda1c3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Fri, 29 Apr 2022 13:53:35 +0200 Subject: [PATCH] windows.gaming.input: Add a type parameter to force_feedback_effect_create. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit And convert it to IDirectInputEffect type GUID. Signed-off-by: RĂ©mi Bernon Signed-off-by: Alexandre Julliard --- dlls/windows.gaming.input/constant_effect.c | 2 +- dlls/windows.gaming.input/force_feedback.c | 28 ++++++++++++++++++++- dlls/windows.gaming.input/private.h | 2 +- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/dlls/windows.gaming.input/constant_effect.c b/dlls/windows.gaming.input/constant_effect.c index ae0c0f9904d..928927144b9 100644 --- a/dlls/windows.gaming.input/constant_effect.c +++ b/dlls/windows.gaming.input/constant_effect.c @@ -205,7 +205,7 @@ static HRESULT WINAPI activation_ActivateInstance( IActivationFactory *iface, II impl->IConstantForceEffect_iface.lpVtbl = &effect_vtbl; impl->ref = 1; - if (FAILED(hr = force_feedback_effect_create( (IInspectable *)&impl->IConstantForceEffect_iface, + if (FAILED(hr = force_feedback_effect_create( WineForceFeedbackEffectType_Constant, (IInspectable *)&impl->IConstantForceEffect_iface, &impl->IWineForceFeedbackEffectImpl_inner ))) { free( impl ); diff --git a/dlls/windows.gaming.input/force_feedback.c b/dlls/windows.gaming.input/force_feedback.c index ab29a179c6a..9d3ead5fc2b 100644 --- a/dlls/windows.gaming.input/force_feedback.c +++ b/dlls/windows.gaming.input/force_feedback.c @@ -33,6 +33,12 @@ struct effect IForceFeedbackEffect IForceFeedbackEffect_iface; IInspectable *IInspectable_outer; LONG ref; + + GUID type; + DWORD axes[3]; + LONG directions[3]; + DICONSTANTFORCE constant_force; + DIEFFECT params; }; static inline struct effect *impl_from_IWineForceFeedbackEffectImpl( IWineForceFeedbackEffectImpl *iface ) @@ -143,7 +149,7 @@ static const struct IForceFeedbackEffectVtbl effect_vtbl = effect_Stop, }; -HRESULT force_feedback_effect_create( IInspectable *outer, IWineForceFeedbackEffectImpl **out ) +HRESULT force_feedback_effect_create( enum WineForceFeedbackEffectType type, IInspectable *outer, IWineForceFeedbackEffectImpl **out ) { struct effect *impl; @@ -155,6 +161,26 @@ HRESULT force_feedback_effect_create( IInspectable *outer, IWineForceFeedbackEff impl->IInspectable_outer = outer; impl->ref = 1; + switch (type) + { + case WineForceFeedbackEffectType_Constant: + impl->type = GUID_ConstantForce; + impl->params.lpvTypeSpecificParams = &impl->constant_force; + impl->params.cbTypeSpecificParams = sizeof(impl->constant_force); + break; + } + + impl->params.dwSize = sizeof(DIEFFECT); + impl->params.rgdwAxes = impl->axes; + impl->params.rglDirection = impl->directions; + impl->params.dwTriggerButton = -1; + impl->params.dwGain = 10000; + impl->params.dwFlags = DIEFF_CARTESIAN|DIEFF_OBJECTOFFSETS; + impl->params.cAxes = 0; + impl->axes[0] = DIJOFS_X; + impl->axes[1] = DIJOFS_Y; + impl->axes[2] = DIJOFS_Z; + *out = &impl->IWineForceFeedbackEffectImpl_iface; TRACE( "created ForceFeedbackEffect %p\n", *out ); return S_OK; diff --git a/dlls/windows.gaming.input/private.h b/dlls/windows.gaming.input/private.h index 58378304a26..f8edff61455 100644 --- a/dlls/windows.gaming.input/private.h +++ b/dlls/windows.gaming.input/private.h @@ -71,7 +71,7 @@ extern HRESULT event_handlers_remove( struct list *list, EventRegistrationToken extern void event_handlers_notify( struct list *list, IInspectable *element ); extern HRESULT force_feedback_motor_create( IDirectInputDevice8W *device, IForceFeedbackMotor **out ); -extern HRESULT force_feedback_effect_create( IInspectable *outer, IWineForceFeedbackEffectImpl **out ); +extern HRESULT force_feedback_effect_create( enum WineForceFeedbackEffectType type, IInspectable *outer, IWineForceFeedbackEffectImpl **out ); typedef HRESULT (WINAPI *async_operation_callback)( IUnknown *invoker, IUnknown *param, PROPVARIANT *result ); extern HRESULT async_operation_boolean_create( IUnknown *invoker, IUnknown *param, async_operation_callback callback,