Merge branch 'mr/comimpl-macros' into 'master'

include: Introduce new COM implementation helper macros.

See merge request wine/wine!6207
This commit is contained in:
Rémi Bernon 2024-11-19 22:27:27 +00:00
commit 99b942bac9
17 changed files with 921 additions and 2682 deletions

View file

@ -32,8 +32,10 @@ struct async_info
{
IWineAsyncInfoImpl IWineAsyncInfoImpl_iface;
IAsyncInfo IAsyncInfo_iface;
IInspectable *IInspectable_outer;
LONG ref;
IAgileObject IAgileObject_iface;
IInspectable *outer;
const WCHAR *class_name;
LONG refcount;
async_operation_callback callback;
TP_WORK *async_run_work;
@ -47,68 +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 )
INTERFACE_IMPL_OUTER_IWineAsyncInfoImpl( async_info, IAgileObject, IAsyncInfo, END, FIXME );
static HRESULT WINAPI async_info_put_Completed( IWineAsyncInfoImpl *iface, IWineAsyncOperationCompletedHandler *handler )
{
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_IAgileObject ) ||
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;
}
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 );
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 )
{
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 );
@ -122,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 );
@ -138,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 );
@ -154,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 );
@ -172,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, struct 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 );
@ -215,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 );
@ -230,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 );
@ -245,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 );
@ -260,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 );
@ -281,28 +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,
};
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;
@ -338,10 +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->IInspectable_outer = outer;
impl->ref = 1;
impl->IWineAsyncInfoImpl_iface.lpVtbl = &async_info_vtbl;
impl->IAsyncInfo_iface.lpVtbl = &async_info_IAsyncInfo_vtbl;
impl->IAgileObject_iface.lpVtbl = &async_info_IAgileObject_vtbl;
impl->outer = outer;
impl->refcount = 1;
impl->callback = callback;
impl->handler = HANDLER_NOT_SET;
@ -367,80 +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_IAgileObject ) ||
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 )
IUNKNOWN_IMPL_ADDREF( async_bool, IAsyncOperation_boolean );
static void async_bool_destroy( struct async_bool *impl )
{
struct async_bool *impl = impl_from_IAsyncOperation_boolean( iface );
ULONG ref = InterlockedIncrement( &impl->ref );
TRACE( "iface %p, ref %lu.\n", iface, ref );
return ref;
IWineAsyncInfoImpl_Release( impl->IWineAsyncInfoImpl_inner );
free( impl );
}
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;
}
static HRESULT WINAPI async_bool_GetRuntimeClassName( IAsyncOperation_boolean *iface, HSTRING *class_name )
{
return WindowsCreateString( L"Windows.Foundation.IAsyncOperation`1<Boolean>",
ARRAY_SIZE(L"Windows.Foundation.IAsyncOperation`1<Boolean>"),
class_name );
}
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 );
}
@ -448,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;
@ -468,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 )
@ -493,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 )))
@ -512,93 +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_IAgileObject ) ||
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 )
IUNKNOWN_IMPL_ADDREF( async_result, IAsyncOperation_ForceFeedbackLoadEffectResult );
static void async_result_destroy( struct async_result *impl )
{
struct async_result *impl = impl_from_IAsyncOperation_ForceFeedbackLoadEffectResult( iface );
ULONG ref = InterlockedIncrement( &impl->ref );
TRACE( "iface %p, ref %lu.\n", iface, ref );
return ref;
IWineAsyncInfoImpl_Release( impl->IWineAsyncInfoImpl_inner );
free( impl );
}
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;
}
static HRESULT WINAPI async_result_GetRuntimeClassName( IAsyncOperation_ForceFeedbackLoadEffectResult *iface, HSTRING *class_name )
{
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 );
}
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;
@ -611,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 )
@ -636,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 )))

View file

@ -26,91 +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_IAgileObject ) ||
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 )
IUNKNOWN_IMPL_ADDREF( condition_effect, IConditionForceEffect );
static void condition_effect_destroy( struct condition_effect *impl )
{
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;
IWineForceFeedbackEffectImpl_Release( impl->IWineForceFeedbackEffectImpl_inner );
free( impl );
}
static ULONG WINAPI effect_Release( IConditionForceEffect *iface )
IUNKNOWN_IMPL_RELEASE( condition_effect, IConditionForceEffect );
IINSPECTABLE_IMPL( condition_effect, IConditionForceEffect );
static HRESULT WINAPI condition_effect_get_Kind( IConditionForceEffect *iface, ConditionForceEffectKind *kind )
{
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;
}
static HRESULT WINAPI effect_GetRuntimeClassName( IConditionForceEffect *iface, HSTRING *class_name )
{
return WindowsCreateString( RuntimeClass_Windows_Gaming_Input_ForceFeedback_ConditionForceEffect,
ARRAY_SIZE(RuntimeClass_Windows_Gaming_Input_ForceFeedback_ConditionForceEffect),
class_name );
}
static HRESULT WINAPI effect_GetTrustLevel( IConditionForceEffect *iface, TrustLevel *trust_level )
{
FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level );
return E_NOTIMPL;
}
static HRESULT WINAPI 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 =
@ -132,114 +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;
LONG ref;
IAgileObject IAgileObject_iface;
const WCHAR *class_name;
};
static inline struct condition_factory *impl_from_IActivationFactory( IActivationFactory *iface )
{
return CONTAINING_RECORD( iface, struct condition_factory, IActivationFactory_iface );
}
INTERFACE_IMPL_STATIC_IActivationFactory( condition_factory, IConditionForceEffectFactory, IAgileObject, END, FIXME );
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_IAgileObject ) ||
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;
}
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;
}
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,
};
INTERFACE_VTBL_IActivationFactory( condition_factory );
DEFINE_IINSPECTABLE( factory, IConditionForceEffectFactory, struct condition_factory, IActivationFactory_iface )
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;
@ -248,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 )) ||
@ -265,24 +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,
};
INTERFACE_VTBL_IConditionForceEffectFactory( condition_factory_IConditionForceEffectFactory );
INTERFACE_VTBL_IAgileObject( condition_factory_IAgileObject );
static struct condition_factory condition_statics =
{
{&activation_vtbl},
{&factory_vtbl},
1,
{&condition_factory_vtbl},
{&condition_factory_IConditionForceEffectFactory_vtbl},
{&condition_factory_IAgileObject_vtbl},
RuntimeClass_Windows_Gaming_Input_ForceFeedback_ConditionForceEffect,
};
IInspectable *condition_effect_factory = (IInspectable *)&condition_statics.IActivationFactory_iface;

View file

@ -26,78 +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_IAgileObject ) ||
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 )
IUNKNOWN_IMPL_ADDREF( constant_effect, IConstantForceEffect );
static void constant_effect_destroy( struct constant_effect *impl )
{
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;
IWineForceFeedbackEffectImpl_Release( impl->IWineForceFeedbackEffectImpl_inner );
free( impl );
}
static ULONG WINAPI effect_Release( IConstantForceEffect *iface )
{
struct constant_effect *impl = impl_from_IConstantForceEffect( iface );
ULONG ref = InterlockedDecrement( &impl->ref );
IUNKNOWN_IMPL_RELEASE( constant_effect, IConstantForceEffect );
IINSPECTABLE_IMPL( constant_effect, IConstantForceEffect );
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( 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;
}
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 =
{
@ -110,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 )
@ -141,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 ),
@ -151,86 +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;
LONG ref;
IAgileObject IAgileObject_iface;
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, FIXME );
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_IAgileObject ) ||
IsEqualGUID( iid, &IID_IActivationFactory ))
{
IInspectable_AddRef( (*out = &impl->IActivationFactory_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;
@ -238,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 )))
@ -253,23 +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,
};
INTERFACE_VTBL_IActivationFactory( constant_factory );
INTERFACE_VTBL_IAgileObject( constant_factory_IAgileObject );
static struct constant_factory constant_statics =
{
{&activation_vtbl},
1,
{&constant_factory_vtbl},
{&constant_factory_IAgileObject_vtbl},
RuntimeClass_Windows_Gaming_Input_ForceFeedback_ConstantForceEffect,
};
IInspectable *constant_effect_factory = (IInspectable *)&constant_statics.IActivationFactory_iface;

View file

@ -62,109 +62,33 @@ struct controller
IGameControllerInputSink IGameControllerInputSink_iface;
IRawGameController IRawGameController_iface;
IRawGameController2 IRawGameController2_iface;
IGameController *IGameController_outer;
LONG ref;
IInspectable *outer;
const WCHAR *class_name;
LONG refcount;
IGameControllerProvider *provider;
IWineGameControllerProvider *wine_provider;
};
static inline struct controller *impl_from_IGameControllerImpl( IGameControllerImpl *iface )
static void controller_destroy( struct controller *impl )
{
return CONTAINING_RECORD( iface, struct controller, 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 controller *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_IRawGameController ))
{
IInspectable_AddRef( (*out = &impl->IRawGameController_iface) );
return S_OK;
}
if (IsEqualGUID( iid, &IID_IRawGameController2 ))
{
IInspectable_AddRef( (*out = &impl->IRawGameController2_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 controller *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 controller *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_RawGameController,
ARRAY_SIZE(RuntimeClass_Windows_Gaming_Input_RawGameController),
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;
}
INTERFACE_IMPL_OUTER_IGameControllerImpl( controller, IGameControllerInputSink,
IRawGameController, IRawGameController2, END, FIXME );
static HRESULT WINAPI controller_Initialize( IGameControllerImpl *iface, IGameController *outer,
IGameControllerProvider *provider )
{
struct controller *impl = impl_from_IGameControllerImpl( iface );
struct controller *impl = controller_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,62 +103,36 @@ 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,
};
INTERFACE_VTBL_IGameControllerImpl( controller );
DEFINE_IINSPECTABLE_OUTER( input_sink, IGameControllerInputSink, struct controller, IGameController_outer )
static HRESULT WINAPI input_sink_OnInputResumed( IGameControllerInputSink *iface, UINT64 timestamp )
static HRESULT WINAPI controller_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 controller_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,
};
INTERFACE_VTBL_IGameControllerInputSink( controller_IGameControllerInputSink );
DEFINE_IINSPECTABLE_OUTER( raw_controller, IRawGameController, struct controller, IGameController_outer )
static HRESULT WINAPI raw_controller_get_AxisCount( IRawGameController *iface, INT32 *value )
static HRESULT WINAPI controller_IRawGameController_get_AxisCount( IRawGameController *iface, INT32 *value )
{
struct controller *impl = impl_from_IRawGameController( iface );
struct controller *impl = controller_from_IRawGameController( iface );
return IWineGameControllerProvider_get_AxisCount( impl->wine_provider, value );
}
static HRESULT WINAPI raw_controller_get_ButtonCount( IRawGameController *iface, INT32 *value )
static HRESULT WINAPI controller_IRawGameController_get_ButtonCount( IRawGameController *iface, INT32 *value )
{
struct controller *impl = impl_from_IRawGameController( iface );
struct controller *impl = controller_from_IRawGameController( iface );
return IWineGameControllerProvider_get_ButtonCount( impl->wine_provider, value );
}
static HRESULT WINAPI raw_controller_get_ForceFeedbackMotors( IRawGameController *iface, IVectorView_ForceFeedbackMotor **value )
static HRESULT WINAPI controller_IRawGameController_get_ForceFeedbackMotors( IRawGameController *iface,
IVectorView_ForceFeedbackMotor **value )
{
static const struct vector_iids iids =
{
@ -243,7 +141,7 @@ static HRESULT WINAPI raw_controller_get_ForceFeedbackMotors( IRawGameController
.iterable = &IID_IIterable_ForceFeedbackMotor,
.iterator = &IID_IIterator_ForceFeedbackMotor,
};
struct controller *impl = impl_from_IRawGameController( iface );
struct controller *impl = controller_from_IRawGameController( iface );
IVector_ForceFeedbackMotor *vector;
IForceFeedbackMotor *motor;
HRESULT hr;
@ -264,36 +162,37 @@ static HRESULT WINAPI raw_controller_get_ForceFeedbackMotors( IRawGameController
return hr;
}
static HRESULT WINAPI raw_controller_get_HardwareProductId( IRawGameController *iface, UINT16 *value )
static HRESULT WINAPI controller_IRawGameController_get_HardwareProductId( IRawGameController *iface, UINT16 *value )
{
struct controller *impl = impl_from_IRawGameController( iface );
struct controller *impl = controller_from_IRawGameController( iface );
return IGameControllerProvider_get_HardwareProductId( impl->provider, value );
}
static HRESULT WINAPI raw_controller_get_HardwareVendorId( IRawGameController *iface, UINT16 *value )
static HRESULT WINAPI controller_IRawGameController_get_HardwareVendorId( IRawGameController *iface, UINT16 *value )
{
struct controller *impl = impl_from_IRawGameController( iface );
struct controller *impl = controller_from_IRawGameController( iface );
return IGameControllerProvider_get_HardwareVendorId( impl->provider, value );
}
static HRESULT WINAPI raw_controller_get_SwitchCount( IRawGameController *iface, INT32 *value )
static HRESULT WINAPI controller_IRawGameController_get_SwitchCount( IRawGameController *iface, INT32 *value )
{
struct controller *impl = impl_from_IRawGameController( iface );
struct controller *impl = controller_from_IRawGameController( iface );
return IWineGameControllerProvider_get_SwitchCount( impl->wine_provider, value );
}
static HRESULT WINAPI raw_controller_GetButtonLabel( IRawGameController *iface, INT32 index,
enum GameControllerButtonLabel *value )
static HRESULT WINAPI controller_IRawGameController_GetButtonLabel( IRawGameController *iface, INT32 index,
enum GameControllerButtonLabel *value )
{
FIXME( "iface %p, index %d, value %p stub!\n", iface, index, value );
return E_NOTIMPL;
}
static HRESULT WINAPI raw_controller_GetCurrentReading( IRawGameController *iface, UINT32 buttons_size, BOOLEAN *buttons,
UINT32 switches_size, enum GameControllerSwitchPosition *switches,
UINT32 axes_size, DOUBLE *axes, UINT64 *timestamp )
static HRESULT WINAPI
controller_IRawGameController_GetCurrentReading( IRawGameController *iface, UINT32 buttons_size, BOOLEAN *buttons,
UINT32 switches_size, enum GameControllerSwitchPosition *switches,
UINT32 axes_size, DOUBLE *axes, UINT64 *timestamp )
{
struct controller *impl = impl_from_IRawGameController( iface );
struct controller *impl = controller_from_IRawGameController( iface );
WineGameControllerState state;
HRESULT hr;
@ -310,36 +209,18 @@ static HRESULT WINAPI raw_controller_GetCurrentReading( IRawGameController *ifac
return hr;
}
static HRESULT WINAPI raw_controller_GetSwitchKind( IRawGameController *iface, INT32 index, enum GameControllerSwitchKind *value )
static HRESULT WINAPI controller_IRawGameController_GetSwitchKind( IRawGameController *iface, INT32 index,
enum GameControllerSwitchKind *value )
{
FIXME( "iface %p, index %d, value %p stub!\n", iface, index, value );
return E_NOTIMPL;
}
static const struct IRawGameControllerVtbl raw_controller_vtbl =
{
raw_controller_QueryInterface,
raw_controller_AddRef,
raw_controller_Release,
/* IInspectable methods */
raw_controller_GetIids,
raw_controller_GetRuntimeClassName,
raw_controller_GetTrustLevel,
/* IRawGameController methods */
raw_controller_get_AxisCount,
raw_controller_get_ButtonCount,
raw_controller_get_ForceFeedbackMotors,
raw_controller_get_HardwareProductId,
raw_controller_get_HardwareVendorId,
raw_controller_get_SwitchCount,
raw_controller_GetButtonLabel,
raw_controller_GetCurrentReading,
raw_controller_GetSwitchKind,
};
INTERFACE_VTBL_IRawGameController( controller_IRawGameController );
DEFINE_IINSPECTABLE_OUTER( raw_controller_2, IRawGameController2, struct controller, IGameController_outer )
static HRESULT WINAPI raw_controller_2_get_SimpleHapticsControllers( IRawGameController2 *iface, IVectorView_SimpleHapticsController** value)
static HRESULT WINAPI
controller_IRawGameController2_get_SimpleHapticsControllers( IRawGameController2 *iface,
IVectorView_SimpleHapticsController **value )
{
static const struct vector_iids iids =
{
@ -362,164 +243,78 @@ static HRESULT WINAPI raw_controller_2_get_SimpleHapticsControllers( IRawGameCon
return hr;
}
static HRESULT WINAPI raw_controller_2_get_NonRoamableId( IRawGameController2 *iface, HSTRING* value )
static HRESULT WINAPI controller_IRawGameController2_get_NonRoamableId( IRawGameController2 *iface, HSTRING *value )
{
FIXME( "iface %p, value %p stub!\n", iface, value );
return E_NOTIMPL;
}
static HRESULT WINAPI raw_controller_2_get_DisplayName( IRawGameController2 *iface, HSTRING* value )
static HRESULT WINAPI controller_IRawGameController2_get_DisplayName( IRawGameController2 *iface, HSTRING *value )
{
FIXME( "iface %p, value %p stub!\n", iface, value );
return E_NOTIMPL;
}
static const struct IRawGameController2Vtbl raw_controller_2_vtbl =
{
raw_controller_2_QueryInterface,
raw_controller_2_AddRef,
raw_controller_2_Release,
/* IInspectable methods */
raw_controller_2_GetIids,
raw_controller_2_GetRuntimeClassName,
raw_controller_2_GetTrustLevel,
/* IRawGameController2 methods */
raw_controller_2_get_SimpleHapticsControllers,
raw_controller_2_get_NonRoamableId,
raw_controller_2_get_DisplayName,
};
INTERFACE_VTBL_IRawGameController2( controller_IRawGameController2 );
struct controller_statics
{
IActivationFactory IActivationFactory_iface;
IRawGameControllerStatics IRawGameControllerStatics_iface;
ICustomGameControllerFactory ICustomGameControllerFactory_iface;
LONG ref;
IAgileObject IAgileObject_iface;
const WCHAR *class_name;
};
static inline struct controller_statics *impl_from_IActivationFactory( IActivationFactory *iface )
{
return CONTAINING_RECORD( iface, struct controller_statics, IActivationFactory_iface );
}
INTERFACE_IMPL_STATIC_IActivationFactory( controller_statics, IRawGameControllerStatics,
ICustomGameControllerFactory, IAgileObject, END, FIXME );
static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID iid, void **out )
{
struct controller_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_IAgileObject ) ||
IsEqualGUID( iid, &IID_IActivationFactory ))
{
IInspectable_AddRef( (*out = &impl->IActivationFactory_iface) );
return S_OK;
}
if (IsEqualGUID( iid, &IID_IRawGameControllerStatics ))
{
IInspectable_AddRef( (*out = &impl->IRawGameControllerStatics_iface) );
return S_OK;
}
if (IsEqualGUID( iid, &IID_ICustomGameControllerFactory ))
{
IInspectable_AddRef( (*out = &impl->ICustomGameControllerFactory_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 controller_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 controller_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 controller_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,
};
INTERFACE_VTBL_IActivationFactory( controller_statics );
INTERFACE_VTBL_IAgileObject( controller_statics_IAgileObject );
DEFINE_IINSPECTABLE( statics, IRawGameControllerStatics, struct controller_statics, IActivationFactory_iface )
static HRESULT WINAPI statics_add_RawGameControllerAdded( IRawGameControllerStatics *iface,
IEventHandler_RawGameController *handler,
EventRegistrationToken *token )
static HRESULT WINAPI
controller_statics_IRawGameControllerStatics_add_RawGameControllerAdded( IRawGameControllerStatics *iface,
IEventHandler_RawGameController *handler,
EventRegistrationToken *token )
{
TRACE( "iface %p, handler %p, token %p.\n", iface, handler, token );
if (!handler) return E_INVALIDARG;
return event_handlers_append( &controller_added_handlers, (IEventHandler_IInspectable *)handler, token );
}
static HRESULT WINAPI statics_remove_RawGameControllerAdded( IRawGameControllerStatics *iface, EventRegistrationToken token )
static HRESULT WINAPI
controller_statics_IRawGameControllerStatics_remove_RawGameControllerAdded( IRawGameControllerStatics *iface, EventRegistrationToken token )
{
TRACE( "iface %p, token %#I64x.\n", iface, token.value );
return event_handlers_remove( &controller_added_handlers, &token );
}
static HRESULT WINAPI statics_add_RawGameControllerRemoved( IRawGameControllerStatics *iface,
IEventHandler_RawGameController *handler,
EventRegistrationToken *token )
static HRESULT WINAPI
controller_statics_IRawGameControllerStatics_add_RawGameControllerRemoved( IRawGameControllerStatics *iface,
IEventHandler_RawGameController *handler,
EventRegistrationToken *token )
{
TRACE( "iface %p, handler %p, token %p.\n", iface, handler, token );
if (!handler) return E_INVALIDARG;
return event_handlers_append( &controller_removed_handlers, (IEventHandler_IInspectable *)handler, token );
}
static HRESULT WINAPI statics_remove_RawGameControllerRemoved( IRawGameControllerStatics *iface, EventRegistrationToken token )
static HRESULT WINAPI
controller_statics_IRawGameControllerStatics_remove_RawGameControllerRemoved( IRawGameControllerStatics *iface, EventRegistrationToken token )
{
TRACE( "iface %p, token %#I64x.\n", iface, token.value );
return event_handlers_remove( &controller_removed_handlers, &token );
}
static HRESULT WINAPI statics_get_RawGameControllers( IRawGameControllerStatics *iface, IVectorView_RawGameController **value )
static HRESULT WINAPI
controller_statics_IRawGameControllerStatics_get_RawGameControllers( IRawGameControllerStatics *iface,
IVectorView_RawGameController **value )
{
HRESULT hr;
@ -533,10 +328,11 @@ static HRESULT WINAPI statics_get_RawGameControllers( IRawGameControllerStatics
return hr;
}
static HRESULT WINAPI statics_FromGameController( IRawGameControllerStatics *iface, IGameController *game_controller,
IRawGameController **value )
static HRESULT WINAPI
controller_statics_IRawGameControllerStatics_FromGameController( IRawGameControllerStatics *iface, IGameController *game_controller,
IRawGameController **value )
{
struct controller_statics *impl = impl_from_IRawGameControllerStatics( iface );
struct controller_statics *impl = controller_statics_from_IRawGameControllerStatics( iface );
IGameController *controller;
HRESULT hr;
@ -553,28 +349,11 @@ static HRESULT WINAPI statics_FromGameController( IRawGameControllerStatics *ifa
return hr;
}
static const struct IRawGameControllerStaticsVtbl statics_vtbl =
{
statics_QueryInterface,
statics_AddRef,
statics_Release,
/* IInspectable methods */
statics_GetIids,
statics_GetRuntimeClassName,
statics_GetTrustLevel,
/* IRawGameControllerStatics methods */
statics_add_RawGameControllerAdded,
statics_remove_RawGameControllerAdded,
statics_add_RawGameControllerRemoved,
statics_remove_RawGameControllerRemoved,
statics_get_RawGameControllers,
statics_FromGameController,
};
INTERFACE_VTBL_IRawGameControllerStatics( controller_statics_IRawGameControllerStatics );
DEFINE_IINSPECTABLE( controller_factory, ICustomGameControllerFactory, struct controller_statics, IActivationFactory_iface )
static HRESULT WINAPI controller_factory_CreateGameController( ICustomGameControllerFactory *iface, IGameControllerProvider *provider,
IInspectable **value )
static HRESULT WINAPI
controller_statics_ICustomGameControllerFactory_CreateGameController( ICustomGameControllerFactory *iface,
IGameControllerProvider *provider, IInspectable **value )
{
struct controller *impl;
@ -582,10 +361,11 @@ static HRESULT WINAPI controller_factory_CreateGameController( ICustomGameContro
if (!(impl = calloc( 1, sizeof(*impl) ))) return E_OUTOFMEMORY;
impl->IGameControllerImpl_iface.lpVtbl = &controller_vtbl;
impl->IGameControllerInputSink_iface.lpVtbl = &input_sink_vtbl;
impl->IRawGameController_iface.lpVtbl = &raw_controller_vtbl;
impl->IRawGameController2_iface.lpVtbl = &raw_controller_2_vtbl;
impl->ref = 1;
impl->IGameControllerInputSink_iface.lpVtbl = &controller_IGameControllerInputSink_vtbl;
impl->IRawGameController_iface.lpVtbl = &controller_IRawGameController_vtbl;
impl->IRawGameController2_iface.lpVtbl = &controller_IRawGameController2_vtbl;
impl->class_name = RuntimeClass_Windows_Gaming_Input_RawGameController;
impl->refcount = 1;
TRACE( "created RawGameController %p\n", impl );
@ -593,7 +373,8 @@ static HRESULT WINAPI controller_factory_CreateGameController( ICustomGameContro
return S_OK;
}
static HRESULT WINAPI controller_factory_OnGameControllerAdded( ICustomGameControllerFactory *iface, IGameController *value )
static HRESULT WINAPI
controller_statics_ICustomGameControllerFactory_OnGameControllerAdded( ICustomGameControllerFactory *iface, IGameController *value )
{
IRawGameController *controller;
HRESULT hr;
@ -608,7 +389,8 @@ static HRESULT WINAPI controller_factory_OnGameControllerAdded( ICustomGameContr
return S_OK;
}
static HRESULT WINAPI controller_factory_OnGameControllerRemoved( ICustomGameControllerFactory *iface, IGameController *value )
static HRESULT WINAPI
controller_statics_ICustomGameControllerFactory_OnGameControllerRemoved( ICustomGameControllerFactory *iface, IGameController *value )
{
IRawGameController *controller;
BOOLEAN found;
@ -642,27 +424,15 @@ 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,
};
INTERFACE_VTBL_ICustomGameControllerFactory( controller_statics_ICustomGameControllerFactory );
static struct controller_statics controller_statics =
{
{&factory_vtbl},
{&statics_vtbl},
{&controller_factory_vtbl},
1,
{&controller_statics_vtbl},
{&controller_statics_IRawGameControllerStatics_vtbl},
{&controller_statics_ICustomGameControllerFactory_vtbl},
{&controller_statics_IAgileObject_vtbl},
RuntimeClass_Windows_Gaming_Input_RawGameController,
};
ICustomGameControllerFactory *controller_factory = &controller_statics.ICustomGameControllerFactory_iface;

View file

@ -34,8 +34,10 @@ struct effect
{
IWineForceFeedbackEffectImpl IWineForceFeedbackEffectImpl_iface;
IForceFeedbackEffect IForceFeedbackEffect_iface;
IInspectable *IInspectable_outer;
LONG ref;
IAgileObject IAgileObject_iface;
IInspectable *outer;
const WCHAR *class_name;
LONG refcount;
CRITICAL_SECTION cs;
IDirectInputEffect *effect;
@ -52,62 +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_IAgileObject ) ||
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;
}
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, FIXME );
static int effect_reorient_direction( const WineForceFeedbackEffectParameters *params, Vector3 *direction )
{
@ -149,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;
@ -235,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, struct 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 );
@ -259,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 );
@ -275,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;
@ -298,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;
@ -313,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 );
@ -327,22 +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,
};
INTERFACE_VTBL_IForceFeedbackEffect( effect_IForceFeedbackEffect );
INTERFACE_VTBL_IAgileObject( effect_IAgileObject );
HRESULT force_feedback_effect_create( enum WineForceFeedbackEffectType type, IInspectable *outer, IWineForceFeedbackEffectImpl **out )
{
@ -351,10 +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->IInspectable_outer = outer;
impl->ref = 1;
impl->IWineForceFeedbackEffectImpl_iface.lpVtbl = &effect_vtbl;
impl->IForceFeedbackEffect_iface.lpVtbl = &effect_IForceFeedbackEffect_vtbl;
impl->IAgileObject_iface.lpVtbl = &effect_IAgileObject_vtbl;
impl->outer = outer;
impl->refcount = 1;
switch (type)
{
@ -431,82 +364,24 @@ HRESULT force_feedback_effect_create( enum WineForceFeedbackEffectType type, IIn
struct motor
{
IForceFeedbackMotor IForceFeedbackMotor_iface;
LONG ref;
IAgileObject IAgileObject_iface;
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_IAgileObject ) ||
IsEqualGUID( iid, &IID_IForceFeedbackMotor ))
{
IInspectable_AddRef( (*out = &impl->IForceFeedbackMotor_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, FIXME );
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;
@ -520,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 =
@ -542,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 =
@ -561,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;
@ -589,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 );
@ -603,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;
@ -667,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 );
@ -676,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 );
@ -685,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 );
@ -694,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 );
@ -712,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 );
@ -730,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 );
@ -748,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;
@ -772,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 );
@ -785,30 +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,
};
INTERFACE_VTBL_IForceFeedbackMotor( motor );
INTERFACE_VTBL_IAgileObject( motor_IAgileObject );
HRESULT force_feedback_motor_create( IDirectInputDevice8W *device, IForceFeedbackMotor **out )
{
@ -823,7 +676,9 @@ HRESULT force_feedback_motor_create( IDirectInputDevice8W *device, IForceFeedbac
if (!(impl = calloc( 1, sizeof(*impl) ))) return E_OUTOFMEMORY;
impl->IForceFeedbackMotor_iface.lpVtbl = &motor_vtbl;
impl->ref = 1;
impl->IAgileObject_iface.lpVtbl = &motor_IAgileObject_vtbl;
impl->class_name = RuntimeClass_Windows_Gaming_Input_ForceFeedback_ForceFeedbackMotor;
impl->refcount = 1;
IDirectInputDevice_AddRef( device );
impl->device = device;

View file

@ -62,8 +62,9 @@ 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;
@ -72,102 +73,25 @@ struct gamepad
BOOL state_changed;
};
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 );
INTERFACE_IMPL_OUTER_IGameControllerImpl( gamepad, IGameControllerInputSink, IGamepad, IGamepad2, END, FIXME );
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;
}
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,
@ -186,52 +110,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,
};
INTERFACE_VTBL_IGameControllerImpl( gamepad );
DEFINE_IINSPECTABLE_OUTER( input_sink, IGameControllerInputSink, struct gamepad, IGameController_outer )
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,
};
INTERFACE_VTBL_IGameControllerInputSink( gamepad_IGameControllerInputSink );
DEFINE_IINSPECTABLE_OUTER( gamepad, IGamepad, struct gamepad, IGameController_outer )
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;
@ -247,9 +144,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.,
@ -263,9 +160,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;
@ -334,42 +231,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,
};
INTERFACE_VTBL_IGamepad( gamepad_IGamepad );
DEFINE_IINSPECTABLE_OUTER( gamepad2, IGamepad2, struct gamepad, IGameController_outer )
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
{
@ -377,108 +248,22 @@ struct gamepad_statics
IGamepadStatics IGamepadStatics_iface;
IGamepadStatics2 IGamepadStatics2_iface;
ICustomGameControllerFactory ICustomGameControllerFactory_iface;
LONG ref;
IAgileObject IAgileObject_iface;
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, FIXME );
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_IAgileObject ) ||
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;
}
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,
};
INTERFACE_VTBL_IActivationFactory( gamepad_statics );
DEFINE_IINSPECTABLE( statics, IGamepadStatics, struct gamepad_statics, IActivationFactory_iface )
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 );
@ -486,13 +271,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 );
@ -500,13 +285,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;
@ -520,28 +305,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,
};
INTERFACE_VTBL_IGamepadStatics( gamepad_statics_IGamepadStatics );
DEFINE_IINSPECTABLE( statics2, IGamepadStatics2, struct gamepad_statics, IActivationFactory_iface )
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;
@ -557,22 +325,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,
};
INTERFACE_VTBL_IGamepadStatics2( gamepad_statics_IGamepadStatics2 );
DEFINE_IINSPECTABLE( controller_factory, ICustomGameControllerFactory, struct gamepad_statics, IActivationFactory_iface )
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;
@ -580,11 +335,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 );
@ -592,7 +348,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;
@ -607,7 +363,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;
@ -641,28 +397,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,
};
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},
1,
{&gamepad_statics_vtbl},
{&gamepad_statics_IGamepadStatics_vtbl},
{&gamepad_statics_IGamepadStatics2_vtbl},
{&gamepad_statics_ICustomGameControllerFactory_vtbl},
{&gamepad_statics_IAgileObject_vtbl},
RuntimeClass_Windows_Gaming_Input_Gamepad,
};
ICustomGameControllerFactory *gamepad_factory = &gamepad_statics.ICustomGameControllerFactory_iface;

View file

@ -39,70 +39,39 @@ struct controller
{
IGameController IGameController_iface;
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_IAgileObject ) ||
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;
}
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 )
IUNKNOWN_IMPL_ADDREF( controller, IGameController );
static void controller_destroy( struct controller *impl )
{
struct controller *impl = impl_from_IGameController( iface );
ULONG ref = InterlockedIncrement( &impl->ref );
TRACE( "iface %p increasing refcount to %lu.\n", iface, ref );
return ref;
IInspectable_Release( impl->IInspectable_inner );
ICustomGameControllerFactory_Release( impl->factory );
IGameControllerProvider_Release( impl->provider );
free( impl );
}
static ULONG WINAPI controller_Release( IGameController *iface )
{
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;
}
IUNKNOWN_IMPL_RELEASE( controller, IGameController );
static HRESULT WINAPI controller_GetIids( IGameController *iface, ULONG *iid_count, IID **iids )
{
@ -112,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 );
}
@ -180,150 +149,43 @@ 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, struct 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 );
INTERFACE_FWD_IAgileObject( controller, IGameController, &object->IGameController_iface );
INTERFACE_VTBL_IAgileObject( controller_IAgileObject );
struct manager_statics
{
IActivationFactory IActivationFactory_iface;
IGameControllerFactoryManagerStatics IGameControllerFactoryManagerStatics_iface;
IGameControllerFactoryManagerStatics2 IGameControllerFactoryManagerStatics2_iface;
LONG ref;
IAgileObject IAgileObject_iface;
const WCHAR *class_name;
};
static inline struct manager_statics *impl_from_IActivationFactory( IActivationFactory *iface )
{
return CONTAINING_RECORD( iface, struct manager_statics, IActivationFactory_iface );
}
INTERFACE_IMPL_STATIC_IActivationFactory( manager_statics, IGameControllerFactoryManagerStatics,
IGameControllerFactoryManagerStatics2, IAgileObject, END, FIXME )
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_IAgileObject ) ||
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;
}
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, struct 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 )
{
@ -332,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 )
{
@ -341,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 )
{
@ -349,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, struct 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 )
{
@ -403,25 +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,
};
INTERFACE_VTBL_IGameControllerFactoryManagerStatics2( manager_statics_IGameControllerFactoryManagerStatics2 );
INTERFACE_VTBL_IAgileObject( manager_statics_IAgileObject );
static struct manager_statics manager_statics =
{
{&factory_vtbl},
{&statics_vtbl},
{&statics2_vtbl},
1,
{&manager_statics_vtbl},
{&manager_statics_IGameControllerFactoryManagerStatics_vtbl},
{&manager_statics_IGameControllerFactoryManagerStatics2_vtbl},
{&manager_statics_IAgileObject_vtbl},
RuntimeClass_Windows_Gaming_Input_Custom_GameControllerFactoryManager,
};
IGameControllerFactoryManagerStatics2 *manager_factory = &manager_statics.IGameControllerFactoryManagerStatics2_iface;
@ -435,8 +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->ref = 1;
impl->IGameControllerBatteryInfo_iface.lpVtbl = &controller_IGameControllerBatteryInfo_vtbl;
impl->IAgileObject_iface.lpVtbl = &controller_IAgileObject_vtbl;
impl->refcount = 1;
if (FAILED(hr = ICustomGameControllerFactory_CreateGameController( factory, provider, &impl->IInspectable_inner )))
WARN( "Failed to create game controller, hr %#lx\n", hr );

View file

@ -26,91 +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_IAgileObject ) ||
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 )
IUNKNOWN_IMPL_ADDREF( periodic_effect, IPeriodicForceEffect );
static void periodic_effect_destroy( struct periodic_effect *impl )
{
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;
IWineForceFeedbackEffectImpl_Release( impl->IWineForceFeedbackEffectImpl_inner );
free( impl );
}
static ULONG WINAPI effect_Release( IPeriodicForceEffect *iface )
IUNKNOWN_IMPL_RELEASE( periodic_effect, IPeriodicForceEffect );
IINSPECTABLE_IMPL( periodic_effect, IPeriodicForceEffect );
static HRESULT WINAPI periodic_effect_get_Kind( IPeriodicForceEffect *iface, PeriodicForceEffectKind *kind )
{
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;
}
static HRESULT WINAPI effect_GetRuntimeClassName( IPeriodicForceEffect *iface, HSTRING *class_name )
{
return WindowsCreateString( RuntimeClass_Windows_Gaming_Input_ForceFeedback_PeriodicForceEffect,
ARRAY_SIZE(RuntimeClass_Windows_Gaming_Input_ForceFeedback_PeriodicForceEffect),
class_name );
}
static HRESULT WINAPI effect_GetTrustLevel( IPeriodicForceEffect *iface, TrustLevel *trust_level )
{
FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level );
return E_NOTIMPL;
}
static HRESULT WINAPI 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 =
@ -132,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 =
@ -169,115 +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;
LONG ref;
IAgileObject IAgileObject_iface;
const WCHAR *class_name;
};
static inline struct periodic_factory *impl_from_IActivationFactory( IActivationFactory *iface )
{
return CONTAINING_RECORD( iface, struct periodic_factory, IActivationFactory_iface );
}
INTERFACE_IMPL_STATIC_IActivationFactory( periodic_factory, IPeriodicForceEffectFactory, IAgileObject, END, FIXME )
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_IAgileObject ) ||
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;
}
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;
}
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,
};
INTERFACE_VTBL_IActivationFactory( periodic_factory );
DEFINE_IINSPECTABLE( factory, IPeriodicForceEffectFactory, struct periodic_factory, IActivationFactory_iface )
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;
@ -286,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 )) ||
@ -303,24 +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,
};
INTERFACE_VTBL_IPeriodicForceEffectFactory( periodic_factory_IPeriodicForceEffectFactory );
INTERFACE_VTBL_IAgileObject( periodic_factory_IAgileObject );
static struct periodic_factory periodic_statics =
{
{&activation_vtbl},
{&factory_vtbl},
1,
{&periodic_factory_vtbl},
{&periodic_factory_IPeriodicForceEffectFactory_vtbl},
{&periodic_factory_IAgileObject_vtbl},
RuntimeClass_Windows_Gaming_Input_ForceFeedback_PeriodicForceEffect,
};
IInspectable *periodic_effect_factory = (IInspectable *)&periodic_statics.IActivationFactory_iface;

View file

@ -39,6 +39,7 @@
#define WIDL_using_Windows_Gaming_Input_ForceFeedback
#include "windows.gaming.input.custom.h"
#include "wine/comimpl.h"
#include "wine/debug.h"
#include "wine/list.h"
@ -82,46 +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 ) \
static inline impl_type *impl_from( iface_type *iface ) \
{ \
return CONTAINING_RECORD( iface, impl_type, iface_mem ); \
} \
static HRESULT WINAPI pfx##_QueryInterface( iface_type *iface, REFIID iid, void **out ) \
{ \
impl_type *impl = impl_from( iface ); \
return IInspectable_QueryInterface( (IInspectable *)(expr), iid, out ); \
} \
static ULONG WINAPI pfx##_AddRef( iface_type *iface ) \
{ \
impl_type *impl = impl_from( iface ); \
return IInspectable_AddRef( (IInspectable *)(expr) ); \
} \
static ULONG WINAPI pfx##_Release( iface_type *iface ) \
{ \
impl_type *impl = impl_from( iface ); \
return IInspectable_Release( (IInspectable *)(expr) ); \
} \
static HRESULT WINAPI pfx##_GetIids( iface_type *iface, ULONG *iid_count, IID **iids ) \
{ \
impl_type *impl = impl_from( iface ); \
return IInspectable_GetIids( (IInspectable *)(expr), iid_count, iids ); \
} \
static HRESULT WINAPI pfx##_GetRuntimeClassName( iface_type *iface, HSTRING *class_name ) \
{ \
impl_type *impl = impl_from( iface ); \
return IInspectable_GetRuntimeClassName( (IInspectable *)(expr), class_name ); \
} \
static HRESULT WINAPI pfx##_GetTrustLevel( iface_type *iface, TrustLevel *trust_level ) \
{ \
impl_type *impl = impl_from( iface ); \
return IInspectable_GetTrustLevel( (IInspectable *)(expr), trust_level ); \
}
#define DEFINE_IINSPECTABLE( pfx, iface_type, impl_type, base_iface ) \
DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from_##iface_type, iface_type##_iface, &impl->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, impl->outer_iface )
static inline const char *debugstr_vector3( const Vector3 *vector )
{
if (!vector) return "(null)";

View file

@ -46,7 +46,9 @@ struct provider
{
IWineGameControllerProvider IWineGameControllerProvider_iface;
IGameControllerProvider IGameControllerProvider_iface;
LONG ref;
IAgileObject IAgileObject_iface;
const WCHAR *class_name;
LONG refcount;
IDirectInputDevice8W *dinput_device;
WCHAR device_path[MAX_PATH];
@ -65,81 +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_IAgileObject ) ||
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;
}
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, FIXME );
static BOOL CALLBACK count_ffb_axes( const DIDEVICEOBJECTINSTANCEW *obj, void *args )
{
@ -148,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;
@ -175,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;
@ -188,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;
@ -201,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;
@ -214,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;
@ -277,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;
@ -329,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;
@ -344,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,
};
INTERFACE_VTBL_IWineGameControllerProvider( provider );
DEFINE_IINSPECTABLE( game_provider, IGameControllerProvider, struct provider, IWineGameControllerProvider_iface )
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 );
@ -385,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 );
@ -398,34 +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,
};
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 )
@ -571,11 +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 );

View file

@ -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);

View file

@ -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 );
INTERFACE_IMPL_OUTER_IGameControllerImpl( racing_wheel, IGameControllerInputSink, IRacingWheel, END, FIXME );
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;
}
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,
};
INTERFACE_VTBL_IGameControllerImpl( racing_wheel );
DEFINE_IINSPECTABLE_OUTER( input_sink, IGameControllerInputSink, struct racing_wheel, IGameController_outer )
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,
};
INTERFACE_VTBL_IGameControllerInputSink( racing_wheel_IGameControllerInputSink );
DEFINE_IINSPECTABLE_OUTER( racing_wheel, IRacingWheel, struct racing_wheel, IGameController_outer )
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
{
@ -291,108 +177,22 @@ struct racing_wheel_statics
IRacingWheelStatics IRacingWheelStatics_iface;
IRacingWheelStatics2 IRacingWheelStatics2_iface;
ICustomGameControllerFactory ICustomGameControllerFactory_iface;
LONG ref;
IAgileObject IAgileObject_iface;
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, FIXME );
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_IAgileObject ) ||
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;
}
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,
};
INTERFACE_VTBL_IActivationFactory( racing_wheel_statics );
DEFINE_IINSPECTABLE( statics, IRacingWheelStatics, struct racing_wheel_statics, IActivationFactory_iface )
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 );
@ -400,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 );
@ -414,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;
@ -433,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,
};
INTERFACE_VTBL_IRacingWheelStatics( racing_wheel_statics_IRacingWheelStatics );
DEFINE_IINSPECTABLE( statics2, IRacingWheelStatics2, struct racing_wheel_statics, IActivationFactory_iface )
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;
@ -470,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,
};
INTERFACE_VTBL_IRacingWheelStatics2( racing_wheel_statics_IRacingWheelStatics2 );
DEFINE_IINSPECTABLE( controller_factory, ICustomGameControllerFactory, struct racing_wheel_statics, IActivationFactory_iface )
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;
@ -493,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 );
@ -504,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;
@ -519,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;
@ -553,28 +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,
};
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},
1,
{&racing_wheel_statics_vtbl},
{&racing_wheel_statics_IRacingWheelStatics_vtbl},
{&racing_wheel_statics_IRacingWheelStatics2_vtbl},
{&racing_wheel_statics_ICustomGameControllerFactory_vtbl},
{&racing_wheel_statics_IAgileObject_vtbl},
RuntimeClass_Windows_Gaming_Input_RacingWheel,
};
ICustomGameControllerFactory *racing_wheel_factory = &racing_wheel_statics.ICustomGameControllerFactory_iface;

View file

@ -26,78 +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_IAgileObject ) ||
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 )
IUNKNOWN_IMPL_ADDREF( ramp_effect, IRampForceEffect );
static void ramp_effect_destroy( struct ramp_effect *impl )
{
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;
IWineForceFeedbackEffectImpl_Release( impl->IWineForceFeedbackEffectImpl_inner );
free( impl );
}
static ULONG WINAPI effect_Release( IRampForceEffect *iface )
{
struct ramp_effect *impl = impl_from_IRampForceEffect( iface );
ULONG ref = InterlockedDecrement( &impl->ref );
IUNKNOWN_IMPL_RELEASE( ramp_effect, IRampForceEffect );
IINSPECTABLE_IMPL( ramp_effect, IRampForceEffect );
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( 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;
}
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 =
{
@ -111,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 );
@ -119,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 )
@ -144,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 ),
@ -154,86 +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;
LONG ref;
IAgileObject IAgileObject_iface;
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, FIXME );
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_IAgileObject ) ||
IsEqualGUID( iid, &IID_IActivationFactory ))
{
IInspectable_AddRef( (*out = &impl->IActivationFactory_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;
@ -241,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 )))
@ -256,23 +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,
};
INTERFACE_VTBL_IActivationFactory( ramp_factory );
INTERFACE_VTBL_IAgileObject( ramp_factory_IAgileObject );
static struct ramp_factory ramp_statics =
{
{&activation_vtbl},
1,
{&ramp_factory_vtbl},
{&ramp_factory_IAgileObject_vtbl},
RuntimeClass_Windows_Gaming_Input_ForceFeedback_RampForceEffect,
};
IInspectable *ramp_effect_factory = (IInspectable *)&ramp_statics.IActivationFactory_iface;

View file

@ -26,91 +26,60 @@ WINE_DEFAULT_DEBUG_CHANNEL(combase);
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 );
if (IsEqualGUID( iid, &IID_IUnknown ) ||
IsEqualGUID( iid, &IID_IInspectable ) ||
IsEqualGUID( iid, &IID_IAgileObject ) ||
IsEqualGUID( iid, impl->iid ))
{
IInspectable_AddRef( (*out = &impl->IIterator_IInspectable_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 )
IUNKNOWN_IMPL_ADDREF( iterator, IIterator_IInspectable );
static void iterator_destroy( struct iterator *impl )
{
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;
IVectorView_IInspectable_Release( impl->view );
free( impl );
}
static ULONG WINAPI iterator_Release( IIterator_IInspectable *iface )
{
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;
}
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 );
@ -120,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 );
@ -131,52 +100,39 @@ 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 );
INTERFACE_FWD_IAgileObject( iterator, IIterator_IInspectable, &object->IIterator_IInspectable_iface );
INTERFACE_VTBL_IAgileObject( iterator_IAgileObject );
struct vector_view
{
IVectorView_IInspectable IVectorView_IInspectable_iface;
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 );
if (IsEqualGUID( iid, &IID_IUnknown ) ||
IsEqualGUID( iid, &IID_IInspectable ) ||
IsEqualGUID( iid, &IID_IAgileObject ) ||
IsEqualGUID( iid, impl->iids.view ))
{
IInspectable_AddRef( (*out = &impl->IVectorView_IInspectable_iface) );
@ -189,56 +145,28 @@ static HRESULT WINAPI vector_view_QueryInterface( IVectorView_IInspectable *ifac
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 )
IUNKNOWN_IMPL_ADDREF( vector_view, IVectorView_IInspectable );
static void vector_view_destroy( struct vector_view *impl )
{
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;
UINT i;
for (i = 0; i < impl->size; ++i) IInspectable_Release( impl->elements[i] );
free( impl );
}
static ULONG WINAPI vector_view_Release( IVectorView_IInspectable *iface )
{
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;
}
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 );
@ -251,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 );
@ -262,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 );
@ -277,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",
@ -295,36 +223,22 @@ 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, struct vector_view, view_impl_from_IIterable_IInspectable,
IIterable_IInspectable_iface, &impl->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 );
if (!(iter = calloc( 1, sizeof(struct iterator) ))) return E_OUTOFMEMORY;
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;
@ -333,45 +247,35 @@ 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 );
INTERFACE_FWD_IAgileObject( vector_view, IIterable_IInspectable, &object->IIterable_IInspectable_iface );
INTERFACE_VTBL_IAgileObject( vector_view_IAgileObject );
struct vector
{
IVector_IInspectable IVector_IInspectable_iface;
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 );
if (IsEqualGUID( iid, &IID_IUnknown ) ||
IsEqualGUID( iid, &IID_IInspectable ) ||
IsEqualGUID( iid, &IID_IAgileObject ) ||
IsEqualGUID( iid, impl->iids.vector ))
{
IInspectable_AddRef( (*out = &impl->IVector_IInspectable_iface) );
@ -384,56 +288,27 @@ static HRESULT WINAPI vector_QueryInterface( IVector_IInspectable *iface, REFIID
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 )
IUNKNOWN_IMPL_ADDREF( vector, IVector_IInspectable );
static void vector_destroy( struct vector *impl )
{
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;
IVector_IInspectable_Clear( &impl->IVector_IInspectable_iface );
free( impl );
}
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;
}
static HRESULT WINAPI vector_GetRuntimeClassName( IVector_IInspectable *iface, HSTRING *class_name )
{
FIXME( "iface %p, class_name %p stub!\n", iface, class_name );
return E_NOTIMPL;
}
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 );
@ -446,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;
@ -454,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;
@ -462,9 +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]) );
@ -474,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 );
@ -488,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 );
@ -500,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 );
@ -522,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 );
@ -534,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 );
@ -543,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 );
@ -553,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 );
@ -568,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",
@ -598,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, struct 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;
@ -644,18 +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 );
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 )
{
@ -665,9 +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 );

View file

@ -915,6 +915,7 @@ SOURCES = \
wine/afd.h \
wine/asm.h \
wine/atsvc.idl \
wine/comimpl.h \
wine/condrv.h \
wine/dcetypes.idl \
wine/debug.h \

166
include/wine/comimpl.h Normal file
View file

@ -0,0 +1,166 @@
/*
* Wine COM implementation helpers
*
* Copyright 2024 Rémi Bernon for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#if 0
#pragma makedep install
#endif
#ifndef __WINE_WINE_COMIMPL_H
#define __WINE_WINE_COMIMPL_H
#include <stdarg.h>
#include <stdio.h>
#include <windef.h>
#include <winbase.h>
#define QUERY_INTERFACES( object, iid, out, X, ... ) QUERY_INTERFACES_ ## X( object, iid, out, __VA_ARGS__ )
#define QUERY_INTERFACES_END( object, iid, out, X, ... ) \
*out = NULL; \
X( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid) ); \
return E_NOINTERFACE;
#define INTERFACES_FWD( type, base, expr, X, ... ) INTERFACES_FWD_ ## X( type, base, expr, __VA_ARGS__ )
#define INTERFACES_FWD_END( type, base, expr, ... )
#define INTERFACE_IMPL_FROM( type, name ) INTERFACE_IMPL_FROM_( type, name, type ## _from_ ## name, name ## _iface )
#define INTERFACE_IMPL_FROM_( type, name, impl_from, iface_mem ) \
static struct type *impl_from( name *iface ) \
{ \
return CONTAINING_RECORD( iface, struct type, iface_mem ); \
}
#define IUNKNOWN_IMPL_QUERY_INTERFACE( type, name, ... ) IUNKNOWN_IMPL_QUERY_INTERFACE_( type, name, type ## _from_ ## name, __VA_ARGS__ )
#define IUNKNOWN_IMPL_QUERY_INTERFACE_( type, name, impl_from, ... ) \
static HRESULT WINAPI type ## _QueryInterface( name *iface, REFIID iid, void **out ) \
{ \
struct type *object = impl_from( iface ); \
TRACE( "object %p, iid %s, out %p.\n", object, debugstr_guid(iid), out ); \
QUERY_INTERFACES( object, iid, out, name, __VA_ARGS__ ); \
}
#define IUNKNOWN_IMPL_ADDREF( type, name ) IUNKNOWN_IMPL_ADDREF_( type, name, type ## _from_ ## name )
#define IUNKNOWN_IMPL_ADDREF_( type, name, impl_from ) \
static ULONG WINAPI type ## _AddRef( name *iface ) \
{ \
struct type *object = impl_from( iface ); \
ULONG ref = InterlockedIncrement( &object->refcount ); \
TRACE( "object %p increasing refcount to %lu.\n", object, ref ); \
return ref; \
}
#define IUNKNOWN_IMPL_STATIC_ADDREF( type, name ) \
static ULONG WINAPI type ## _AddRef( name *iface ) \
{ \
return 2; \
}
#define IUNKNOWN_IMPL_RELEASE( type, name ) IUNKNOWN_IMPL_RELEASE_( type, name, type ## _from_ ## name )
#define IUNKNOWN_IMPL_RELEASE_( type, name, impl_from ) \
static ULONG WINAPI type ## _Release( name *iface ) \
{ \
struct type *object = impl_from( iface ); \
ULONG ref = InterlockedDecrement( &object->refcount ); \
TRACE( "object %p decreasing refcount to %lu.\n", object, ref); \
if (!ref) \
{ \
InterlockedIncrement( &object->refcount ); /* guard against re-entry when aggregated */ \
type ## _destroy( object ); \
} \
return ref; \
}
#define IUNKNOWN_IMPL_STATIC_RELEASE( type, name ) \
static ULONG WINAPI type ## _Release( name *iface ) \
{ \
return 1; \
}
#define IUNKNOWN_IMPL( type, name, ... ) \
IUNKNOWN_IMPL_QUERY_INTERFACE_( type, name, type ## _from_ ## name, __VA_ARGS__ ) \
IUNKNOWN_IMPL_ADDREF_( type, name, type ## _from_ ## name ) \
IUNKNOWN_IMPL_RELEASE_( type, name, type ## _from_ ## name )
#define IUNKNOWN_IMPL_STATIC( type, name, ... ) \
IUNKNOWN_IMPL_QUERY_INTERFACE_( type, name, type ## _from_ ## name, __VA_ARGS__ ) \
IUNKNOWN_IMPL_STATIC_ADDREF( type, name ) \
IUNKNOWN_IMPL_STATIC_RELEASE( type, name )
#define IUNKNOWN_FWD( type, name, base, expr ) IUNKNOWN_FWD_( type, name, base, expr, type ## _from_ ## name, type ## _ ## name )
#define IUNKNOWN_FWD_( type, name, base, expr, impl_from, prefix ) \
static HRESULT WINAPI prefix ## _QueryInterface( name *iface, REFIID iid, void **out ) \
{ \
struct type *object = impl_from( iface ); \
return base ## _QueryInterface( (expr), iid, out ); \
} \
static ULONG WINAPI prefix ## _AddRef( name *iface ) \
{ \
struct type *object = impl_from( iface ); \
return base ## _AddRef( (expr) ); \
} \
static ULONG WINAPI prefix ## _Release( name *iface ) \
{ \
struct type *object = impl_from( iface ); \
return base ## _Release( (expr) ); \
}
#define IINSPECTABLE_IMPL( type, name ) IINSPECTABLE_IMPL_( type, name, type ## _from_ ## name )
#define IINSPECTABLE_IMPL_( type, name, impl_from ) \
static HRESULT WINAPI type ## _GetIids( name *iface, ULONG *count, IID **iids ) \
{ \
struct type *object = impl_from( iface ); \
FIXME( "object %p, count %p, iids %p, stub!\n", object, count, iids ); \
return E_NOTIMPL; \
} \
static HRESULT WINAPI type ## _GetRuntimeClassName( name *iface, HSTRING *class_name ) \
{ \
struct type *object = impl_from( iface ); \
if (!object->class_name) \
{ \
FIXME( "object %p, class_name %p, stub!\n", object, class_name ); \
return E_NOTIMPL; \
} \
TRACE( "object %p, class_name %p.\n", object, class_name ); \
return WindowsCreateString( object->class_name, wcslen( object->class_name ), class_name ); \
} \
static HRESULT WINAPI type ## _GetTrustLevel( name *iface, TrustLevel *trust_level ) \
{ \
struct type *object = impl_from( iface ); \
FIXME( "object %p, trust_level %p, stub!\n", object, trust_level ); \
return E_NOTIMPL; \
}
#define IINSPECTABLE_FWD( type, name, base, expr ) IINSPECTABLE_FWD_( type, name, base, expr, type ## _from_ ## name, type ## _ ## name )
#define IINSPECTABLE_FWD_( type, name, base, expr, impl_from, prefix ) \
static HRESULT WINAPI prefix ## _GetIids( name *iface, ULONG *count, IID **iids ) \
{ \
struct type *object = impl_from( iface ); \
return base ## _GetIids( (expr), count, iids ); \
} \
static HRESULT WINAPI prefix ## _GetRuntimeClassName( name *iface, HSTRING *class_name ) \
{ \
struct type *object = impl_from( iface ); \
return base ## _GetRuntimeClassName( (expr), class_name ); \
} \
static HRESULT WINAPI prefix ## _GetTrustLevel( name *iface, TrustLevel *trust_level ) \
{ \
struct type *object = impl_from( iface ); \
return base ## _GetTrustLevel( (expr), trust_level ); \
}
#endif /* __WINE_WINE_COMIMPL_H */

View file

@ -46,6 +46,7 @@ static void write_apicontract_guard_start(FILE *header, const expr_t *expr);
static void write_apicontract_guard_end(FILE *header, const expr_t *expr);
static void write_widl_using_macros(FILE *header, type_t *iface);
static void write_widl_impl_macros(FILE *header, type_t *iface);
static void indent(FILE *h, int delta)
{
@ -1641,6 +1642,21 @@ static void write_widl_using_macros(FILE *header, type_t *iface)
macro = format_namespace(iface->namespace, "WIDL_using_", "_", NULL, NULL);
fprintf(header, "#ifdef %s\n", macro);
fprintf(header, "#define QUERY_INTERFACE_OPT_%s QUERY_INTERFACE_OPT_%s\n", name, iface->c_name);
fprintf(header, "#define QUERY_INTERFACE_%s QUERY_INTERFACE_%s\n", name, iface->c_name);
fprintf(header, "#define QUERY_INTERFACES_OPT_%s QUERY_INTERFACES_OPT_%s\n", name, iface->c_name);
fprintf(header, "#define QUERY_INTERFACES_%s QUERY_INTERFACES_%s\n", name, iface->c_name);
fprintf(header, "#define INTERFACE_VTBL_%s INTERFACE_VTBL_%s\n", name, iface->c_name);
fprintf(header, "#define INTERFACE_IMPL_%s INTERFACE_IMPL_%s\n", name, iface->c_name);
fprintf(header, "#define INTERFACE_IMPL_OUTER_%s INTERFACE_IMPL_OUTER_%s\n", name, iface->c_name);
fprintf(header, "#define INTERFACE_IMPL_STATIC_%s INTERFACE_IMPL_STATIC_%s\n", name, iface->c_name);
fprintf(header, "#define INTERFACE_FWD_OPT_%s INTERFACE_FWD_OPT_%s\n", name, iface->c_name);
fprintf(header, "#define INTERFACE_FWD_%s INTERFACE_FWD_%s\n", name, iface->c_name);
fprintf(header, "#define INTERFACES_FWD_OPT_%s INTERFACES_FWD_OPT_%s\n", name, iface->c_name);
fprintf(header, "#define INTERFACES_FWD_%s INTERFACES_FWD_%s\n", name, iface->c_name);
if (uuid) fprintf(header, "#define IID_%s IID_%s\n", name, iface->c_name);
if (iface->type_type == TYPE_INTERFACE) fprintf(header, "#define %sVtbl %sVtbl\n", name, iface->c_name);
fprintf(header, "#define %s %s\n", name, iface->c_name);
@ -1651,6 +1667,92 @@ static void write_widl_using_macros(FILE *header, type_t *iface)
free(macro);
}
static void write_widl_impl_macros_methods(FILE *header, const type_t *iface, const type_t *top_iface, const char *prefix)
{
const statement_t *stmt;
if (type_iface_get_inherit(iface)) write_widl_impl_macros_methods(header, type_iface_get_inherit(iface), top_iface, prefix);
STATEMENTS_FOR_EACH_FUNC(stmt, type_iface_get_stmts(iface))
{
const var_t *func = stmt->u.var;
if (is_override_method(iface, top_iface, func)) continue;
if (is_callas(func->attrs)) continue;
fprintf(header, " %s_%s, \\\n", prefix, get_name(func));
}
}
static void write_widl_impl_macros(FILE *header, type_t *iface)
{
const struct uuid *uuid = get_attrp(iface->attrs, ATTR_UUID);
const char *name = iface->short_name ? iface->short_name : iface->name;
type_t *base = type_iface_get_inherit(iface);
if (uuid)
{
int inspectable = base && !strcmp(base->c_name, "IInspectable");
fprintf(header, "#define QUERY_INTERFACE_OPT_%s( object, iid, out, mem ) \\\n", iface->c_name);
fprintf(header, " if ((object)->mem.lpVtbl) QUERY_INTERFACE_%s( object, iid, out, mem )\n", iface->c_name);
fprintf(header, "#define QUERY_INTERFACE_%s( object, iid, out, mem ) \\\n", iface->c_name);
fprintf(header, " if (0 " );
for (base = iface; base; (base = type_iface_get_inherit(base)))
fprintf(header, "%s|| IsEqualGUID( (iid), &IID_%s )", base == iface ? "" : " \\\n ", base->c_name );
fprintf(header, ") \\\n" );
fprintf(header, " { \\\n" );
fprintf(header, " *(out) = &(object)->mem; \\\n" );
fprintf(header, " %s_AddRef( &(object)->mem ); \\\n", iface->c_name );
fprintf(header, " return S_OK; \\\n" );
fprintf(header, " }\n" );
fprintf(header, "#define QUERY_INTERFACES_OPT_%s( object, iid, out, X, ... ) \\\n", iface->c_name);
fprintf(header, " QUERY_INTERFACE_OPT_%s( object, iid, out, %s_iface ) \\\n", iface->c_name, name);
fprintf(header, " QUERY_INTERFACES_ ## X( object, iid, out, __VA_ARGS__ )\n");
fprintf(header, "#define QUERY_INTERFACES_%s( object, iid, out, X, ... ) \\\n", iface->c_name);
fprintf(header, " QUERY_INTERFACE_%s( object, iid, out, %s_iface ) \\\n", iface->c_name, name);
fprintf(header, " QUERY_INTERFACES_ ## X( object, iid, out, __VA_ARGS__ )\n");
fprintf(header, "\n");
fprintf(header, "#define INTERFACE_VTBL_%s( pfx ) \\\n", iface->c_name);
fprintf(header, " static const %sVtbl %s_vtbl = \\\n", iface->c_name, "pfx ## ");
fprintf(header, " { \\\n");
write_widl_impl_macros_methods(header, iface, iface, "pfx ## ");
fprintf(header, " };\n");
fprintf(header, "\n" );
fprintf(header, "#define INTERFACE_IMPL_%s( type, ... ) \\\n", iface->c_name);
fprintf(header, " INTERFACE_IMPL_FROM_( type, %s, type ## _from_%s, %s_iface ) \\\n", name, name, name );
fprintf(header, " IUNKNOWN_IMPL( type, %s, __VA_ARGS__ ) \\\n", name );
if (inspectable) fprintf(header, " IINSPECTABLE_IMPL( type, %s ) \\\n", name );
fprintf(header, " INTERFACES_FWD( type, %s, &object->%s_iface, __VA_ARGS__ )\n", name, name);
fprintf(header, "#define INTERFACE_IMPL_OUTER_%s( type, ... ) \\\n", iface->c_name);
fprintf(header, " INTERFACE_IMPL_FROM_( type, %s, type ## _from_%s, %s_iface ) \\\n", name, name, name);
fprintf(header, " IUNKNOWN_IMPL( type, %s, __VA_ARGS__ ) \\\n", name);
if (inspectable) fprintf(header, " IINSPECTABLE_IMPL( type, %s ) \\\n", name );
fprintf(header, " INTERFACES_FWD( type, %s, object->outer, __VA_ARGS__ )\n", inspectable ? "IInspectable" : "IUnknown");
fprintf(header, "#define INTERFACE_IMPL_STATIC_%s( type, ... ) \\\n", iface->c_name);
fprintf(header, " INTERFACE_IMPL_FROM_( type, %s, type ## _from_%s, %s_iface ) \\\n", name, name, name );
fprintf(header, " IUNKNOWN_IMPL_STATIC( type, %s, __VA_ARGS__ ) \\\n", name );
if (inspectable) fprintf(header, " IINSPECTABLE_IMPL( type, %s ) \\\n", name );
fprintf(header, " INTERFACES_FWD( type, %s, &object->%s_iface, __VA_ARGS__ )\n", name, name);
fprintf(header, "#define INTERFACE_FWD_%s( type, base, expr ) \\\n", iface->c_name);
fprintf(header, " INTERFACE_IMPL_FROM_( type, %s, type ## _from_%s, %s_iface ) \\\n", name, name, name );
fprintf(header, " IUNKNOWN_FWD( type, %s, base, expr ) \\\n", name );
if (inspectable) fprintf(header, " IINSPECTABLE_FWD( type, %s, base, expr ) \\\n", name );
fprintf(header, "\n");
fprintf(header, "#define INTERFACES_FWD_OPT_%s INTERFACES_FWD_%s\n", iface->c_name, iface->c_name);
fprintf(header, "#define INTERFACES_FWD_%s( type, base, expr, X, ... ) \\\n", iface->c_name);
fprintf(header, " INTERFACE_FWD_%s( type, base, expr ) \\\n", name);
fprintf(header, " INTERFACES_FWD_ ## X( type, base, expr, __VA_ARGS__ )\n");
fprintf(header, "\n");
}
}
static void write_com_interface_end(FILE *header, type_t *iface)
{
int dispinterface = is_attr(iface->attrs, ATTR_DISPINTERFACE);
@ -1727,7 +1829,10 @@ static void write_com_interface_end(FILE *header, type_t *iface)
write_method_macro(header, type, type, iface->c_name);
fprintf(header, "#else\n");
write_inline_wrappers(header, type, type, iface->c_name);
fprintf(header, "#endif\n");
fprintf(header, "#endif\n\n");
fprintf(header, "#ifdef __WINESRC__\n\n");
write_widl_impl_macros(header, iface);
fprintf(header, "#endif /* __WINESRC__ */\n\n");
if (winrt_mode) write_widl_using_macros(header, iface);
fprintf(header, "#endif\n");
fprintf(header, "\n");