From: Rémi Bernon rbernon@codeweavers.com
--- dlls/windows.gaming.input/controller.c | 86 +++++--------------------- include/wine/comimpl.h | 15 +++++ 2 files changed, 31 insertions(+), 70 deletions(-)
diff --git a/dlls/windows.gaming.input/controller.c b/dlls/windows.gaming.input/controller.c index 510ccddbd27..9007ed59209 100644 --- a/dlls/windows.gaming.input/controller.c +++ b/dlls/windows.gaming.input/controller.c @@ -59,6 +59,7 @@ static HRESULT init_controllers(void) struct controller { IGameControllerImpl IGameControllerImpl_iface; + IAgileObject IAgileObject_iface; IGameControllerInputSink IGameControllerInputSink_iface; IRawGameController IRawGameController_iface; IRawGameController2 IRawGameController2_iface; @@ -70,43 +71,8 @@ struct controller };
INTERFACE_IMPL_FROM( controller, IGameControllerImpl ); - -static HRESULT WINAPI controller_QueryInterface( IGameControllerImpl *iface, REFIID iid, void **out ) -{ - struct controller *impl = controller_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; -} +IUNKNOWN_IMPL_QUERY_INTERFACE( controller, IGameControllerImpl, IAgileObject, IGameControllerInputSink, + IRawGameController, IRawGameController2, END );
static void controller_destroy( struct controller *impl ) { @@ -162,6 +128,10 @@ static HRESULT WINAPI controller_Initialize( IGameControllerImpl *iface, IGameCo
INTERFACE_VTBL_IGameControllerImpl( controller );
+INTERFACE_IMPL_FROM( controller, IAgileObject ); +IUNKNOWN_FWD( controller, IAgileObject, IGameController, object->IGameController_outer ); +INTERFACE_VTBL_IAgileObject( controller_IAgileObject ); + DEFINE_IINSPECTABLE_OUTER( controller_IGameControllerInputSink, IGameControllerInputSink, controller, IGameController_outer )
static HRESULT WINAPI controller_IGameControllerInputSink_OnInputResumed( IGameControllerInputSink *iface, UINT64 timestamp ) @@ -323,44 +293,14 @@ INTERFACE_VTBL_IRawGameController2( controller_IRawGameController2 ); struct controller_statics { IActivationFactory IActivationFactory_iface; + IAgileObject IAgileObject_iface; IRawGameControllerStatics IRawGameControllerStatics_iface; ICustomGameControllerFactory ICustomGameControllerFactory_iface; };
INTERFACE_IMPL_FROM( controller_statics, IActivationFactory ); - -static HRESULT WINAPI controller_statics_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) -{ - struct controller_statics *impl = controller_statics_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; -} - +IUNKNOWN_IMPL_QUERY_INTERFACE( controller_statics, IActivationFactory, IAgileObject, + IRawGameControllerStatics, ICustomGameControllerFactory, END ); IUNKNOWN_IMPL_STATIC_ADDREF( controller_statics, IActivationFactory ); IUNKNOWN_IMPL_STATIC_RELEASE( controller_statics, IActivationFactory );
@@ -390,6 +330,10 @@ static HRESULT WINAPI controller_statics_ActivateInstance( IActivationFactory *i
INTERFACE_VTBL_IActivationFactory( controller_statics );
+INTERFACE_IMPL_FROM_( controller_statics, IAgileObject, controller_statics_from_IAgileObject, IAgileObject_iface ); +IUNKNOWN_FWD( controller_statics, IAgileObject, IActivationFactory, &object->IActivationFactory_iface ); +INTERFACE_VTBL_IAgileObject( controller_statics_IAgileObject ); + DEFINE_IINSPECTABLE( controller_statics_IRawGameControllerStatics, IRawGameControllerStatics, controller_statics, IActivationFactory_iface )
@@ -479,6 +423,7 @@ controller_statics_ICustomGameControllerFactory_CreateGameController( ICustomGam
if (!(impl = calloc( 1, sizeof(*impl) ))) return E_OUTOFMEMORY; impl->IGameControllerImpl_iface.lpVtbl = &controller_vtbl; + impl->IAgileObject_iface.lpVtbl = &controller_IAgileObject_vtbl; impl->IGameControllerInputSink_iface.lpVtbl = &controller_IGameControllerInputSink_vtbl; impl->IRawGameController_iface.lpVtbl = &controller_IRawGameController_vtbl; impl->IRawGameController2_iface.lpVtbl = &controller_IRawGameController2_vtbl; @@ -546,6 +491,7 @@ INTERFACE_VTBL_ICustomGameControllerFactory( controller_statics_ICustomGameContr static struct controller_statics controller_statics = { {&controller_statics_vtbl}, + {&controller_statics_IAgileObject_vtbl}, {&controller_statics_IRawGameControllerStatics_vtbl}, {&controller_statics_ICustomGameControllerFactory_vtbl}, }; diff --git a/include/wine/comimpl.h b/include/wine/comimpl.h index 5eff3b5ff02..41691d21ef3 100644 --- a/include/wine/comimpl.h +++ b/include/wine/comimpl.h @@ -31,6 +31,9 @@ #include <windef.h> #include <winbase.h>
+#define QUERY_INTERFACES_END( object, iid, out, ... ) +#define QUERY_INTERFACES( object, iid, out, X, ... ) QUERY_INTERFACES_ ## X( object, iid, out, __VA_ARGS__ ) + #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 ) \ @@ -38,6 +41,18 @@ 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__ ); \ + *out = NULL; \ + WARN( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid) ); \ + return E_NOINTERFACE; \ + } + #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 ) \