From: Rémi Bernon rbernon@codeweavers.com
--- dlls/windows.gaming.input/async.c | 344 ++++------------- dlls/windows.gaming.input/condition_effect.c | 209 ++--------- dlls/windows.gaming.input/constant_effect.c | 184 ++------- dlls/windows.gaming.input/force_feedback.c | 269 +++---------- dlls/windows.gaming.input/gamepad.c | 374 +++---------------- dlls/windows.gaming.input/manager.c | 261 ++----------- dlls/windows.gaming.input/periodic_effect.c | 214 ++--------- dlls/windows.gaming.input/private.h | 14 - dlls/windows.gaming.input/provider.c | 181 ++------- dlls/windows.gaming.input/provider.idl | 4 +- dlls/windows.gaming.input/racing_wheel.c | 357 +++--------------- dlls/windows.gaming.input/ramp_effect.c | 184 ++------- dlls/windows.gaming.input/vector.c | 330 ++++------------ 13 files changed, 509 insertions(+), 2416 deletions(-)
diff --git a/dlls/windows.gaming.input/async.c b/dlls/windows.gaming.input/async.c index c142c6426d7..1b03cfac761 100644 --- a/dlls/windows.gaming.input/async.c +++ b/dlls/windows.gaming.input/async.c @@ -33,8 +33,9 @@ struct async_info IWineAsyncInfoImpl IWineAsyncInfoImpl_iface; IAsyncInfo IAsyncInfo_iface; IAgileObject IAgileObject_iface; - IInspectable *IInspectable_outer; - LONG ref; + IInspectable *outer; + const WCHAR *class_name; + LONG refcount;
async_operation_callback callback; TP_WORK *async_run_work; @@ -48,73 +49,22 @@ struct async_info HRESULT hr; };
-static inline struct async_info *impl_from_IWineAsyncInfoImpl( IWineAsyncInfoImpl *iface ) +static void async_info_destroy( struct async_info *impl ) { - return CONTAINING_RECORD( iface, struct async_info, IWineAsyncInfoImpl_iface ); + if (impl->handler && impl->handler != HANDLER_NOT_SET) IWineAsyncOperationCompletedHandler_Release( impl->handler ); + IAsyncInfo_Close( &impl->IAsyncInfo_iface ); + if (impl->param) IUnknown_Release( impl->param ); + if (impl->invoker) IUnknown_Release( impl->invoker ); + impl->cs.DebugInfo->Spare[0] = 0; + DeleteCriticalSection( &impl->cs ); + free( impl ); }
-static HRESULT WINAPI async_impl_QueryInterface( IWineAsyncInfoImpl *iface, REFIID iid, void **out ) -{ - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); - - TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out ); - - if (IsEqualGUID( iid, &IID_IUnknown ) || - IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IWineAsyncInfoImpl )) - { - IInspectable_AddRef( (*out = &impl->IWineAsyncInfoImpl_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IAsyncInfo )) - { - IInspectable_AddRef( (*out = &impl->IAsyncInfo_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IAgileObject )) - { - IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); - return S_OK; - } - - FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); - *out = NULL; - return E_NOINTERFACE; -} - -static ULONG WINAPI async_impl_AddRef( IWineAsyncInfoImpl *iface ) -{ - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p, ref %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI async_impl_Release( IWineAsyncInfoImpl *iface ) -{ - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - TRACE( "iface %p, ref %lu.\n", iface, ref ); +INTERFACE_IMPL_OUTER_IWineAsyncInfoImpl( async_info, IAgileObject, IAsyncInfo, END );
- if (!ref) - { - if (impl->handler && impl->handler != HANDLER_NOT_SET) IWineAsyncOperationCompletedHandler_Release( impl->handler ); - IAsyncInfo_Close( &impl->IAsyncInfo_iface ); - if (impl->param) IUnknown_Release( impl->param ); - if (impl->invoker) IUnknown_Release( impl->invoker ); - impl->cs.DebugInfo->Spare[0] = 0; - DeleteCriticalSection( &impl->cs ); - free( impl ); - } - - return ref; -} - -static HRESULT WINAPI async_impl_put_Completed( IWineAsyncInfoImpl *iface, IWineAsyncOperationCompletedHandler *handler ) +static HRESULT WINAPI async_info_put_Completed( IWineAsyncInfoImpl *iface, IWineAsyncOperationCompletedHandler *handler ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = async_info_from_IWineAsyncInfoImpl( iface ); HRESULT hr = S_OK;
TRACE( "iface %p, handler %p.\n", iface, handler ); @@ -128,7 +78,7 @@ static HRESULT WINAPI async_impl_put_Completed( IWineAsyncInfoImpl *iface, IWine
if (impl->status > Started) { - IInspectable *operation = impl->IInspectable_outer; + IInspectable *operation = impl->outer; AsyncStatus status = impl->status; impl->handler = NULL; /* Prevent concurrent invoke. */ LeaveCriticalSection( &impl->cs ); @@ -144,9 +94,9 @@ static HRESULT WINAPI async_impl_put_Completed( IWineAsyncInfoImpl *iface, IWine return hr; }
-static HRESULT WINAPI async_impl_get_Completed( IWineAsyncInfoImpl *iface, IWineAsyncOperationCompletedHandler **handler ) +static HRESULT WINAPI async_info_get_Completed( IWineAsyncInfoImpl *iface, IWineAsyncOperationCompletedHandler **handler ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = async_info_from_IWineAsyncInfoImpl( iface ); HRESULT hr = S_OK;
TRACE( "iface %p, handler %p.\n", iface, handler ); @@ -160,9 +110,9 @@ static HRESULT WINAPI async_impl_get_Completed( IWineAsyncInfoImpl *iface, IWine return hr; }
-static HRESULT WINAPI async_impl_get_Result( IWineAsyncInfoImpl *iface, PROPVARIANT *result ) +static HRESULT WINAPI async_info_get_Result( IWineAsyncInfoImpl *iface, PROPVARIANT *result ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = async_info_from_IWineAsyncInfoImpl( iface ); HRESULT hr = E_ILLEGAL_METHOD_CALL;
TRACE( "iface %p, result %p.\n", iface, result ); @@ -178,37 +128,24 @@ static HRESULT WINAPI async_impl_get_Result( IWineAsyncInfoImpl *iface, PROPVARI return hr; }
-static HRESULT WINAPI async_impl_Start( IWineAsyncInfoImpl *iface ) +static HRESULT WINAPI async_info_Start( IWineAsyncInfoImpl *iface ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = async_info_from_IWineAsyncInfoImpl( iface );
TRACE( "iface %p.\n", iface );
/* keep the async alive in the callback */ - IInspectable_AddRef( impl->IInspectable_outer ); + IInspectable_AddRef( impl->outer ); SubmitThreadpoolWork( impl->async_run_work );
return S_OK; }
-static const struct IWineAsyncInfoImplVtbl async_impl_vtbl = -{ - /* IUnknown methods */ - async_impl_QueryInterface, - async_impl_AddRef, - async_impl_Release, - /* IWineAsyncInfoImpl */ - async_impl_put_Completed, - async_impl_get_Completed, - async_impl_get_Result, - async_impl_Start, -}; +INTERFACE_VTBL_IWineAsyncInfoImpl( async_info );
-DEFINE_IINSPECTABLE_OUTER( async_info, IAsyncInfo, async_info, IInspectable_outer ) - -static HRESULT WINAPI async_info_get_Id( IAsyncInfo *iface, UINT32 *id ) +static HRESULT WINAPI async_info_IAsyncInfo_get_Id( IAsyncInfo *iface, UINT32 *id ) { - struct async_info *impl = impl_from_IAsyncInfo( iface ); + struct async_info *impl = async_info_from_IAsyncInfo( iface ); HRESULT hr = S_OK;
TRACE( "iface %p, id %p.\n", iface, id ); @@ -221,9 +158,9 @@ static HRESULT WINAPI async_info_get_Id( IAsyncInfo *iface, UINT32 *id ) return hr; }
-static HRESULT WINAPI async_info_get_Status( IAsyncInfo *iface, AsyncStatus *status ) +static HRESULT WINAPI async_info_IAsyncInfo_get_Status( IAsyncInfo *iface, AsyncStatus *status ) { - struct async_info *impl = impl_from_IAsyncInfo( iface ); + struct async_info *impl = async_info_from_IAsyncInfo( iface ); HRESULT hr = S_OK;
TRACE( "iface %p, status %p.\n", iface, status ); @@ -236,9 +173,9 @@ static HRESULT WINAPI async_info_get_Status( IAsyncInfo *iface, AsyncStatus *sta return hr; }
-static HRESULT WINAPI async_info_get_ErrorCode( IAsyncInfo *iface, HRESULT *error_code ) +static HRESULT WINAPI async_info_IAsyncInfo_get_ErrorCode( IAsyncInfo *iface, HRESULT *error_code ) { - struct async_info *impl = impl_from_IAsyncInfo( iface ); + struct async_info *impl = async_info_from_IAsyncInfo( iface ); HRESULT hr = S_OK;
TRACE( "iface %p, error_code %p.\n", iface, error_code ); @@ -251,9 +188,9 @@ static HRESULT WINAPI async_info_get_ErrorCode( IAsyncInfo *iface, HRESULT *erro return hr; }
-static HRESULT WINAPI async_info_Cancel( IAsyncInfo *iface ) +static HRESULT WINAPI async_info_IAsyncInfo_Cancel( IAsyncInfo *iface ) { - struct async_info *impl = impl_from_IAsyncInfo( iface ); + struct async_info *impl = async_info_from_IAsyncInfo( iface ); HRESULT hr = S_OK;
TRACE( "iface %p.\n", iface ); @@ -266,9 +203,9 @@ static HRESULT WINAPI async_info_Cancel( IAsyncInfo *iface ) return hr; }
-static HRESULT WINAPI async_info_Close( IAsyncInfo *iface ) +static HRESULT WINAPI async_info_IAsyncInfo_Close( IAsyncInfo *iface ) { - struct async_info *impl = impl_from_IAsyncInfo( iface ); + struct async_info *impl = async_info_from_IAsyncInfo( iface ); HRESULT hr = S_OK;
TRACE( "iface %p.\n", iface ); @@ -287,30 +224,13 @@ static HRESULT WINAPI async_info_Close( IAsyncInfo *iface ) return hr; }
-static const struct IAsyncInfoVtbl async_info_vtbl = -{ - /* IUnknown methods */ - async_info_QueryInterface, - async_info_AddRef, - async_info_Release, - /* IInspectable methods */ - async_info_GetIids, - async_info_GetRuntimeClassName, - async_info_GetTrustLevel, - /* IAsyncInfo */ - async_info_get_Id, - async_info_get_Status, - async_info_get_ErrorCode, - async_info_Cancel, - async_info_Close, -}; - -DEFINE_IAGILEOBJECT( async_info, IInspectable, object->IInspectable_outer ); +INTERFACE_VTBL_IAgileObject( async_info_IAgileObject ); +INTERFACE_VTBL_IAsyncInfo( async_info_IAsyncInfo );
static void CALLBACK async_info_callback( TP_CALLBACK_INSTANCE *instance, void *iface, TP_WORK *work ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); - IInspectable *operation = impl->IInspectable_outer; + struct async_info *impl = async_info_from_IWineAsyncInfoImpl( iface ); + IInspectable *operation = impl->outer; PROPVARIANT result; HRESULT hr;
@@ -346,11 +266,11 @@ static HRESULT async_info_create( IUnknown *invoker, IUnknown *param, async_oper HRESULT hr;
if (!(impl = calloc( 1, sizeof(struct async_info) ))) return E_OUTOFMEMORY; - impl->IWineAsyncInfoImpl_iface.lpVtbl = &async_impl_vtbl; - impl->IAsyncInfo_iface.lpVtbl = &async_info_vtbl; + impl->IWineAsyncInfoImpl_iface.lpVtbl = &async_info_vtbl; + impl->IAsyncInfo_iface.lpVtbl = &async_info_IAsyncInfo_vtbl; impl->IAgileObject_iface.lpVtbl = &async_info_IAgileObject_vtbl; - impl->IInspectable_outer = outer; - impl->ref = 1; + impl->outer = outer; + impl->refcount = 1;
impl->callback = callback; impl->handler = HANDLER_NOT_SET; @@ -376,79 +296,35 @@ struct async_bool { IAsyncOperation_boolean IAsyncOperation_boolean_iface; IWineAsyncInfoImpl *IWineAsyncInfoImpl_inner; - LONG ref; + const WCHAR *class_name; + LONG refcount; };
-static inline struct async_bool *impl_from_IAsyncOperation_boolean( IAsyncOperation_boolean *iface ) -{ - return CONTAINING_RECORD( iface, struct async_bool, IAsyncOperation_boolean_iface ); -} +INTERFACE_IMPL_FROM( async_bool, IAsyncOperation_boolean );
static HRESULT WINAPI async_bool_QueryInterface( IAsyncOperation_boolean *iface, REFIID iid, void **out ) { - struct async_bool *impl = impl_from_IAsyncOperation_boolean( iface ); - + struct async_bool *impl = async_bool_from_IAsyncOperation_boolean( iface ); TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out ); - - if (IsEqualGUID( iid, &IID_IUnknown ) || - IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IAsyncOperation_boolean )) - { - IInspectable_AddRef( (*out = &impl->IAsyncOperation_boolean_iface) ); - return S_OK; - } - + QUERY_INTERFACE_IAsyncOperation_boolean( impl, iid, out, IAsyncOperation_boolean_iface ) return IWineAsyncInfoImpl_QueryInterface( impl->IWineAsyncInfoImpl_inner, iid, out ); }
-static ULONG WINAPI async_bool_AddRef( IAsyncOperation_boolean *iface ) -{ - struct async_bool *impl = impl_from_IAsyncOperation_boolean( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p, ref %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI async_bool_Release( IAsyncOperation_boolean *iface ) -{ - struct async_bool *impl = impl_from_IAsyncOperation_boolean( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - TRACE( "iface %p, ref %lu.\n", iface, ref ); - - if (!ref) - { - /* guard against re-entry if inner releases an outer iface */ - InterlockedIncrement( &impl->ref ); - IWineAsyncInfoImpl_Release( impl->IWineAsyncInfoImpl_inner ); - free( impl ); - } - - return ref; -} - -static HRESULT WINAPI async_bool_GetIids( IAsyncOperation_boolean *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} +IUNKNOWN_IMPL_ADDREF( async_bool, IAsyncOperation_boolean );
-static HRESULT WINAPI async_bool_GetRuntimeClassName( IAsyncOperation_boolean *iface, HSTRING *class_name ) +static void async_bool_destroy( struct async_bool *impl ) { - return WindowsCreateString( L"Windows.Foundation.IAsyncOperation`1<Boolean>", - ARRAY_SIZE(L"Windows.Foundation.IAsyncOperation`1<Boolean>"), - class_name ); + IWineAsyncInfoImpl_Release( impl->IWineAsyncInfoImpl_inner ); + free( impl ); }
-static HRESULT WINAPI async_bool_GetTrustLevel( IAsyncOperation_boolean *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} +IUNKNOWN_IMPL_RELEASE( async_bool, IAsyncOperation_boolean ); +IINSPECTABLE_IMPL( async_bool, IAsyncOperation_boolean );
static HRESULT WINAPI async_bool_put_Completed( IAsyncOperation_boolean *iface, IAsyncOperationCompletedHandler_boolean *bool_handler ) { IWineAsyncOperationCompletedHandler *handler = (IWineAsyncOperationCompletedHandler *)bool_handler; - struct async_bool *impl = impl_from_IAsyncOperation_boolean( iface ); + struct async_bool *impl = async_bool_from_IAsyncOperation_boolean( iface ); TRACE( "iface %p, handler %p.\n", iface, handler ); return IWineAsyncInfoImpl_put_Completed( impl->IWineAsyncInfoImpl_inner, handler ); } @@ -456,14 +332,14 @@ static HRESULT WINAPI async_bool_put_Completed( IAsyncOperation_boolean *iface, static HRESULT WINAPI async_bool_get_Completed( IAsyncOperation_boolean *iface, IAsyncOperationCompletedHandler_boolean **bool_handler ) { IWineAsyncOperationCompletedHandler **handler = (IWineAsyncOperationCompletedHandler **)bool_handler; - struct async_bool *impl = impl_from_IAsyncOperation_boolean( iface ); + struct async_bool *impl = async_bool_from_IAsyncOperation_boolean( iface ); TRACE( "iface %p, handler %p.\n", iface, handler ); return IWineAsyncInfoImpl_get_Completed( impl->IWineAsyncInfoImpl_inner, handler ); }
static HRESULT WINAPI async_bool_GetResults( IAsyncOperation_boolean *iface, BOOLEAN *results ) { - struct async_bool *impl = impl_from_IAsyncOperation_boolean( iface ); + struct async_bool *impl = async_bool_from_IAsyncOperation_boolean( iface ); PROPVARIANT result = {.vt = VT_BOOL}; HRESULT hr;
@@ -476,21 +352,7 @@ static HRESULT WINAPI async_bool_GetResults( IAsyncOperation_boolean *iface, BOO return hr; }
-static const struct IAsyncOperation_booleanVtbl async_bool_vtbl = -{ - /* IUnknown methods */ - async_bool_QueryInterface, - async_bool_AddRef, - async_bool_Release, - /* IInspectable methods */ - async_bool_GetIids, - async_bool_GetRuntimeClassName, - async_bool_GetTrustLevel, - /* IAsyncOperation<boolean> */ - async_bool_put_Completed, - async_bool_get_Completed, - async_bool_GetResults, -}; +INTERFACE_VTBL_IAsyncOperation_boolean( async_bool );
HRESULT async_operation_boolean_create( IUnknown *invoker, IUnknown *param, async_operation_callback callback, IAsyncOperation_boolean **out ) @@ -501,7 +363,8 @@ HRESULT async_operation_boolean_create( IUnknown *invoker, IUnknown *param, asyn *out = NULL; if (!(impl = calloc( 1, sizeof(*impl) ))) return E_OUTOFMEMORY; impl->IAsyncOperation_boolean_iface.lpVtbl = &async_bool_vtbl; - impl->ref = 1; + impl->class_name = L"Windows.Foundation.IAsyncOperation`1<Boolean>"; + impl->refcount = 1;
if (FAILED(hr = async_info_create( invoker, param, callback, (IInspectable *)&impl->IAsyncOperation_boolean_iface, &impl->IWineAsyncInfoImpl_inner )) || FAILED(hr = IWineAsyncInfoImpl_Start( impl->IWineAsyncInfoImpl_inner ))) @@ -520,92 +383,48 @@ struct async_result { IAsyncOperation_ForceFeedbackLoadEffectResult IAsyncOperation_ForceFeedbackLoadEffectResult_iface; IWineAsyncInfoImpl *IWineAsyncInfoImpl_inner; - LONG ref; + const WCHAR *class_name; + LONG refcount; };
-static inline struct async_result *impl_from_IAsyncOperation_ForceFeedbackLoadEffectResult( IAsyncOperation_ForceFeedbackLoadEffectResult *iface ) -{ - return CONTAINING_RECORD( iface, struct async_result, IAsyncOperation_ForceFeedbackLoadEffectResult_iface ); -} +INTERFACE_IMPL_FROM( async_result, IAsyncOperation_ForceFeedbackLoadEffectResult );
static HRESULT WINAPI async_result_QueryInterface( IAsyncOperation_ForceFeedbackLoadEffectResult *iface, REFIID iid, void **out ) { - struct async_result *impl = impl_from_IAsyncOperation_ForceFeedbackLoadEffectResult( iface ); - + struct async_result *impl = async_result_from_IAsyncOperation_ForceFeedbackLoadEffectResult( iface ); TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out ); - - if (IsEqualGUID( iid, &IID_IUnknown ) || - IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IAsyncOperation_ForceFeedbackLoadEffectResult )) - { - IInspectable_AddRef( (*out = &impl->IAsyncOperation_ForceFeedbackLoadEffectResult_iface) ); - return S_OK; - } - + QUERY_INTERFACE_IAsyncOperation_ForceFeedbackLoadEffectResult( impl, iid, out, IAsyncOperation_ForceFeedbackLoadEffectResult_iface ) return IWineAsyncInfoImpl_QueryInterface( impl->IWineAsyncInfoImpl_inner, iid, out ); }
-static ULONG WINAPI async_result_AddRef( IAsyncOperation_ForceFeedbackLoadEffectResult *iface ) -{ - struct async_result *impl = impl_from_IAsyncOperation_ForceFeedbackLoadEffectResult( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p, ref %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI async_result_Release( IAsyncOperation_ForceFeedbackLoadEffectResult *iface ) -{ - struct async_result *impl = impl_from_IAsyncOperation_ForceFeedbackLoadEffectResult( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - TRACE( "iface %p, ref %lu.\n", iface, ref ); - - if (!ref) - { - /* guard against re-entry if inner releases an outer iface */ - InterlockedIncrement( &impl->ref ); - IWineAsyncInfoImpl_Release( impl->IWineAsyncInfoImpl_inner ); - free( impl ); - } - - return ref; -} - -static HRESULT WINAPI async_result_GetIids( IAsyncOperation_ForceFeedbackLoadEffectResult *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} +IUNKNOWN_IMPL_ADDREF( async_result, IAsyncOperation_ForceFeedbackLoadEffectResult );
-static HRESULT WINAPI async_result_GetRuntimeClassName( IAsyncOperation_ForceFeedbackLoadEffectResult *iface, HSTRING *class_name ) +static void async_result_destroy( struct async_result *impl ) { - return WindowsCreateString( L"Windows.Foundation.IAsyncOperation`1<Windows.Gaming.Input.ForceFeedback.ForceFeedbackLoadEffectResult>", - ARRAY_SIZE(L"Windows.Foundation.IAsyncOperation`1<Windows.Gaming.Input.ForceFeedback.ForceFeedbackLoadEffectResult>"), - class_name ); + IWineAsyncInfoImpl_Release( impl->IWineAsyncInfoImpl_inner ); + free( impl ); }
-static HRESULT WINAPI async_result_GetTrustLevel( IAsyncOperation_ForceFeedbackLoadEffectResult *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} +IUNKNOWN_IMPL_RELEASE( async_result, IAsyncOperation_ForceFeedbackLoadEffectResult ); +IINSPECTABLE_IMPL( async_result, IAsyncOperation_ForceFeedbackLoadEffectResult );
static HRESULT WINAPI async_result_put_Completed( IAsyncOperation_ForceFeedbackLoadEffectResult *iface, IAsyncOperationCompletedHandler_ForceFeedbackLoadEffectResult *handler ) { - struct async_result *impl = impl_from_IAsyncOperation_ForceFeedbackLoadEffectResult( iface ); + struct async_result *impl = async_result_from_IAsyncOperation_ForceFeedbackLoadEffectResult( iface ); TRACE( "iface %p, handler %p.\n", iface, handler ); return IWineAsyncInfoImpl_put_Completed( impl->IWineAsyncInfoImpl_inner, (IWineAsyncOperationCompletedHandler *)handler ); }
static HRESULT WINAPI async_result_get_Completed( IAsyncOperation_ForceFeedbackLoadEffectResult *iface, IAsyncOperationCompletedHandler_ForceFeedbackLoadEffectResult **handler ) { - struct async_result *impl = impl_from_IAsyncOperation_ForceFeedbackLoadEffectResult( iface ); + struct async_result *impl = async_result_from_IAsyncOperation_ForceFeedbackLoadEffectResult( iface ); TRACE( "iface %p, handler %p.\n", iface, handler ); return IWineAsyncInfoImpl_get_Completed( impl->IWineAsyncInfoImpl_inner, (IWineAsyncOperationCompletedHandler **)handler ); }
static HRESULT WINAPI async_result_GetResults( IAsyncOperation_ForceFeedbackLoadEffectResult *iface, ForceFeedbackLoadEffectResult *results ) { - struct async_result *impl = impl_from_IAsyncOperation_ForceFeedbackLoadEffectResult( iface ); + struct async_result *impl = async_result_from_IAsyncOperation_ForceFeedbackLoadEffectResult( iface ); PROPVARIANT result = {.vt = VT_UI4}; HRESULT hr;
@@ -618,21 +437,7 @@ static HRESULT WINAPI async_result_GetResults( IAsyncOperation_ForceFeedbackLoad return hr; }
-static const struct IAsyncOperation_ForceFeedbackLoadEffectResultVtbl async_result_vtbl = -{ - /* IUnknown methods */ - async_result_QueryInterface, - async_result_AddRef, - async_result_Release, - /* IInspectable methods */ - async_result_GetIids, - async_result_GetRuntimeClassName, - async_result_GetTrustLevel, - /* IAsyncOperation<ForceFeedbackLoadEffectResult> */ - async_result_put_Completed, - async_result_get_Completed, - async_result_GetResults, -}; +INTERFACE_VTBL_IAsyncOperation_ForceFeedbackLoadEffectResult( async_result );
HRESULT async_operation_effect_result_create( IUnknown *invoker, IUnknown *param, async_operation_callback callback, IAsyncOperation_ForceFeedbackLoadEffectResult **out ) @@ -643,7 +448,8 @@ HRESULT async_operation_effect_result_create( IUnknown *invoker, IUnknown *param *out = NULL; if (!(impl = calloc( 1, sizeof(*impl) ))) return E_OUTOFMEMORY; impl->IAsyncOperation_ForceFeedbackLoadEffectResult_iface.lpVtbl = &async_result_vtbl; - impl->ref = 1; + impl->class_name = L"Windows.Foundation.IAsyncOperation`1<Windows.Gaming.Input.ForceFeedback.ForceFeedbackLoadEffectResult>"; + impl->refcount = 1;
if (FAILED(hr = async_info_create( invoker, param, callback, (IInspectable *)&impl->IAsyncOperation_ForceFeedbackLoadEffectResult_iface, &impl->IWineAsyncInfoImpl_inner )) || FAILED(hr = IWineAsyncInfoImpl_Start( impl->IWineAsyncInfoImpl_inner ))) diff --git a/dlls/windows.gaming.input/condition_effect.c b/dlls/windows.gaming.input/condition_effect.c index 46b82523eeb..82506f9b506 100644 --- a/dlls/windows.gaming.input/condition_effect.c +++ b/dlls/windows.gaming.input/condition_effect.c @@ -26,90 +26,45 @@ struct condition_effect { IConditionForceEffect IConditionForceEffect_iface; IWineForceFeedbackEffectImpl *IWineForceFeedbackEffectImpl_inner; - LONG ref; + const WCHAR *class_name; + LONG refcount;
ConditionForceEffectKind kind; };
-static inline struct condition_effect *impl_from_IConditionForceEffect( IConditionForceEffect *iface ) -{ - return CONTAINING_RECORD( iface, struct condition_effect, IConditionForceEffect_iface ); -} +INTERFACE_IMPL_FROM( condition_effect, IConditionForceEffect );
-static HRESULT WINAPI effect_QueryInterface( IConditionForceEffect *iface, REFIID iid, void **out ) +static HRESULT WINAPI condition_effect_QueryInterface( IConditionForceEffect *iface, REFIID iid, void **out ) { - struct condition_effect *impl = impl_from_IConditionForceEffect( iface ); - + struct condition_effect *impl = condition_effect_from_IConditionForceEffect( iface ); TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out ); - - if (IsEqualGUID( iid, &IID_IUnknown ) || - IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IConditionForceEffect )) - { - IInspectable_AddRef( (*out = &impl->IConditionForceEffect_iface) ); - return S_OK; - } - + QUERY_INTERFACE_IConditionForceEffect( impl, iid, out, IConditionForceEffect_iface ) return IWineForceFeedbackEffectImpl_QueryInterface( impl->IWineForceFeedbackEffectImpl_inner, iid, out ); }
-static ULONG WINAPI effect_AddRef( IConditionForceEffect *iface ) -{ - struct condition_effect *impl = impl_from_IConditionForceEffect( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI effect_Release( IConditionForceEffect *iface ) -{ - struct condition_effect *impl = impl_from_IConditionForceEffect( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - - if (!ref) - { - /* guard against re-entry if inner releases an outer iface */ - InterlockedIncrement( &impl->ref ); - IWineForceFeedbackEffectImpl_Release( impl->IWineForceFeedbackEffectImpl_inner ); - free( impl ); - } - - return ref; -} - -static HRESULT WINAPI effect_GetIids( IConditionForceEffect *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} +IUNKNOWN_IMPL_ADDREF( condition_effect, IConditionForceEffect );
-static HRESULT WINAPI effect_GetRuntimeClassName( IConditionForceEffect *iface, HSTRING *class_name ) +static void condition_effect_destroy( struct condition_effect *impl ) { - return WindowsCreateString( RuntimeClass_Windows_Gaming_Input_ForceFeedback_ConditionForceEffect, - ARRAY_SIZE(RuntimeClass_Windows_Gaming_Input_ForceFeedback_ConditionForceEffect), - class_name ); + IWineForceFeedbackEffectImpl_Release( impl->IWineForceFeedbackEffectImpl_inner ); + free( impl ); }
-static HRESULT WINAPI effect_GetTrustLevel( IConditionForceEffect *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} +IUNKNOWN_IMPL_RELEASE( condition_effect, IConditionForceEffect ); +IINSPECTABLE_IMPL( condition_effect, IConditionForceEffect );
-static HRESULT WINAPI effect_get_Kind( IConditionForceEffect *iface, ConditionForceEffectKind *kind ) +static HRESULT WINAPI condition_effect_get_Kind( IConditionForceEffect *iface, ConditionForceEffectKind *kind ) { - struct condition_effect *impl = impl_from_IConditionForceEffect( iface ); + struct condition_effect *impl = condition_effect_from_IConditionForceEffect( iface ); TRACE( "iface %p, kind %p.\n", iface, kind ); *kind = impl->kind; return S_OK; }
-static HRESULT WINAPI effect_SetParameters( IConditionForceEffect *iface, Vector3 direction, FLOAT positive_coeff, FLOAT negative_coeff, +static HRESULT WINAPI condition_effect_SetParameters( IConditionForceEffect *iface, Vector3 direction, FLOAT positive_coeff, FLOAT negative_coeff, FLOAT max_positive_magnitude, FLOAT max_negative_magnitude, FLOAT deadzone, FLOAT bias ) { - struct condition_effect *impl = impl_from_IConditionForceEffect( iface ); + struct condition_effect *impl = condition_effect_from_IConditionForceEffect( iface ); WineForceFeedbackEffectParameters params = { .condition = @@ -131,120 +86,27 @@ static HRESULT WINAPI effect_SetParameters( IConditionForceEffect *iface, Vector return IWineForceFeedbackEffectImpl_put_Parameters( impl->IWineForceFeedbackEffectImpl_inner, params, NULL ); }
-static const struct IConditionForceEffectVtbl effect_vtbl = -{ - effect_QueryInterface, - effect_AddRef, - effect_Release, - /* IInspectable methods */ - effect_GetIids, - effect_GetRuntimeClassName, - effect_GetTrustLevel, - /* IConditionForceEffect methods */ - effect_get_Kind, - effect_SetParameters, -}; +INTERFACE_VTBL_IConditionForceEffect( condition_effect );
struct condition_factory { IActivationFactory IActivationFactory_iface; IConditionForceEffectFactory IConditionForceEffectFactory_iface; IAgileObject IAgileObject_iface; - LONG ref; + const WCHAR *class_name; };
-static inline struct condition_factory *impl_from_IActivationFactory( IActivationFactory *iface ) -{ - return CONTAINING_RECORD( iface, struct condition_factory, IActivationFactory_iface ); -} - -static HRESULT WINAPI activation_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) -{ - struct condition_factory *impl = impl_from_IActivationFactory( iface ); - - TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out ); - - if (IsEqualGUID( iid, &IID_IUnknown ) || - IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IActivationFactory )) - { - IInspectable_AddRef( (*out = &impl->IActivationFactory_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IConditionForceEffectFactory )) - { - IInspectable_AddRef( (*out = &impl->IConditionForceEffectFactory_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IAgileObject )) - { - IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); - return S_OK; - } - - FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); - *out = NULL; - return E_NOINTERFACE; -} - -static ULONG WINAPI activation_AddRef( IActivationFactory *iface ) -{ - struct condition_factory *impl = impl_from_IActivationFactory( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI activation_Release( IActivationFactory *iface ) -{ - struct condition_factory *impl = impl_from_IActivationFactory( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static HRESULT WINAPI activation_GetIids( IActivationFactory *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} +INTERFACE_IMPL_STATIC_IActivationFactory( condition_factory, IConditionForceEffectFactory, IAgileObject, END );
-static HRESULT WINAPI activation_GetRuntimeClassName( IActivationFactory *iface, HSTRING *class_name ) -{ - FIXME( "iface %p, class_name %p stub!\n", iface, class_name ); - return E_NOTIMPL; -} - -static HRESULT WINAPI activation_GetTrustLevel( IActivationFactory *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} - -static HRESULT WINAPI activation_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) +static HRESULT WINAPI condition_factory_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) { FIXME( "iface %p, instance %p stub!\n", iface, instance ); return E_NOTIMPL; }
-static const struct IActivationFactoryVtbl activation_vtbl = -{ - activation_QueryInterface, - activation_AddRef, - activation_Release, - /* IInspectable methods */ - activation_GetIids, - activation_GetRuntimeClassName, - activation_GetTrustLevel, - /* IActivationFactory methods */ - activation_ActivateInstance, -}; - -DEFINE_IINSPECTABLE( factory, IConditionForceEffectFactory, condition_factory, IActivationFactory_iface ) +INTERFACE_VTBL_IActivationFactory( condition_factory );
-static HRESULT WINAPI factory_CreateInstance( IConditionForceEffectFactory *iface, enum ConditionForceEffectKind kind, IForceFeedbackEffect **out ) +static HRESULT WINAPI condition_factory_IConditionForceEffectFactory_CreateInstance( IConditionForceEffectFactory *iface, enum ConditionForceEffectKind kind, IForceFeedbackEffect **out ) { enum WineForceFeedbackEffectType type = WineForceFeedbackEffectType_Condition + kind; struct condition_effect *impl; @@ -253,8 +115,9 @@ static HRESULT WINAPI factory_CreateInstance( IConditionForceEffectFactory *ifac TRACE( "iface %p, kind %u, out %p.\n", iface, kind, out );
if (!(impl = calloc( 1, sizeof(struct condition_effect) ))) return E_OUTOFMEMORY; - impl->IConditionForceEffect_iface.lpVtbl = &effect_vtbl; - impl->ref = 1; + impl->IConditionForceEffect_iface.lpVtbl = &condition_effect_vtbl; + impl->class_name = RuntimeClass_Windows_Gaming_Input_ForceFeedback_ConditionForceEffect; + impl->refcount = 1; impl->kind = kind;
if (FAILED(hr = force_feedback_effect_create( type, (IInspectable *)&impl->IConditionForceEffect_iface, &impl->IWineForceFeedbackEffectImpl_inner )) || @@ -270,27 +133,15 @@ static HRESULT WINAPI factory_CreateInstance( IConditionForceEffectFactory *ifac return S_OK; }
-static const struct IConditionForceEffectFactoryVtbl factory_vtbl = -{ - factory_QueryInterface, - factory_AddRef, - factory_Release, - /* IInspectable methods */ - factory_GetIids, - factory_GetRuntimeClassName, - factory_GetTrustLevel, - /* IConditionForceEffectFactory methods */ - factory_CreateInstance, -}; - -DEFINE_IAGILEOBJECT( condition_factory, IActivationFactory, &object->IActivationFactory_iface ); +INTERFACE_VTBL_IConditionForceEffectFactory( condition_factory_IConditionForceEffectFactory ); +INTERFACE_VTBL_IAgileObject( condition_factory_IAgileObject );
static struct condition_factory condition_statics = { - {&activation_vtbl}, - {&factory_vtbl}, + {&condition_factory_vtbl}, + {&condition_factory_IConditionForceEffectFactory_vtbl}, {&condition_factory_IAgileObject_vtbl}, - 1, + RuntimeClass_Windows_Gaming_Input_ForceFeedback_ConditionForceEffect, };
IInspectable *condition_effect_factory = (IInspectable *)&condition_statics.IActivationFactory_iface; diff --git a/dlls/windows.gaming.input/constant_effect.c b/dlls/windows.gaming.input/constant_effect.c index 3e0a8cb0295..d20be1ad13f 100644 --- a/dlls/windows.gaming.input/constant_effect.c +++ b/dlls/windows.gaming.input/constant_effect.c @@ -26,77 +26,32 @@ struct constant_effect { IConstantForceEffect IConstantForceEffect_iface; IWineForceFeedbackEffectImpl *IWineForceFeedbackEffectImpl_inner; - LONG ref; + const WCHAR *class_name; + LONG refcount; };
-static inline struct constant_effect *impl_from_IConstantForceEffect( IConstantForceEffect *iface ) -{ - return CONTAINING_RECORD( iface, struct constant_effect, IConstantForceEffect_iface ); -} +INTERFACE_IMPL_FROM( constant_effect, IConstantForceEffect );
-static HRESULT WINAPI effect_QueryInterface( IConstantForceEffect *iface, REFIID iid, void **out ) +static HRESULT WINAPI constant_effect_QueryInterface( IConstantForceEffect *iface, REFIID iid, void **out ) { - struct constant_effect *impl = impl_from_IConstantForceEffect( iface ); - + struct constant_effect *impl = constant_effect_from_IConstantForceEffect( iface ); TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out ); - - if (IsEqualGUID( iid, &IID_IUnknown ) || - IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IConstantForceEffect )) - { - IInspectable_AddRef( (*out = &impl->IConstantForceEffect_iface) ); - return S_OK; - } - + QUERY_INTERFACE_IConstantForceEffect( impl, iid, out, IConstantForceEffect_iface ) return IWineForceFeedbackEffectImpl_QueryInterface( impl->IWineForceFeedbackEffectImpl_inner, iid, out ); }
-static ULONG WINAPI effect_AddRef( IConstantForceEffect *iface ) -{ - struct constant_effect *impl = impl_from_IConstantForceEffect( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} +IUNKNOWN_IMPL_ADDREF( constant_effect, IConstantForceEffect );
-static ULONG WINAPI effect_Release( IConstantForceEffect *iface ) +static void constant_effect_destroy( struct constant_effect *impl ) { - struct constant_effect *impl = impl_from_IConstantForceEffect( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - - if (!ref) - { - /* guard against re-entry if inner releases an outer iface */ - InterlockedIncrement( &impl->ref ); - IWineForceFeedbackEffectImpl_Release( impl->IWineForceFeedbackEffectImpl_inner ); - free( impl ); - } - - return ref; + IWineForceFeedbackEffectImpl_Release( impl->IWineForceFeedbackEffectImpl_inner ); + free( impl ); }
-static HRESULT WINAPI effect_GetIids( IConstantForceEffect *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} - -static HRESULT WINAPI effect_GetRuntimeClassName( IConstantForceEffect *iface, HSTRING *class_name ) -{ - return WindowsCreateString( RuntimeClass_Windows_Gaming_Input_ForceFeedback_ConstantForceEffect, - ARRAY_SIZE(RuntimeClass_Windows_Gaming_Input_ForceFeedback_ConstantForceEffect), - class_name ); -} - -static HRESULT WINAPI effect_GetTrustLevel( IConstantForceEffect *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} +IUNKNOWN_IMPL_RELEASE( constant_effect, IConstantForceEffect ); +IINSPECTABLE_IMPL( constant_effect, IConstantForceEffect );
-static HRESULT WINAPI effect_SetParameters( IConstantForceEffect *iface, Vector3 direction, TimeSpan duration ) +static HRESULT WINAPI constant_effect_SetParameters( IConstantForceEffect *iface, Vector3 direction, TimeSpan duration ) { WineForceFeedbackEffectParameters params = { @@ -109,14 +64,14 @@ static HRESULT WINAPI effect_SetParameters( IConstantForceEffect *iface, Vector3 .gain = 1., }, }; - struct constant_effect *impl = impl_from_IConstantForceEffect( iface ); + struct constant_effect *impl = constant_effect_from_IConstantForceEffect( iface );
TRACE( "iface %p, direction %s, duration %I64u.\n", iface, debugstr_vector3( &direction ), duration.Duration );
return IWineForceFeedbackEffectImpl_put_Parameters( impl->IWineForceFeedbackEffectImpl_inner, params, NULL ); }
-static HRESULT WINAPI effect_SetParametersWithEnvelope( IConstantForceEffect *iface, Vector3 direction, FLOAT attack_gain, +static HRESULT WINAPI constant_effect_SetParametersWithEnvelope( IConstantForceEffect *iface, Vector3 direction, FLOAT attack_gain, FLOAT sustain_gain, FLOAT release_gain, TimeSpan start_delay, TimeSpan attack_duration, TimeSpan sustain_duration, TimeSpan release_duration, UINT32 repeat_count ) @@ -140,7 +95,7 @@ static HRESULT WINAPI effect_SetParametersWithEnvelope( IConstantForceEffect *if .attack_duration = attack_duration, .release_duration = release_duration, }; - struct constant_effect *impl = impl_from_IConstantForceEffect( iface ); + struct constant_effect *impl = constant_effect_from_IConstantForceEffect( iface );
TRACE( "iface %p, direction %s, attack_gain %f, sustain_gain %f, release_gain %f, start_delay %I64u, attack_duration %I64u, " "sustain_duration %I64u, release_duration %I64u, repeat_count %u.\n", iface, debugstr_vector3( &direction ), @@ -150,92 +105,18 @@ static HRESULT WINAPI effect_SetParametersWithEnvelope( IConstantForceEffect *if return IWineForceFeedbackEffectImpl_put_Parameters( impl->IWineForceFeedbackEffectImpl_inner, params, &envelope ); }
-static const struct IConstantForceEffectVtbl effect_vtbl = -{ - effect_QueryInterface, - effect_AddRef, - effect_Release, - /* IInspectable methods */ - effect_GetIids, - effect_GetRuntimeClassName, - effect_GetTrustLevel, - /* IConstantForceEffect methods */ - effect_SetParameters, - effect_SetParametersWithEnvelope, -}; +INTERFACE_VTBL_IConstantForceEffect( constant_effect );
struct constant_factory { IActivationFactory IActivationFactory_iface; IAgileObject IAgileObject_iface; - LONG ref; + const WCHAR *class_name; };
-static inline struct constant_factory *impl_from_IActivationFactory( IActivationFactory *iface ) -{ - return CONTAINING_RECORD( iface, struct constant_factory, IActivationFactory_iface ); -} +INTERFACE_IMPL_STATIC_IActivationFactory( constant_factory, IAgileObject, END );
-static HRESULT WINAPI activation_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) -{ - struct constant_factory *impl = impl_from_IActivationFactory( iface ); - - TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out ); - - if (IsEqualGUID( iid, &IID_IUnknown ) || - IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IActivationFactory )) - { - IInspectable_AddRef( (*out = &impl->IActivationFactory_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IAgileObject )) - { - IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); - return S_OK; - } - - FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); - *out = NULL; - return E_NOINTERFACE; -} - -static ULONG WINAPI activation_AddRef( IActivationFactory *iface ) -{ - struct constant_factory *impl = impl_from_IActivationFactory( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI activation_Release( IActivationFactory *iface ) -{ - struct constant_factory *impl = impl_from_IActivationFactory( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static HRESULT WINAPI activation_GetIids( IActivationFactory *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} - -static HRESULT WINAPI activation_GetRuntimeClassName( IActivationFactory *iface, HSTRING *class_name ) -{ - FIXME( "iface %p, class_name %p stub!\n", iface, class_name ); - return E_NOTIMPL; -} - -static HRESULT WINAPI activation_GetTrustLevel( IActivationFactory *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} - -static HRESULT WINAPI activation_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) +static HRESULT WINAPI constant_factory_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) { struct constant_effect *impl; HRESULT hr; @@ -243,8 +124,9 @@ static HRESULT WINAPI activation_ActivateInstance( IActivationFactory *iface, II TRACE( "iface %p, instance %p.\n", iface, instance );
if (!(impl = calloc( 1, sizeof(struct constant_effect) ))) return E_OUTOFMEMORY; - impl->IConstantForceEffect_iface.lpVtbl = &effect_vtbl; - impl->ref = 1; + impl->IConstantForceEffect_iface.lpVtbl = &constant_effect_vtbl; + impl->class_name = RuntimeClass_Windows_Gaming_Input_ForceFeedback_ConstantForceEffect; + impl->refcount = 1;
if (FAILED(hr = force_feedback_effect_create( WineForceFeedbackEffectType_Constant, (IInspectable *)&impl->IConstantForceEffect_iface, &impl->IWineForceFeedbackEffectImpl_inner ))) @@ -258,26 +140,14 @@ static HRESULT WINAPI activation_ActivateInstance( IActivationFactory *iface, II return S_OK; }
-static const struct IActivationFactoryVtbl activation_vtbl = -{ - activation_QueryInterface, - activation_AddRef, - activation_Release, - /* IInspectable methods */ - activation_GetIids, - activation_GetRuntimeClassName, - activation_GetTrustLevel, - /* IActivationFactory methods */ - activation_ActivateInstance, -}; - -DEFINE_IAGILEOBJECT( constant_factory, IActivationFactory, &object->IActivationFactory_iface ); +INTERFACE_VTBL_IActivationFactory( constant_factory ); +INTERFACE_VTBL_IAgileObject( constant_factory_IAgileObject );
static struct constant_factory constant_statics = { - {&activation_vtbl}, + {&constant_factory_vtbl}, {&constant_factory_IAgileObject_vtbl}, - 1, + RuntimeClass_Windows_Gaming_Input_ForceFeedback_ConstantForceEffect, };
IInspectable *constant_effect_factory = (IInspectable *)&constant_statics.IActivationFactory_iface; diff --git a/dlls/windows.gaming.input/force_feedback.c b/dlls/windows.gaming.input/force_feedback.c index 296dfa2a1e0..bf98a4702fb 100644 --- a/dlls/windows.gaming.input/force_feedback.c +++ b/dlls/windows.gaming.input/force_feedback.c @@ -35,8 +35,9 @@ struct effect IWineForceFeedbackEffectImpl IWineForceFeedbackEffectImpl_iface; IForceFeedbackEffect IForceFeedbackEffect_iface; IAgileObject IAgileObject_iface; - IInspectable *IInspectable_outer; - LONG ref; + IInspectable *outer; + const WCHAR *class_name; + LONG refcount;
CRITICAL_SECTION cs; IDirectInputEffect *effect; @@ -53,67 +54,15 @@ struct effect DIEFFECT params; };
-static inline struct effect *impl_from_IWineForceFeedbackEffectImpl( IWineForceFeedbackEffectImpl *iface ) +static void effect_destroy( struct effect *impl ) { - return CONTAINING_RECORD( iface, struct effect, IWineForceFeedbackEffectImpl_iface ); + if (impl->effect) IDirectInputEffect_Release( impl->effect ); + impl->cs.DebugInfo->Spare[0] = 0; + DeleteCriticalSection( &impl->cs ); + free( impl ); }
-static HRESULT WINAPI effect_impl_QueryInterface( IWineForceFeedbackEffectImpl *iface, REFIID iid, void **out ) -{ - struct effect *impl = impl_from_IWineForceFeedbackEffectImpl( iface ); - - TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out ); - - if (IsEqualGUID( iid, &IID_IUnknown ) || - IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IWineForceFeedbackEffectImpl )) - { - IWineForceFeedbackEffectImpl_AddRef( (*out = &impl->IWineForceFeedbackEffectImpl_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IForceFeedbackEffect )) - { - IInspectable_AddRef( (*out = &impl->IForceFeedbackEffect_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IAgileObject )) - { - IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); - return S_OK; - } - - FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); - *out = NULL; - return E_NOINTERFACE; -} - -static ULONG WINAPI effect_impl_AddRef( IWineForceFeedbackEffectImpl *iface ) -{ - struct effect *impl = impl_from_IWineForceFeedbackEffectImpl( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI effect_impl_Release( IWineForceFeedbackEffectImpl *iface ) -{ - struct effect *impl = impl_from_IWineForceFeedbackEffectImpl( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - - if (!ref) - { - if (impl->effect) IDirectInputEffect_Release( impl->effect ); - impl->cs.DebugInfo->Spare[0] = 0; - DeleteCriticalSection( &impl->cs ); - free( impl ); - } - - return ref; -} +INTERFACE_IMPL_OUTER_IWineForceFeedbackEffectImpl( effect, IForceFeedbackEffect, IAgileObject, END );
static int effect_reorient_direction( const WineForceFeedbackEffectParameters *params, Vector3 *direction ) { @@ -155,10 +104,10 @@ static int effect_reorient_direction( const WineForceFeedbackEffectParameters *p return sign; }
-static HRESULT WINAPI effect_impl_put_Parameters( IWineForceFeedbackEffectImpl *iface, WineForceFeedbackEffectParameters params, +static HRESULT WINAPI effect_put_Parameters( IWineForceFeedbackEffectImpl *iface, WineForceFeedbackEffectParameters params, WineForceFeedbackEffectEnvelope *envelope ) { - struct effect *impl = impl_from_IWineForceFeedbackEffectImpl( iface ); + struct effect *impl = effect_from_IWineForceFeedbackEffectImpl( iface ); Vector3 direction = {0}; double magnitude = 0; DWORD count = 0; @@ -241,20 +190,11 @@ static HRESULT WINAPI effect_impl_put_Parameters( IWineForceFeedbackEffectImpl * return hr; }
-static const struct IWineForceFeedbackEffectImplVtbl effect_impl_vtbl = -{ - effect_impl_QueryInterface, - effect_impl_AddRef, - effect_impl_Release, - /* IWineForceFeedbackEffectImpl methods */ - effect_impl_put_Parameters, -}; +INTERFACE_VTBL_IWineForceFeedbackEffectImpl( effect );
-DEFINE_IINSPECTABLE_OUTER( effect, IForceFeedbackEffect, effect, IInspectable_outer ) - -static HRESULT WINAPI effect_get_Gain( IForceFeedbackEffect *iface, DOUBLE *value ) +static HRESULT WINAPI effect_IForceFeedbackEffect_get_Gain( IForceFeedbackEffect *iface, DOUBLE *value ) { - struct effect *impl = impl_from_IForceFeedbackEffect( iface ); + struct effect *impl = effect_from_IForceFeedbackEffect( iface );
TRACE( "iface %p, value %p.\n", iface, value );
@@ -265,9 +205,9 @@ static HRESULT WINAPI effect_get_Gain( IForceFeedbackEffect *iface, DOUBLE *valu return S_OK; }
-static HRESULT WINAPI effect_put_Gain( IForceFeedbackEffect *iface, DOUBLE value ) +static HRESULT WINAPI effect_IForceFeedbackEffect_put_Gain( IForceFeedbackEffect *iface, DOUBLE value ) { - struct effect *impl = impl_from_IForceFeedbackEffect( iface ); + struct effect *impl = effect_from_IForceFeedbackEffect( iface ); HRESULT hr;
TRACE( "iface %p, value %f.\n", iface, value ); @@ -281,9 +221,9 @@ static HRESULT WINAPI effect_put_Gain( IForceFeedbackEffect *iface, DOUBLE value return hr; }
-static HRESULT WINAPI effect_get_State( IForceFeedbackEffect *iface, ForceFeedbackEffectState *value ) +static HRESULT WINAPI effect_IForceFeedbackEffect_get_State( IForceFeedbackEffect *iface, ForceFeedbackEffectState *value ) { - struct effect *impl = impl_from_IForceFeedbackEffect( iface ); + struct effect *impl = effect_from_IForceFeedbackEffect( iface ); DWORD status; HRESULT hr;
@@ -304,9 +244,9 @@ static HRESULT WINAPI effect_get_State( IForceFeedbackEffect *iface, ForceFeedba return S_OK; }
-static HRESULT WINAPI effect_Start( IForceFeedbackEffect *iface ) +static HRESULT WINAPI effect_IForceFeedbackEffect_Start( IForceFeedbackEffect *iface ) { - struct effect *impl = impl_from_IForceFeedbackEffect( iface ); + struct effect *impl = effect_from_IForceFeedbackEffect( iface ); HRESULT hr = E_UNEXPECTED; DWORD flags = 0;
@@ -319,9 +259,9 @@ static HRESULT WINAPI effect_Start( IForceFeedbackEffect *iface ) return hr; }
-static HRESULT WINAPI effect_Stop( IForceFeedbackEffect *iface ) +static HRESULT WINAPI effect_IForceFeedbackEffect_Stop( IForceFeedbackEffect *iface ) { - struct effect *impl = impl_from_IForceFeedbackEffect( iface ); + struct effect *impl = effect_from_IForceFeedbackEffect( iface ); HRESULT hr = E_UNEXPECTED;
TRACE( "iface %p.\n", iface ); @@ -333,24 +273,8 @@ static HRESULT WINAPI effect_Stop( IForceFeedbackEffect *iface ) return hr; }
-static const struct IForceFeedbackEffectVtbl effect_vtbl = -{ - effect_QueryInterface, - effect_AddRef, - effect_Release, - /* IInspectable methods */ - effect_GetIids, - effect_GetRuntimeClassName, - effect_GetTrustLevel, - /* IForceFeedbackEffect methods */ - effect_get_Gain, - effect_put_Gain, - effect_get_State, - effect_Start, - effect_Stop, -}; - -DEFINE_IAGILEOBJECT( effect, IInspectable, object->IInspectable_outer ); +INTERFACE_VTBL_IForceFeedbackEffect( effect_IForceFeedbackEffect ); +INTERFACE_VTBL_IAgileObject( effect_IAgileObject );
HRESULT force_feedback_effect_create( enum WineForceFeedbackEffectType type, IInspectable *outer, IWineForceFeedbackEffectImpl **out ) { @@ -359,11 +283,11 @@ HRESULT force_feedback_effect_create( enum WineForceFeedbackEffectType type, IIn TRACE( "outer %p, out %p\n", outer, out );
if (!(impl = calloc( 1, sizeof(*impl) ))) return E_OUTOFMEMORY; - impl->IWineForceFeedbackEffectImpl_iface.lpVtbl = &effect_impl_vtbl; - impl->IForceFeedbackEffect_iface.lpVtbl = &effect_vtbl; + impl->IWineForceFeedbackEffectImpl_iface.lpVtbl = &effect_vtbl; + impl->IForceFeedbackEffect_iface.lpVtbl = &effect_IForceFeedbackEffect_vtbl; impl->IAgileObject_iface.lpVtbl = &effect_IAgileObject_vtbl; - impl->IInspectable_outer = outer; - impl->ref = 1; + impl->outer = outer; + impl->refcount = 1;
switch (type) { @@ -441,87 +365,23 @@ struct motor { IForceFeedbackMotor IForceFeedbackMotor_iface; IAgileObject IAgileObject_iface; - LONG ref; + const WCHAR *class_name; + LONG refcount;
IDirectInputDevice8W *device; };
-static inline struct motor *impl_from_IForceFeedbackMotor( IForceFeedbackMotor *iface ) +static void motor_destroy( struct motor *impl ) { - return CONTAINING_RECORD( iface, struct motor, IForceFeedbackMotor_iface ); + IDirectInputDevice8_Release( impl->device ); + free( impl ); }
-static HRESULT WINAPI motor_QueryInterface( IForceFeedbackMotor *iface, REFIID iid, void **out ) -{ - struct motor *impl = impl_from_IForceFeedbackMotor( iface ); - - TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out ); - - if (IsEqualGUID( iid, &IID_IUnknown ) || - IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IForceFeedbackMotor )) - { - IInspectable_AddRef( (*out = &impl->IForceFeedbackMotor_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IAgileObject )) - { - IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); - return S_OK; - } - - FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); - *out = NULL; - return E_NOINTERFACE; -} - -static ULONG WINAPI motor_AddRef( IForceFeedbackMotor *iface ) -{ - struct motor *impl = impl_from_IForceFeedbackMotor( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI motor_Release( IForceFeedbackMotor *iface ) -{ - struct motor *impl = impl_from_IForceFeedbackMotor( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - - if (!ref) - { - IDirectInputDevice8_Release( impl->device ); - free( impl ); - } - - return ref; -} - -static HRESULT WINAPI motor_GetIids( IForceFeedbackMotor *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} - -static HRESULT WINAPI motor_GetRuntimeClassName( IForceFeedbackMotor *iface, HSTRING *class_name ) -{ - return WindowsCreateString( RuntimeClass_Windows_Gaming_Input_ForceFeedback_ForceFeedbackMotor, - ARRAY_SIZE(RuntimeClass_Windows_Gaming_Input_ForceFeedback_ForceFeedbackMotor), - class_name ); -} - -static HRESULT WINAPI motor_GetTrustLevel( IForceFeedbackMotor *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} +INTERFACE_IMPL_IForceFeedbackMotor( motor, IAgileObject, END );
static HRESULT WINAPI motor_get_AreEffectsPaused( IForceFeedbackMotor *iface, BOOLEAN *value ) { - struct motor *impl = impl_from_IForceFeedbackMotor( iface ); + struct motor *impl = motor_from_IForceFeedbackMotor( iface ); DWORD state; HRESULT hr;
@@ -535,7 +395,7 @@ static HRESULT WINAPI motor_get_AreEffectsPaused( IForceFeedbackMotor *iface, BO
static HRESULT WINAPI motor_get_MasterGain( IForceFeedbackMotor *iface, double *value ) { - struct motor *impl = impl_from_IForceFeedbackMotor( iface ); + struct motor *impl = motor_from_IForceFeedbackMotor( iface ); DIPROPDWORD gain = { .diph = @@ -557,7 +417,7 @@ static HRESULT WINAPI motor_get_MasterGain( IForceFeedbackMotor *iface, double *
static HRESULT WINAPI motor_put_MasterGain( IForceFeedbackMotor *iface, double value ) { - struct motor *impl = impl_from_IForceFeedbackMotor( iface ); + struct motor *impl = motor_from_IForceFeedbackMotor( iface ); DIPROPDWORD gain = { .diph = @@ -576,7 +436,7 @@ static HRESULT WINAPI motor_put_MasterGain( IForceFeedbackMotor *iface, double v
static HRESULT WINAPI motor_get_IsEnabled( IForceFeedbackMotor *iface, BOOLEAN *value ) { - struct motor *impl = impl_from_IForceFeedbackMotor( iface ); + struct motor *impl = motor_from_IForceFeedbackMotor( iface ); DWORD state; HRESULT hr;
@@ -604,7 +464,7 @@ static BOOL CALLBACK check_ffb_axes( const DIDEVICEOBJECTINSTANCEW *obj, void *a
static HRESULT WINAPI motor_get_SupportedAxes( IForceFeedbackMotor *iface, enum ForceFeedbackEffectAxes *value ) { - struct motor *impl = impl_from_IForceFeedbackMotor( iface ); + struct motor *impl = motor_from_IForceFeedbackMotor( iface ); HRESULT hr;
TRACE( "iface %p, value %p.\n", iface, value ); @@ -618,9 +478,9 @@ static HRESULT WINAPI motor_get_SupportedAxes( IForceFeedbackMotor *iface, enum
static HRESULT WINAPI motor_load_effect_async( IUnknown *invoker, IUnknown *param, PROPVARIANT *result ) { - struct effect *effect = impl_from_IForceFeedbackEffect( (IForceFeedbackEffect *)param ); + struct effect *effect = effect_from_IForceFeedbackEffect( (IForceFeedbackEffect *)param ); IForceFeedbackMotor *motor = (IForceFeedbackMotor *)invoker; - struct motor *impl = impl_from_IForceFeedbackMotor( motor ); + struct motor *impl = motor_from_IForceFeedbackMotor( motor ); ForceFeedbackEffectAxes supported_axes = 0; IDirectInputEffect *dinput_effect; HRESULT hr; @@ -682,7 +542,7 @@ static HRESULT WINAPI motor_LoadEffectAsync( IForceFeedbackMotor *iface, IForceF
static HRESULT WINAPI motor_PauseAllEffects( IForceFeedbackMotor *iface ) { - struct motor *impl = impl_from_IForceFeedbackMotor( iface ); + struct motor *impl = motor_from_IForceFeedbackMotor( iface );
TRACE( "iface %p.\n", iface );
@@ -691,7 +551,7 @@ static HRESULT WINAPI motor_PauseAllEffects( IForceFeedbackMotor *iface )
static HRESULT WINAPI motor_ResumeAllEffects( IForceFeedbackMotor *iface ) { - struct motor *impl = impl_from_IForceFeedbackMotor( iface ); + struct motor *impl = motor_from_IForceFeedbackMotor( iface );
TRACE( "iface %p.\n", iface );
@@ -700,7 +560,7 @@ static HRESULT WINAPI motor_ResumeAllEffects( IForceFeedbackMotor *iface )
static HRESULT WINAPI motor_StopAllEffects( IForceFeedbackMotor *iface ) { - struct motor *impl = impl_from_IForceFeedbackMotor( iface ); + struct motor *impl = motor_from_IForceFeedbackMotor( iface );
TRACE( "iface %p.\n", iface );
@@ -709,7 +569,7 @@ static HRESULT WINAPI motor_StopAllEffects( IForceFeedbackMotor *iface )
static HRESULT WINAPI motor_try_disable_async( IUnknown *invoker, IUnknown *param, PROPVARIANT *result ) { - struct motor *impl = impl_from_IForceFeedbackMotor( (IForceFeedbackMotor *)invoker ); + struct motor *impl = motor_from_IForceFeedbackMotor( (IForceFeedbackMotor *)invoker ); HRESULT hr;
hr = IDirectInputDevice8_SendForceFeedbackCommand( impl->device, DISFFC_SETACTUATORSOFF ); @@ -727,7 +587,7 @@ static HRESULT WINAPI motor_TryDisableAsync( IForceFeedbackMotor *iface, IAsyncO
static HRESULT WINAPI motor_try_enable_async( IUnknown *invoker, IUnknown *param, PROPVARIANT *result ) { - struct motor *impl = impl_from_IForceFeedbackMotor( (IForceFeedbackMotor *)invoker ); + struct motor *impl = motor_from_IForceFeedbackMotor( (IForceFeedbackMotor *)invoker ); HRESULT hr;
hr = IDirectInputDevice8_SendForceFeedbackCommand( impl->device, DISFFC_SETACTUATORSON ); @@ -745,7 +605,7 @@ static HRESULT WINAPI motor_TryEnableAsync( IForceFeedbackMotor *iface, IAsyncOp
static HRESULT WINAPI motor_try_reset_async( IUnknown *invoker, IUnknown *param, PROPVARIANT *result ) { - struct motor *impl = impl_from_IForceFeedbackMotor( (IForceFeedbackMotor *)invoker ); + struct motor *impl = motor_from_IForceFeedbackMotor( (IForceFeedbackMotor *)invoker ); HRESULT hr;
hr = IDirectInputDevice8_SendForceFeedbackCommand( impl->device, DISFFC_RESET ); @@ -763,7 +623,7 @@ static HRESULT WINAPI motor_TryResetAsync( IForceFeedbackMotor *iface, IAsyncOpe
static HRESULT WINAPI motor_unload_effect_async( IUnknown *iface, IUnknown *param, PROPVARIANT *result ) { - struct effect *effect = impl_from_IForceFeedbackEffect( (IForceFeedbackEffect *)param ); + struct effect *effect = effect_from_IForceFeedbackEffect( (IForceFeedbackEffect *)param ); IDirectInputEffect *dinput_effect; HRESULT hr;
@@ -787,7 +647,7 @@ static HRESULT WINAPI motor_unload_effect_async( IUnknown *iface, IUnknown *para static HRESULT WINAPI motor_TryUnloadEffectAsync( IForceFeedbackMotor *iface, IForceFeedbackEffect *effect, IAsyncOperation_boolean **async_op ) { - struct effect *impl = impl_from_IForceFeedbackEffect( (IForceFeedbackEffect *)effect ); + struct effect *impl = effect_from_IForceFeedbackEffect( (IForceFeedbackEffect *)effect ); HRESULT hr = S_OK;
TRACE( "iface %p, effect %p, async_op %p.\n", iface, effect, async_op ); @@ -800,32 +660,8 @@ static HRESULT WINAPI motor_TryUnloadEffectAsync( IForceFeedbackMotor *iface, IF return async_operation_boolean_create( (IUnknown *)iface, (IUnknown *)effect, motor_unload_effect_async, async_op ); }
-static const struct IForceFeedbackMotorVtbl motor_vtbl = -{ - motor_QueryInterface, - motor_AddRef, - motor_Release, - /* IInspectable methods */ - motor_GetIids, - motor_GetRuntimeClassName, - motor_GetTrustLevel, - /* IForceFeedbackMotor methods */ - motor_get_AreEffectsPaused, - motor_get_MasterGain, - motor_put_MasterGain, - motor_get_IsEnabled, - motor_get_SupportedAxes, - motor_LoadEffectAsync, - motor_PauseAllEffects, - motor_ResumeAllEffects, - motor_StopAllEffects, - motor_TryDisableAsync, - motor_TryEnableAsync, - motor_TryResetAsync, - motor_TryUnloadEffectAsync, -}; - -DEFINE_IAGILEOBJECT( motor, IForceFeedbackMotor, &object->IForceFeedbackMotor_iface ); +INTERFACE_VTBL_IForceFeedbackMotor( motor ); +INTERFACE_VTBL_IAgileObject( motor_IAgileObject );
HRESULT force_feedback_motor_create( IDirectInputDevice8W *device, IForceFeedbackMotor **out ) { @@ -841,7 +677,8 @@ HRESULT force_feedback_motor_create( IDirectInputDevice8W *device, IForceFeedbac if (!(impl = calloc( 1, sizeof(*impl) ))) return E_OUTOFMEMORY; impl->IForceFeedbackMotor_iface.lpVtbl = &motor_vtbl; impl->IAgileObject_iface.lpVtbl = &motor_IAgileObject_vtbl; - impl->ref = 1; + impl->class_name = RuntimeClass_Windows_Gaming_Input_ForceFeedback_ForceFeedbackMotor; + impl->refcount = 1;
IDirectInputDevice_AddRef( device ); impl->device = device; diff --git a/dlls/windows.gaming.input/gamepad.c b/dlls/windows.gaming.input/gamepad.c index 1c2d0c53299..2712152f99f 100644 --- a/dlls/windows.gaming.input/gamepad.c +++ b/dlls/windows.gaming.input/gamepad.c @@ -62,109 +62,33 @@ struct gamepad IGameControllerInputSink IGameControllerInputSink_iface; IGamepad IGamepad_iface; IGamepad2 IGamepad2_iface; - IGameController *IGameController_outer; - LONG ref; + IInspectable *outer; + const WCHAR *class_name; + LONG refcount;
IGameControllerProvider *provider; IWineGameControllerProvider *wine_provider; };
-static inline struct gamepad *impl_from_IGameControllerImpl( IGameControllerImpl *iface ) +static void gamepad_destroy( struct gamepad *impl ) { - return CONTAINING_RECORD( iface, struct gamepad, IGameControllerImpl_iface ); + if (impl->wine_provider) + IWineGameControllerProvider_Release( impl->wine_provider ); + IGameControllerProvider_Release( impl->provider ); + free( impl ); }
-static HRESULT WINAPI controller_QueryInterface( IGameControllerImpl *iface, REFIID iid, void **out ) -{ - struct gamepad *impl = impl_from_IGameControllerImpl( iface ); - - TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out ); - - if (IsEqualGUID( iid, &IID_IUnknown ) || - IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IGameControllerImpl )) - { - IInspectable_AddRef( (*out = &impl->IGameControllerImpl_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IGameControllerInputSink )) - { - IInspectable_AddRef( (*out = &impl->IGameControllerInputSink_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IGamepad )) - { - IInspectable_AddRef( (*out = &impl->IGamepad_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IGamepad2 )) - { - IInspectable_AddRef( (*out = &impl->IGamepad2_iface) ); - return S_OK; - } - - FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); - *out = NULL; - return E_NOINTERFACE; -} +INTERFACE_IMPL_OUTER_IGameControllerImpl( gamepad, IGameControllerInputSink, IGamepad, IGamepad2, END );
-static ULONG WINAPI controller_AddRef( IGameControllerImpl *iface ) -{ - struct gamepad *impl = impl_from_IGameControllerImpl( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI controller_Release( IGameControllerImpl *iface ) -{ - struct gamepad *impl = impl_from_IGameControllerImpl( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - - if (!ref) - { - if (impl->wine_provider) - IWineGameControllerProvider_Release( impl->wine_provider ); - IGameControllerProvider_Release( impl->provider ); - free( impl ); - } - - return ref; -} - -static HRESULT WINAPI controller_GetIids( IGameControllerImpl *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} - -static HRESULT WINAPI controller_GetRuntimeClassName( IGameControllerImpl *iface, HSTRING *class_name ) -{ - return WindowsCreateString( RuntimeClass_Windows_Gaming_Input_Gamepad, - ARRAY_SIZE(RuntimeClass_Windows_Gaming_Input_Gamepad), - class_name ); -} - -static HRESULT WINAPI controller_GetTrustLevel( IGameControllerImpl *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} - -static HRESULT WINAPI controller_Initialize( IGameControllerImpl *iface, IGameController *outer, +static HRESULT WINAPI gamepad_Initialize( IGameControllerImpl *iface, IGameController *outer, IGameControllerProvider *provider ) { - struct gamepad *impl = impl_from_IGameControllerImpl( iface ); + struct gamepad *impl = gamepad_from_IGameControllerImpl( iface ); HRESULT hr;
TRACE( "iface %p, outer %p, provider %p.\n", iface, outer, provider );
- impl->IGameController_outer = outer; + impl->outer = (IInspectable *)outer; IGameControllerProvider_AddRef( (impl->provider = provider) );
hr = IGameControllerProvider_QueryInterface( provider, &IID_IWineGameControllerProvider, @@ -179,52 +103,25 @@ static HRESULT WINAPI controller_Initialize( IGameControllerImpl *iface, IGameCo return hr; }
-static const struct IGameControllerImplVtbl controller_vtbl = -{ - controller_QueryInterface, - controller_AddRef, - controller_Release, - /* IInspectable methods */ - controller_GetIids, - controller_GetRuntimeClassName, - controller_GetTrustLevel, - /* IGameControllerImpl methods */ - controller_Initialize, -}; - -DEFINE_IINSPECTABLE_OUTER( input_sink, IGameControllerInputSink, gamepad, IGameController_outer ) +INTERFACE_VTBL_IGameControllerImpl( gamepad );
-static HRESULT WINAPI input_sink_OnInputResumed( IGameControllerInputSink *iface, UINT64 timestamp ) +static HRESULT WINAPI gamepad_IGameControllerInputSink_OnInputResumed( IGameControllerInputSink *iface, UINT64 timestamp ) { FIXME( "iface %p, timestamp %I64u stub!\n", iface, timestamp ); return E_NOTIMPL; }
-static HRESULT WINAPI input_sink_OnInputSuspended( IGameControllerInputSink *iface, UINT64 timestamp ) +static HRESULT WINAPI gamepad_IGameControllerInputSink_OnInputSuspended( IGameControllerInputSink *iface, UINT64 timestamp ) { FIXME( "iface %p, timestamp %I64u stub!\n", iface, timestamp ); return E_NOTIMPL; }
-static const struct IGameControllerInputSinkVtbl input_sink_vtbl = -{ - input_sink_QueryInterface, - input_sink_AddRef, - input_sink_Release, - /* IInspectable methods */ - input_sink_GetIids, - input_sink_GetRuntimeClassName, - input_sink_GetTrustLevel, - /* IGameControllerInputSink methods */ - input_sink_OnInputResumed, - input_sink_OnInputSuspended, -}; - -DEFINE_IINSPECTABLE_OUTER( gamepad, IGamepad, gamepad, IGameController_outer ) +INTERFACE_VTBL_IGameControllerInputSink( gamepad_IGameControllerInputSink );
-static HRESULT WINAPI gamepad_get_Vibration( IGamepad *iface, struct GamepadVibration *value ) +static HRESULT WINAPI gamepad_IGamepad_get_Vibration( IGamepad *iface, struct GamepadVibration *value ) { - struct gamepad *impl = impl_from_IGamepad( iface ); + struct gamepad *impl = gamepad_from_IGamepad( iface ); struct WineGameControllerVibration vibration; HRESULT hr;
@@ -240,9 +137,9 @@ static HRESULT WINAPI gamepad_get_Vibration( IGamepad *iface, struct GamepadVibr return S_OK; }
-static HRESULT WINAPI gamepad_put_Vibration( IGamepad *iface, struct GamepadVibration value ) +static HRESULT WINAPI gamepad_IGamepad_put_Vibration( IGamepad *iface, struct GamepadVibration value ) { - struct gamepad *impl = impl_from_IGamepad( iface ); + struct gamepad *impl = gamepad_from_IGamepad( iface ); struct WineGameControllerVibration vibration = { .rumble = value.LeftMotor * 65535., @@ -256,9 +153,9 @@ static HRESULT WINAPI gamepad_put_Vibration( IGamepad *iface, struct GamepadVibr return IWineGameControllerProvider_put_Vibration( impl->wine_provider, vibration ); }
-static HRESULT WINAPI gamepad_GetCurrentReading( IGamepad *iface, struct GamepadReading *value ) +static HRESULT WINAPI gamepad_IGamepad_GetCurrentReading( IGamepad *iface, struct GamepadReading *value ) { - struct gamepad *impl = impl_from_IGamepad( iface ); + struct gamepad *impl = gamepad_from_IGamepad( iface ); struct WineGameControllerState state; HRESULT hr;
@@ -322,42 +219,16 @@ static HRESULT WINAPI gamepad_GetCurrentReading( IGamepad *iface, struct Gamepad return hr; }
-static const struct IGamepadVtbl gamepad_vtbl = -{ - gamepad_QueryInterface, - gamepad_AddRef, - gamepad_Release, - /* IInspectable methods */ - gamepad_GetIids, - gamepad_GetRuntimeClassName, - gamepad_GetTrustLevel, - /* IGamepad methods */ - gamepad_get_Vibration, - gamepad_put_Vibration, - gamepad_GetCurrentReading, -}; - -DEFINE_IINSPECTABLE_OUTER( gamepad2, IGamepad2, gamepad, IGameController_outer ) +INTERFACE_VTBL_IGamepad( gamepad_IGamepad );
-static HRESULT WINAPI gamepad2_GetButtonLabel( IGamepad2 *iface, GamepadButtons button, GameControllerButtonLabel *value ) +static HRESULT WINAPI gamepad_IGamepad2_GetButtonLabel( IGamepad2 *iface, GamepadButtons button, GameControllerButtonLabel *value ) { FIXME( "iface %p, button %#x, value %p stub!\n", iface, button, value ); *value = GameControllerButtonLabel_None; return S_OK; }
-static const struct IGamepad2Vtbl gamepad2_vtbl = -{ - gamepad2_QueryInterface, - gamepad2_AddRef, - gamepad2_Release, - /* IInspectable methods */ - gamepad2_GetIids, - gamepad2_GetRuntimeClassName, - gamepad2_GetTrustLevel, - /* IGamepad2 methods */ - gamepad2_GetButtonLabel, -}; +INTERFACE_VTBL_IGamepad2( gamepad_IGamepad2 );
struct gamepad_statics { @@ -366,113 +237,21 @@ struct gamepad_statics IGamepadStatics2 IGamepadStatics2_iface; ICustomGameControllerFactory ICustomGameControllerFactory_iface; IAgileObject IAgileObject_iface; - LONG ref; + const WCHAR *class_name; };
-static inline struct gamepad_statics *impl_from_IActivationFactory( IActivationFactory *iface ) -{ - return CONTAINING_RECORD( iface, struct gamepad_statics, IActivationFactory_iface ); -} +INTERFACE_IMPL_STATIC_IActivationFactory( gamepad_statics, IGamepadStatics, IGamepadStatics2, + ICustomGameControllerFactory, IAgileObject, END );
-static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) -{ - struct gamepad_statics *impl = impl_from_IActivationFactory( iface ); - - TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out ); - - if (IsEqualGUID( iid, &IID_IUnknown ) || - IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IActivationFactory )) - { - IInspectable_AddRef( (*out = &impl->IActivationFactory_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IGamepadStatics )) - { - IInspectable_AddRef( (*out = &impl->IGamepadStatics_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IGamepadStatics2 )) - { - IInspectable_AddRef( (*out = &impl->IGamepadStatics2_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_ICustomGameControllerFactory )) - { - IInspectable_AddRef( (*out = &impl->ICustomGameControllerFactory_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IAgileObject )) - { - IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); - return S_OK; - } - - FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); - *out = NULL; - return E_NOINTERFACE; -} - -static ULONG WINAPI factory_AddRef( IActivationFactory *iface ) -{ - struct gamepad_statics *impl = impl_from_IActivationFactory( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI factory_Release( IActivationFactory *iface ) -{ - struct gamepad_statics *impl = impl_from_IActivationFactory( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static HRESULT WINAPI factory_GetIids( IActivationFactory *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} - -static HRESULT WINAPI factory_GetRuntimeClassName( IActivationFactory *iface, HSTRING *class_name ) -{ - FIXME( "iface %p, class_name %p stub!\n", iface, class_name ); - return E_NOTIMPL; -} - -static HRESULT WINAPI factory_GetTrustLevel( IActivationFactory *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} - -static HRESULT WINAPI factory_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) +static HRESULT WINAPI gamepad_statics_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) { FIXME( "iface %p, instance %p stub!\n", iface, instance ); return E_NOTIMPL; }
-static const struct IActivationFactoryVtbl factory_vtbl = -{ - factory_QueryInterface, - factory_AddRef, - factory_Release, - /* IInspectable methods */ - factory_GetIids, - factory_GetRuntimeClassName, - factory_GetTrustLevel, - /* IActivationFactory methods */ - factory_ActivateInstance, -}; - -DEFINE_IINSPECTABLE( statics, IGamepadStatics, gamepad_statics, IActivationFactory_iface ) +INTERFACE_VTBL_IActivationFactory( gamepad_statics );
-static HRESULT WINAPI statics_add_GamepadAdded( IGamepadStatics *iface, IEventHandler_Gamepad *handler, +static HRESULT WINAPI gamepad_statics_IGamepadStatics_add_GamepadAdded( IGamepadStatics *iface, IEventHandler_Gamepad *handler, EventRegistrationToken *token ) { TRACE( "iface %p, handler %p, token %p.\n", iface, handler, token ); @@ -480,13 +259,13 @@ static HRESULT WINAPI statics_add_GamepadAdded( IGamepadStatics *iface, IEventHa return event_handlers_append( &gamepad_added_handlers, (IEventHandler_IInspectable *)handler, token ); }
-static HRESULT WINAPI statics_remove_GamepadAdded( IGamepadStatics *iface, EventRegistrationToken token ) +static HRESULT WINAPI gamepad_statics_IGamepadStatics_remove_GamepadAdded( IGamepadStatics *iface, EventRegistrationToken token ) { TRACE( "iface %p, token %#I64x.\n", iface, token.value ); return event_handlers_remove( &gamepad_added_handlers, &token ); }
-static HRESULT WINAPI statics_add_GamepadRemoved( IGamepadStatics *iface, IEventHandler_Gamepad *handler, +static HRESULT WINAPI gamepad_statics_IGamepadStatics_add_GamepadRemoved( IGamepadStatics *iface, IEventHandler_Gamepad *handler, EventRegistrationToken *token ) { TRACE( "iface %p, handler %p, token %p.\n", iface, handler, token ); @@ -494,13 +273,13 @@ static HRESULT WINAPI statics_add_GamepadRemoved( IGamepadStatics *iface, IEvent return event_handlers_append( &gamepad_removed_handlers, (IEventHandler_IInspectable *)handler, token ); }
-static HRESULT WINAPI statics_remove_GamepadRemoved( IGamepadStatics *iface, EventRegistrationToken token ) +static HRESULT WINAPI gamepad_statics_IGamepadStatics_remove_GamepadRemoved( IGamepadStatics *iface, EventRegistrationToken token ) { TRACE( "iface %p, token %#I64x.\n", iface, token.value ); return event_handlers_remove( &gamepad_removed_handlers, &token ); }
-static HRESULT WINAPI statics_get_Gamepads( IGamepadStatics *iface, IVectorView_Gamepad **value ) +static HRESULT WINAPI gamepad_statics_IGamepadStatics_get_Gamepads( IGamepadStatics *iface, IVectorView_Gamepad **value ) { HRESULT hr;
@@ -514,28 +293,11 @@ static HRESULT WINAPI statics_get_Gamepads( IGamepadStatics *iface, IVectorView_ return hr; }
-static const struct IGamepadStaticsVtbl statics_vtbl = -{ - statics_QueryInterface, - statics_AddRef, - statics_Release, - /* IInspectable methods */ - statics_GetIids, - statics_GetRuntimeClassName, - statics_GetTrustLevel, - /* IGamepadStatics methods */ - statics_add_GamepadAdded, - statics_remove_GamepadAdded, - statics_add_GamepadRemoved, - statics_remove_GamepadRemoved, - statics_get_Gamepads, -}; - -DEFINE_IINSPECTABLE( statics2, IGamepadStatics2, gamepad_statics, IActivationFactory_iface ) +INTERFACE_VTBL_IGamepadStatics( gamepad_statics_IGamepadStatics );
-static HRESULT WINAPI statics2_FromGameController( IGamepadStatics2 *iface, IGameController *game_controller, IGamepad **value ) +static HRESULT WINAPI gamepad_statics_IGamepadStatics2_FromGameController( IGamepadStatics2 *iface, IGameController *game_controller, IGamepad **value ) { - struct gamepad_statics *impl = impl_from_IGamepadStatics2( iface ); + struct gamepad_statics *impl = gamepad_statics_from_IGamepadStatics2( iface ); IGameController *controller; HRESULT hr;
@@ -551,22 +313,9 @@ static HRESULT WINAPI statics2_FromGameController( IGamepadStatics2 *iface, IGam return hr; }
-static const struct IGamepadStatics2Vtbl statics2_vtbl = -{ - statics2_QueryInterface, - statics2_AddRef, - statics2_Release, - /* IInspectable methods */ - statics2_GetIids, - statics2_GetRuntimeClassName, - statics2_GetTrustLevel, - /* IGamepadStatics2 methods */ - statics2_FromGameController, -}; - -DEFINE_IINSPECTABLE( controller_factory, ICustomGameControllerFactory, gamepad_statics, IActivationFactory_iface ) +INTERFACE_VTBL_IGamepadStatics2( gamepad_statics_IGamepadStatics2 );
-static HRESULT WINAPI controller_factory_CreateGameController( ICustomGameControllerFactory *iface, IGameControllerProvider *provider, +static HRESULT WINAPI gamepad_statics_ICustomGameControllerFactory_CreateGameController( ICustomGameControllerFactory *iface, IGameControllerProvider *provider, IInspectable **value ) { struct gamepad *impl; @@ -574,11 +323,12 @@ static HRESULT WINAPI controller_factory_CreateGameController( ICustomGameContro TRACE( "iface %p, provider %p, value %p.\n", iface, provider, value );
if (!(impl = calloc( 1, sizeof(*impl) ))) return E_OUTOFMEMORY; - impl->IGameControllerImpl_iface.lpVtbl = &controller_vtbl; - impl->IGameControllerInputSink_iface.lpVtbl = &input_sink_vtbl; - impl->IGamepad_iface.lpVtbl = &gamepad_vtbl; - impl->IGamepad2_iface.lpVtbl = &gamepad2_vtbl; - impl->ref = 1; + impl->IGameControllerImpl_iface.lpVtbl = &gamepad_vtbl; + impl->IGameControllerInputSink_iface.lpVtbl = &gamepad_IGameControllerInputSink_vtbl; + impl->IGamepad_iface.lpVtbl = &gamepad_IGamepad_vtbl; + impl->IGamepad2_iface.lpVtbl = &gamepad_IGamepad2_vtbl; + impl->class_name = RuntimeClass_Windows_Gaming_Input_Gamepad; + impl->refcount = 1;
TRACE( "created Gamepad %p\n", impl );
@@ -586,7 +336,7 @@ static HRESULT WINAPI controller_factory_CreateGameController( ICustomGameContro return S_OK; }
-static HRESULT WINAPI controller_factory_OnGameControllerAdded( ICustomGameControllerFactory *iface, IGameController *value ) +static HRESULT WINAPI gamepad_statics_ICustomGameControllerFactory_OnGameControllerAdded( ICustomGameControllerFactory *iface, IGameController *value ) { IGamepad *gamepad; HRESULT hr; @@ -601,7 +351,7 @@ static HRESULT WINAPI controller_factory_OnGameControllerAdded( ICustomGameContr return S_OK; }
-static HRESULT WINAPI controller_factory_OnGameControllerRemoved( ICustomGameControllerFactory *iface, IGameController *value ) +static HRESULT WINAPI gamepad_statics_ICustomGameControllerFactory_OnGameControllerRemoved( ICustomGameControllerFactory *iface, IGameController *value ) { IGamepad *gamepad; BOOLEAN found; @@ -635,31 +385,17 @@ static HRESULT WINAPI controller_factory_OnGameControllerRemoved( ICustomGameCon return S_OK; }
-static const struct ICustomGameControllerFactoryVtbl controller_factory_vtbl = -{ - controller_factory_QueryInterface, - controller_factory_AddRef, - controller_factory_Release, - /* IInspectable methods */ - controller_factory_GetIids, - controller_factory_GetRuntimeClassName, - controller_factory_GetTrustLevel, - /* ICustomGameControllerFactory methods */ - controller_factory_CreateGameController, - controller_factory_OnGameControllerAdded, - controller_factory_OnGameControllerRemoved, -}; - -DEFINE_IAGILEOBJECT( gamepad_statics, IActivationFactory, &object->IActivationFactory_iface ); +INTERFACE_VTBL_ICustomGameControllerFactory( gamepad_statics_ICustomGameControllerFactory ); +INTERFACE_VTBL_IAgileObject( gamepad_statics_IAgileObject );
static struct gamepad_statics gamepad_statics = { - {&factory_vtbl}, - {&statics_vtbl}, - {&statics2_vtbl}, - {&controller_factory_vtbl}, + {&gamepad_statics_vtbl}, + {&gamepad_statics_IGamepadStatics_vtbl}, + {&gamepad_statics_IGamepadStatics2_vtbl}, + {&gamepad_statics_ICustomGameControllerFactory_vtbl}, {&gamepad_statics_IAgileObject_vtbl}, - 1, + RuntimeClass_Windows_Gaming_Input_Gamepad, };
ICustomGameControllerFactory *gamepad_factory = &gamepad_statics.ICustomGameControllerFactory_iface; diff --git a/dlls/windows.gaming.input/manager.c b/dlls/windows.gaming.input/manager.c index 3c6334bc0eb..1a3640a2b0f 100644 --- a/dlls/windows.gaming.input/manager.c +++ b/dlls/windows.gaming.input/manager.c @@ -41,75 +41,38 @@ struct controller IGameControllerBatteryInfo IGameControllerBatteryInfo_iface; IAgileObject IAgileObject_iface; IInspectable *IInspectable_inner; - LONG ref; + const WCHAR *class_name; + LONG refcount;
struct list entry; IGameControllerProvider *provider; ICustomGameControllerFactory *factory; };
-static inline struct controller *impl_from_IGameController( IGameController *iface ) -{ - return CONTAINING_RECORD( iface, struct controller, IGameController_iface ); -} +INTERFACE_IMPL_FROM( controller, IGameController );
static HRESULT WINAPI controller_QueryInterface( IGameController *iface, REFIID iid, void **out ) { - struct controller *impl = impl_from_IGameController( iface ); - + struct controller *impl = controller_from_IGameController( iface ); TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out ); - - if (IsEqualGUID( iid, &IID_IUnknown ) || - IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IGameController )) - { - IInspectable_AddRef( (*out = &impl->IGameController_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IGameControllerBatteryInfo )) - { - IInspectable_AddRef( (*out = &impl->IGameControllerBatteryInfo_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IAgileObject )) - { - IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); - return S_OK; - } - + QUERY_INTERFACE_IGameController( impl, iid, out, IGameController_iface ) + QUERY_INTERFACE_IGameControllerBatteryInfo( impl, iid, out, IGameControllerBatteryInfo_iface ) + QUERY_INTERFACE_IAgileObject( impl, iid, out, IAgileObject_iface ) return IInspectable_QueryInterface( impl->IInspectable_inner, iid, out ); }
-static ULONG WINAPI controller_AddRef( IGameController *iface ) -{ - struct controller *impl = impl_from_IGameController( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} +IUNKNOWN_IMPL_ADDREF( controller, IGameController );
-static ULONG WINAPI controller_Release( IGameController *iface ) +static void controller_destroy( struct controller *impl ) { - struct controller *impl = impl_from_IGameController( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - - if (!ref) - { - /* guard against re-entry if inner releases an outer iface */ - InterlockedIncrement( &impl->ref ); - IInspectable_Release( impl->IInspectable_inner ); - ICustomGameControllerFactory_Release( impl->factory ); - IGameControllerProvider_Release( impl->provider ); - free( impl ); - } - - return ref; + IInspectable_Release( impl->IInspectable_inner ); + ICustomGameControllerFactory_Release( impl->factory ); + IGameControllerProvider_Release( impl->provider ); + free( impl ); }
+IUNKNOWN_IMPL_RELEASE( controller, IGameController ); + static HRESULT WINAPI controller_GetIids( IGameController *iface, ULONG *iid_count, IID **iids ) { FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); @@ -118,13 +81,13 @@ static HRESULT WINAPI controller_GetIids( IGameController *iface, ULONG *iid_cou
static HRESULT WINAPI controller_GetRuntimeClassName( IGameController *iface, HSTRING *class_name ) { - struct controller *impl = impl_from_IGameController( iface ); + struct controller *impl = controller_from_IGameController( iface ); return IInspectable_GetRuntimeClassName( impl->IInspectable_inner, class_name ); }
static HRESULT WINAPI controller_GetTrustLevel( IGameController *iface, TrustLevel *trust_level ) { - struct controller *impl = impl_from_IGameController( iface ); + struct controller *impl = controller_from_IGameController( iface ); return IInspectable_GetTrustLevel( impl->IInspectable_inner, trust_level ); }
@@ -186,49 +149,20 @@ static HRESULT WINAPI controller_get_User( IGameController *iface, __x_ABI_CWind return E_NOTIMPL; }
-static const struct IGameControllerVtbl controller_vtbl = -{ - controller_QueryInterface, - controller_AddRef, - controller_Release, - /* IInspectable methods */ - controller_GetIids, - controller_GetRuntimeClassName, - controller_GetTrustLevel, - /* IGameController methods */ - controller_add_HeadsetConnected, - controller_remove_HeadsetConnected, - controller_add_HeadsetDisconnected, - controller_remove_HeadsetDisconnected, - controller_add_UserChanged, - controller_remove_UserChanged, - controller_get_Headset, - controller_get_IsWireless, - controller_get_User, -}; +INTERFACE_VTBL_IGameController( controller );
-DEFINE_IINSPECTABLE( battery, IGameControllerBatteryInfo, controller, IGameController_iface ) +INTERFACE_FWD_IGameControllerBatteryInfo( controller, IGameController, &object->IGameController_iface );
-static HRESULT WINAPI battery_TryGetBatteryReport( IGameControllerBatteryInfo *iface, IBatteryReport **value ) +static HRESULT WINAPI controller_IGameControllerBatteryInfo_TryGetBatteryReport( IGameControllerBatteryInfo *iface, IBatteryReport **value ) { FIXME( "iface %p, value %p stub!\n", iface, value ); return E_NOTIMPL; }
-static const struct IGameControllerBatteryInfoVtbl battery_vtbl = -{ - battery_QueryInterface, - battery_AddRef, - battery_Release, - /* IInspectable methods */ - battery_GetIids, - battery_GetRuntimeClassName, - battery_GetTrustLevel, - /* IGameControllerBatteryInfo methods */ - battery_TryGetBatteryReport, -}; +INTERFACE_VTBL_IGameControllerBatteryInfo( controller_IGameControllerBatteryInfo );
-DEFINE_IAGILEOBJECT( controller, IGameController, &object->IGameController_iface ); +INTERFACE_FWD_IAgileObject( controller, IGameController, &object->IGameController_iface ); +INTERFACE_VTBL_IAgileObject( controller_IAgileObject );
struct manager_statics { @@ -236,108 +170,22 @@ struct manager_statics IGameControllerFactoryManagerStatics IGameControllerFactoryManagerStatics_iface; IGameControllerFactoryManagerStatics2 IGameControllerFactoryManagerStatics2_iface; IAgileObject IAgileObject_iface; - LONG ref; + const WCHAR *class_name; };
-static inline struct manager_statics *impl_from_IActivationFactory( IActivationFactory *iface ) -{ - return CONTAINING_RECORD( iface, struct manager_statics, IActivationFactory_iface ); -} - -static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) -{ - struct manager_statics *impl = impl_from_IActivationFactory( iface ); - - TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out ); - - if (IsEqualGUID( iid, &IID_IUnknown ) || - IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IActivationFactory )) - { - IInspectable_AddRef( (*out = &impl->IActivationFactory_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IGameControllerFactoryManagerStatics )) - { - IInspectable_AddRef( (*out = &impl->IGameControllerFactoryManagerStatics_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IGameControllerFactoryManagerStatics2 )) - { - IInspectable_AddRef( (*out = &impl->IGameControllerFactoryManagerStatics2_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IAgileObject )) - { - IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); - return S_OK; - } +INTERFACE_IMPL_STATIC_IActivationFactory( manager_statics, IGameControllerFactoryManagerStatics, + IGameControllerFactoryManagerStatics2, IAgileObject, END )
- FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); - *out = NULL; - return E_NOINTERFACE; -} - -static ULONG WINAPI factory_AddRef( IActivationFactory *iface ) -{ - struct manager_statics *impl = impl_from_IActivationFactory( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI factory_Release( IActivationFactory *iface ) -{ - struct manager_statics *impl = impl_from_IActivationFactory( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static HRESULT WINAPI factory_GetIids( IActivationFactory *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} - -static HRESULT WINAPI factory_GetRuntimeClassName( IActivationFactory *iface, HSTRING *class_name ) -{ - FIXME( "iface %p, class_name %p stub!\n", iface, class_name ); - return E_NOTIMPL; -} - -static HRESULT WINAPI factory_GetTrustLevel( IActivationFactory *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} - -static HRESULT WINAPI factory_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) +static HRESULT WINAPI manager_statics_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) { FIXME( "iface %p, instance %p stub!\n", iface, instance ); return E_NOTIMPL; }
-static const struct IActivationFactoryVtbl factory_vtbl = -{ - factory_QueryInterface, - factory_AddRef, - factory_Release, - /* IInspectable methods */ - factory_GetIids, - factory_GetRuntimeClassName, - factory_GetTrustLevel, - /* IActivationFactory methods */ - factory_ActivateInstance, -}; - -DEFINE_IINSPECTABLE( statics, IGameControllerFactoryManagerStatics, manager_statics, IActivationFactory_iface ) +INTERFACE_VTBL_IActivationFactory( manager_statics );
static HRESULT WINAPI -statics_RegisterCustomFactoryForGipInterface( IGameControllerFactoryManagerStatics *iface, +manager_statics_IGameControllerFactoryManagerStatics_RegisterCustomFactoryForGipInterface( IGameControllerFactoryManagerStatics *iface, ICustomGameControllerFactory *factory, GUID interface_id ) { @@ -346,7 +194,7 @@ statics_RegisterCustomFactoryForGipInterface( IGameControllerFactoryManagerStati }
static HRESULT WINAPI -statics_RegisterCustomFactoryForHardwareId( IGameControllerFactoryManagerStatics *iface, +manager_statics_IGameControllerFactoryManagerStatics_RegisterCustomFactoryForHardwareId( IGameControllerFactoryManagerStatics *iface, ICustomGameControllerFactory *factory, UINT16 vendor_id, UINT16 product_id ) { @@ -355,7 +203,7 @@ statics_RegisterCustomFactoryForHardwareId( IGameControllerFactoryManagerStatics }
static HRESULT WINAPI -statics_RegisterCustomFactoryForXusbType( IGameControllerFactoryManagerStatics *iface, +manager_statics_IGameControllerFactoryManagerStatics_RegisterCustomFactoryForXusbType( IGameControllerFactoryManagerStatics *iface, ICustomGameControllerFactory *factory, XusbDeviceType type, XusbDeviceSubtype subtype ) { @@ -363,25 +211,10 @@ statics_RegisterCustomFactoryForXusbType( IGameControllerFactoryManagerStatics * return E_NOTIMPL; }
-static const struct IGameControllerFactoryManagerStaticsVtbl statics_vtbl = -{ - statics_QueryInterface, - statics_AddRef, - statics_Release, - /* IInspectable methods */ - statics_GetIids, - statics_GetRuntimeClassName, - statics_GetTrustLevel, - /* IGameControllerFactoryManagerStatics methods */ - statics_RegisterCustomFactoryForGipInterface, - statics_RegisterCustomFactoryForHardwareId, - statics_RegisterCustomFactoryForXusbType, -}; - -DEFINE_IINSPECTABLE( statics2, IGameControllerFactoryManagerStatics2, manager_statics, IActivationFactory_iface ) +INTERFACE_VTBL_IGameControllerFactoryManagerStatics( manager_statics_IGameControllerFactoryManagerStatics );
static HRESULT WINAPI -statics2_TryGetFactoryControllerFromGameController( IGameControllerFactoryManagerStatics2 *iface, +manager_statics_IGameControllerFactoryManagerStatics2_TryGetFactoryControllerFromGameController( IGameControllerFactoryManagerStatics2 *iface, ICustomGameControllerFactory *factory, IGameController *controller, IGameController **value ) { @@ -417,28 +250,16 @@ done: return S_OK; }
-static const struct IGameControllerFactoryManagerStatics2Vtbl statics2_vtbl = -{ - statics2_QueryInterface, - statics2_AddRef, - statics2_Release, - /* IInspectable methods */ - statics2_GetIids, - statics2_GetRuntimeClassName, - statics2_GetTrustLevel, - /* IGameControllerFactoryManagerStatics2 methods */ - statics2_TryGetFactoryControllerFromGameController, -}; - -DEFINE_IAGILEOBJECT( manager_statics, IActivationFactory, &object->IActivationFactory_iface ); +INTERFACE_VTBL_IGameControllerFactoryManagerStatics2( manager_statics_IGameControllerFactoryManagerStatics2 ); +INTERFACE_VTBL_IAgileObject( manager_statics_IAgileObject );
static struct manager_statics manager_statics = { - {&factory_vtbl}, - {&statics_vtbl}, - {&statics2_vtbl}, + {&manager_statics_vtbl}, + {&manager_statics_IGameControllerFactoryManagerStatics_vtbl}, + {&manager_statics_IGameControllerFactoryManagerStatics2_vtbl}, {&manager_statics_IAgileObject_vtbl}, - 1, + RuntimeClass_Windows_Gaming_Input_Custom_GameControllerFactoryManager, };
IGameControllerFactoryManagerStatics2 *manager_factory = &manager_statics.IGameControllerFactoryManagerStatics2_iface; @@ -452,9 +273,9 @@ static HRESULT controller_create( ICustomGameControllerFactory *factory, IGameCo
if (!(impl = malloc(sizeof(*impl)))) return E_OUTOFMEMORY; impl->IGameController_iface.lpVtbl = &controller_vtbl; - impl->IGameControllerBatteryInfo_iface.lpVtbl = &battery_vtbl; + impl->IGameControllerBatteryInfo_iface.lpVtbl = &controller_IGameControllerBatteryInfo_vtbl; impl->IAgileObject_iface.lpVtbl = &controller_IAgileObject_vtbl; - impl->ref = 1; + impl->refcount = 1;
if (FAILED(hr = ICustomGameControllerFactory_CreateGameController( factory, provider, &impl->IInspectable_inner ))) WARN( "Failed to create game controller, hr %#lx\n", hr ); diff --git a/dlls/windows.gaming.input/periodic_effect.c b/dlls/windows.gaming.input/periodic_effect.c index 335c9f903fc..c3a07e090a6 100644 --- a/dlls/windows.gaming.input/periodic_effect.c +++ b/dlls/windows.gaming.input/periodic_effect.c @@ -26,90 +26,45 @@ struct periodic_effect { IPeriodicForceEffect IPeriodicForceEffect_iface; IWineForceFeedbackEffectImpl *IWineForceFeedbackEffectImpl_inner; - LONG ref; + const WCHAR *class_name; + LONG refcount;
PeriodicForceEffectKind kind; };
-static inline struct periodic_effect *impl_from_IPeriodicForceEffect( IPeriodicForceEffect *iface ) -{ - return CONTAINING_RECORD( iface, struct periodic_effect, IPeriodicForceEffect_iface ); -} +INTERFACE_IMPL_FROM( periodic_effect, IPeriodicForceEffect );
-static HRESULT WINAPI effect_QueryInterface( IPeriodicForceEffect *iface, REFIID iid, void **out ) +static HRESULT WINAPI periodic_effect_QueryInterface( IPeriodicForceEffect *iface, REFIID iid, void **out ) { - struct periodic_effect *impl = impl_from_IPeriodicForceEffect( iface ); - + struct periodic_effect *impl = periodic_effect_from_IPeriodicForceEffect( iface ); TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out ); - - if (IsEqualGUID( iid, &IID_IUnknown ) || - IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IPeriodicForceEffect )) - { - IInspectable_AddRef( (*out = &impl->IPeriodicForceEffect_iface) ); - return S_OK; - } - + QUERY_INTERFACE_IPeriodicForceEffect( impl, iid, out, IPeriodicForceEffect_iface ) return IWineForceFeedbackEffectImpl_QueryInterface( impl->IWineForceFeedbackEffectImpl_inner, iid, out ); }
-static ULONG WINAPI effect_AddRef( IPeriodicForceEffect *iface ) -{ - struct periodic_effect *impl = impl_from_IPeriodicForceEffect( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI effect_Release( IPeriodicForceEffect *iface ) -{ - struct periodic_effect *impl = impl_from_IPeriodicForceEffect( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - - if (!ref) - { - /* guard against re-entry if inner releases an outer iface */ - InterlockedIncrement( &impl->ref ); - IWineForceFeedbackEffectImpl_Release( impl->IWineForceFeedbackEffectImpl_inner ); - free( impl ); - } - - return ref; -} - -static HRESULT WINAPI effect_GetIids( IPeriodicForceEffect *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} +IUNKNOWN_IMPL_ADDREF( periodic_effect, IPeriodicForceEffect );
-static HRESULT WINAPI effect_GetRuntimeClassName( IPeriodicForceEffect *iface, HSTRING *class_name ) +static void periodic_effect_destroy( struct periodic_effect *impl ) { - return WindowsCreateString( RuntimeClass_Windows_Gaming_Input_ForceFeedback_PeriodicForceEffect, - ARRAY_SIZE(RuntimeClass_Windows_Gaming_Input_ForceFeedback_PeriodicForceEffect), - class_name ); + IWineForceFeedbackEffectImpl_Release( impl->IWineForceFeedbackEffectImpl_inner ); + free( impl ); }
-static HRESULT WINAPI effect_GetTrustLevel( IPeriodicForceEffect *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} +IUNKNOWN_IMPL_RELEASE( periodic_effect, IPeriodicForceEffect ); +IINSPECTABLE_IMPL( periodic_effect, IPeriodicForceEffect );
-static HRESULT WINAPI effect_get_Kind( IPeriodicForceEffect *iface, PeriodicForceEffectKind *kind ) +static HRESULT WINAPI periodic_effect_get_Kind( IPeriodicForceEffect *iface, PeriodicForceEffectKind *kind ) { - struct periodic_effect *impl = impl_from_IPeriodicForceEffect( iface ); + struct periodic_effect *impl = periodic_effect_from_IPeriodicForceEffect( iface ); TRACE( "iface %p, kind %p.\n", iface, kind ); *kind = impl->kind; return S_OK; }
-static HRESULT WINAPI effect_SetParameters( IPeriodicForceEffect *iface, Vector3 direction, FLOAT frequency, FLOAT phase, +static HRESULT WINAPI periodic_effect_SetParameters( IPeriodicForceEffect *iface, Vector3 direction, FLOAT frequency, FLOAT phase, FLOAT bias, TimeSpan duration ) { - struct periodic_effect *impl = impl_from_IPeriodicForceEffect( iface ); + struct periodic_effect *impl = periodic_effect_from_IPeriodicForceEffect( iface ); WineForceFeedbackEffectParameters params = { .periodic = @@ -131,12 +86,12 @@ static HRESULT WINAPI effect_SetParameters( IPeriodicForceEffect *iface, Vector3 return IWineForceFeedbackEffectImpl_put_Parameters( impl->IWineForceFeedbackEffectImpl_inner, params, NULL ); }
-static HRESULT WINAPI effect_SetParametersWithEnvelope( IPeriodicForceEffect *iface, Vector3 direction, FLOAT frequency, FLOAT phase, FLOAT bias, +static HRESULT WINAPI periodic_effect_SetParametersWithEnvelope( IPeriodicForceEffect *iface, Vector3 direction, FLOAT frequency, FLOAT phase, FLOAT bias, FLOAT attack_gain, FLOAT sustain_gain, FLOAT release_gain, TimeSpan start_delay, TimeSpan attack_duration, TimeSpan sustain_duration, TimeSpan release_duration, UINT32 repeat_count ) { - struct periodic_effect *impl = impl_from_IPeriodicForceEffect( iface ); + struct periodic_effect *impl = periodic_effect_from_IPeriodicForceEffect( iface ); WineForceFeedbackEffectParameters params = { .periodic = @@ -168,121 +123,27 @@ static HRESULT WINAPI effect_SetParametersWithEnvelope( IPeriodicForceEffect *if return IWineForceFeedbackEffectImpl_put_Parameters( impl->IWineForceFeedbackEffectImpl_inner, params, &envelope ); }
-static const struct IPeriodicForceEffectVtbl effect_vtbl = -{ - effect_QueryInterface, - effect_AddRef, - effect_Release, - /* IInspectable methods */ - effect_GetIids, - effect_GetRuntimeClassName, - effect_GetTrustLevel, - /* IPeriodicForceEffect methods */ - effect_get_Kind, - effect_SetParameters, - effect_SetParametersWithEnvelope, -}; +INTERFACE_VTBL_IPeriodicForceEffect( periodic_effect );
struct periodic_factory { IActivationFactory IActivationFactory_iface; IPeriodicForceEffectFactory IPeriodicForceEffectFactory_iface; IAgileObject IAgileObject_iface; - LONG ref; + const WCHAR *class_name; };
-static inline struct periodic_factory *impl_from_IActivationFactory( IActivationFactory *iface ) -{ - return CONTAINING_RECORD( iface, struct periodic_factory, IActivationFactory_iface ); -} - -static HRESULT WINAPI activation_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) -{ - struct periodic_factory *impl = impl_from_IActivationFactory( iface ); - - TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out ); - - if (IsEqualGUID( iid, &IID_IUnknown ) || - IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IActivationFactory )) - { - IInspectable_AddRef( (*out = &impl->IActivationFactory_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IPeriodicForceEffectFactory )) - { - IInspectable_AddRef( (*out = &impl->IPeriodicForceEffectFactory_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IAgileObject )) - { - IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); - return S_OK; - } - - FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); - *out = NULL; - return E_NOINTERFACE; -} - -static ULONG WINAPI activation_AddRef( IActivationFactory *iface ) -{ - struct periodic_factory *impl = impl_from_IActivationFactory( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI activation_Release( IActivationFactory *iface ) -{ - struct periodic_factory *impl = impl_from_IActivationFactory( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static HRESULT WINAPI activation_GetIids( IActivationFactory *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} +INTERFACE_IMPL_STATIC_IActivationFactory( periodic_factory, IPeriodicForceEffectFactory, IAgileObject, END )
-static HRESULT WINAPI activation_GetRuntimeClassName( IActivationFactory *iface, HSTRING *class_name ) -{ - FIXME( "iface %p, class_name %p stub!\n", iface, class_name ); - return E_NOTIMPL; -} - -static HRESULT WINAPI activation_GetTrustLevel( IActivationFactory *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} - -static HRESULT WINAPI activation_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) +static HRESULT WINAPI periodic_factory_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) { FIXME( "iface %p, instance %p stub!\n", iface, instance ); return E_NOTIMPL; }
-static const struct IActivationFactoryVtbl activation_vtbl = -{ - activation_QueryInterface, - activation_AddRef, - activation_Release, - /* IInspectable methods */ - activation_GetIids, - activation_GetRuntimeClassName, - activation_GetTrustLevel, - /* IActivationFactory methods */ - activation_ActivateInstance, -}; - -DEFINE_IINSPECTABLE( factory, IPeriodicForceEffectFactory, periodic_factory, IActivationFactory_iface ) +INTERFACE_VTBL_IActivationFactory( periodic_factory );
-static HRESULT WINAPI factory_CreateInstance( IPeriodicForceEffectFactory *iface, enum PeriodicForceEffectKind kind, IForceFeedbackEffect **out ) +static HRESULT WINAPI periodic_factory_IPeriodicForceEffectFactory_CreateInstance( IPeriodicForceEffectFactory *iface, enum PeriodicForceEffectKind kind, IForceFeedbackEffect **out ) { enum WineForceFeedbackEffectType type = WineForceFeedbackEffectType_Periodic + kind; struct periodic_effect *impl; @@ -291,8 +152,9 @@ static HRESULT WINAPI factory_CreateInstance( IPeriodicForceEffectFactory *iface TRACE( "iface %p, kind %u, out %p.\n", iface, kind, out );
if (!(impl = calloc( 1, sizeof(struct periodic_effect) ))) return E_OUTOFMEMORY; - impl->IPeriodicForceEffect_iface.lpVtbl = &effect_vtbl; - impl->ref = 1; + impl->IPeriodicForceEffect_iface.lpVtbl = &periodic_effect_vtbl; + impl->class_name = RuntimeClass_Windows_Gaming_Input_ForceFeedback_PeriodicForceEffect; + impl->refcount = 1; impl->kind = kind;
if (FAILED(hr = force_feedback_effect_create( type, (IInspectable *)&impl->IPeriodicForceEffect_iface, &impl->IWineForceFeedbackEffectImpl_inner )) || @@ -308,27 +170,15 @@ static HRESULT WINAPI factory_CreateInstance( IPeriodicForceEffectFactory *iface return S_OK; }
-static const struct IPeriodicForceEffectFactoryVtbl factory_vtbl = -{ - factory_QueryInterface, - factory_AddRef, - factory_Release, - /* IInspectable methods */ - factory_GetIids, - factory_GetRuntimeClassName, - factory_GetTrustLevel, - /* IPeriodicForceEffectFactory methods */ - factory_CreateInstance, -}; - -DEFINE_IAGILEOBJECT( periodic_factory, IActivationFactory, &object->IActivationFactory_iface ); +INTERFACE_VTBL_IPeriodicForceEffectFactory( periodic_factory_IPeriodicForceEffectFactory ); +INTERFACE_VTBL_IAgileObject( periodic_factory_IAgileObject );
static struct periodic_factory periodic_statics = { - {&activation_vtbl}, - {&factory_vtbl}, + {&periodic_factory_vtbl}, + {&periodic_factory_IPeriodicForceEffectFactory_vtbl}, {&periodic_factory_IAgileObject_vtbl}, - 1, + RuntimeClass_Windows_Gaming_Input_ForceFeedback_PeriodicForceEffect, };
IInspectable *periodic_effect_factory = (IInspectable *)&periodic_statics.IActivationFactory_iface; diff --git a/dlls/windows.gaming.input/private.h b/dlls/windows.gaming.input/private.h index 07650e52fad..90907553aeb 100644 --- a/dlls/windows.gaming.input/private.h +++ b/dlls/windows.gaming.input/private.h @@ -83,20 +83,6 @@ extern HRESULT async_operation_boolean_create( IUnknown *invoker, IUnknown *para extern HRESULT async_operation_effect_result_create( IUnknown *invoker, IUnknown *param, async_operation_callback callback, IAsyncOperation_ForceFeedbackLoadEffectResult **out );
-#define DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from, iface_mem, expr ) \ - INTERFACE_IMPL_FROM_( impl_type, iface_type, impl_from, iface_mem ) \ - IUNKNOWN_FWD_( impl_type, iface_type, IInspectable, expr, impl_from, pfx ) \ - IINSPECTABLE_FWD_( impl_type, iface_type, IInspectable, expr, impl_from, pfx ) -#define DEFINE_IINSPECTABLE( pfx, iface_type, impl_type, base_iface ) \ - DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from_##iface_type, iface_type##_iface, (IInspectable *)&object->base_iface ) -#define DEFINE_IINSPECTABLE_OUTER( pfx, iface_type, impl_type, outer_iface ) \ - DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from_##iface_type, iface_type##_iface, (IInspectable *)object->outer_iface ) - -#define DEFINE_IAGILEOBJECT( type, base, expr ) \ - INTERFACE_IMPL_FROM_( type, IAgileObject, type ## _from_IAgileObject, IAgileObject_iface ) \ - IUNKNOWN_FWD_( type, IAgileObject, base, expr, type ## _from_IAgileObject, type ## _IAgileObject ) \ - INTERFACE_VTBL_IAgileObject( type ## _IAgileObject ); - static inline const char *debugstr_vector3( const Vector3 *vector ) { if (!vector) return "(null)"; diff --git a/dlls/windows.gaming.input/provider.c b/dlls/windows.gaming.input/provider.c index 33f9471fae1..a7e49918513 100644 --- a/dlls/windows.gaming.input/provider.c +++ b/dlls/windows.gaming.input/provider.c @@ -47,7 +47,8 @@ struct provider IWineGameControllerProvider IWineGameControllerProvider_iface; IGameControllerProvider IGameControllerProvider_iface; IAgileObject IAgileObject_iface; - LONG ref; + const WCHAR *class_name; + LONG refcount;
IDirectInputDevice8W *dinput_device; WCHAR device_path[MAX_PATH]; @@ -66,86 +67,16 @@ struct provider HANDLE device; };
-static inline struct provider *impl_from_IWineGameControllerProvider( IWineGameControllerProvider *iface ) +static void provider_destroy( struct provider *impl ) { - return CONTAINING_RECORD( iface, struct provider, IWineGameControllerProvider_iface ); + IDirectInputDevice8_Release( impl->dinput_device ); + HidD_FreePreparsedData( impl->preparsed ); + CloseHandle( impl->device ); + free( impl->report_buf ); + free( impl ); }
-static HRESULT WINAPI wine_provider_QueryInterface( IWineGameControllerProvider *iface, REFIID iid, void **out ) -{ - struct provider *impl = impl_from_IWineGameControllerProvider( iface ); - - TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out ); - - if (IsEqualGUID( iid, &IID_IUnknown ) || - IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IWineGameControllerProvider )) - { - IInspectable_AddRef( (*out = &impl->IWineGameControllerProvider_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IGameControllerProvider )) - { - IInspectable_AddRef( (*out = &impl->IGameControllerProvider_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IAgileObject )) - { - IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); - return S_OK; - } - - FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); - *out = NULL; - return E_NOINTERFACE; -} - -static ULONG WINAPI wine_provider_AddRef( IWineGameControllerProvider *iface ) -{ - struct provider *impl = impl_from_IWineGameControllerProvider( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI wine_provider_Release( IWineGameControllerProvider *iface ) -{ - struct provider *impl = impl_from_IWineGameControllerProvider( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - - if (!ref) - { - IDirectInputDevice8_Release( impl->dinput_device ); - HidD_FreePreparsedData( impl->preparsed ); - CloseHandle( impl->device ); - free( impl->report_buf ); - free( impl ); - } - - return ref; -} - -static HRESULT WINAPI wine_provider_GetIids( IWineGameControllerProvider *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} - -static HRESULT WINAPI wine_provider_GetRuntimeClassName( IWineGameControllerProvider *iface, HSTRING *class_name ) -{ - FIXME( "iface %p, class_name %p stub!\n", iface, class_name ); - return E_NOTIMPL; -} - -static HRESULT WINAPI wine_provider_GetTrustLevel( IWineGameControllerProvider *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} +INTERFACE_IMPL_IWineGameControllerProvider( provider, IGameControllerProvider, IAgileObject, END );
static BOOL CALLBACK count_ffb_axes( const DIDEVICEOBJECTINSTANCEW *obj, void *args ) { @@ -154,9 +85,9 @@ static BOOL CALLBACK count_ffb_axes( const DIDEVICEOBJECTINSTANCEW *obj, void *a return DIENUM_CONTINUE; }
-static HRESULT WINAPI wine_provider_get_Type( IWineGameControllerProvider *iface, WineGameControllerType *value ) +static HRESULT WINAPI provider_get_Type( IWineGameControllerProvider *iface, WineGameControllerType *value ) { - struct provider *impl = impl_from_IWineGameControllerProvider( iface ); + struct provider *impl = provider_from_IWineGameControllerProvider( iface ); DIDEVICEINSTANCEW instance = {.dwSize = sizeof(DIDEVICEINSTANCEW)}; HRESULT hr;
@@ -181,9 +112,9 @@ static HRESULT WINAPI wine_provider_get_Type( IWineGameControllerProvider *iface return S_OK; }
-static HRESULT WINAPI wine_provider_get_AxisCount( IWineGameControllerProvider *iface, INT32 *value ) +static HRESULT WINAPI provider_get_AxisCount( IWineGameControllerProvider *iface, INT32 *value ) { - struct provider *impl = impl_from_IWineGameControllerProvider( iface ); + struct provider *impl = provider_from_IWineGameControllerProvider( iface ); DIDEVCAPS caps = {.dwSize = sizeof(DIDEVCAPS)}; HRESULT hr;
@@ -194,9 +125,9 @@ static HRESULT WINAPI wine_provider_get_AxisCount( IWineGameControllerProvider * return hr; }
-static HRESULT WINAPI wine_provider_get_ButtonCount( IWineGameControllerProvider *iface, INT32 *value ) +static HRESULT WINAPI provider_get_ButtonCount( IWineGameControllerProvider *iface, INT32 *value ) { - struct provider *impl = impl_from_IWineGameControllerProvider( iface ); + struct provider *impl = provider_from_IWineGameControllerProvider( iface ); DIDEVCAPS caps = {.dwSize = sizeof(DIDEVCAPS)}; HRESULT hr;
@@ -207,9 +138,9 @@ static HRESULT WINAPI wine_provider_get_ButtonCount( IWineGameControllerProvider return hr; }
-static HRESULT WINAPI wine_provider_get_SwitchCount( IWineGameControllerProvider *iface, INT32 *value ) +static HRESULT WINAPI provider_get_SwitchCount( IWineGameControllerProvider *iface, INT32 *value ) { - struct provider *impl = impl_from_IWineGameControllerProvider( iface ); + struct provider *impl = provider_from_IWineGameControllerProvider( iface ); DIDEVCAPS caps = {.dwSize = sizeof(DIDEVCAPS)}; HRESULT hr;
@@ -220,9 +151,9 @@ static HRESULT WINAPI wine_provider_get_SwitchCount( IWineGameControllerProvider return hr; }
-static HRESULT WINAPI wine_provider_get_State( IWineGameControllerProvider *iface, struct WineGameControllerState *out ) +static HRESULT WINAPI provider_get_State( IWineGameControllerProvider *iface, struct WineGameControllerState *out ) { - struct provider *impl = impl_from_IWineGameControllerProvider( iface ); + struct provider *impl = provider_from_IWineGameControllerProvider( iface ); DIJOYSTATE2 state = {0}; UINT32 i = 0; HRESULT hr; @@ -283,17 +214,17 @@ static HRESULT WINAPI wine_provider_get_State( IWineGameControllerProvider *ifac return S_OK; }
-static HRESULT WINAPI wine_provider_get_Vibration( IWineGameControllerProvider *iface, struct WineGameControllerVibration *out ) +static HRESULT WINAPI provider_get_Vibration( IWineGameControllerProvider *iface, struct WineGameControllerVibration *out ) { - struct provider *impl = impl_from_IWineGameControllerProvider( iface ); + struct provider *impl = provider_from_IWineGameControllerProvider( iface ); TRACE( "iface %p, out %p.\n", iface, out ); *out = impl->vibration; return S_OK; }
-static HRESULT WINAPI wine_provider_put_Vibration( IWineGameControllerProvider *iface, struct WineGameControllerVibration value ) +static HRESULT WINAPI provider_put_Vibration( IWineGameControllerProvider *iface, struct WineGameControllerVibration value ) { - struct provider *impl = impl_from_IWineGameControllerProvider( iface ); + struct provider *impl = provider_from_IWineGameControllerProvider( iface ); ULONG report_len = impl->caps.OutputReportByteLength; PHIDP_PREPARSED_DATA preparsed = impl->preparsed; char *report_buf = impl->report_buf; @@ -335,9 +266,9 @@ static HRESULT WINAPI wine_provider_put_Vibration( IWineGameControllerProvider * return S_OK; }
-static HRESULT WINAPI wine_provider_get_ForceFeedbackMotor( IWineGameControllerProvider *iface, IForceFeedbackMotor **value ) +static HRESULT WINAPI provider_get_ForceFeedbackMotor( IWineGameControllerProvider *iface, IForceFeedbackMotor **value ) { - struct provider *impl = impl_from_IWineGameControllerProvider( iface ); + struct provider *impl = provider_from_IWineGameControllerProvider( iface ); DIDEVCAPS caps = {.dwSize = sizeof(DIDEVCAPS)}; HRESULT hr;
@@ -350,38 +281,18 @@ static HRESULT WINAPI wine_provider_get_ForceFeedbackMotor( IWineGameControllerP return S_OK; }
-static const struct IWineGameControllerProviderVtbl wine_provider_vtbl = -{ - wine_provider_QueryInterface, - wine_provider_AddRef, - wine_provider_Release, - /* IInspectable methods */ - wine_provider_GetIids, - wine_provider_GetRuntimeClassName, - wine_provider_GetTrustLevel, - /* IWineGameControllerProvider methods */ - wine_provider_get_Type, - wine_provider_get_AxisCount, - wine_provider_get_ButtonCount, - wine_provider_get_SwitchCount, - wine_provider_get_State, - wine_provider_get_Vibration, - wine_provider_put_Vibration, - wine_provider_get_ForceFeedbackMotor, -}; - -DEFINE_IINSPECTABLE( game_provider, IGameControllerProvider, provider, IWineGameControllerProvider_iface ) +INTERFACE_VTBL_IWineGameControllerProvider( provider );
-static HRESULT WINAPI game_provider_get_FirmwareVersionInfo( IGameControllerProvider *iface, GameControllerVersionInfo *value ) +static HRESULT WINAPI provider_IGameControllerProvider_get_FirmwareVersionInfo( IGameControllerProvider *iface, GameControllerVersionInfo *value ) { FIXME( "iface %p, value %p stub!\n", iface, value ); return E_NOTIMPL; }
-static HRESULT WINAPI game_provider_get_HardwareProductId( IGameControllerProvider *iface, UINT16 *value ) +static HRESULT WINAPI provider_IGameControllerProvider_get_HardwareProductId( IGameControllerProvider *iface, UINT16 *value ) { DIPROPDWORD vid_pid = {.diph = {.dwHeaderSize = sizeof(DIPROPHEADER), .dwSize = sizeof(DIPROPDWORD)}}; - struct provider *impl = impl_from_IGameControllerProvider( iface ); + struct provider *impl = provider_from_IGameControllerProvider( iface ); HRESULT hr;
TRACE( "iface %p, value %p.\n", iface, value ); @@ -391,10 +302,10 @@ static HRESULT WINAPI game_provider_get_HardwareProductId( IGameControllerProvid return hr; }
-static HRESULT WINAPI game_provider_get_HardwareVendorId( IGameControllerProvider *iface, UINT16 *value ) +static HRESULT WINAPI provider_IGameControllerProvider_get_HardwareVendorId( IGameControllerProvider *iface, UINT16 *value ) { DIPROPDWORD vid_pid = {.diph = {.dwHeaderSize = sizeof(DIPROPHEADER), .dwSize = sizeof(DIPROPDWORD)}}; - struct provider *impl = impl_from_IGameControllerProvider( iface ); + struct provider *impl = provider_from_IGameControllerProvider( iface ); HRESULT hr;
TRACE( "iface %p, value %p.\n", iface, value ); @@ -404,36 +315,20 @@ static HRESULT WINAPI game_provider_get_HardwareVendorId( IGameControllerProvide return hr; }
-static HRESULT WINAPI game_provider_get_HardwareVersionInfo( IGameControllerProvider *iface, GameControllerVersionInfo *value ) +static HRESULT WINAPI provider_IGameControllerProvider_get_HardwareVersionInfo( IGameControllerProvider *iface, GameControllerVersionInfo *value ) { FIXME( "iface %p, value %p stub!\n", iface, value ); return E_NOTIMPL; }
-static HRESULT WINAPI game_provider_get_IsConnected( IGameControllerProvider *iface, boolean *value ) +static HRESULT WINAPI provider_IGameControllerProvider_get_IsConnected( IGameControllerProvider *iface, boolean *value ) { FIXME( "iface %p, value %p stub!\n", iface, value ); return E_NOTIMPL; }
-static const struct IGameControllerProviderVtbl game_provider_vtbl = -{ - game_provider_QueryInterface, - game_provider_AddRef, - game_provider_Release, - /* IInspectable methods */ - game_provider_GetIids, - game_provider_GetRuntimeClassName, - game_provider_GetTrustLevel, - /* IGameControllerProvider methods */ - game_provider_get_FirmwareVersionInfo, - game_provider_get_HardwareProductId, - game_provider_get_HardwareVendorId, - game_provider_get_HardwareVersionInfo, - game_provider_get_IsConnected, -}; - -DEFINE_IAGILEOBJECT( provider, IWineGameControllerProvider, &object->IWineGameControllerProvider_iface ); +INTERFACE_VTBL_IGameControllerProvider( provider_IGameControllerProvider ); +INTERFACE_VTBL_IAgileObject( provider_IAgileObject );
static void check_haptics_caps( struct provider *provider, HANDLE device, PHIDP_PREPARSED_DATA preparsed, HIDP_LINK_COLLECTION_NODE *collections, HIDP_VALUE_CAPS *caps ) @@ -579,12 +474,12 @@ void provider_create( const WCHAR *device_path ) if (FAILED(hr = IDirectInputDevice8_Acquire( dinput_device ))) goto done;
if (!(impl = calloc( 1, sizeof(*impl) ))) goto done; - impl->IWineGameControllerProvider_iface.lpVtbl = &wine_provider_vtbl; - impl->IGameControllerProvider_iface.lpVtbl = &game_provider_vtbl; + impl->IWineGameControllerProvider_iface.lpVtbl = &provider_vtbl; + impl->IGameControllerProvider_iface.lpVtbl = &provider_IGameControllerProvider_vtbl; impl->IAgileObject_iface.lpVtbl = &provider_IAgileObject_vtbl; IDirectInputDevice_AddRef( dinput_device ); impl->dinput_device = dinput_device; - impl->ref = 1; + impl->refcount = 1;
wcscpy( impl->device_path, device_path ); list_init( &impl->entry ); diff --git a/dlls/windows.gaming.input/provider.idl b/dlls/windows.gaming.input/provider.idl index e7b6e96b8aa..072c381461e 100644 --- a/dlls/windows.gaming.input/provider.idl +++ b/dlls/windows.gaming.input/provider.idl @@ -188,7 +188,7 @@ namespace Windows.Gaming.Input.Custom { [ uuid(27833469-7760-417e-adbe-e011a66e16ee) ] - interface IWineForceFeedbackEffectImpl : IUnknown + interface IWineForceFeedbackEffectImpl : IInspectable requires Windows.Gaming.Input.ForceFeedback.IForceFeedbackEffect { [propput] HRESULT Parameters([in] WineForceFeedbackEffectParameters parameters, @@ -198,7 +198,7 @@ namespace Windows.Gaming.Input.Custom { [ uuid(83f377ee-c799-11ec-9d64-0242ac120002) ] - interface IWineAsyncInfoImpl : IUnknown + interface IWineAsyncInfoImpl : IInspectable { [propput] HRESULT Completed([in] WineAsyncOperationCompletedHandler *handler); [propget] HRESULT Completed([out, retval] WineAsyncOperationCompletedHandler **handler); diff --git a/dlls/windows.gaming.input/racing_wheel.c b/dlls/windows.gaming.input/racing_wheel.c index c7004d935af..e6045be9665 100644 --- a/dlls/windows.gaming.input/racing_wheel.c +++ b/dlls/windows.gaming.input/racing_wheel.c @@ -61,101 +61,32 @@ struct racing_wheel IGameControllerImpl IGameControllerImpl_iface; IGameControllerInputSink IGameControllerInputSink_iface; IRacingWheel IRacingWheel_iface; - IGameController *IGameController_outer; - LONG ref; + IInspectable *outer; + const WCHAR *class_name; + LONG refcount;
IGameControllerProvider *provider; IWineGameControllerProvider *wine_provider; };
-static inline struct racing_wheel *impl_from_IGameControllerImpl( IGameControllerImpl *iface ) +static void racing_wheel_destroy( struct racing_wheel *impl ) { - return CONTAINING_RECORD( iface, struct racing_wheel, IGameControllerImpl_iface ); + if (impl->wine_provider) IWineGameControllerProvider_Release( impl->wine_provider ); + IGameControllerProvider_Release( impl->provider ); + free( impl ); }
-static HRESULT WINAPI controller_QueryInterface( IGameControllerImpl *iface, REFIID iid, void **out ) -{ - struct racing_wheel *impl = impl_from_IGameControllerImpl( iface ); - - TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out ); - - if (IsEqualGUID( iid, &IID_IUnknown ) || - IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IGameControllerImpl )) - { - IInspectable_AddRef( (*out = &impl->IGameControllerImpl_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IGameControllerInputSink )) - { - IInspectable_AddRef( (*out = &impl->IGameControllerInputSink_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IRacingWheel )) - { - IInspectable_AddRef( (*out = &impl->IRacingWheel_iface) ); - return S_OK; - } - - FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); - *out = NULL; - return E_NOINTERFACE; -} - -static ULONG WINAPI controller_AddRef( IGameControllerImpl *iface ) -{ - struct racing_wheel *impl = impl_from_IGameControllerImpl( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI controller_Release( IGameControllerImpl *iface ) -{ - struct racing_wheel *impl = impl_from_IGameControllerImpl( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - - if (!ref) - { - if (impl->wine_provider) IWineGameControllerProvider_Release( impl->wine_provider ); - IGameControllerProvider_Release( impl->provider ); - free( impl ); - } - - return ref; -} +INTERFACE_IMPL_OUTER_IGameControllerImpl( racing_wheel, IGameControllerInputSink, IRacingWheel, END );
-static HRESULT WINAPI controller_GetIids( IGameControllerImpl *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} - -static HRESULT WINAPI controller_GetRuntimeClassName( IGameControllerImpl *iface, HSTRING *class_name ) -{ - return WindowsCreateString( RuntimeClass_Windows_Gaming_Input_RacingWheel, - ARRAY_SIZE(RuntimeClass_Windows_Gaming_Input_RacingWheel), class_name ); -} - -static HRESULT WINAPI controller_GetTrustLevel( IGameControllerImpl *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} - -static HRESULT WINAPI controller_Initialize( IGameControllerImpl *iface, IGameController *outer, +static HRESULT WINAPI racing_wheel_Initialize( IGameControllerImpl *iface, IGameController *outer, IGameControllerProvider *provider ) { - struct racing_wheel *impl = impl_from_IGameControllerImpl( iface ); + struct racing_wheel *impl = racing_wheel_from_IGameControllerImpl( iface ); HRESULT hr;
TRACE( "iface %p, outer %p, provider %p.\n", iface, outer, provider );
- impl->IGameController_outer = outer; + impl->outer = (IInspectable *)outer; IGameControllerProvider_AddRef( (impl->provider = provider) );
hr = IGameControllerProvider_QueryInterface( provider, &IID_IWineGameControllerProvider, @@ -170,120 +101,75 @@ static HRESULT WINAPI controller_Initialize( IGameControllerImpl *iface, IGameCo return hr; }
-static const struct IGameControllerImplVtbl controller_vtbl = -{ - controller_QueryInterface, - controller_AddRef, - controller_Release, - /* IInspectable methods */ - controller_GetIids, - controller_GetRuntimeClassName, - controller_GetTrustLevel, - /* IGameControllerImpl methods */ - controller_Initialize, -}; - -DEFINE_IINSPECTABLE_OUTER( input_sink, IGameControllerInputSink, racing_wheel, IGameController_outer ) +INTERFACE_VTBL_IGameControllerImpl( racing_wheel );
-static HRESULT WINAPI input_sink_OnInputResumed( IGameControllerInputSink *iface, UINT64 timestamp ) +static HRESULT WINAPI racing_wheel_IGameControllerInputSink_OnInputResumed( IGameControllerInputSink *iface, UINT64 timestamp ) { FIXME( "iface %p, timestamp %I64u stub!\n", iface, timestamp ); return E_NOTIMPL; }
-static HRESULT WINAPI input_sink_OnInputSuspended( IGameControllerInputSink *iface, UINT64 timestamp ) +static HRESULT WINAPI racing_wheel_IGameControllerInputSink_OnInputSuspended( IGameControllerInputSink *iface, UINT64 timestamp ) { FIXME( "iface %p, timestamp %I64u stub!\n", iface, timestamp ); return E_NOTIMPL; }
-static const struct IGameControllerInputSinkVtbl input_sink_vtbl = -{ - input_sink_QueryInterface, - input_sink_AddRef, - input_sink_Release, - /* IInspectable methods */ - input_sink_GetIids, - input_sink_GetRuntimeClassName, - input_sink_GetTrustLevel, - /* IGameControllerInputSink methods */ - input_sink_OnInputResumed, - input_sink_OnInputSuspended, -}; - -DEFINE_IINSPECTABLE_OUTER( racing_wheel, IRacingWheel, racing_wheel, IGameController_outer ) +INTERFACE_VTBL_IGameControllerInputSink( racing_wheel_IGameControllerInputSink );
-static HRESULT WINAPI racing_wheel_get_HasClutch( IRacingWheel *iface, boolean *value ) +static HRESULT WINAPI racing_wheel_IRacingWheel_get_HasClutch( IRacingWheel *iface, boolean *value ) { FIXME( "iface %p, value %p stub!\n", iface, value ); return E_NOTIMPL; }
-static HRESULT WINAPI racing_wheel_get_HasHandbrake( IRacingWheel *iface, boolean *value ) +static HRESULT WINAPI racing_wheel_IRacingWheel_get_HasHandbrake( IRacingWheel *iface, boolean *value ) { FIXME( "iface %p, value %p stub!\n", iface, value ); return E_NOTIMPL; }
-static HRESULT WINAPI racing_wheel_get_HasPatternShifter( IRacingWheel *iface, boolean *value ) +static HRESULT WINAPI racing_wheel_IRacingWheel_get_HasPatternShifter( IRacingWheel *iface, boolean *value ) { FIXME( "iface %p, value %p stub!\n", iface, value ); return E_NOTIMPL; }
-static HRESULT WINAPI racing_wheel_get_MaxPatternShifterGear( IRacingWheel *iface, INT32 *value ) +static HRESULT WINAPI racing_wheel_IRacingWheel_get_MaxPatternShifterGear( IRacingWheel *iface, INT32 *value ) { FIXME( "iface %p, value %p stub!\n", iface, value ); return E_NOTIMPL; }
-static HRESULT WINAPI racing_wheel_get_MaxWheelAngle( IRacingWheel *iface, DOUBLE *value ) +static HRESULT WINAPI racing_wheel_IRacingWheel_get_MaxWheelAngle( IRacingWheel *iface, DOUBLE *value ) { FIXME( "iface %p, value %p stub!\n", iface, value ); return E_NOTIMPL; }
-static HRESULT WINAPI racing_wheel_get_WheelMotor( IRacingWheel *iface, IForceFeedbackMotor **value ) +static HRESULT WINAPI racing_wheel_IRacingWheel_get_WheelMotor( IRacingWheel *iface, IForceFeedbackMotor **value ) { - struct racing_wheel *impl = impl_from_IRacingWheel( iface ); + struct racing_wheel *impl = racing_wheel_from_IRacingWheel( iface );
TRACE( "iface %p, value %p\n", iface, value );
return IWineGameControllerProvider_get_ForceFeedbackMotor( impl->wine_provider, value ); }
-static HRESULT WINAPI racing_wheel_GetButtonLabel( IRacingWheel *iface, enum RacingWheelButtons button, +static HRESULT WINAPI racing_wheel_IRacingWheel_GetButtonLabel( IRacingWheel *iface, enum RacingWheelButtons button, enum GameControllerButtonLabel *value ) { FIXME( "iface %p, button %d, value %p stub!\n", iface, button, value ); return E_NOTIMPL; }
-static HRESULT WINAPI racing_wheel_GetCurrentReading( IRacingWheel *iface, struct RacingWheelReading *value ) +static HRESULT WINAPI racing_wheel_IRacingWheel_GetCurrentReading( IRacingWheel *iface, struct RacingWheelReading *value ) { FIXME( "iface %p, value %p stub!\n", iface, value ); return E_NOTIMPL; }
-static const struct IRacingWheelVtbl racing_wheel_vtbl = -{ - racing_wheel_QueryInterface, - racing_wheel_AddRef, - racing_wheel_Release, - /* IInspectable methods */ - racing_wheel_GetIids, - racing_wheel_GetRuntimeClassName, - racing_wheel_GetTrustLevel, - /* IRacingWheel methods */ - racing_wheel_get_HasClutch, - racing_wheel_get_HasHandbrake, - racing_wheel_get_HasPatternShifter, - racing_wheel_get_MaxPatternShifterGear, - racing_wheel_get_MaxWheelAngle, - racing_wheel_get_WheelMotor, - racing_wheel_GetButtonLabel, - racing_wheel_GetCurrentReading, -}; +INTERFACE_VTBL_IRacingWheel( racing_wheel_IRacingWheel );
struct racing_wheel_statics { @@ -292,113 +178,21 @@ struct racing_wheel_statics IRacingWheelStatics2 IRacingWheelStatics2_iface; ICustomGameControllerFactory ICustomGameControllerFactory_iface; IAgileObject IAgileObject_iface; - LONG ref; + const WCHAR *class_name; };
-static inline struct racing_wheel_statics *impl_from_IActivationFactory( IActivationFactory *iface ) -{ - return CONTAINING_RECORD( iface, struct racing_wheel_statics, IActivationFactory_iface ); -} +INTERFACE_IMPL_STATIC_IActivationFactory( racing_wheel_statics, IRacingWheelStatics, IRacingWheelStatics2, + ICustomGameControllerFactory, IAgileObject, END );
-static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) -{ - struct racing_wheel_statics *impl = impl_from_IActivationFactory( iface ); - - TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out ); - - if (IsEqualGUID( iid, &IID_IUnknown ) || - IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IActivationFactory )) - { - IInspectable_AddRef( (*out = &impl->IActivationFactory_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IRacingWheelStatics )) - { - IInspectable_AddRef( (*out = &impl->IRacingWheelStatics_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IRacingWheelStatics2 )) - { - IInspectable_AddRef( (*out = &impl->IRacingWheelStatics2_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_ICustomGameControllerFactory )) - { - IInspectable_AddRef( (*out = &impl->ICustomGameControllerFactory_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IAgileObject )) - { - IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); - return S_OK; - } - - FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); - *out = NULL; - return E_NOINTERFACE; -} - -static ULONG WINAPI factory_AddRef( IActivationFactory *iface ) -{ - struct racing_wheel_statics *impl = impl_from_IActivationFactory( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI factory_Release( IActivationFactory *iface ) -{ - struct racing_wheel_statics *impl = impl_from_IActivationFactory( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static HRESULT WINAPI factory_GetIids( IActivationFactory *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} - -static HRESULT WINAPI factory_GetRuntimeClassName( IActivationFactory *iface, HSTRING *class_name ) -{ - FIXME( "iface %p, class_name %p stub!\n", iface, class_name ); - return E_NOTIMPL; -} - -static HRESULT WINAPI factory_GetTrustLevel( IActivationFactory *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} - -static HRESULT WINAPI factory_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) +static HRESULT WINAPI racing_wheel_statics_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) { FIXME( "iface %p, instance %p stub!\n", iface, instance ); return E_NOTIMPL; }
-static const struct IActivationFactoryVtbl factory_vtbl = -{ - factory_QueryInterface, - factory_AddRef, - factory_Release, - /* IInspectable methods */ - factory_GetIids, - factory_GetRuntimeClassName, - factory_GetTrustLevel, - /* IActivationFactory methods */ - factory_ActivateInstance, -}; - -DEFINE_IINSPECTABLE( statics, IRacingWheelStatics, racing_wheel_statics, IActivationFactory_iface ) +INTERFACE_VTBL_IActivationFactory( racing_wheel_statics );
-static HRESULT WINAPI statics_add_RacingWheelAdded( IRacingWheelStatics *iface, IEventHandler_RacingWheel *handler, +static HRESULT WINAPI racing_wheel_statics_IRacingWheelStatics_add_RacingWheelAdded( IRacingWheelStatics *iface, IEventHandler_RacingWheel *handler, EventRegistrationToken *token ) { TRACE( "iface %p, handler %p, token %p.\n", iface, handler, token ); @@ -406,13 +200,13 @@ static HRESULT WINAPI statics_add_RacingWheelAdded( IRacingWheelStatics *iface, return event_handlers_append( &racing_wheel_added_handlers, (IEventHandler_IInspectable *)handler, token ); }
-static HRESULT WINAPI statics_remove_RacingWheelAdded( IRacingWheelStatics *iface, EventRegistrationToken token ) +static HRESULT WINAPI racing_wheel_statics_IRacingWheelStatics_remove_RacingWheelAdded( IRacingWheelStatics *iface, EventRegistrationToken token ) { TRACE( "iface %p, token %#I64x.\n", iface, token.value ); return event_handlers_remove( &racing_wheel_added_handlers, &token ); }
-static HRESULT WINAPI statics_add_RacingWheelRemoved( IRacingWheelStatics *iface, IEventHandler_RacingWheel *handler, +static HRESULT WINAPI racing_wheel_statics_IRacingWheelStatics_add_RacingWheelRemoved( IRacingWheelStatics *iface, IEventHandler_RacingWheel *handler, EventRegistrationToken *token ) { TRACE( "iface %p, handler %p, token %p.\n", iface, handler, token ); @@ -420,13 +214,13 @@ static HRESULT WINAPI statics_add_RacingWheelRemoved( IRacingWheelStatics *iface return event_handlers_append( &racing_wheel_removed_handlers, (IEventHandler_IInspectable *)handler, token ); }
-static HRESULT WINAPI statics_remove_RacingWheelRemoved( IRacingWheelStatics *iface, EventRegistrationToken token ) +static HRESULT WINAPI racing_wheel_statics_IRacingWheelStatics_remove_RacingWheelRemoved( IRacingWheelStatics *iface, EventRegistrationToken token ) { TRACE( "iface %p, token %#I64x.\n", iface, token.value ); return event_handlers_remove( &racing_wheel_removed_handlers, &token ); }
-static HRESULT WINAPI statics_get_RacingWheels( IRacingWheelStatics *iface, IVectorView_RacingWheel **value ) +static HRESULT WINAPI racing_wheel_statics_IRacingWheelStatics_get_RacingWheels( IRacingWheelStatics *iface, IVectorView_RacingWheel **value ) { HRESULT hr;
@@ -439,28 +233,11 @@ static HRESULT WINAPI statics_get_RacingWheels( IRacingWheelStatics *iface, IVec return hr; }
-static const struct IRacingWheelStaticsVtbl statics_vtbl = -{ - statics_QueryInterface, - statics_AddRef, - statics_Release, - /* IInspectable methods */ - statics_GetIids, - statics_GetRuntimeClassName, - statics_GetTrustLevel, - /* IRacingWheelStatics methods */ - statics_add_RacingWheelAdded, - statics_remove_RacingWheelAdded, - statics_add_RacingWheelRemoved, - statics_remove_RacingWheelRemoved, - statics_get_RacingWheels, -}; - -DEFINE_IINSPECTABLE( statics2, IRacingWheelStatics2, racing_wheel_statics, IActivationFactory_iface ) +INTERFACE_VTBL_IRacingWheelStatics( racing_wheel_statics_IRacingWheelStatics );
-static HRESULT WINAPI statics2_FromGameController( IRacingWheelStatics2 *iface, IGameController *game_controller, IRacingWheel **value ) +static HRESULT WINAPI racing_wheel_statics_IRacingWheelStatics2_FromGameController( IRacingWheelStatics2 *iface, IGameController *game_controller, IRacingWheel **value ) { - struct racing_wheel_statics *impl = impl_from_IRacingWheelStatics2( iface ); + struct racing_wheel_statics *impl = racing_wheel_statics_from_IRacingWheelStatics2( iface ); IGameController *controller; HRESULT hr;
@@ -476,22 +253,9 @@ static HRESULT WINAPI statics2_FromGameController( IRacingWheelStatics2 *iface, return hr; }
-static const struct IRacingWheelStatics2Vtbl statics2_vtbl = -{ - statics2_QueryInterface, - statics2_AddRef, - statics2_Release, - /* IInspectable methods */ - statics2_GetIids, - statics2_GetRuntimeClassName, - statics2_GetTrustLevel, - /* IRacingWheelStatics2 methods */ - statics2_FromGameController, -}; - -DEFINE_IINSPECTABLE( controller_factory, ICustomGameControllerFactory, racing_wheel_statics, IActivationFactory_iface ) +INTERFACE_VTBL_IRacingWheelStatics2( racing_wheel_statics_IRacingWheelStatics2 );
-static HRESULT WINAPI controller_factory_CreateGameController( ICustomGameControllerFactory *iface, IGameControllerProvider *provider, +static HRESULT WINAPI racing_wheel_statics_ICustomGameControllerFactory_CreateGameController( ICustomGameControllerFactory *iface, IGameControllerProvider *provider, IInspectable **value ) { struct racing_wheel *impl; @@ -499,10 +263,11 @@ static HRESULT WINAPI controller_factory_CreateGameController( ICustomGameContro TRACE( "iface %p, provider %p, value %p.\n", iface, provider, value );
if (!(impl = calloc( 1, sizeof(*impl) ))) return E_OUTOFMEMORY; - impl->IGameControllerImpl_iface.lpVtbl = &controller_vtbl; - impl->IGameControllerInputSink_iface.lpVtbl = &input_sink_vtbl; - impl->IRacingWheel_iface.lpVtbl = &racing_wheel_vtbl; - impl->ref = 1; + impl->IGameControllerImpl_iface.lpVtbl = &racing_wheel_vtbl; + impl->IGameControllerInputSink_iface.lpVtbl = &racing_wheel_IGameControllerInputSink_vtbl; + impl->IRacingWheel_iface.lpVtbl = &racing_wheel_IRacingWheel_vtbl; + impl->class_name = RuntimeClass_Windows_Gaming_Input_RacingWheel; + impl->refcount = 1;
TRACE( "created RacingWheel %p\n", impl );
@@ -510,7 +275,7 @@ static HRESULT WINAPI controller_factory_CreateGameController( ICustomGameContro return S_OK; }
-static HRESULT WINAPI controller_factory_OnGameControllerAdded( ICustomGameControllerFactory *iface, IGameController *value ) +static HRESULT WINAPI racing_wheel_statics_ICustomGameControllerFactory_OnGameControllerAdded( ICustomGameControllerFactory *iface, IGameController *value ) { IRacingWheel *racing_wheel; HRESULT hr; @@ -525,7 +290,7 @@ static HRESULT WINAPI controller_factory_OnGameControllerAdded( ICustomGameContr return S_OK; }
-static HRESULT WINAPI controller_factory_OnGameControllerRemoved( ICustomGameControllerFactory *iface, IGameController *value ) +static HRESULT WINAPI racing_wheel_statics_ICustomGameControllerFactory_OnGameControllerRemoved( ICustomGameControllerFactory *iface, IGameController *value ) { IRacingWheel *racing_wheel; BOOLEAN found; @@ -559,31 +324,17 @@ static HRESULT WINAPI controller_factory_OnGameControllerRemoved( ICustomGameCon return S_OK; }
-static const struct ICustomGameControllerFactoryVtbl controller_factory_vtbl = -{ - controller_factory_QueryInterface, - controller_factory_AddRef, - controller_factory_Release, - /* IInspectable methods */ - controller_factory_GetIids, - controller_factory_GetRuntimeClassName, - controller_factory_GetTrustLevel, - /* ICustomGameControllerFactory methods */ - controller_factory_CreateGameController, - controller_factory_OnGameControllerAdded, - controller_factory_OnGameControllerRemoved, -}; - -DEFINE_IAGILEOBJECT( racing_wheel_statics, IActivationFactory, &object->IActivationFactory_iface ); +INTERFACE_VTBL_ICustomGameControllerFactory( racing_wheel_statics_ICustomGameControllerFactory ); +INTERFACE_VTBL_IAgileObject( racing_wheel_statics_IAgileObject );
static struct racing_wheel_statics racing_wheel_statics = { - {&factory_vtbl}, - {&statics_vtbl}, - {&statics2_vtbl}, - {&controller_factory_vtbl}, + {&racing_wheel_statics_vtbl}, + {&racing_wheel_statics_IRacingWheelStatics_vtbl}, + {&racing_wheel_statics_IRacingWheelStatics2_vtbl}, + {&racing_wheel_statics_ICustomGameControllerFactory_vtbl}, {&racing_wheel_statics_IAgileObject_vtbl}, - 1, + RuntimeClass_Windows_Gaming_Input_RacingWheel, };
ICustomGameControllerFactory *racing_wheel_factory = &racing_wheel_statics.ICustomGameControllerFactory_iface; diff --git a/dlls/windows.gaming.input/ramp_effect.c b/dlls/windows.gaming.input/ramp_effect.c index f0eb4efaa31..eb2aef856a5 100644 --- a/dlls/windows.gaming.input/ramp_effect.c +++ b/dlls/windows.gaming.input/ramp_effect.c @@ -26,77 +26,32 @@ struct ramp_effect { IRampForceEffect IRampForceEffect_iface; IWineForceFeedbackEffectImpl *IWineForceFeedbackEffectImpl_inner; - LONG ref; + const WCHAR *class_name; + LONG refcount; };
-static inline struct ramp_effect *impl_from_IRampForceEffect( IRampForceEffect *iface ) -{ - return CONTAINING_RECORD( iface, struct ramp_effect, IRampForceEffect_iface ); -} +INTERFACE_IMPL_FROM( ramp_effect, IRampForceEffect );
-static HRESULT WINAPI effect_QueryInterface( IRampForceEffect *iface, REFIID iid, void **out ) +static HRESULT WINAPI ramp_effect_QueryInterface( IRampForceEffect *iface, REFIID iid, void **out ) { - struct ramp_effect *impl = impl_from_IRampForceEffect( iface ); - + struct ramp_effect *impl = ramp_effect_from_IRampForceEffect( iface ); TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out ); - - if (IsEqualGUID( iid, &IID_IUnknown ) || - IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IRampForceEffect )) - { - IInspectable_AddRef( (*out = &impl->IRampForceEffect_iface) ); - return S_OK; - } - + QUERY_INTERFACE_IRampForceEffect( impl, iid, out, IRampForceEffect_iface ) return IWineForceFeedbackEffectImpl_QueryInterface( impl->IWineForceFeedbackEffectImpl_inner, iid, out ); }
-static ULONG WINAPI effect_AddRef( IRampForceEffect *iface ) -{ - struct ramp_effect *impl = impl_from_IRampForceEffect( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} +IUNKNOWN_IMPL_ADDREF( ramp_effect, IRampForceEffect );
-static ULONG WINAPI effect_Release( IRampForceEffect *iface ) +static void ramp_effect_destroy( struct ramp_effect *impl ) { - struct ramp_effect *impl = impl_from_IRampForceEffect( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - - if (!ref) - { - /* guard against re-entry if inner releases an outer iface */ - InterlockedIncrement( &impl->ref ); - IWineForceFeedbackEffectImpl_Release( impl->IWineForceFeedbackEffectImpl_inner ); - free( impl ); - } - - return ref; + IWineForceFeedbackEffectImpl_Release( impl->IWineForceFeedbackEffectImpl_inner ); + free( impl ); }
-static HRESULT WINAPI effect_GetIids( IRampForceEffect *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} - -static HRESULT WINAPI effect_GetRuntimeClassName( IRampForceEffect *iface, HSTRING *class_name ) -{ - return WindowsCreateString( RuntimeClass_Windows_Gaming_Input_ForceFeedback_RampForceEffect, - ARRAY_SIZE(RuntimeClass_Windows_Gaming_Input_ForceFeedback_RampForceEffect), - class_name ); -} - -static HRESULT WINAPI effect_GetTrustLevel( IRampForceEffect *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} +IUNKNOWN_IMPL_RELEASE( ramp_effect, IRampForceEffect ); +IINSPECTABLE_IMPL( ramp_effect, IRampForceEffect );
-static HRESULT WINAPI effect_SetParameters( IRampForceEffect *iface, Vector3 start_vector, Vector3 end_vector, TimeSpan duration ) +static HRESULT WINAPI ramp_effect_SetParameters( IRampForceEffect *iface, Vector3 start_vector, Vector3 end_vector, TimeSpan duration ) { WineForceFeedbackEffectParameters params = { @@ -110,7 +65,7 @@ static HRESULT WINAPI effect_SetParameters( IRampForceEffect *iface, Vector3 sta .gain = 1., }, }; - struct ramp_effect *impl = impl_from_IRampForceEffect( iface ); + struct ramp_effect *impl = ramp_effect_from_IRampForceEffect( iface );
TRACE( "iface %p, start_vector %s, end_vector %s, duration %I64u.\n", iface, debugstr_vector3( &start_vector ), debugstr_vector3( &end_vector ), duration.Duration ); @@ -118,7 +73,7 @@ static HRESULT WINAPI effect_SetParameters( IRampForceEffect *iface, Vector3 sta return IWineForceFeedbackEffectImpl_put_Parameters( impl->IWineForceFeedbackEffectImpl_inner, params, NULL ); }
-static HRESULT WINAPI effect_SetParametersWithEnvelope( IRampForceEffect *iface, Vector3 start_vector, Vector3 end_vector, FLOAT attack_gain, +static HRESULT WINAPI ramp_effect_SetParametersWithEnvelope( IRampForceEffect *iface, Vector3 start_vector, Vector3 end_vector, FLOAT attack_gain, FLOAT sustain_gain, FLOAT release_gain, TimeSpan start_delay, TimeSpan attack_duration, TimeSpan sustain_duration, TimeSpan release_duration, UINT32 repeat_count ) @@ -143,7 +98,7 @@ static HRESULT WINAPI effect_SetParametersWithEnvelope( IRampForceEffect *iface, .attack_duration = attack_duration, .release_duration = release_duration, }; - struct ramp_effect *impl = impl_from_IRampForceEffect( iface ); + struct ramp_effect *impl = ramp_effect_from_IRampForceEffect( iface );
TRACE( "iface %p, start_vector %s, end_vector %s, attack_gain %f, sustain_gain %f, release_gain %f, start_delay %I64u, attack_duration %I64u, " "sustain_duration %I64u, release_duration %I64u, repeat_count %u.\n", iface, debugstr_vector3( &start_vector ), debugstr_vector3( &end_vector ), @@ -153,92 +108,18 @@ static HRESULT WINAPI effect_SetParametersWithEnvelope( IRampForceEffect *iface, return IWineForceFeedbackEffectImpl_put_Parameters( impl->IWineForceFeedbackEffectImpl_inner, params, &envelope ); }
-static const struct IRampForceEffectVtbl effect_vtbl = -{ - effect_QueryInterface, - effect_AddRef, - effect_Release, - /* IInspectable methods */ - effect_GetIids, - effect_GetRuntimeClassName, - effect_GetTrustLevel, - /* IRampForceEffect methods */ - effect_SetParameters, - effect_SetParametersWithEnvelope, -}; +INTERFACE_VTBL_IRampForceEffect( ramp_effect );
struct ramp_factory { IActivationFactory IActivationFactory_iface; IAgileObject IAgileObject_iface; - LONG ref; + const WCHAR *class_name; };
-static inline struct ramp_factory *impl_from_IActivationFactory( IActivationFactory *iface ) -{ - return CONTAINING_RECORD( iface, struct ramp_factory, IActivationFactory_iface ); -} +INTERFACE_IMPL_STATIC_IActivationFactory( ramp_factory, IAgileObject, END );
-static HRESULT WINAPI activation_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) -{ - struct ramp_factory *impl = impl_from_IActivationFactory( iface ); - - TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out ); - - if (IsEqualGUID( iid, &IID_IUnknown ) || - IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IActivationFactory )) - { - IInspectable_AddRef( (*out = &impl->IActivationFactory_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IAgileObject )) - { - IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); - return S_OK; - } - - FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); - *out = NULL; - return E_NOINTERFACE; -} - -static ULONG WINAPI activation_AddRef( IActivationFactory *iface ) -{ - struct ramp_factory *impl = impl_from_IActivationFactory( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI activation_Release( IActivationFactory *iface ) -{ - struct ramp_factory *impl = impl_from_IActivationFactory( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static HRESULT WINAPI activation_GetIids( IActivationFactory *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} - -static HRESULT WINAPI activation_GetRuntimeClassName( IActivationFactory *iface, HSTRING *class_name ) -{ - FIXME( "iface %p, class_name %p stub!\n", iface, class_name ); - return E_NOTIMPL; -} - -static HRESULT WINAPI activation_GetTrustLevel( IActivationFactory *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} - -static HRESULT WINAPI activation_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) +static HRESULT WINAPI ramp_factory_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) { struct ramp_effect *impl; HRESULT hr; @@ -246,8 +127,9 @@ static HRESULT WINAPI activation_ActivateInstance( IActivationFactory *iface, II TRACE( "iface %p, instance %p.\n", iface, instance );
if (!(impl = calloc( 1, sizeof(struct ramp_effect) ))) return E_OUTOFMEMORY; - impl->IRampForceEffect_iface.lpVtbl = &effect_vtbl; - impl->ref = 1; + impl->IRampForceEffect_iface.lpVtbl = &ramp_effect_vtbl; + impl->class_name = RuntimeClass_Windows_Gaming_Input_ForceFeedback_RampForceEffect; + impl->refcount = 1;
if (FAILED(hr = force_feedback_effect_create( WineForceFeedbackEffectType_Ramp, (IInspectable *)&impl->IRampForceEffect_iface, &impl->IWineForceFeedbackEffectImpl_inner ))) @@ -261,26 +143,14 @@ static HRESULT WINAPI activation_ActivateInstance( IActivationFactory *iface, II return S_OK; }
-static const struct IActivationFactoryVtbl activation_vtbl = -{ - activation_QueryInterface, - activation_AddRef, - activation_Release, - /* IInspectable methods */ - activation_GetIids, - activation_GetRuntimeClassName, - activation_GetTrustLevel, - /* IActivationFactory methods */ - activation_ActivateInstance, -}; - -DEFINE_IAGILEOBJECT( ramp_factory, IActivationFactory, &object->IActivationFactory_iface ); +INTERFACE_VTBL_IActivationFactory( ramp_factory ); +INTERFACE_VTBL_IAgileObject( ramp_factory_IAgileObject );
static struct ramp_factory ramp_statics = { - {&activation_vtbl}, + {&ramp_factory_vtbl}, {&ramp_factory_IAgileObject_vtbl}, - 1, + RuntimeClass_Windows_Gaming_Input_ForceFeedback_RampForceEffect, };
IInspectable *ramp_effect_factory = (IInspectable *)&ramp_statics.IActivationFactory_iface; diff --git a/dlls/windows.gaming.input/vector.c b/dlls/windows.gaming.input/vector.c index 6e16e9ace01..9ed3d7e2f62 100644 --- a/dlls/windows.gaming.input/vector.c +++ b/dlls/windows.gaming.input/vector.c @@ -27,22 +27,20 @@ struct iterator { IIterator_IInspectable IIterator_IInspectable_iface; IAgileObject IAgileObject_iface; + const WCHAR *class_name; const GUID *iid; - LONG ref; + LONG refcount;
IVectorView_IInspectable *view; UINT32 index; UINT32 size; };
-static inline struct iterator *impl_from_IIterator_IInspectable( IIterator_IInspectable *iface ) -{ - return CONTAINING_RECORD( iface, struct iterator, IIterator_IInspectable_iface ); -} +INTERFACE_IMPL_FROM( iterator, IIterator_IInspectable );
static HRESULT WINAPI iterator_QueryInterface( IIterator_IInspectable *iface, REFIID iid, void **out ) { - struct iterator *impl = impl_from_IIterator_IInspectable( iface ); + struct iterator *impl = iterator_from_IIterator_IInspectable( iface );
TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out );
@@ -54,69 +52,34 @@ static HRESULT WINAPI iterator_QueryInterface( IIterator_IInspectable *iface, RE return S_OK; }
- if (IsEqualGUID( iid, &IID_IAgileObject )) - { - IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); - return S_OK; - } + QUERY_INTERFACE_IAgileObject( impl, iid, out, IAgileObject_iface );
FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); *out = NULL; return E_NOINTERFACE; }
-static ULONG WINAPI iterator_AddRef( IIterator_IInspectable *iface ) -{ - struct iterator *impl = impl_from_IIterator_IInspectable( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} +IUNKNOWN_IMPL_ADDREF( iterator, IIterator_IInspectable );
-static ULONG WINAPI iterator_Release( IIterator_IInspectable *iface ) +static void iterator_destroy( struct iterator *impl ) { - struct iterator *impl = impl_from_IIterator_IInspectable( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - - if (!ref) - { - IVectorView_IInspectable_Release( impl->view ); - free( impl ); - } - - return ref; -} - -static HRESULT WINAPI iterator_GetIids( IIterator_IInspectable *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; + IVectorView_IInspectable_Release( impl->view ); + free( impl ); }
-static HRESULT WINAPI iterator_GetRuntimeClassName( IIterator_IInspectable *iface, HSTRING *class_name ) -{ - FIXME( "iface %p, class_name %p stub!\n", iface, class_name ); - return E_NOTIMPL; -} - -static HRESULT WINAPI iterator_GetTrustLevel( IIterator_IInspectable *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} +IUNKNOWN_IMPL_RELEASE( iterator, IIterator_IInspectable ); +IINSPECTABLE_IMPL( iterator, IIterator_IInspectable );
static HRESULT WINAPI iterator_get_Current( IIterator_IInspectable *iface, IInspectable **value ) { - struct iterator *impl = impl_from_IIterator_IInspectable( iface ); + struct iterator *impl = iterator_from_IIterator_IInspectable( iface ); TRACE( "iface %p, value %p.\n", iface, value ); return IVectorView_IInspectable_GetAt( impl->view, impl->index, value ); }
static HRESULT WINAPI iterator_get_HasCurrent( IIterator_IInspectable *iface, boolean *value ) { - struct iterator *impl = impl_from_IIterator_IInspectable( iface ); + struct iterator *impl = iterator_from_IIterator_IInspectable( iface );
TRACE( "iface %p, value %p.\n", iface, value );
@@ -126,7 +89,7 @@ static HRESULT WINAPI iterator_get_HasCurrent( IIterator_IInspectable *iface, bo
static HRESULT WINAPI iterator_MoveNext( IIterator_IInspectable *iface, boolean *value ) { - struct iterator *impl = impl_from_IIterator_IInspectable( iface ); + struct iterator *impl = iterator_from_IIterator_IInspectable( iface );
TRACE( "iface %p, value %p.\n", iface, value );
@@ -137,28 +100,15 @@ static HRESULT WINAPI iterator_MoveNext( IIterator_IInspectable *iface, boolean static HRESULT WINAPI iterator_GetMany( IIterator_IInspectable *iface, UINT32 items_size, IInspectable **items, UINT *count ) { - struct iterator *impl = impl_from_IIterator_IInspectable( iface ); + struct iterator *impl = iterator_from_IIterator_IInspectable( iface ); TRACE( "iface %p, items_size %u, items %p, count %p.\n", iface, items_size, items, count ); return IVectorView_IInspectable_GetMany( impl->view, impl->index, items_size, items, count ); }
-static const IIterator_IInspectableVtbl iterator_vtbl = -{ - iterator_QueryInterface, - iterator_AddRef, - iterator_Release, - /* IInspectable methods */ - iterator_GetIids, - iterator_GetRuntimeClassName, - iterator_GetTrustLevel, - /* IIterator<IInspectable*> methods */ - iterator_get_Current, - iterator_get_HasCurrent, - iterator_MoveNext, - iterator_GetMany, -}; +INTERFACE_VTBL_IIterator_IInspectable( iterator );
-DEFINE_IAGILEOBJECT( iterator, IIterator_IInspectable, &object->IIterator_IInspectable_iface ); +INTERFACE_FWD_IAgileObject( iterator, IIterator_IInspectable, &object->IIterator_IInspectable_iface ); +INTERFACE_VTBL_IAgileObject( iterator_IAgileObject );
struct vector_view { @@ -166,20 +116,18 @@ struct vector_view IIterable_IInspectable IIterable_IInspectable_iface; IAgileObject IAgileObject_iface; struct vector_iids iids; - LONG ref; + const WCHAR *class_name; + LONG refcount;
UINT32 size; IInspectable *elements[1]; };
-static inline struct vector_view *impl_from_IVectorView_IInspectable( IVectorView_IInspectable *iface ) -{ - return CONTAINING_RECORD( iface, struct vector_view, IVectorView_IInspectable_iface ); -} +INTERFACE_IMPL_FROM( vector_view, IVectorView_IInspectable );
static HRESULT WINAPI vector_view_QueryInterface( IVectorView_IInspectable *iface, REFIID iid, void **out ) { - struct vector_view *impl = impl_from_IVectorView_IInspectable( iface ); + struct vector_view *impl = vector_view_from_IVectorView_IInspectable( iface );
TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out );
@@ -197,62 +145,28 @@ static HRESULT WINAPI vector_view_QueryInterface( IVectorView_IInspectable *ifac return S_OK; }
- if (IsEqualGUID( iid, &IID_IAgileObject )) - { - IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); - return S_OK; - } + QUERY_INTERFACE_IAgileObject( impl, iid, out, IAgileObject_iface );
FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); *out = NULL; return E_NOINTERFACE; }
-static ULONG WINAPI vector_view_AddRef( IVectorView_IInspectable *iface ) -{ - struct vector_view *impl = impl_from_IVectorView_IInspectable( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} +IUNKNOWN_IMPL_ADDREF( vector_view, IVectorView_IInspectable );
-static ULONG WINAPI vector_view_Release( IVectorView_IInspectable *iface ) +static void vector_view_destroy( struct vector_view *impl ) { - struct vector_view *impl = impl_from_IVectorView_IInspectable( iface ); - ULONG i, ref = InterlockedDecrement( &impl->ref ); - - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - - if (!ref) - { - for (i = 0; i < impl->size; ++i) IInspectable_Release( impl->elements[i] ); - free( impl ); - } - - return ref; + UINT i; + for (i = 0; i < impl->size; ++i) IInspectable_Release( impl->elements[i] ); + free( impl ); }
-static HRESULT WINAPI vector_view_GetIids( IVectorView_IInspectable *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} - -static HRESULT WINAPI vector_view_GetRuntimeClassName( IVectorView_IInspectable *iface, HSTRING *class_name ) -{ - FIXME( "iface %p, class_name %p stub!\n", iface, class_name ); - return E_NOTIMPL; -} - -static HRESULT WINAPI vector_view_GetTrustLevel( IVectorView_IInspectable *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} +IUNKNOWN_IMPL_RELEASE( vector_view, IVectorView_IInspectable ); +IINSPECTABLE_IMPL( vector_view, IVectorView_IInspectable );
static HRESULT WINAPI vector_view_GetAt( IVectorView_IInspectable *iface, UINT32 index, IInspectable **value ) { - struct vector_view *impl = impl_from_IVectorView_IInspectable( iface ); + struct vector_view *impl = vector_view_from_IVectorView_IInspectable( iface );
TRACE( "iface %p, index %u, value %p.\n", iface, index, value );
@@ -265,7 +179,7 @@ static HRESULT WINAPI vector_view_GetAt( IVectorView_IInspectable *iface, UINT32
static HRESULT WINAPI vector_view_get_Size( IVectorView_IInspectable *iface, UINT32 *value ) { - struct vector_view *impl = impl_from_IVectorView_IInspectable( iface ); + struct vector_view *impl = vector_view_from_IVectorView_IInspectable( iface );
TRACE( "iface %p, value %p.\n", iface, value );
@@ -276,7 +190,7 @@ static HRESULT WINAPI vector_view_get_Size( IVectorView_IInspectable *iface, UIN static HRESULT WINAPI vector_view_IndexOf( IVectorView_IInspectable *iface, IInspectable *element, UINT32 *index, BOOLEAN *found ) { - struct vector_view *impl = impl_from_IVectorView_IInspectable( iface ); + struct vector_view *impl = vector_view_from_IVectorView_IInspectable( iface ); ULONG i;
TRACE( "iface %p, element %p, index %p, found %p.\n", iface, element, index, found ); @@ -291,7 +205,7 @@ static HRESULT WINAPI vector_view_IndexOf( IVectorView_IInspectable *iface, IIns static HRESULT WINAPI vector_view_GetMany( IVectorView_IInspectable *iface, UINT32 start_index, UINT32 items_size, IInspectable **items, UINT *count ) { - struct vector_view *impl = impl_from_IVectorView_IInspectable( iface ); + struct vector_view *impl = vector_view_from_IVectorView_IInspectable( iface ); UINT32 i;
TRACE( "iface %p, start_index %u, items_size %u, items %p, count %p.\n", @@ -309,28 +223,13 @@ static HRESULT WINAPI vector_view_GetMany( IVectorView_IInspectable *iface, UINT return S_OK; }
-static const struct IVectorView_IInspectableVtbl vector_view_vtbl = -{ - vector_view_QueryInterface, - vector_view_AddRef, - vector_view_Release, - /* IInspectable methods */ - vector_view_GetIids, - vector_view_GetRuntimeClassName, - vector_view_GetTrustLevel, - /* IVectorView<IInspectable*> methods */ - vector_view_GetAt, - vector_view_get_Size, - vector_view_IndexOf, - vector_view_GetMany, -}; +INTERFACE_VTBL_IVectorView_IInspectable( vector_view );
-DEFINE_IINSPECTABLE_( iterable_view, IIterable_IInspectable, vector_view, view_impl_from_IIterable_IInspectable, - IIterable_IInspectable_iface, (IInspectable *)&object->IVectorView_IInspectable_iface ) +INTERFACE_FWD_IIterable_IInspectable( vector_view, IVectorView_IInspectable, &object->IVectorView_IInspectable_iface );
-static HRESULT WINAPI iterable_view_First( IIterable_IInspectable *iface, IIterator_IInspectable **value ) +static HRESULT WINAPI vector_view_IIterable_IInspectable_First( IIterable_IInspectable *iface, IIterator_IInspectable **value ) { - struct vector_view *impl = view_impl_from_IIterable_IInspectable( iface ); + struct vector_view *impl = vector_view_from_IIterable_IInspectable( iface ); struct iterator *iter;
TRACE( "iface %p, value %p.\n", iface, value ); @@ -339,7 +238,7 @@ static HRESULT WINAPI iterable_view_First( IIterable_IInspectable *iface, IItera iter->IIterator_IInspectable_iface.lpVtbl = &iterator_vtbl; iter->IAgileObject_iface.lpVtbl = &iterator_IAgileObject_vtbl; iter->iid = impl->iids.iterator; - iter->ref = 1; + iter->refcount = 1;
IVectorView_IInspectable_AddRef( (iter->view = &impl->IVectorView_IInspectable_iface) ); iter->size = impl->size; @@ -348,20 +247,10 @@ static HRESULT WINAPI iterable_view_First( IIterable_IInspectable *iface, IItera return S_OK; }
-static const struct IIterable_IInspectableVtbl iterable_view_vtbl = -{ - iterable_view_QueryInterface, - iterable_view_AddRef, - iterable_view_Release, - /* IInspectable methods */ - iterable_view_GetIids, - iterable_view_GetRuntimeClassName, - iterable_view_GetTrustLevel, - /* IIterable<T> methods */ - iterable_view_First, -}; +INTERFACE_VTBL_IIterable_IInspectable( vector_view_IIterable_IInspectable );
-DEFINE_IAGILEOBJECT( vector_view, IVectorView_IInspectable, &object->IVectorView_IInspectable_iface ); +INTERFACE_FWD_IAgileObject( vector_view, IIterable_IInspectable, &object->IIterable_IInspectable_iface ); +INTERFACE_VTBL_IAgileObject( vector_view_IAgileObject );
struct vector { @@ -369,21 +258,19 @@ struct vector IIterable_IInspectable IIterable_IInspectable_iface; IAgileObject IAgileObject_iface; struct vector_iids iids; - LONG ref; + const WCHAR *class_name; + LONG refcount;
UINT32 size; UINT32 capacity; IInspectable **elements; };
-static inline struct vector *impl_from_IVector_IInspectable( IVector_IInspectable *iface ) -{ - return CONTAINING_RECORD( iface, struct vector, IVector_IInspectable_iface ); -} +INTERFACE_IMPL_FROM( vector, IVector_IInspectable );
static HRESULT WINAPI vector_QueryInterface( IVector_IInspectable *iface, REFIID iid, void **out ) { - struct vector *impl = impl_from_IVector_IInspectable( iface ); + struct vector *impl = vector_from_IVector_IInspectable( iface );
TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out );
@@ -401,62 +288,27 @@ static HRESULT WINAPI vector_QueryInterface( IVector_IInspectable *iface, REFIID return S_OK; }
- if (IsEqualGUID( iid, &IID_IAgileObject )) - { - IInspectable_AddRef( (*out = &impl->IAgileObject_iface) ); - return S_OK; - } + QUERY_INTERFACE_IAgileObject( impl, iid, out, IAgileObject_iface );
FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); *out = NULL; return E_NOINTERFACE; }
-static ULONG WINAPI vector_AddRef( IVector_IInspectable *iface ) -{ - struct vector *impl = impl_from_IVector_IInspectable( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI vector_Release( IVector_IInspectable *iface ) -{ - struct vector *impl = impl_from_IVector_IInspectable( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - - if (!ref) - { - IVector_IInspectable_Clear( iface ); - free( impl ); - } - - return ref; -} - -static HRESULT WINAPI vector_GetIids( IVector_IInspectable *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} +IUNKNOWN_IMPL_ADDREF( vector, IVector_IInspectable );
-static HRESULT WINAPI vector_GetRuntimeClassName( IVector_IInspectable *iface, HSTRING *class_name ) +static void vector_destroy( struct vector *impl ) { - FIXME( "iface %p, class_name %p stub!\n", iface, class_name ); - return E_NOTIMPL; + IVector_IInspectable_Clear( &impl->IVector_IInspectable_iface ); + free( impl ); }
-static HRESULT WINAPI vector_GetTrustLevel( IVector_IInspectable *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} +IUNKNOWN_IMPL_RELEASE( vector, IVector_IInspectable ); +IINSPECTABLE_IMPL( vector, IVector_IInspectable );
static HRESULT WINAPI vector_GetAt( IVector_IInspectable *iface, UINT32 index, IInspectable **value ) { - struct vector *impl = impl_from_IVector_IInspectable( iface ); + struct vector *impl = vector_from_IVector_IInspectable( iface );
TRACE( "iface %p, index %u, value %p.\n", iface, index, value );
@@ -469,7 +321,7 @@ static HRESULT WINAPI vector_GetAt( IVector_IInspectable *iface, UINT32 index, I
static HRESULT WINAPI vector_get_Size( IVector_IInspectable *iface, UINT32 *value ) { - struct vector *impl = impl_from_IVector_IInspectable( iface ); + struct vector *impl = vector_from_IVector_IInspectable( iface ); TRACE( "iface %p, value %p.\n", iface, value ); *value = impl->size; return S_OK; @@ -477,7 +329,7 @@ static HRESULT WINAPI vector_get_Size( IVector_IInspectable *iface, UINT32 *valu
static HRESULT WINAPI vector_GetView( IVector_IInspectable *iface, IVectorView_IInspectable **value ) { - struct vector *impl = impl_from_IVector_IInspectable( iface ); + struct vector *impl = vector_from_IVector_IInspectable( iface ); struct vector_view *view; ULONG i;
@@ -485,10 +337,10 @@ static HRESULT WINAPI vector_GetView( IVector_IInspectable *iface, IVectorView_I
if (!(view = calloc( 1, offsetof( struct vector_view, elements[impl->size] ) ))) return E_OUTOFMEMORY; view->IVectorView_IInspectable_iface.lpVtbl = &vector_view_vtbl; - view->IIterable_IInspectable_iface.lpVtbl = &iterable_view_vtbl; + view->IIterable_IInspectable_iface.lpVtbl = &vector_view_IIterable_IInspectable_vtbl; view->IAgileObject_iface.lpVtbl = &vector_view_IAgileObject_vtbl; view->iids = impl->iids; - view->ref = 1; + view->refcount = 1;
for (i = 0; i < impl->size; ++i) IInspectable_AddRef( (view->elements[view->size++] = impl->elements[i]) );
@@ -498,7 +350,7 @@ static HRESULT WINAPI vector_GetView( IVector_IInspectable *iface, IVectorView_I
static HRESULT WINAPI vector_IndexOf( IVector_IInspectable *iface, IInspectable *element, UINT32 *index, BOOLEAN *found ) { - struct vector *impl = impl_from_IVector_IInspectable( iface ); + struct vector *impl = vector_from_IVector_IInspectable( iface ); ULONG i;
TRACE( "iface %p, element %p, index %p, found %p.\n", iface, element, index, found ); @@ -512,7 +364,7 @@ static HRESULT WINAPI vector_IndexOf( IVector_IInspectable *iface, IInspectable
static HRESULT WINAPI vector_SetAt( IVector_IInspectable *iface, UINT32 index, IInspectable *value ) { - struct vector *impl = impl_from_IVector_IInspectable( iface ); + struct vector *impl = vector_from_IVector_IInspectable( iface );
TRACE( "iface %p, index %u, value %p.\n", iface, index, value );
@@ -524,7 +376,7 @@ static HRESULT WINAPI vector_SetAt( IVector_IInspectable *iface, UINT32 index, I
static HRESULT WINAPI vector_InsertAt( IVector_IInspectable *iface, UINT32 index, IInspectable *value ) { - struct vector *impl = impl_from_IVector_IInspectable( iface ); + struct vector *impl = vector_from_IVector_IInspectable( iface ); IInspectable **tmp = impl->elements;
TRACE( "iface %p, index %u, value %p.\n", iface, index, value ); @@ -546,7 +398,7 @@ static HRESULT WINAPI vector_InsertAt( IVector_IInspectable *iface, UINT32 index
static HRESULT WINAPI vector_RemoveAt( IVector_IInspectable *iface, UINT32 index ) { - struct vector *impl = impl_from_IVector_IInspectable( iface ); + struct vector *impl = vector_from_IVector_IInspectable( iface );
TRACE( "iface %p, index %u.\n", iface, index );
@@ -558,7 +410,7 @@ static HRESULT WINAPI vector_RemoveAt( IVector_IInspectable *iface, UINT32 index
static HRESULT WINAPI vector_Append( IVector_IInspectable *iface, IInspectable *value ) { - struct vector *impl = impl_from_IVector_IInspectable( iface ); + struct vector *impl = vector_from_IVector_IInspectable( iface );
TRACE( "iface %p, value %p.\n", iface, value );
@@ -567,7 +419,7 @@ static HRESULT WINAPI vector_Append( IVector_IInspectable *iface, IInspectable *
static HRESULT WINAPI vector_RemoveAtEnd( IVector_IInspectable *iface ) { - struct vector *impl = impl_from_IVector_IInspectable( iface ); + struct vector *impl = vector_from_IVector_IInspectable( iface );
TRACE( "iface %p.\n", iface );
@@ -577,7 +429,7 @@ static HRESULT WINAPI vector_RemoveAtEnd( IVector_IInspectable *iface )
static HRESULT WINAPI vector_Clear( IVector_IInspectable *iface ) { - struct vector *impl = impl_from_IVector_IInspectable( iface ); + struct vector *impl = vector_from_IVector_IInspectable( iface );
TRACE( "iface %p.\n", iface );
@@ -592,7 +444,7 @@ static HRESULT WINAPI vector_Clear( IVector_IInspectable *iface ) static HRESULT WINAPI vector_GetMany( IVector_IInspectable *iface, UINT32 start_index, UINT32 items_size, IInspectable **items, UINT *count ) { - struct vector *impl = impl_from_IVector_IInspectable( iface ); + struct vector *impl = vector_from_IVector_IInspectable( iface ); UINT32 i;
TRACE( "iface %p, start_index %u, items_size %u, items %p, count %p.\n", @@ -622,35 +474,13 @@ static HRESULT WINAPI vector_ReplaceAll( IVector_IInspectable *iface, UINT32 cou return hr; }
-static const struct IVector_IInspectableVtbl vector_vtbl = -{ - vector_QueryInterface, - vector_AddRef, - vector_Release, - /* IInspectable methods */ - vector_GetIids, - vector_GetRuntimeClassName, - vector_GetTrustLevel, - /* IVector<IInspectable*> methods */ - vector_GetAt, - vector_get_Size, - vector_GetView, - vector_IndexOf, - vector_SetAt, - vector_InsertAt, - vector_RemoveAt, - vector_Append, - vector_RemoveAtEnd, - vector_Clear, - vector_GetMany, - vector_ReplaceAll, -}; +INTERFACE_VTBL_IVector_IInspectable( vector );
-DEFINE_IINSPECTABLE( iterable, IIterable_IInspectable, vector, IVector_IInspectable_iface ) +INTERFACE_FWD_IIterable_IInspectable( vector, IVector_IInspectable, &object->IVector_IInspectable_iface );
-static HRESULT WINAPI iterable_First( IIterable_IInspectable *iface, IIterator_IInspectable **value ) +static HRESULT WINAPI vector_IIterable_IInspectable_First( IIterable_IInspectable *iface, IIterator_IInspectable **value ) { - struct vector *impl = impl_from_IIterable_IInspectable( iface ); + struct vector *impl = vector_from_IIterable_IInspectable( iface ); IIterable_IInspectable *iterable; IVectorView_IInspectable *view; HRESULT hr; @@ -668,20 +498,10 @@ static HRESULT WINAPI iterable_First( IIterable_IInspectable *iface, IIterator_I return hr; }
-static const struct IIterable_IInspectableVtbl iterable_vtbl = -{ - iterable_QueryInterface, - iterable_AddRef, - iterable_Release, - /* IInspectable methods */ - iterable_GetIids, - iterable_GetRuntimeClassName, - iterable_GetTrustLevel, - /* IIterable<T> methods */ - iterable_First, -}; +INTERFACE_VTBL_IIterable_IInspectable( vector_IIterable_IInspectable );
-DEFINE_IAGILEOBJECT( vector, IVector_IInspectable, &object->IVector_IInspectable_iface ); +INTERFACE_FWD_IAgileObject( vector, IVector_IInspectable, &object->IVector_IInspectable_iface ); +INTERFACE_VTBL_IAgileObject( vector_IAgileObject );
HRESULT vector_create( const struct vector_iids *iids, void **out ) { @@ -691,10 +511,10 @@ HRESULT vector_create( const struct vector_iids *iids, void **out )
if (!(impl = calloc( 1, sizeof(*impl) ))) return E_OUTOFMEMORY; impl->IVector_IInspectable_iface.lpVtbl = &vector_vtbl; - impl->IIterable_IInspectable_iface.lpVtbl = &iterable_vtbl; + impl->IIterable_IInspectable_iface.lpVtbl = &vector_IIterable_IInspectable_vtbl; impl->IAgileObject_iface.lpVtbl = &vector_IAgileObject_vtbl; impl->iids = *iids; - impl->ref = 1; + impl->refcount = 1;
*out = &impl->IVector_IInspectable_iface; TRACE( "created %p\n", *out );