I think it would be very nice to have something like that to reduce the burden of implementing COM interfaces. This shows for instance on the windows.gaming.input module a 30% LoC reduction (from ~6800 to ~4700), even though the module already had a boilerplate helper macros already.
The MR introduces macros to automatically implement each IUnknown method, as well as all of them at once. It also includes a helper to implement IInspectable methods at once, as well as macros to forward both interface methods to a base interface or an outer object. Last, it provides higher-level macros to implement a main interface and any number of sub interfaces and generate IUnknown, forwarding and vtables for all of them at once.
It uses widl to generate additional per-interface macros, for things like inheritance and vtable generation. The rest of the macros are otherwise shared in a Wine-specific header.
The implementation is split to show individual macro being used, although they are later replaced by higher-level macros. The individual helpers are still useful in some corner cases where specific behavior needs to be implemented, or for aggregating classes.
From: Rémi Bernon rbernon@codeweavers.com
--- tools/widl/header.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-)
diff --git a/tools/widl/header.c b/tools/widl/header.c index 413354d5b56..bd625b385af 100644 --- a/tools/widl/header.c +++ b/tools/widl/header.c @@ -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) { @@ -1645,6 +1646,8 @@ 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 INTERFACE_VTBL_%s INTERFACE_VTBL_%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); @@ -1655,6 +1658,38 @@ 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); + + if (uuid) + { + 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" ); + } +} + static void write_com_interface_end(FILE *header, type_t *iface) { int dispinterface = is_attr(iface->attrs, ATTR_DISPINTERFACE); @@ -1731,7 +1766,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");
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/windows.gaming.input/controller.c | 228 ++++++++----------------- 1 file changed, 74 insertions(+), 154 deletions(-)
diff --git a/dlls/windows.gaming.input/controller.c b/dlls/windows.gaming.input/controller.c index e1749a3032d..686295018d0 100644 --- a/dlls/windows.gaming.input/controller.c +++ b/dlls/windows.gaming.input/controller.c @@ -179,62 +179,40 @@ 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 ) +DEFINE_IINSPECTABLE_OUTER( controller_IGameControllerInputSink, 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 ) +DEFINE_IINSPECTABLE_OUTER( controller_IRawGameController, 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 ); 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 ); 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 = { @@ -264,34 +242,35 @@ 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 ); 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 ); 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 ); 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 ); WineGameControllerState state; @@ -310,36 +289,20 @@ 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 ) +DEFINE_IINSPECTABLE_OUTER( controller_IRawGameController2, 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,32 +325,19 @@ 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 { @@ -402,7 +352,7 @@ static inline struct controller_statics *impl_from_IActivationFactory( IActivati return CONTAINING_RECORD( iface, struct controller_statics, IActivationFactory_iface ); }
-static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) +static HRESULT WINAPI controller_statics_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) { struct controller_statics *impl = impl_from_IActivationFactory( iface );
@@ -434,7 +384,7 @@ static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID return E_NOINTERFACE; }
-static ULONG WINAPI factory_AddRef( IActivationFactory *iface ) +static ULONG WINAPI controller_statics_AddRef( IActivationFactory *iface ) { struct controller_statics *impl = impl_from_IActivationFactory( iface ); ULONG ref = InterlockedIncrement( &impl->ref ); @@ -442,7 +392,7 @@ static ULONG WINAPI factory_AddRef( IActivationFactory *iface ) return ref; }
-static ULONG WINAPI factory_Release( IActivationFactory *iface ) +static ULONG WINAPI controller_statics_Release( IActivationFactory *iface ) { struct controller_statics *impl = impl_from_IActivationFactory( iface ); ULONG ref = InterlockedDecrement( &impl->ref ); @@ -450,76 +400,72 @@ static ULONG WINAPI factory_Release( IActivationFactory *iface ) return ref; }
-static HRESULT WINAPI factory_GetIids( IActivationFactory *iface, ULONG *iid_count, IID **iids ) +static HRESULT WINAPI controller_statics_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 ) +static HRESULT WINAPI controller_statics_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 ) +static HRESULT WINAPI controller_statics_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 );
-DEFINE_IINSPECTABLE( statics, IRawGameControllerStatics, struct controller_statics, IActivationFactory_iface ) +DEFINE_IINSPECTABLE( controller_statics_IRawGameControllerStatics, 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,8 +479,9 @@ 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 ); IGameController *controller; @@ -553,28 +500,14 @@ 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 ) +DEFINE_IINSPECTABLE( controller_statics_ICustomGameControllerFactory, 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 +515,9 @@ 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;
TRACE( "created RawGameController %p\n", impl );
@@ -593,7 +525,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 +541,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 +576,13 @@ 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}, };
ICustomGameControllerFactory *controller_factory = &controller_statics.ICustomGameControllerFactory_iface;
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/windows.gaming.input/async.c | 2 +- dlls/windows.gaming.input/condition_effect.c | 2 +- dlls/windows.gaming.input/controller.c | 34 ++++----- dlls/windows.gaming.input/force_feedback.c | 2 +- dlls/windows.gaming.input/gamepad.c | 12 +-- dlls/windows.gaming.input/manager.c | 6 +- dlls/windows.gaming.input/periodic_effect.c | 2 +- dlls/windows.gaming.input/private.h | 46 ++---------- dlls/windows.gaming.input/provider.c | 2 +- dlls/windows.gaming.input/racing_wheel.c | 10 +-- dlls/windows.gaming.input/vector.c | 6 +- include/Makefile.in | 1 + include/wine/comimpl.h | 77 ++++++++++++++++++++ 13 files changed, 122 insertions(+), 80 deletions(-) create mode 100644 include/wine/comimpl.h
diff --git a/dlls/windows.gaming.input/async.c b/dlls/windows.gaming.input/async.c index d70994289f1..0639280215b 100644 --- a/dlls/windows.gaming.input/async.c +++ b/dlls/windows.gaming.input/async.c @@ -198,7 +198,7 @@ static const struct IWineAsyncInfoImplVtbl async_impl_vtbl = async_impl_Start, };
-DEFINE_IINSPECTABLE_OUTER( async_info, IAsyncInfo, struct async_info, IInspectable_outer ) +DEFINE_IINSPECTABLE_OUTER( async_info, IAsyncInfo, async_info, IInspectable_outer )
static HRESULT WINAPI async_info_get_Id( IAsyncInfo *iface, UINT32 *id ) { diff --git a/dlls/windows.gaming.input/condition_effect.c b/dlls/windows.gaming.input/condition_effect.c index c3a5a1fcd8b..a2c4329f3ae 100644 --- a/dlls/windows.gaming.input/condition_effect.c +++ b/dlls/windows.gaming.input/condition_effect.c @@ -237,7 +237,7 @@ static const struct IActivationFactoryVtbl activation_vtbl = activation_ActivateInstance, };
-DEFINE_IINSPECTABLE( factory, IConditionForceEffectFactory, struct condition_factory, IActivationFactory_iface ) +DEFINE_IINSPECTABLE( factory, IConditionForceEffectFactory, condition_factory, IActivationFactory_iface )
static HRESULT WINAPI factory_CreateInstance( IConditionForceEffectFactory *iface, enum ConditionForceEffectKind kind, IForceFeedbackEffect **out ) { diff --git a/dlls/windows.gaming.input/controller.c b/dlls/windows.gaming.input/controller.c index 686295018d0..72abbb6b417 100644 --- a/dlls/windows.gaming.input/controller.c +++ b/dlls/windows.gaming.input/controller.c @@ -69,14 +69,11 @@ struct controller IWineGameControllerProvider *wine_provider; };
-static inline struct controller *impl_from_IGameControllerImpl( IGameControllerImpl *iface ) -{ - return CONTAINING_RECORD( iface, struct controller, IGameControllerImpl_iface ); -} +INTERFACE_IMPL_FROM( controller, IGameControllerImpl );
static HRESULT WINAPI controller_QueryInterface( IGameControllerImpl *iface, REFIID iid, void **out ) { - struct controller *impl = impl_from_IGameControllerImpl( iface ); + struct controller *impl = controller_from_IGameControllerImpl( iface );
TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out );
@@ -113,7 +110,7 @@ static HRESULT WINAPI controller_QueryInterface( IGameControllerImpl *iface, REF
static ULONG WINAPI controller_AddRef( IGameControllerImpl *iface ) { - struct controller *impl = impl_from_IGameControllerImpl( iface ); + struct controller *impl = controller_from_IGameControllerImpl( iface ); ULONG ref = InterlockedIncrement( &impl->ref ); TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); return ref; @@ -121,7 +118,7 @@ static ULONG WINAPI controller_AddRef( IGameControllerImpl *iface )
static ULONG WINAPI controller_Release( IGameControllerImpl *iface ) { - struct controller *impl = impl_from_IGameControllerImpl( iface ); + struct controller *impl = controller_from_IGameControllerImpl( iface ); ULONG ref = InterlockedDecrement( &impl->ref );
TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); @@ -159,7 +156,7 @@ static HRESULT WINAPI controller_GetTrustLevel( IGameControllerImpl *iface, Trus 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 ); @@ -181,7 +178,7 @@ static HRESULT WINAPI controller_Initialize( IGameControllerImpl *iface, IGameCo
INTERFACE_VTBL_IGameControllerImpl( controller );
-DEFINE_IINSPECTABLE_OUTER( controller_IGameControllerInputSink, IGameControllerInputSink, struct controller, IGameController_outer ) +DEFINE_IINSPECTABLE_OUTER( controller_IGameControllerInputSink, IGameControllerInputSink, controller, IGameController_outer )
static HRESULT WINAPI controller_IGameControllerInputSink_OnInputResumed( IGameControllerInputSink *iface, UINT64 timestamp ) { @@ -197,7 +194,7 @@ static HRESULT WINAPI controller_IGameControllerInputSink_OnInputSuspended( IGam
INTERFACE_VTBL_IGameControllerInputSink( controller_IGameControllerInputSink );
-DEFINE_IINSPECTABLE_OUTER( controller_IRawGameController, IRawGameController, struct controller, IGameController_outer ) +DEFINE_IINSPECTABLE_OUTER( controller_IRawGameController, IRawGameController, controller, IGameController_outer )
static HRESULT WINAPI controller_IRawGameController_get_AxisCount( IRawGameController *iface, INT32 *value ) { @@ -298,7 +295,7 @@ static HRESULT WINAPI controller_IRawGameController_GetSwitchKind( IRawGameContr
INTERFACE_VTBL_IRawGameController( controller_IRawGameController );
-DEFINE_IINSPECTABLE_OUTER( controller_IRawGameController2, IRawGameController2, struct controller, IGameController_outer ) +DEFINE_IINSPECTABLE_OUTER( controller_IRawGameController2, IRawGameController2, controller, IGameController_outer )
static HRESULT WINAPI controller_IRawGameController2_get_SimpleHapticsControllers( IRawGameController2 *iface, @@ -347,14 +344,11 @@ struct controller_statics LONG ref; };
-static inline struct controller_statics *impl_from_IActivationFactory( IActivationFactory *iface ) -{ - return CONTAINING_RECORD( iface, struct controller_statics, IActivationFactory_iface ); -} +INTERFACE_IMPL_FROM( controller_statics, IActivationFactory );
static HRESULT WINAPI controller_statics_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) { - struct controller_statics *impl = impl_from_IActivationFactory( iface ); + struct controller_statics *impl = controller_statics_from_IActivationFactory( iface );
TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out );
@@ -386,7 +380,7 @@ static HRESULT WINAPI controller_statics_QueryInterface( IActivationFactory *ifa
static ULONG WINAPI controller_statics_AddRef( IActivationFactory *iface ) { - struct controller_statics *impl = impl_from_IActivationFactory( iface ); + struct controller_statics *impl = controller_statics_from_IActivationFactory( iface ); ULONG ref = InterlockedIncrement( &impl->ref ); TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); return ref; @@ -394,7 +388,7 @@ static ULONG WINAPI controller_statics_AddRef( IActivationFactory *iface )
static ULONG WINAPI controller_statics_Release( IActivationFactory *iface ) { - struct controller_statics *impl = impl_from_IActivationFactory( iface ); + struct controller_statics *impl = controller_statics_from_IActivationFactory( iface ); ULONG ref = InterlockedDecrement( &impl->ref ); TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); return ref; @@ -427,7 +421,7 @@ static HRESULT WINAPI controller_statics_ActivateInstance( IActivationFactory *i INTERFACE_VTBL_IActivationFactory( controller_statics );
DEFINE_IINSPECTABLE( controller_statics_IRawGameControllerStatics, IRawGameControllerStatics, - struct controller_statics, IActivationFactory_iface ) + controller_statics, IActivationFactory_iface )
static HRESULT WINAPI controller_statics_IRawGameControllerStatics_add_RawGameControllerAdded( IRawGameControllerStatics *iface, @@ -503,7 +497,7 @@ controller_statics_IRawGameControllerStatics_FromGameController( IRawGameControl INTERFACE_VTBL_IRawGameControllerStatics( controller_statics_IRawGameControllerStatics );
DEFINE_IINSPECTABLE( controller_statics_ICustomGameControllerFactory, ICustomGameControllerFactory, - struct controller_statics, IActivationFactory_iface ) + controller_statics, IActivationFactory_iface )
static HRESULT WINAPI controller_statics_ICustomGameControllerFactory_CreateGameController( ICustomGameControllerFactory *iface, diff --git a/dlls/windows.gaming.input/force_feedback.c b/dlls/windows.gaming.input/force_feedback.c index a272daee25f..89904e058cc 100644 --- a/dlls/windows.gaming.input/force_feedback.c +++ b/dlls/windows.gaming.input/force_feedback.c @@ -244,7 +244,7 @@ static const struct IWineForceFeedbackEffectImplVtbl effect_impl_vtbl = effect_impl_put_Parameters, };
-DEFINE_IINSPECTABLE_OUTER( effect, IForceFeedbackEffect, struct effect, IInspectable_outer ) +DEFINE_IINSPECTABLE_OUTER( effect, IForceFeedbackEffect, effect, IInspectable_outer )
static HRESULT WINAPI effect_get_Gain( IForceFeedbackEffect *iface, DOUBLE *value ) { diff --git a/dlls/windows.gaming.input/gamepad.c b/dlls/windows.gaming.input/gamepad.c index 0d7cd690821..427d297480f 100644 --- a/dlls/windows.gaming.input/gamepad.c +++ b/dlls/windows.gaming.input/gamepad.c @@ -192,7 +192,7 @@ static const struct IGameControllerImplVtbl controller_vtbl = controller_Initialize, };
-DEFINE_IINSPECTABLE_OUTER( input_sink, IGameControllerInputSink, struct gamepad, IGameController_outer ) +DEFINE_IINSPECTABLE_OUTER( input_sink, IGameControllerInputSink, gamepad, IGameController_outer )
static HRESULT WINAPI input_sink_OnInputResumed( IGameControllerInputSink *iface, UINT64 timestamp ) { @@ -220,7 +220,7 @@ static const struct IGameControllerInputSinkVtbl input_sink_vtbl = input_sink_OnInputSuspended, };
-DEFINE_IINSPECTABLE_OUTER( gamepad, IGamepad, struct gamepad, IGameController_outer ) +DEFINE_IINSPECTABLE_OUTER( gamepad, IGamepad, gamepad, IGameController_outer )
static HRESULT WINAPI gamepad_get_Vibration( IGamepad *iface, struct GamepadVibration *value ) { @@ -337,7 +337,7 @@ static const struct IGamepadVtbl gamepad_vtbl = gamepad_GetCurrentReading, };
-DEFINE_IINSPECTABLE_OUTER( gamepad2, IGamepad2, struct gamepad, IGameController_outer ) +DEFINE_IINSPECTABLE_OUTER( gamepad2, IGamepad2, gamepad, IGameController_outer )
static HRESULT WINAPI gamepad2_GetButtonLabel( IGamepad2 *iface, GamepadButtons button, GameControllerButtonLabel *value ) { @@ -464,7 +464,7 @@ static const struct IActivationFactoryVtbl factory_vtbl = factory_ActivateInstance, };
-DEFINE_IINSPECTABLE( statics, IGamepadStatics, struct gamepad_statics, IActivationFactory_iface ) +DEFINE_IINSPECTABLE( statics, IGamepadStatics, gamepad_statics, IActivationFactory_iface )
static HRESULT WINAPI statics_add_GamepadAdded( IGamepadStatics *iface, IEventHandler_Gamepad *handler, EventRegistrationToken *token ) @@ -525,7 +525,7 @@ static const struct IGamepadStaticsVtbl statics_vtbl = statics_get_Gamepads, };
-DEFINE_IINSPECTABLE( statics2, IGamepadStatics2, struct gamepad_statics, IActivationFactory_iface ) +DEFINE_IINSPECTABLE( statics2, IGamepadStatics2, gamepad_statics, IActivationFactory_iface )
static HRESULT WINAPI statics2_FromGameController( IGamepadStatics2 *iface, IGameController *game_controller, IGamepad **value ) { @@ -558,7 +558,7 @@ static const struct IGamepadStatics2Vtbl statics2_vtbl = statics2_FromGameController, };
-DEFINE_IINSPECTABLE( controller_factory, ICustomGameControllerFactory, struct gamepad_statics, IActivationFactory_iface ) +DEFINE_IINSPECTABLE( controller_factory, ICustomGameControllerFactory, gamepad_statics, IActivationFactory_iface )
static HRESULT WINAPI controller_factory_CreateGameController( ICustomGameControllerFactory *iface, IGameControllerProvider *provider, IInspectable **value ) diff --git a/dlls/windows.gaming.input/manager.c b/dlls/windows.gaming.input/manager.c index d54b01d92e3..6ba1e046ce1 100644 --- a/dlls/windows.gaming.input/manager.c +++ b/dlls/windows.gaming.input/manager.c @@ -201,7 +201,7 @@ static const struct IGameControllerVtbl controller_vtbl = controller_get_User, };
-DEFINE_IINSPECTABLE( battery, IGameControllerBatteryInfo, struct controller, IGameController_iface ) +DEFINE_IINSPECTABLE( battery, IGameControllerBatteryInfo, controller, IGameController_iface )
static HRESULT WINAPI battery_TryGetBatteryReport( IGameControllerBatteryInfo *iface, IBatteryReport **value ) { @@ -320,7 +320,7 @@ static const struct IActivationFactoryVtbl factory_vtbl = factory_ActivateInstance, };
-DEFINE_IINSPECTABLE( statics, IGameControllerFactoryManagerStatics, struct manager_statics, IActivationFactory_iface ) +DEFINE_IINSPECTABLE( statics, IGameControllerFactoryManagerStatics, manager_statics, IActivationFactory_iface )
static HRESULT WINAPI statics_RegisterCustomFactoryForGipInterface( IGameControllerFactoryManagerStatics *iface, @@ -364,7 +364,7 @@ static const struct IGameControllerFactoryManagerStaticsVtbl statics_vtbl = statics_RegisterCustomFactoryForXusbType, };
-DEFINE_IINSPECTABLE( statics2, IGameControllerFactoryManagerStatics2, struct manager_statics, IActivationFactory_iface ) +DEFINE_IINSPECTABLE( statics2, IGameControllerFactoryManagerStatics2, manager_statics, IActivationFactory_iface )
static HRESULT WINAPI statics2_TryGetFactoryControllerFromGameController( IGameControllerFactoryManagerStatics2 *iface, diff --git a/dlls/windows.gaming.input/periodic_effect.c b/dlls/windows.gaming.input/periodic_effect.c index 8633a8fb9b9..6ba43ee6637 100644 --- a/dlls/windows.gaming.input/periodic_effect.c +++ b/dlls/windows.gaming.input/periodic_effect.c @@ -275,7 +275,7 @@ static const struct IActivationFactoryVtbl activation_vtbl = activation_ActivateInstance, };
-DEFINE_IINSPECTABLE( factory, IPeriodicForceEffectFactory, struct periodic_factory, IActivationFactory_iface ) +DEFINE_IINSPECTABLE( factory, IPeriodicForceEffectFactory, periodic_factory, IActivationFactory_iface )
static HRESULT WINAPI factory_CreateInstance( IPeriodicForceEffectFactory *iface, enum PeriodicForceEffectKind kind, IForceFeedbackEffect **out ) { diff --git a/dlls/windows.gaming.input/private.h b/dlls/windows.gaming.input/private.h index f53d5b5bc37..2d383bade00 100644 --- a/dlls/windows.gaming.input/private.h +++ b/dlls/windows.gaming.input/private.h @@ -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"
@@ -83,44 +84,13 @@ extern HRESULT async_operation_effect_result_create( IUnknown *invoker, IUnknown 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 ) + INTERFACE_IMPL_FROM_( impl_type, iface_type, impl_from, iface_mem ) \ + IUNKNOWN_FWD_( impl_type, iface_type, IInspectable, expr, impl_from, pfx ) \ + IINSPECTABLE_FWD_( impl_type, iface_type, IInspectable, expr, impl_from, pfx ) +#define DEFINE_IINSPECTABLE( pfx, iface_type, impl_type, base_iface ) \ + DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from_##iface_type, iface_type##_iface, (IInspectable *)&object->base_iface ) +#define DEFINE_IINSPECTABLE_OUTER( pfx, iface_type, impl_type, outer_iface ) \ + DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from_##iface_type, iface_type##_iface, (IInspectable *)object->outer_iface )
static inline const char *debugstr_vector3( const Vector3 *vector ) { diff --git a/dlls/windows.gaming.input/provider.c b/dlls/windows.gaming.input/provider.c index 6908d733a53..e13afaf00ce 100644 --- a/dlls/windows.gaming.input/provider.c +++ b/dlls/windows.gaming.input/provider.c @@ -364,7 +364,7 @@ static const struct IWineGameControllerProviderVtbl wine_provider_vtbl = wine_provider_get_ForceFeedbackMotor, };
-DEFINE_IINSPECTABLE( game_provider, IGameControllerProvider, struct provider, IWineGameControllerProvider_iface ) +DEFINE_IINSPECTABLE( game_provider, IGameControllerProvider, provider, IWineGameControllerProvider_iface )
static HRESULT WINAPI game_provider_get_FirmwareVersionInfo( IGameControllerProvider *iface, GameControllerVersionInfo *value ) { diff --git a/dlls/windows.gaming.input/racing_wheel.c b/dlls/windows.gaming.input/racing_wheel.c index d646ca26c03..0bf41481689 100644 --- a/dlls/windows.gaming.input/racing_wheel.c +++ b/dlls/windows.gaming.input/racing_wheel.c @@ -183,7 +183,7 @@ static const struct IGameControllerImplVtbl controller_vtbl = controller_Initialize, };
-DEFINE_IINSPECTABLE_OUTER( input_sink, IGameControllerInputSink, struct racing_wheel, IGameController_outer ) +DEFINE_IINSPECTABLE_OUTER( input_sink, IGameControllerInputSink, racing_wheel, IGameController_outer )
static HRESULT WINAPI input_sink_OnInputResumed( IGameControllerInputSink *iface, UINT64 timestamp ) { @@ -211,7 +211,7 @@ static const struct IGameControllerInputSinkVtbl input_sink_vtbl = input_sink_OnInputSuspended, };
-DEFINE_IINSPECTABLE_OUTER( racing_wheel, IRacingWheel, struct racing_wheel, IGameController_outer ) +DEFINE_IINSPECTABLE_OUTER( racing_wheel, IRacingWheel, racing_wheel, IGameController_outer )
static HRESULT WINAPI racing_wheel_get_HasClutch( IRacingWheel *iface, boolean *value ) { @@ -390,7 +390,7 @@ static const struct IActivationFactoryVtbl factory_vtbl = factory_ActivateInstance, };
-DEFINE_IINSPECTABLE( statics, IRacingWheelStatics, struct racing_wheel_statics, IActivationFactory_iface ) +DEFINE_IINSPECTABLE( statics, IRacingWheelStatics, racing_wheel_statics, IActivationFactory_iface )
static HRESULT WINAPI statics_add_RacingWheelAdded( IRacingWheelStatics *iface, IEventHandler_RacingWheel *handler, EventRegistrationToken *token ) @@ -450,7 +450,7 @@ static const struct IRacingWheelStaticsVtbl statics_vtbl = statics_get_RacingWheels, };
-DEFINE_IINSPECTABLE( statics2, IRacingWheelStatics2, struct racing_wheel_statics, IActivationFactory_iface ) +DEFINE_IINSPECTABLE( statics2, IRacingWheelStatics2, racing_wheel_statics, IActivationFactory_iface )
static HRESULT WINAPI statics2_FromGameController( IRacingWheelStatics2 *iface, IGameController *game_controller, IRacingWheel **value ) { @@ -483,7 +483,7 @@ static const struct IRacingWheelStatics2Vtbl statics2_vtbl = statics2_FromGameController, };
-DEFINE_IINSPECTABLE( controller_factory, ICustomGameControllerFactory, struct racing_wheel_statics, IActivationFactory_iface ) +DEFINE_IINSPECTABLE( controller_factory, ICustomGameControllerFactory, racing_wheel_statics, IActivationFactory_iface )
static HRESULT WINAPI controller_factory_CreateGameController( ICustomGameControllerFactory *iface, IGameControllerProvider *provider, IInspectable **value ) diff --git a/dlls/windows.gaming.input/vector.c b/dlls/windows.gaming.input/vector.c index 954d7df3552..201d6f2c756 100644 --- a/dlls/windows.gaming.input/vector.c +++ b/dlls/windows.gaming.input/vector.c @@ -311,8 +311,8 @@ static const struct IVectorView_IInspectableVtbl vector_view_vtbl = vector_view_GetMany, };
-DEFINE_IINSPECTABLE_( iterable_view, IIterable_IInspectable, struct vector_view, view_impl_from_IIterable_IInspectable, - IIterable_IInspectable_iface, &impl->IVectorView_IInspectable_iface ) +DEFINE_IINSPECTABLE_( iterable_view, IIterable_IInspectable, vector_view, view_impl_from_IIterable_IInspectable, + IIterable_IInspectable_iface, (IInspectable *)&object->IVectorView_IInspectable_iface )
static HRESULT WINAPI iterable_view_First( IIterable_IInspectable *iface, IIterator_IInspectable **value ) { @@ -622,7 +622,7 @@ static const struct IVector_IInspectableVtbl vector_vtbl = vector_ReplaceAll, };
-DEFINE_IINSPECTABLE( iterable, IIterable_IInspectable, struct vector, IVector_IInspectable_iface ) +DEFINE_IINSPECTABLE( iterable, IIterable_IInspectable, vector, IVector_IInspectable_iface )
static HRESULT WINAPI iterable_First( IIterable_IInspectable *iface, IIterator_IInspectable **value ) { diff --git a/include/Makefile.in b/include/Makefile.in index bbf28cfc87e..83d27a84031 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -899,6 +899,7 @@ SOURCES = \ wine/afd.h \ wine/asm.h \ wine/atsvc.idl \ + wine/comimpl.h \ wine/condrv.h \ wine/dcetypes.idl \ wine/debug.h \ diff --git a/include/wine/comimpl.h b/include/wine/comimpl.h new file mode 100644 index 00000000000..c8078f40827 --- /dev/null +++ b/include/wine/comimpl.h @@ -0,0 +1,77 @@ +/* + * 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 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_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_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 */
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/windows.gaming.input/controller.c | 49 ++++++-------------------- include/wine/comimpl.h | 35 ++++++++++++++++++ 2 files changed, 45 insertions(+), 39 deletions(-)
diff --git a/dlls/windows.gaming.input/controller.c b/dlls/windows.gaming.input/controller.c index 72abbb6b417..510ccddbd27 100644 --- a/dlls/windows.gaming.input/controller.c +++ b/dlls/windows.gaming.input/controller.c @@ -63,7 +63,7 @@ struct controller IRawGameController IRawGameController_iface; IRawGameController2 IRawGameController2_iface; IGameController *IGameController_outer; - LONG ref; + LONG refcount;
IGameControllerProvider *provider; IWineGameControllerProvider *wine_provider; @@ -108,31 +108,15 @@ static HRESULT WINAPI controller_QueryInterface( IGameControllerImpl *iface, REF return E_NOINTERFACE; }
-static ULONG WINAPI controller_AddRef( IGameControllerImpl *iface ) +static void controller_destroy( struct controller *impl ) { - struct controller *impl = controller_from_IGameControllerImpl( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; + if (impl->wine_provider) IWineGameControllerProvider_Release( impl->wine_provider ); + IGameControllerProvider_Release( impl->provider ); + free( impl ); }
-static ULONG WINAPI controller_Release( IGameControllerImpl *iface ) -{ - struct controller *impl = controller_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; -} +IUNKNOWN_IMPL_ADDREF( controller, IGameControllerImpl ); +IUNKNOWN_IMPL_RELEASE( controller, IGameControllerImpl );
static HRESULT WINAPI controller_GetIids( IGameControllerImpl *iface, ULONG *iid_count, IID **iids ) { @@ -341,7 +325,6 @@ struct controller_statics IActivationFactory IActivationFactory_iface; IRawGameControllerStatics IRawGameControllerStatics_iface; ICustomGameControllerFactory ICustomGameControllerFactory_iface; - LONG ref; };
INTERFACE_IMPL_FROM( controller_statics, IActivationFactory ); @@ -378,21 +361,8 @@ static HRESULT WINAPI controller_statics_QueryInterface( IActivationFactory *ifa return E_NOINTERFACE; }
-static ULONG WINAPI controller_statics_AddRef( IActivationFactory *iface ) -{ - struct controller_statics *impl = controller_statics_from_IActivationFactory( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI controller_statics_Release( IActivationFactory *iface ) -{ - struct controller_statics *impl = controller_statics_from_IActivationFactory( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - return ref; -} +IUNKNOWN_IMPL_STATIC_ADDREF( controller_statics, IActivationFactory ); +IUNKNOWN_IMPL_STATIC_RELEASE( controller_statics, IActivationFactory );
static HRESULT WINAPI controller_statics_GetIids( IActivationFactory *iface, ULONG *iid_count, IID **iids ) { @@ -512,6 +482,7 @@ controller_statics_ICustomGameControllerFactory_CreateGameController( ICustomGam impl->IGameControllerInputSink_iface.lpVtbl = &controller_IGameControllerInputSink_vtbl; impl->IRawGameController_iface.lpVtbl = &controller_IRawGameController_vtbl; impl->IRawGameController2_iface.lpVtbl = &controller_IRawGameController2_vtbl; + impl->refcount = 1;
TRACE( "created RawGameController %p\n", impl );
diff --git a/include/wine/comimpl.h b/include/wine/comimpl.h index c8078f40827..5eff3b5ff02 100644 --- a/include/wine/comimpl.h +++ b/include/wine/comimpl.h @@ -38,6 +38,41 @@ return CONTAINING_RECORD( iface, struct type, iface_mem ); \ }
+#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_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 ) \
From: Rémi Bernon rbernon@codeweavers.com
--- tools/widl/header.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
diff --git a/tools/widl/header.c b/tools/widl/header.c index bd625b385af..b815b07c791 100644 --- a/tools/widl/header.c +++ b/tools/widl/header.c @@ -1646,6 +1646,11 @@ 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);
if (uuid) fprintf(header, "#define IID_%s IID_%s\n", name, iface->c_name); @@ -1678,9 +1683,31 @@ static void write_widl_impl_macros_methods(FILE *header, const type_t *iface, co 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) { + 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");
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 ) \
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/windows.gaming.input/controller.c | 12 ++++-------- include/wine/comimpl.h | 10 ++++++++++ 2 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/dlls/windows.gaming.input/controller.c b/dlls/windows.gaming.input/controller.c index 9007ed59209..1e6b839a6e6 100644 --- a/dlls/windows.gaming.input/controller.c +++ b/dlls/windows.gaming.input/controller.c @@ -71,8 +71,6 @@ struct controller };
INTERFACE_IMPL_FROM( controller, IGameControllerImpl ); -IUNKNOWN_IMPL_QUERY_INTERFACE( controller, IGameControllerImpl, IAgileObject, IGameControllerInputSink, - IRawGameController, IRawGameController2, END );
static void controller_destroy( struct controller *impl ) { @@ -81,8 +79,8 @@ static void controller_destroy( struct controller *impl ) free( impl ); }
-IUNKNOWN_IMPL_ADDREF( controller, IGameControllerImpl ); -IUNKNOWN_IMPL_RELEASE( controller, IGameControllerImpl ); +IUNKNOWN_IMPL( controller, IGameControllerImpl, IAgileObject, IGameControllerInputSink, + IRawGameController, IRawGameController2, END );
static HRESULT WINAPI controller_GetIids( IGameControllerImpl *iface, ULONG *iid_count, IID **iids ) { @@ -299,10 +297,8 @@ struct controller_statics };
INTERFACE_IMPL_FROM( controller_statics, IActivationFactory ); -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 ); +IUNKNOWN_IMPL_STATIC( controller_statics, IActivationFactory, IAgileObject, + IRawGameControllerStatics, ICustomGameControllerFactory, END );
static HRESULT WINAPI controller_statics_GetIids( IActivationFactory *iface, ULONG *iid_count, IID **iids ) { diff --git a/include/wine/comimpl.h b/include/wine/comimpl.h index 41691d21ef3..2631f2d97ac 100644 --- a/include/wine/comimpl.h +++ b/include/wine/comimpl.h @@ -88,6 +88,16 @@ 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 ) \
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/windows.gaming.input/controller.c | 43 ++++---------------------- include/wine/comimpl.h | 26 ++++++++++++++++ 2 files changed, 32 insertions(+), 37 deletions(-)
diff --git a/dlls/windows.gaming.input/controller.c b/dlls/windows.gaming.input/controller.c index 1e6b839a6e6..90f03f3b7fa 100644 --- a/dlls/windows.gaming.input/controller.c +++ b/dlls/windows.gaming.input/controller.c @@ -64,6 +64,7 @@ struct controller IRawGameController IRawGameController_iface; IRawGameController2 IRawGameController2_iface; IGameController *IGameController_outer; + const WCHAR *class_name; LONG refcount;
IGameControllerProvider *provider; @@ -81,25 +82,7 @@ static void controller_destroy( struct controller *impl )
IUNKNOWN_IMPL( controller, IGameControllerImpl, IAgileObject, IGameControllerInputSink, IRawGameController, IRawGameController2, END ); - -static HRESULT WINAPI controller_GetIids( IGameControllerImpl *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} - -static HRESULT WINAPI controller_GetRuntimeClassName( IGameControllerImpl *iface, HSTRING *class_name ) -{ - return WindowsCreateString( RuntimeClass_Windows_Gaming_Input_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; -} +IINSPECTABLE_IMPL( controller, IGameControllerImpl );
static HRESULT WINAPI controller_Initialize( IGameControllerImpl *iface, IGameController *outer, IGameControllerProvider *provider ) @@ -294,29 +277,13 @@ struct controller_statics IAgileObject IAgileObject_iface; IRawGameControllerStatics IRawGameControllerStatics_iface; ICustomGameControllerFactory ICustomGameControllerFactory_iface; + const WCHAR *class_name; };
INTERFACE_IMPL_FROM( controller_statics, IActivationFactory ); IUNKNOWN_IMPL_STATIC( controller_statics, IActivationFactory, IAgileObject, IRawGameControllerStatics, ICustomGameControllerFactory, END ); - -static HRESULT WINAPI controller_statics_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 controller_statics_GetRuntimeClassName( IActivationFactory *iface, HSTRING *class_name ) -{ - FIXME( "iface %p, class_name %p stub!\n", iface, class_name ); - return E_NOTIMPL; -} - -static HRESULT WINAPI controller_statics_GetTrustLevel( IActivationFactory *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} +IINSPECTABLE_IMPL( controller_statics, IActivationFactory );
static HRESULT WINAPI controller_statics_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) { @@ -423,6 +390,7 @@ controller_statics_ICustomGameControllerFactory_CreateGameController( ICustomGam 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 ); @@ -490,6 +458,7 @@ static struct controller_statics controller_statics = {&controller_statics_IAgileObject_vtbl}, {&controller_statics_IRawGameControllerStatics_vtbl}, {&controller_statics_ICustomGameControllerFactory_vtbl}, + RuntimeClass_Windows_Gaming_Input_RawGameController, };
ICustomGameControllerFactory *controller_factory = &controller_statics.ICustomGameControllerFactory_iface; diff --git a/include/wine/comimpl.h b/include/wine/comimpl.h index 2631f2d97ac..44c5d7f204a 100644 --- a/include/wine/comimpl.h +++ b/include/wine/comimpl.h @@ -116,6 +116,32 @@ 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 ) \
From: Rémi Bernon rbernon@codeweavers.com
--- tools/widl/header.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
diff --git a/tools/widl/header.c b/tools/widl/header.c index b815b07c791..d63b33e23b9 100644 --- a/tools/widl/header.c +++ b/tools/widl/header.c @@ -1652,6 +1652,14 @@ static void write_widl_using_macros(FILE *header, type_t *iface) 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); @@ -1688,6 +1696,8 @@ static void write_widl_impl_macros(FILE *header, type_t *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); @@ -1714,6 +1724,36 @@ static void write_widl_impl_macros(FILE *header, type_t *iface) 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"); } }
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/windows.gaming.input/controller.c | 51 +++++++------------------- include/wine/comimpl.h | 3 ++ 2 files changed, 17 insertions(+), 37 deletions(-)
diff --git a/dlls/windows.gaming.input/controller.c b/dlls/windows.gaming.input/controller.c index 90f03f3b7fa..97666199d34 100644 --- a/dlls/windows.gaming.input/controller.c +++ b/dlls/windows.gaming.input/controller.c @@ -63,7 +63,7 @@ struct controller IGameControllerInputSink IGameControllerInputSink_iface; IRawGameController IRawGameController_iface; IRawGameController2 IRawGameController2_iface; - IGameController *IGameController_outer; + IInspectable *outer; const WCHAR *class_name; LONG refcount;
@@ -71,8 +71,6 @@ struct controller IWineGameControllerProvider *wine_provider; };
-INTERFACE_IMPL_FROM( controller, IGameControllerImpl ); - static void controller_destroy( struct controller *impl ) { if (impl->wine_provider) IWineGameControllerProvider_Release( impl->wine_provider ); @@ -80,9 +78,8 @@ static void controller_destroy( struct controller *impl ) free( impl ); }
-IUNKNOWN_IMPL( controller, IGameControllerImpl, IAgileObject, IGameControllerInputSink, - IRawGameController, IRawGameController2, END ); -IINSPECTABLE_IMPL( controller, IGameControllerImpl ); +INTERFACE_IMPL_OUTER_IGameControllerImpl( controller, IAgileObject, IGameControllerInputSink, + IRawGameController, IRawGameController2, END );
static HRESULT WINAPI controller_Initialize( IGameControllerImpl *iface, IGameController *outer, IGameControllerProvider *provider ) @@ -92,7 +89,7 @@ static HRESULT WINAPI controller_Initialize( IGameControllerImpl *iface, IGameCo
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, @@ -108,13 +105,8 @@ 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 ) { FIXME( "iface %p, timestamp %I64u stub!\n", iface, timestamp ); @@ -129,17 +121,15 @@ static HRESULT WINAPI controller_IGameControllerInputSink_OnInputSuspended( IGam
INTERFACE_VTBL_IGameControllerInputSink( controller_IGameControllerInputSink );
-DEFINE_IINSPECTABLE_OUTER( controller_IRawGameController, IRawGameController, controller, IGameController_outer ) - 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 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 ); }
@@ -153,7 +143,7 @@ static HRESULT WINAPI controller_IRawGameController_get_ForceFeedbackMotors( IRa .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; @@ -176,19 +166,19 @@ static HRESULT WINAPI controller_IRawGameController_get_ForceFeedbackMotors( IRa
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 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 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 ); }
@@ -204,7 +194,7 @@ controller_IRawGameController_GetCurrentReading( IRawGameController *iface, UINT 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;
@@ -230,8 +220,6 @@ static HRESULT WINAPI controller_IRawGameController_GetSwitchKind( IRawGameContr
INTERFACE_VTBL_IRawGameController( controller_IRawGameController );
-DEFINE_IINSPECTABLE_OUTER( controller_IRawGameController2, IRawGameController2, controller, IGameController_outer ) - static HRESULT WINAPI controller_IRawGameController2_get_SimpleHapticsControllers( IRawGameController2 *iface, IVectorView_SimpleHapticsController **value ) @@ -280,10 +268,8 @@ struct controller_statics const WCHAR *class_name; };
-INTERFACE_IMPL_FROM( controller_statics, IActivationFactory ); -IUNKNOWN_IMPL_STATIC( controller_statics, IActivationFactory, IAgileObject, - IRawGameControllerStatics, ICustomGameControllerFactory, END ); -IINSPECTABLE_IMPL( controller_statics, IActivationFactory ); +INTERFACE_IMPL_STATIC_IActivationFactory( controller_statics, IAgileObject, IRawGameControllerStatics, + ICustomGameControllerFactory, END );
static HRESULT WINAPI controller_statics_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) { @@ -292,14 +278,8 @@ 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 ) - static HRESULT WINAPI controller_statics_IRawGameControllerStatics_add_RawGameControllerAdded( IRawGameControllerStatics *iface, IEventHandler_RawGameController *handler, @@ -354,7 +334,7 @@ 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;
@@ -373,9 +353,6 @@ controller_statics_IRawGameControllerStatics_FromGameController( IRawGameControl
INTERFACE_VTBL_IRawGameControllerStatics( controller_statics_IRawGameControllerStatics );
-DEFINE_IINSPECTABLE( controller_statics_ICustomGameControllerFactory, ICustomGameControllerFactory, - controller_statics, IActivationFactory_iface ) - static HRESULT WINAPI controller_statics_ICustomGameControllerFactory_CreateGameController( ICustomGameControllerFactory *iface, IGameControllerProvider *provider, IInspectable **value ) diff --git a/include/wine/comimpl.h b/include/wine/comimpl.h index 44c5d7f204a..6b21fa4c16e 100644 --- a/include/wine/comimpl.h +++ b/include/wine/comimpl.h @@ -34,6 +34,9 @@ #define QUERY_INTERFACES_END( object, iid, out, ... ) #define QUERY_INTERFACES( object, iid, out, X, ... ) QUERY_INTERFACES_ ## X( object, iid, out, __VA_ARGS__ )
+#define INTERFACES_FWD_END( type, base, expr, ... ) +#define INTERFACES_FWD( type, base, expr, X, ... ) INTERFACES_FWD_ ## X( type, base, expr, __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 ) \
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/windows.gaming.input/async.c | 341 ++++------------- dlls/windows.gaming.input/condition_effect.c | 205 ++--------- dlls/windows.gaming.input/constant_effect.c | 177 ++------- dlls/windows.gaming.input/force_feedback.c | 259 +++---------- dlls/windows.gaming.input/gamepad.c | 369 +++---------------- dlls/windows.gaming.input/manager.c | 243 ++---------- dlls/windows.gaming.input/periodic_effect.c | 207 ++--------- dlls/windows.gaming.input/private.h | 9 - dlls/windows.gaming.input/provider.c | 173 ++------- dlls/windows.gaming.input/provider.idl | 4 +- dlls/windows.gaming.input/racing_wheel.c | 349 +++--------------- dlls/windows.gaming.input/ramp_effect.c | 177 ++------- dlls/windows.gaming.input/vector.c | 327 +++++----------- 13 files changed, 525 insertions(+), 2315 deletions(-)
diff --git a/dlls/windows.gaming.input/async.c b/dlls/windows.gaming.input/async.c index 0639280215b..3e2c36190d2 100644 --- a/dlls/windows.gaming.input/async.c +++ b/dlls/windows.gaming.input/async.c @@ -31,9 +31,11 @@ WINE_DEFAULT_DEBUG_CHANNEL(input); struct async_info { IWineAsyncInfoImpl IWineAsyncInfoImpl_iface; + IAgileObject IAgileObject_iface; IAsyncInfo IAsyncInfo_iface; - IInspectable *IInspectable_outer; - LONG ref; + 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 ) -{ - 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 ); - } +INTERFACE_IMPL_OUTER_IWineAsyncInfoImpl( async_info, IAgileObject, IAsyncInfo, END );
- return ref; -} - -static HRESULT WINAPI async_impl_put_Completed( IWineAsyncInfoImpl *iface, IWineAsyncOperationCompletedHandler *handler ) +static HRESULT WINAPI async_info_put_Completed( IWineAsyncInfoImpl *iface, IWineAsyncOperationCompletedHandler *handler ) { - struct async_info *impl = impl_from_IWineAsyncInfoImpl( iface ); + struct async_info *impl = async_info_from_IWineAsyncInfoImpl( iface ); HRESULT hr = S_OK;
TRACE( "iface %p, handler %p.\n", iface, handler ); @@ -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, -}; - -DEFINE_IINSPECTABLE_OUTER( async_info, IAsyncInfo, async_info, IInspectable_outer ) +INTERFACE_VTBL_IWineAsyncInfoImpl( async_info );
-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->IAgileObject_iface.lpVtbl = &async_info_IAgileObject_vtbl; + impl->IAsyncInfo_iface.lpVtbl = &async_info_IAsyncInfo_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 ) -{ - struct async_bool *impl = impl_from_IAsyncOperation_boolean( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p, ref %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI async_bool_Release( IAsyncOperation_boolean *iface ) -{ - struct async_bool *impl = impl_from_IAsyncOperation_boolean( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - TRACE( "iface %p, ref %lu.\n", iface, ref ); - - if (!ref) - { - /* guard against re-entry if inner releases an outer iface */ - InterlockedIncrement( &impl->ref ); - IWineAsyncInfoImpl_Release( impl->IWineAsyncInfoImpl_inner ); - free( impl ); - } +IUNKNOWN_IMPL_ADDREF( async_bool, IAsyncOperation_boolean );
- return ref; -} - -static HRESULT WINAPI async_bool_GetIids( IAsyncOperation_boolean *iface, ULONG *iid_count, IID **iids ) +static void async_bool_destroy( struct async_bool *impl ) { - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; + IWineAsyncInfoImpl_Release( impl->IWineAsyncInfoImpl_inner ); + free( impl ); }
-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 ) -{ - struct async_result *impl = impl_from_IAsyncOperation_ForceFeedbackLoadEffectResult( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p, ref %lu.\n", iface, ref ); - return ref; -} +IUNKNOWN_IMPL_ADDREF( async_result, IAsyncOperation_ForceFeedbackLoadEffectResult );
-static ULONG WINAPI async_result_Release( IAsyncOperation_ForceFeedbackLoadEffectResult *iface ) +static void async_result_destroy( struct async_result *impl ) { - 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; + IWineAsyncInfoImpl_Release( impl->IWineAsyncInfoImpl_inner ); + free( impl ); }
-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 ))) diff --git a/dlls/windows.gaming.input/condition_effect.c b/dlls/windows.gaming.input/condition_effect.c index a2c4329f3ae..3e5ea160c45 100644 --- a/dlls/windows.gaming.input/condition_effect.c +++ b/dlls/windows.gaming.input/condition_effect.c @@ -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 ) -{ - struct condition_effect *impl = impl_from_IConditionForceEffect( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI effect_Release( IConditionForceEffect *iface ) -{ - struct condition_effect *impl = impl_from_IConditionForceEffect( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - - if (!ref) - { - /* guard against re-entry if inner releases an outer iface */ - InterlockedIncrement( &impl->ref ); - IWineForceFeedbackEffectImpl_Release( impl->IWineForceFeedbackEffectImpl_inner ); - free( impl ); - } - - return ref; -} - -static HRESULT WINAPI effect_GetIids( IConditionForceEffect *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} +IUNKNOWN_IMPL_ADDREF( condition_effect, IConditionForceEffect );
-static HRESULT WINAPI effect_GetRuntimeClassName( IConditionForceEffect *iface, HSTRING *class_name ) +static void condition_effect_destroy( struct condition_effect *impl ) { - return WindowsCreateString( RuntimeClass_Windows_Gaming_Input_ForceFeedback_ConditionForceEffect, - ARRAY_SIZE(RuntimeClass_Windows_Gaming_Input_ForceFeedback_ConditionForceEffect), - class_name ); + IWineForceFeedbackEffectImpl_Release( impl->IWineForceFeedbackEffectImpl_inner ); + free( impl ); }
-static HRESULT WINAPI effect_GetTrustLevel( IConditionForceEffect *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} +IUNKNOWN_IMPL_RELEASE( condition_effect, IConditionForceEffect ); +IINSPECTABLE_IMPL( condition_effect, IConditionForceEffect );
-static HRESULT WINAPI effect_get_Kind( IConditionForceEffect *iface, ConditionForceEffectKind *kind ) +static HRESULT WINAPI condition_effect_get_Kind( IConditionForceEffect *iface, ConditionForceEffectKind *kind ) { - struct condition_effect *impl = impl_from_IConditionForceEffect( iface ); + struct condition_effect *impl = condition_effect_from_IConditionForceEffect( iface ); TRACE( "iface %p, kind %p.\n", iface, kind ); *kind = impl->kind; return S_OK; }
-static HRESULT WINAPI effect_SetParameters( IConditionForceEffect *iface, Vector3 direction, FLOAT positive_coeff, FLOAT negative_coeff, +static HRESULT WINAPI condition_effect_SetParameters( IConditionForceEffect *iface, Vector3 direction, FLOAT positive_coeff, FLOAT negative_coeff, FLOAT max_positive_magnitude, FLOAT max_negative_magnitude, FLOAT deadzone, FLOAT bias ) { - struct condition_effect *impl = impl_from_IConditionForceEffect( iface ); + struct condition_effect *impl = condition_effect_from_IConditionForceEffect( iface ); WineForceFeedbackEffectParameters params = { .condition = @@ -132,114 +86,28 @@ 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; + IAgileObject IAgileObject_iface; IConditionForceEffectFactory IConditionForceEffectFactory_iface; - LONG ref; + const WCHAR *class_name; };
-static inline struct condition_factory *impl_from_IActivationFactory( IActivationFactory *iface ) -{ - return CONTAINING_RECORD( iface, struct condition_factory, IActivationFactory_iface ); -} - -static HRESULT WINAPI activation_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) -{ - struct condition_factory *impl = impl_from_IActivationFactory( iface ); - - TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out ); - - if (IsEqualGUID( iid, &IID_IUnknown ) || - IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_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; -} +INTERFACE_IMPL_STATIC_IActivationFactory( condition_factory, IAgileObject, IConditionForceEffectFactory, END );
-static HRESULT WINAPI activation_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) +static HRESULT WINAPI condition_factory_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) { FIXME( "iface %p, instance %p stub!\n", iface, instance ); return E_NOTIMPL; }
-static const struct IActivationFactoryVtbl activation_vtbl = -{ - activation_QueryInterface, - activation_AddRef, - activation_Release, - /* IInspectable methods */ - activation_GetIids, - activation_GetRuntimeClassName, - activation_GetTrustLevel, - /* IActivationFactory methods */ - activation_ActivateInstance, -}; - -DEFINE_IINSPECTABLE( factory, IConditionForceEffectFactory, condition_factory, IActivationFactory_iface ) +INTERFACE_VTBL_IActivationFactory( condition_factory ); +INTERFACE_VTBL_IAgileObject( condition_factory_IAgileObject );
-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 +116,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 +134,14 @@ 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 );
static struct condition_factory condition_statics = { - {&activation_vtbl}, - {&factory_vtbl}, - 1, + {&condition_factory_vtbl}, + {&condition_factory_IAgileObject_vtbl}, + {&condition_factory_IConditionForceEffectFactory_vtbl}, + RuntimeClass_Windows_Gaming_Input_ForceFeedback_ConditionForceEffect, };
IInspectable *condition_effect_factory = (IInspectable *)&condition_statics.IActivationFactory_iface; diff --git a/dlls/windows.gaming.input/constant_effect.c b/dlls/windows.gaming.input/constant_effect.c index 15763b30d67..16f1ff55be3 100644 --- a/dlls/windows.gaming.input/constant_effect.c +++ b/dlls/windows.gaming.input/constant_effect.c @@ -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 ) -{ - struct constant_effect *impl = impl_from_IConstantForceEffect( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} +IUNKNOWN_IMPL_ADDREF( constant_effect, IConstantForceEffect );
-static ULONG WINAPI effect_Release( IConstantForceEffect *iface ) +static void constant_effect_destroy( struct constant_effect *impl ) { - struct constant_effect *impl = impl_from_IConstantForceEffect( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - - if (!ref) - { - /* guard against re-entry if inner releases an outer iface */ - InterlockedIncrement( &impl->ref ); - IWineForceFeedbackEffectImpl_Release( impl->IWineForceFeedbackEffectImpl_inner ); - free( impl ); - } - - return ref; + IWineForceFeedbackEffectImpl_Release( impl->IWineForceFeedbackEffectImpl_inner ); + free( impl ); }
-static HRESULT WINAPI effect_GetIids( IConstantForceEffect *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} +IUNKNOWN_IMPL_RELEASE( constant_effect, IConstantForceEffect ); +IINSPECTABLE_IMPL( constant_effect, IConstantForceEffect );
-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,17 @@ 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; + 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, END );
-static HRESULT WINAPI activation_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) -{ - struct constant_factory *impl = impl_from_IActivationFactory( iface ); - - TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out ); - - if (IsEqualGUID( iid, &IID_IUnknown ) || - IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_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 +123,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 +139,12 @@ 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 );
static struct constant_factory constant_statics = { - {&activation_vtbl}, - 1, + {&constant_factory_vtbl}, + RuntimeClass_Windows_Gaming_Input_ForceFeedback_ConstantForceEffect, };
IInspectable *constant_effect_factory = (IInspectable *)&constant_statics.IActivationFactory_iface; diff --git a/dlls/windows.gaming.input/force_feedback.c b/dlls/windows.gaming.input/force_feedback.c index 89904e058cc..05312343d22 100644 --- a/dlls/windows.gaming.input/force_feedback.c +++ b/dlls/windows.gaming.input/force_feedback.c @@ -33,9 +33,11 @@ WINE_DEFAULT_DEBUG_CHANNEL(input); struct effect { IWineForceFeedbackEffectImpl IWineForceFeedbackEffectImpl_iface; + IAgileObject IAgileObject_iface; IForceFeedbackEffect IForceFeedbackEffect_iface; - IInspectable *IInspectable_outer; - LONG ref; + 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, IAgileObject, IForceFeedbackEffect, END );
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,12 @@ 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, -}; - -DEFINE_IINSPECTABLE_OUTER( effect, IForceFeedbackEffect, effect, IInspectable_outer ) +INTERFACE_VTBL_IWineForceFeedbackEffectImpl( effect ); +INTERFACE_VTBL_IAgileObject( effect_IAgileObject );
-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 +206,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 +222,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 +245,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 +260,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 +274,7 @@ 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 );
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->IAgileObject_iface.lpVtbl = &effect_IAgileObject_vtbl; + impl->IForceFeedbackEffect_iface.lpVtbl = &effect_IForceFeedbackEffect_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 );
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; diff --git a/dlls/windows.gaming.input/gamepad.c b/dlls/windows.gaming.input/gamepad.c index 427d297480f..eccba5d2d76 100644 --- a/dlls/windows.gaming.input/gamepad.c +++ b/dlls/windows.gaming.input/gamepad.c @@ -62,109 +62,33 @@ struct gamepad IGameControllerInputSink IGameControllerInputSink_iface; IGamepad IGamepad_iface; IGamepad2 IGamepad2_iface; - IGameController *IGameController_outer; - LONG ref; + IInspectable *outer; + const WCHAR *class_name; + LONG refcount;
IGameControllerProvider *provider; IWineGameControllerProvider *wine_provider; };
-static inline struct gamepad *impl_from_IGameControllerImpl( IGameControllerImpl *iface ) +static void gamepad_destroy( struct gamepad *impl ) { - return CONTAINING_RECORD( iface, struct gamepad, IGameControllerImpl_iface ); + if (impl->wine_provider) + IWineGameControllerProvider_Release( impl->wine_provider ); + IGameControllerProvider_Release( impl->provider ); + free( impl ); }
-static HRESULT WINAPI controller_QueryInterface( IGameControllerImpl *iface, REFIID iid, void **out ) -{ - struct gamepad *impl = impl_from_IGameControllerImpl( iface ); - - TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out ); - - if (IsEqualGUID( iid, &IID_IUnknown ) || - IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IGameControllerImpl )) - { - IInspectable_AddRef( (*out = &impl->IGameControllerImpl_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IGameControllerInputSink )) - { - IInspectable_AddRef( (*out = &impl->IGameControllerInputSink_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IGamepad )) - { - IInspectable_AddRef( (*out = &impl->IGamepad_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IGamepad2 )) - { - IInspectable_AddRef( (*out = &impl->IGamepad2_iface) ); - return S_OK; - } - - FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); - *out = NULL; - return E_NOINTERFACE; -} - -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 ); - } +INTERFACE_IMPL_OUTER_IGameControllerImpl( gamepad, IGameControllerInputSink, IGamepad, IGamepad2, END );
- return ref; -} - -static HRESULT WINAPI controller_GetIids( IGameControllerImpl *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} - -static HRESULT WINAPI controller_GetRuntimeClassName( IGameControllerImpl *iface, HSTRING *class_name ) -{ - return WindowsCreateString( RuntimeClass_Windows_Gaming_Input_Gamepad, - ARRAY_SIZE(RuntimeClass_Windows_Gaming_Input_Gamepad), - class_name ); -} - -static HRESULT WINAPI controller_GetTrustLevel( IGameControllerImpl *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} - -static HRESULT WINAPI controller_Initialize( IGameControllerImpl *iface, IGameController *outer, +static HRESULT WINAPI gamepad_Initialize( IGameControllerImpl *iface, IGameController *outer, IGameControllerProvider *provider ) { - struct gamepad *impl = impl_from_IGameControllerImpl( iface ); + struct gamepad *impl = gamepad_from_IGameControllerImpl( iface ); HRESULT hr;
TRACE( "iface %p, outer %p, provider %p.\n", iface, outer, provider );
- impl->IGameController_outer = outer; + impl->outer = (IInspectable *)outer; IGameControllerProvider_AddRef( (impl->provider = provider) );
hr = IGameControllerProvider_QueryInterface( provider, &IID_IWineGameControllerProvider, @@ -179,52 +103,25 @@ static HRESULT WINAPI controller_Initialize( IGameControllerImpl *iface, IGameCo return hr; }
-static const struct IGameControllerImplVtbl controller_vtbl = -{ - controller_QueryInterface, - controller_AddRef, - controller_Release, - /* IInspectable methods */ - controller_GetIids, - controller_GetRuntimeClassName, - controller_GetTrustLevel, - /* IGameControllerImpl methods */ - controller_Initialize, -}; - -DEFINE_IINSPECTABLE_OUTER( input_sink, IGameControllerInputSink, gamepad, IGameController_outer ) +INTERFACE_VTBL_IGameControllerImpl( gamepad );
-static HRESULT WINAPI input_sink_OnInputResumed( IGameControllerInputSink *iface, UINT64 timestamp ) +static HRESULT WINAPI gamepad_IGameControllerInputSink_OnInputResumed( IGameControllerInputSink *iface, UINT64 timestamp ) { FIXME( "iface %p, timestamp %I64u stub!\n", iface, timestamp ); return E_NOTIMPL; }
-static HRESULT WINAPI input_sink_OnInputSuspended( IGameControllerInputSink *iface, UINT64 timestamp ) +static HRESULT WINAPI gamepad_IGameControllerInputSink_OnInputSuspended( IGameControllerInputSink *iface, UINT64 timestamp ) { FIXME( "iface %p, timestamp %I64u stub!\n", iface, timestamp ); return E_NOTIMPL; }
-static const struct IGameControllerInputSinkVtbl input_sink_vtbl = -{ - input_sink_QueryInterface, - input_sink_AddRef, - input_sink_Release, - /* IInspectable methods */ - input_sink_GetIids, - input_sink_GetRuntimeClassName, - input_sink_GetTrustLevel, - /* IGameControllerInputSink methods */ - input_sink_OnInputResumed, - input_sink_OnInputSuspended, -}; - -DEFINE_IINSPECTABLE_OUTER( gamepad, IGamepad, gamepad, IGameController_outer ) +INTERFACE_VTBL_IGameControllerInputSink( gamepad_IGameControllerInputSink );
-static HRESULT WINAPI gamepad_get_Vibration( IGamepad *iface, struct GamepadVibration *value ) +static HRESULT WINAPI gamepad_IGamepad_get_Vibration( IGamepad *iface, struct GamepadVibration *value ) { - struct gamepad *impl = impl_from_IGamepad( iface ); + struct gamepad *impl = gamepad_from_IGamepad( iface ); struct WineGameControllerVibration vibration; HRESULT hr;
@@ -240,9 +137,9 @@ static HRESULT WINAPI gamepad_get_Vibration( IGamepad *iface, struct GamepadVibr return S_OK; }
-static HRESULT WINAPI gamepad_put_Vibration( IGamepad *iface, struct GamepadVibration value ) +static HRESULT WINAPI gamepad_IGamepad_put_Vibration( IGamepad *iface, struct GamepadVibration value ) { - struct gamepad *impl = impl_from_IGamepad( iface ); + struct gamepad *impl = gamepad_from_IGamepad( iface ); struct WineGameControllerVibration vibration = { .rumble = value.LeftMotor * 65535., @@ -256,9 +153,9 @@ static HRESULT WINAPI gamepad_put_Vibration( IGamepad *iface, struct GamepadVibr return IWineGameControllerProvider_put_Vibration( impl->wine_provider, vibration ); }
-static HRESULT WINAPI gamepad_GetCurrentReading( IGamepad *iface, struct GamepadReading *value ) +static HRESULT WINAPI gamepad_IGamepad_GetCurrentReading( IGamepad *iface, struct GamepadReading *value ) { - struct gamepad *impl = impl_from_IGamepad( iface ); + struct gamepad *impl = gamepad_from_IGamepad( iface ); struct WineGameControllerState state; HRESULT hr;
@@ -322,151 +219,40 @@ static HRESULT WINAPI gamepad_GetCurrentReading( IGamepad *iface, struct Gamepad return hr; }
-static const struct IGamepadVtbl gamepad_vtbl = -{ - gamepad_QueryInterface, - gamepad_AddRef, - gamepad_Release, - /* IInspectable methods */ - gamepad_GetIids, - gamepad_GetRuntimeClassName, - gamepad_GetTrustLevel, - /* IGamepad methods */ - gamepad_get_Vibration, - gamepad_put_Vibration, - gamepad_GetCurrentReading, -}; - -DEFINE_IINSPECTABLE_OUTER( gamepad2, IGamepad2, gamepad, IGameController_outer ) +INTERFACE_VTBL_IGamepad( gamepad_IGamepad );
-static HRESULT WINAPI gamepad2_GetButtonLabel( IGamepad2 *iface, GamepadButtons button, GameControllerButtonLabel *value ) +static HRESULT WINAPI gamepad_IGamepad2_GetButtonLabel( IGamepad2 *iface, GamepadButtons button, GameControllerButtonLabel *value ) { FIXME( "iface %p, button %#x, value %p stub!\n", iface, button, value ); *value = GameControllerButtonLabel_None; return S_OK; }
-static const struct IGamepad2Vtbl gamepad2_vtbl = -{ - gamepad2_QueryInterface, - gamepad2_AddRef, - gamepad2_Release, - /* IInspectable methods */ - gamepad2_GetIids, - gamepad2_GetRuntimeClassName, - gamepad2_GetTrustLevel, - /* IGamepad2 methods */ - gamepad2_GetButtonLabel, -}; +INTERFACE_VTBL_IGamepad2( gamepad_IGamepad2 );
struct gamepad_statics { IActivationFactory IActivationFactory_iface; + IAgileObject IAgileObject_iface; IGamepadStatics IGamepadStatics_iface; IGamepadStatics2 IGamepadStatics2_iface; ICustomGameControllerFactory ICustomGameControllerFactory_iface; - LONG ref; + const WCHAR *class_name; };
-static inline struct gamepad_statics *impl_from_IActivationFactory( IActivationFactory *iface ) -{ - return CONTAINING_RECORD( iface, struct gamepad_statics, IActivationFactory_iface ); -} - -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; -} +INTERFACE_IMPL_STATIC_IActivationFactory( gamepad_statics, IAgileObject, IGamepadStatics, IGamepadStatics2, + ICustomGameControllerFactory, END );
-static HRESULT WINAPI factory_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) +static HRESULT WINAPI gamepad_statics_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) { FIXME( "iface %p, instance %p stub!\n", iface, instance ); return E_NOTIMPL; }
-static const struct IActivationFactoryVtbl factory_vtbl = -{ - factory_QueryInterface, - factory_AddRef, - factory_Release, - /* IInspectable methods */ - factory_GetIids, - factory_GetRuntimeClassName, - factory_GetTrustLevel, - /* IActivationFactory methods */ - factory_ActivateInstance, -}; - -DEFINE_IINSPECTABLE( statics, IGamepadStatics, gamepad_statics, IActivationFactory_iface ) +INTERFACE_VTBL_IActivationFactory( gamepad_statics ); +INTERFACE_VTBL_IAgileObject( gamepad_statics_IAgileObject );
-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 ); @@ -474,13 +260,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 ); @@ -488,13 +274,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;
@@ -508,28 +294,11 @@ static HRESULT WINAPI statics_get_Gamepads( IGamepadStatics *iface, IVectorView_ return hr; }
-static const struct IGamepadStaticsVtbl statics_vtbl = -{ - statics_QueryInterface, - statics_AddRef, - statics_Release, - /* IInspectable methods */ - statics_GetIids, - statics_GetRuntimeClassName, - statics_GetTrustLevel, - /* IGamepadStatics methods */ - statics_add_GamepadAdded, - statics_remove_GamepadAdded, - statics_add_GamepadRemoved, - statics_remove_GamepadRemoved, - statics_get_Gamepads, -}; - -DEFINE_IINSPECTABLE( statics2, IGamepadStatics2, gamepad_statics, IActivationFactory_iface ) +INTERFACE_VTBL_IGamepadStatics( gamepad_statics_IGamepadStatics );
-static HRESULT WINAPI statics2_FromGameController( IGamepadStatics2 *iface, IGameController *game_controller, IGamepad **value ) +static HRESULT WINAPI gamepad_statics_IGamepadStatics2_FromGameController( IGamepadStatics2 *iface, IGameController *game_controller, IGamepad **value ) { - struct gamepad_statics *impl = impl_from_IGamepadStatics2( iface ); + struct gamepad_statics *impl = gamepad_statics_from_IGamepadStatics2( iface ); IGameController *controller; HRESULT hr;
@@ -545,22 +314,9 @@ static HRESULT WINAPI statics2_FromGameController( IGamepadStatics2 *iface, IGam return hr; }
-static const struct IGamepadStatics2Vtbl statics2_vtbl = -{ - statics2_QueryInterface, - statics2_AddRef, - statics2_Release, - /* IInspectable methods */ - statics2_GetIids, - statics2_GetRuntimeClassName, - statics2_GetTrustLevel, - /* IGamepadStatics2 methods */ - statics2_FromGameController, -}; - -DEFINE_IINSPECTABLE( controller_factory, ICustomGameControllerFactory, gamepad_statics, IActivationFactory_iface ) +INTERFACE_VTBL_IGamepadStatics2( gamepad_statics_IGamepadStatics2 );
-static HRESULT WINAPI controller_factory_CreateGameController( ICustomGameControllerFactory *iface, IGameControllerProvider *provider, +static HRESULT WINAPI gamepad_statics_ICustomGameControllerFactory_CreateGameController( ICustomGameControllerFactory *iface, IGameControllerProvider *provider, IInspectable **value ) { struct gamepad *impl; @@ -568,11 +324,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 );
@@ -580,7 +337,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; @@ -595,7 +352,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; @@ -629,28 +386,16 @@ 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 );
static struct gamepad_statics gamepad_statics = { - {&factory_vtbl}, - {&statics_vtbl}, - {&statics2_vtbl}, - {&controller_factory_vtbl}, - 1, + {&gamepad_statics_vtbl}, + {&gamepad_statics_IAgileObject_vtbl}, + {&gamepad_statics_IGamepadStatics_vtbl}, + {&gamepad_statics_IGamepadStatics2_vtbl}, + {&gamepad_statics_ICustomGameControllerFactory_vtbl}, + RuntimeClass_Windows_Gaming_Input_Gamepad, };
ICustomGameControllerFactory *gamepad_factory = &gamepad_statics.ICustomGameControllerFactory_iface; diff --git a/dlls/windows.gaming.input/manager.c b/dlls/windows.gaming.input/manager.c index 6ba1e046ce1..55ce6099c17 100644 --- a/dlls/windows.gaming.input/manager.c +++ b/dlls/windows.gaming.input/manager.c @@ -40,70 +40,37 @@ struct controller IGameController IGameController_iface; IGameControllerBatteryInfo IGameControllerBatteryInfo_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 ) return IInspectable_QueryInterface( impl->IInspectable_inner, iid, out ); }
-static ULONG WINAPI controller_AddRef( IGameController *iface ) -{ - struct controller *impl = impl_from_IGameController( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} +IUNKNOWN_IMPL_ADDREF( controller, IGameController );
-static ULONG WINAPI controller_Release( IGameController *iface ) +static void controller_destroy( struct controller *impl ) { - struct controller *impl = impl_from_IGameController( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - - if (!ref) - { - /* guard against re-entry if inner releases an outer iface */ - InterlockedIncrement( &impl->ref ); - IInspectable_Release( impl->IInspectable_inner ); - ICustomGameControllerFactory_Release( impl->factory ); - IGameControllerProvider_Release( impl->provider ); - free( impl ); - } - - return ref; + IInspectable_Release( impl->IInspectable_inner ); + ICustomGameControllerFactory_Release( impl->factory ); + IGameControllerProvider_Release( impl->provider ); + free( impl ); }
+IUNKNOWN_IMPL_RELEASE( controller, IGameController ); + static HRESULT WINAPI controller_GetIids( IGameController *iface, ULONG *iid_count, IID **iids ) { FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); @@ -112,13 +79,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 +147,38 @@ static HRESULT WINAPI controller_get_User( IGameController *iface, __x_ABI_CWind return E_NOTIMPL; }
-static const struct IGameControllerVtbl controller_vtbl = -{ - controller_QueryInterface, - controller_AddRef, - controller_Release, - /* IInspectable methods */ - controller_GetIids, - controller_GetRuntimeClassName, - controller_GetTrustLevel, - /* IGameController methods */ - controller_add_HeadsetConnected, - controller_remove_HeadsetConnected, - controller_add_HeadsetDisconnected, - controller_remove_HeadsetDisconnected, - controller_add_UserChanged, - controller_remove_UserChanged, - controller_get_Headset, - controller_get_IsWireless, - controller_get_User, -}; +INTERFACE_VTBL_IGameController( controller );
-DEFINE_IINSPECTABLE( battery, IGameControllerBatteryInfo, controller, IGameController_iface ) +INTERFACE_FWD_IGameControllerBatteryInfo( controller, IGameController, &object->IGameController_iface );
-static HRESULT WINAPI battery_TryGetBatteryReport( IGameControllerBatteryInfo *iface, IBatteryReport **value ) +static HRESULT WINAPI controller_IGameControllerBatteryInfo_TryGetBatteryReport( IGameControllerBatteryInfo *iface, IBatteryReport **value ) { FIXME( "iface %p, value %p stub!\n", iface, value ); return E_NOTIMPL; }
-static const struct IGameControllerBatteryInfoVtbl battery_vtbl = -{ - battery_QueryInterface, - battery_AddRef, - battery_Release, - /* IInspectable methods */ - battery_GetIids, - battery_GetRuntimeClassName, - battery_GetTrustLevel, - /* IGameControllerBatteryInfo methods */ - battery_TryGetBatteryReport, -}; +INTERFACE_VTBL_IGameControllerBatteryInfo( controller_IGameControllerBatteryInfo );
struct manager_statics { IActivationFactory IActivationFactory_iface; IGameControllerFactoryManagerStatics IGameControllerFactoryManagerStatics_iface; IGameControllerFactoryManagerStatics2 IGameControllerFactoryManagerStatics2_iface; - LONG ref; + const WCHAR *class_name; };
-static inline struct manager_statics *impl_from_IActivationFactory( IActivationFactory *iface ) -{ - return CONTAINING_RECORD( iface, struct manager_statics, IActivationFactory_iface ); -} +INTERFACE_IMPL_STATIC_IActivationFactory( manager_statics, IGameControllerFactoryManagerStatics, IGameControllerFactoryManagerStatics2, END )
-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, 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 +187,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 +196,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 +204,10 @@ statics_RegisterCustomFactoryForXusbType( IGameControllerFactoryManagerStatics * return E_NOTIMPL; }
-static const struct IGameControllerFactoryManagerStaticsVtbl statics_vtbl = -{ - statics_QueryInterface, - statics_AddRef, - statics_Release, - /* IInspectable methods */ - statics_GetIids, - statics_GetRuntimeClassName, - statics_GetTrustLevel, - /* IGameControllerFactoryManagerStatics methods */ - statics_RegisterCustomFactoryForGipInterface, - statics_RegisterCustomFactoryForHardwareId, - statics_RegisterCustomFactoryForXusbType, -}; - -DEFINE_IINSPECTABLE( statics2, IGameControllerFactoryManagerStatics2, manager_statics, IActivationFactory_iface ) +INTERFACE_VTBL_IGameControllerFactoryManagerStatics( manager_statics_IGameControllerFactoryManagerStatics );
static HRESULT WINAPI -statics2_TryGetFactoryControllerFromGameController( IGameControllerFactoryManagerStatics2 *iface, +manager_statics_IGameControllerFactoryManagerStatics2_TryGetFactoryControllerFromGameController( IGameControllerFactoryManagerStatics2 *iface, ICustomGameControllerFactory *factory, IGameController *controller, IGameController **value ) { @@ -403,25 +243,14 @@ 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 );
static struct manager_statics manager_statics = { - {&factory_vtbl}, - {&statics_vtbl}, - {&statics2_vtbl}, - 1, + {&manager_statics_vtbl}, + {&manager_statics_IGameControllerFactoryManagerStatics_vtbl}, + {&manager_statics_IGameControllerFactoryManagerStatics2_vtbl}, + RuntimeClass_Windows_Gaming_Input_Custom_GameControllerFactoryManager, };
IGameControllerFactoryManagerStatics2 *manager_factory = &manager_statics.IGameControllerFactoryManagerStatics2_iface; @@ -435,8 +264,8 @@ 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->refcount = 1;
if (FAILED(hr = ICustomGameControllerFactory_CreateGameController( factory, provider, &impl->IInspectable_inner ))) WARN( "Failed to create game controller, hr %#lx\n", hr ); diff --git a/dlls/windows.gaming.input/periodic_effect.c b/dlls/windows.gaming.input/periodic_effect.c index 6ba43ee6637..a1239fc7a1e 100644 --- a/dlls/windows.gaming.input/periodic_effect.c +++ b/dlls/windows.gaming.input/periodic_effect.c @@ -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 ) -{ - struct periodic_effect *impl = impl_from_IPeriodicForceEffect( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI effect_Release( IPeriodicForceEffect *iface ) -{ - struct periodic_effect *impl = impl_from_IPeriodicForceEffect( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - - if (!ref) - { - /* guard against re-entry if inner releases an outer iface */ - InterlockedIncrement( &impl->ref ); - IWineForceFeedbackEffectImpl_Release( impl->IWineForceFeedbackEffectImpl_inner ); - free( impl ); - } - - return ref; -} - -static HRESULT WINAPI effect_GetIids( IPeriodicForceEffect *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} +IUNKNOWN_IMPL_ADDREF( periodic_effect, IPeriodicForceEffect );
-static HRESULT WINAPI effect_GetRuntimeClassName( IPeriodicForceEffect *iface, HSTRING *class_name ) +static void periodic_effect_destroy( struct periodic_effect *impl ) { - return WindowsCreateString( RuntimeClass_Windows_Gaming_Input_ForceFeedback_PeriodicForceEffect, - ARRAY_SIZE(RuntimeClass_Windows_Gaming_Input_ForceFeedback_PeriodicForceEffect), - class_name ); + IWineForceFeedbackEffectImpl_Release( impl->IWineForceFeedbackEffectImpl_inner ); + free( impl ); }
-static HRESULT WINAPI effect_GetTrustLevel( IPeriodicForceEffect *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} +IUNKNOWN_IMPL_RELEASE( periodic_effect, IPeriodicForceEffect ); +IINSPECTABLE_IMPL( periodic_effect, IPeriodicForceEffect );
-static HRESULT WINAPI effect_get_Kind( IPeriodicForceEffect *iface, PeriodicForceEffectKind *kind ) +static HRESULT WINAPI periodic_effect_get_Kind( IPeriodicForceEffect *iface, PeriodicForceEffectKind *kind ) { - struct periodic_effect *impl = impl_from_IPeriodicForceEffect( iface ); + struct periodic_effect *impl = periodic_effect_from_IPeriodicForceEffect( iface ); TRACE( "iface %p, kind %p.\n", iface, kind ); *kind = impl->kind; return S_OK; }
-static HRESULT WINAPI effect_SetParameters( IPeriodicForceEffect *iface, Vector3 direction, FLOAT frequency, FLOAT phase, +static HRESULT WINAPI periodic_effect_SetParameters( IPeriodicForceEffect *iface, Vector3 direction, FLOAT frequency, FLOAT phase, FLOAT bias, TimeSpan duration ) { - struct periodic_effect *impl = impl_from_IPeriodicForceEffect( iface ); + struct periodic_effect *impl = periodic_effect_from_IPeriodicForceEffect( iface ); WineForceFeedbackEffectParameters params = { .periodic = @@ -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,33 @@ 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; + IAgileObject IAgileObject_iface; IPeriodicForceEffectFactory IPeriodicForceEffectFactory_iface; - LONG ref; + const WCHAR *class_name; };
+INTERFACE_IMPL_STATIC_IActivationFactory( periodic_factory, IAgileObject, IPeriodicForceEffectFactory, END ) + static inline struct periodic_factory *impl_from_IActivationFactory( IActivationFactory *iface ) { return CONTAINING_RECORD( iface, struct periodic_factory, IActivationFactory_iface ); }
-static HRESULT WINAPI activation_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) -{ - struct periodic_factory *impl = impl_from_IActivationFactory( iface ); - - TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out ); - - if (IsEqualGUID( iid, &IID_IUnknown ) || - IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_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 ); +INTERFACE_VTBL_IAgileObject( periodic_factory_IAgileObject );
-DEFINE_IINSPECTABLE( factory, IPeriodicForceEffectFactory, 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 +158,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 +176,14 @@ 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 );
static struct periodic_factory periodic_statics = { - {&activation_vtbl}, - {&factory_vtbl}, - 1, + {&periodic_factory_vtbl}, + {&periodic_factory_IAgileObject_vtbl}, + {&periodic_factory_IPeriodicForceEffectFactory_vtbl}, + RuntimeClass_Windows_Gaming_Input_ForceFeedback_PeriodicForceEffect, };
IInspectable *periodic_effect_factory = (IInspectable *)&periodic_statics.IActivationFactory_iface; diff --git a/dlls/windows.gaming.input/private.h b/dlls/windows.gaming.input/private.h index 2d383bade00..90907553aeb 100644 --- a/dlls/windows.gaming.input/private.h +++ b/dlls/windows.gaming.input/private.h @@ -83,15 +83,6 @@ extern HRESULT async_operation_boolean_create( IUnknown *invoker, IUnknown *para extern HRESULT async_operation_effect_result_create( IUnknown *invoker, IUnknown *param, async_operation_callback callback, IAsyncOperation_ForceFeedbackLoadEffectResult **out );
-#define DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from, iface_mem, expr ) \ - INTERFACE_IMPL_FROM_( impl_type, iface_type, impl_from, iface_mem ) \ - IUNKNOWN_FWD_( impl_type, iface_type, IInspectable, expr, impl_from, pfx ) \ - IINSPECTABLE_FWD_( impl_type, iface_type, IInspectable, expr, impl_from, pfx ) -#define DEFINE_IINSPECTABLE( pfx, iface_type, impl_type, base_iface ) \ - DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from_##iface_type, iface_type##_iface, (IInspectable *)&object->base_iface ) -#define DEFINE_IINSPECTABLE_OUTER( pfx, iface_type, impl_type, outer_iface ) \ - DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from_##iface_type, iface_type##_iface, (IInspectable *)object->outer_iface ) - static inline const char *debugstr_vector3( const Vector3 *vector ) { if (!vector) return "(null)"; diff --git a/dlls/windows.gaming.input/provider.c b/dlls/windows.gaming.input/provider.c index e13afaf00ce..dfbf436e57e 100644 --- a/dlls/windows.gaming.input/provider.c +++ b/dlls/windows.gaming.input/provider.c @@ -46,7 +46,8 @@ struct provider { IWineGameControllerProvider IWineGameControllerProvider_iface; IGameControllerProvider IGameControllerProvider_iface; - LONG ref; + const WCHAR *class_name; + LONG refcount;
IDirectInputDevice8W *dinput_device; WCHAR device_path[MAX_PATH]; @@ -65,81 +66,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, END );
static BOOL CALLBACK count_ffb_axes( const DIDEVICEOBJECTINSTANCEW *obj, void *args ) { @@ -148,9 +84,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 +111,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 +124,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 +137,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 +150,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 +213,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 +265,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 +280,18 @@ static HRESULT WINAPI wine_provider_get_ForceFeedbackMotor( IWineGameControllerP return S_OK; }
-static const struct IWineGameControllerProviderVtbl wine_provider_vtbl = -{ - wine_provider_QueryInterface, - wine_provider_AddRef, - wine_provider_Release, - /* IInspectable methods */ - wine_provider_GetIids, - wine_provider_GetRuntimeClassName, - wine_provider_GetTrustLevel, - /* IWineGameControllerProvider methods */ - wine_provider_get_Type, - wine_provider_get_AxisCount, - wine_provider_get_ButtonCount, - wine_provider_get_SwitchCount, - wine_provider_get_State, - wine_provider_get_Vibration, - wine_provider_put_Vibration, - wine_provider_get_ForceFeedbackMotor, -}; - -DEFINE_IINSPECTABLE( game_provider, IGameControllerProvider, provider, IWineGameControllerProvider_iface ) +INTERFACE_VTBL_IWineGameControllerProvider( provider );
-static HRESULT WINAPI game_provider_get_FirmwareVersionInfo( IGameControllerProvider *iface, GameControllerVersionInfo *value ) +static HRESULT WINAPI provider_IGameControllerProvider_get_FirmwareVersionInfo( IGameControllerProvider *iface, GameControllerVersionInfo *value ) { FIXME( "iface %p, value %p stub!\n", iface, value ); return E_NOTIMPL; }
-static HRESULT WINAPI game_provider_get_HardwareProductId( IGameControllerProvider *iface, UINT16 *value ) +static HRESULT WINAPI provider_IGameControllerProvider_get_HardwareProductId( IGameControllerProvider *iface, UINT16 *value ) { DIPROPDWORD vid_pid = {.diph = {.dwHeaderSize = sizeof(DIPROPHEADER), .dwSize = sizeof(DIPROPDWORD)}}; - struct provider *impl = impl_from_IGameControllerProvider( iface ); + struct provider *impl = provider_from_IGameControllerProvider( iface ); HRESULT hr;
TRACE( "iface %p, value %p.\n", iface, value ); @@ -385,10 +301,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 +314,19 @@ 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 );
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 +472,11 @@ 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; IDirectInputDevice_AddRef( dinput_device ); impl->dinput_device = dinput_device; - impl->ref = 1; + impl->refcount = 1;
wcscpy( impl->device_path, device_path ); list_init( &impl->entry ); diff --git a/dlls/windows.gaming.input/provider.idl b/dlls/windows.gaming.input/provider.idl index e7b6e96b8aa..072c381461e 100644 --- a/dlls/windows.gaming.input/provider.idl +++ b/dlls/windows.gaming.input/provider.idl @@ -188,7 +188,7 @@ namespace Windows.Gaming.Input.Custom { [ uuid(27833469-7760-417e-adbe-e011a66e16ee) ] - interface IWineForceFeedbackEffectImpl : IUnknown + interface IWineForceFeedbackEffectImpl : IInspectable requires Windows.Gaming.Input.ForceFeedback.IForceFeedbackEffect { [propput] HRESULT Parameters([in] WineForceFeedbackEffectParameters parameters, @@ -198,7 +198,7 @@ namespace Windows.Gaming.Input.Custom { [ uuid(83f377ee-c799-11ec-9d64-0242ac120002) ] - interface IWineAsyncInfoImpl : IUnknown + interface IWineAsyncInfoImpl : IInspectable { [propput] HRESULT Completed([in] WineAsyncOperationCompletedHandler *handler); [propget] HRESULT Completed([out, retval] WineAsyncOperationCompletedHandler **handler); diff --git a/dlls/windows.gaming.input/racing_wheel.c b/dlls/windows.gaming.input/racing_wheel.c index 0bf41481689..54edef031e0 100644 --- a/dlls/windows.gaming.input/racing_wheel.c +++ b/dlls/windows.gaming.input/racing_wheel.c @@ -61,101 +61,32 @@ struct racing_wheel IGameControllerImpl IGameControllerImpl_iface; IGameControllerInputSink IGameControllerInputSink_iface; IRacingWheel IRacingWheel_iface; - IGameController *IGameController_outer; - LONG ref; + IInspectable *outer; + const WCHAR *class_name; + LONG refcount;
IGameControllerProvider *provider; IWineGameControllerProvider *wine_provider; };
-static inline struct racing_wheel *impl_from_IGameControllerImpl( IGameControllerImpl *iface ) +static void racing_wheel_destroy( struct racing_wheel *impl ) { - return CONTAINING_RECORD( iface, struct racing_wheel, IGameControllerImpl_iface ); + if (impl->wine_provider) IWineGameControllerProvider_Release( impl->wine_provider ); + IGameControllerProvider_Release( impl->provider ); + free( impl ); }
-static HRESULT WINAPI controller_QueryInterface( IGameControllerImpl *iface, REFIID iid, void **out ) -{ - struct racing_wheel *impl = impl_from_IGameControllerImpl( iface ); - - TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out ); - - if (IsEqualGUID( iid, &IID_IUnknown ) || - IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_IGameControllerImpl )) - { - IInspectable_AddRef( (*out = &impl->IGameControllerImpl_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IGameControllerInputSink )) - { - IInspectable_AddRef( (*out = &impl->IGameControllerInputSink_iface) ); - return S_OK; - } - - if (IsEqualGUID( iid, &IID_IRacingWheel )) - { - IInspectable_AddRef( (*out = &impl->IRacingWheel_iface) ); - return S_OK; - } - - FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); - *out = NULL; - return E_NOINTERFACE; -} - -static ULONG WINAPI controller_AddRef( IGameControllerImpl *iface ) -{ - struct racing_wheel *impl = impl_from_IGameControllerImpl( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} - -static ULONG WINAPI controller_Release( IGameControllerImpl *iface ) -{ - struct racing_wheel *impl = impl_from_IGameControllerImpl( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - - if (!ref) - { - if (impl->wine_provider) IWineGameControllerProvider_Release( impl->wine_provider ); - IGameControllerProvider_Release( impl->provider ); - free( impl ); - } - - return ref; -} - -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; -} +INTERFACE_IMPL_OUTER_IGameControllerImpl( racing_wheel, IGameControllerInputSink, IRacingWheel, END );
-static HRESULT WINAPI controller_Initialize( IGameControllerImpl *iface, IGameController *outer, +static HRESULT WINAPI racing_wheel_Initialize( IGameControllerImpl *iface, IGameController *outer, IGameControllerProvider *provider ) { - struct racing_wheel *impl = impl_from_IGameControllerImpl( iface ); + struct racing_wheel *impl = racing_wheel_from_IGameControllerImpl( iface ); HRESULT hr;
TRACE( "iface %p, outer %p, provider %p.\n", iface, outer, provider );
- impl->IGameController_outer = outer; + impl->outer = (IInspectable *)outer; IGameControllerProvider_AddRef( (impl->provider = provider) );
hr = IGameControllerProvider_QueryInterface( provider, &IID_IWineGameControllerProvider, @@ -170,120 +101,75 @@ static HRESULT WINAPI controller_Initialize( IGameControllerImpl *iface, IGameCo return hr; }
-static const struct IGameControllerImplVtbl controller_vtbl = -{ - controller_QueryInterface, - controller_AddRef, - controller_Release, - /* IInspectable methods */ - controller_GetIids, - controller_GetRuntimeClassName, - controller_GetTrustLevel, - /* IGameControllerImpl methods */ - controller_Initialize, -}; - -DEFINE_IINSPECTABLE_OUTER( input_sink, IGameControllerInputSink, racing_wheel, IGameController_outer ) +INTERFACE_VTBL_IGameControllerImpl( racing_wheel );
-static HRESULT WINAPI input_sink_OnInputResumed( IGameControllerInputSink *iface, UINT64 timestamp ) +static HRESULT WINAPI racing_wheel_IGameControllerInputSink_OnInputResumed( IGameControllerInputSink *iface, UINT64 timestamp ) { FIXME( "iface %p, timestamp %I64u stub!\n", iface, timestamp ); return E_NOTIMPL; }
-static HRESULT WINAPI input_sink_OnInputSuspended( IGameControllerInputSink *iface, UINT64 timestamp ) +static HRESULT WINAPI racing_wheel_IGameControllerInputSink_OnInputSuspended( IGameControllerInputSink *iface, UINT64 timestamp ) { FIXME( "iface %p, timestamp %I64u stub!\n", iface, timestamp ); return E_NOTIMPL; }
-static const struct IGameControllerInputSinkVtbl input_sink_vtbl = -{ - input_sink_QueryInterface, - input_sink_AddRef, - input_sink_Release, - /* IInspectable methods */ - input_sink_GetIids, - input_sink_GetRuntimeClassName, - input_sink_GetTrustLevel, - /* IGameControllerInputSink methods */ - input_sink_OnInputResumed, - input_sink_OnInputSuspended, -}; - -DEFINE_IINSPECTABLE_OUTER( racing_wheel, IRacingWheel, racing_wheel, IGameController_outer ) +INTERFACE_VTBL_IGameControllerInputSink( racing_wheel_IGameControllerInputSink );
-static HRESULT WINAPI racing_wheel_get_HasClutch( IRacingWheel *iface, boolean *value ) +static HRESULT WINAPI racing_wheel_IRacingWheel_get_HasClutch( IRacingWheel *iface, boolean *value ) { FIXME( "iface %p, value %p stub!\n", iface, value ); return E_NOTIMPL; }
-static HRESULT WINAPI racing_wheel_get_HasHandbrake( IRacingWheel *iface, boolean *value ) +static HRESULT WINAPI racing_wheel_IRacingWheel_get_HasHandbrake( IRacingWheel *iface, boolean *value ) { FIXME( "iface %p, value %p stub!\n", iface, value ); return E_NOTIMPL; }
-static HRESULT WINAPI racing_wheel_get_HasPatternShifter( IRacingWheel *iface, boolean *value ) +static HRESULT WINAPI racing_wheel_IRacingWheel_get_HasPatternShifter( IRacingWheel *iface, boolean *value ) { FIXME( "iface %p, value %p stub!\n", iface, value ); return E_NOTIMPL; }
-static HRESULT WINAPI racing_wheel_get_MaxPatternShifterGear( IRacingWheel *iface, INT32 *value ) +static HRESULT WINAPI racing_wheel_IRacingWheel_get_MaxPatternShifterGear( IRacingWheel *iface, INT32 *value ) { FIXME( "iface %p, value %p stub!\n", iface, value ); return E_NOTIMPL; }
-static HRESULT WINAPI racing_wheel_get_MaxWheelAngle( IRacingWheel *iface, DOUBLE *value ) +static HRESULT WINAPI racing_wheel_IRacingWheel_get_MaxWheelAngle( IRacingWheel *iface, DOUBLE *value ) { FIXME( "iface %p, value %p stub!\n", iface, value ); return E_NOTIMPL; }
-static HRESULT WINAPI racing_wheel_get_WheelMotor( IRacingWheel *iface, IForceFeedbackMotor **value ) +static HRESULT WINAPI racing_wheel_IRacingWheel_get_WheelMotor( IRacingWheel *iface, IForceFeedbackMotor **value ) { - struct racing_wheel *impl = impl_from_IRacingWheel( iface ); + struct racing_wheel *impl = racing_wheel_from_IRacingWheel( iface );
TRACE( "iface %p, value %p\n", iface, value );
return IWineGameControllerProvider_get_ForceFeedbackMotor( impl->wine_provider, value ); }
-static HRESULT WINAPI racing_wheel_GetButtonLabel( IRacingWheel *iface, enum RacingWheelButtons button, +static HRESULT WINAPI racing_wheel_IRacingWheel_GetButtonLabel( IRacingWheel *iface, enum RacingWheelButtons button, enum GameControllerButtonLabel *value ) { FIXME( "iface %p, button %d, value %p stub!\n", iface, button, value ); return E_NOTIMPL; }
-static HRESULT WINAPI racing_wheel_GetCurrentReading( IRacingWheel *iface, struct RacingWheelReading *value ) +static HRESULT WINAPI racing_wheel_IRacingWheel_GetCurrentReading( IRacingWheel *iface, struct RacingWheelReading *value ) { FIXME( "iface %p, value %p stub!\n", iface, value ); return E_NOTIMPL; }
-static const struct IRacingWheelVtbl racing_wheel_vtbl = -{ - racing_wheel_QueryInterface, - racing_wheel_AddRef, - racing_wheel_Release, - /* IInspectable methods */ - racing_wheel_GetIids, - racing_wheel_GetRuntimeClassName, - racing_wheel_GetTrustLevel, - /* IRacingWheel methods */ - racing_wheel_get_HasClutch, - racing_wheel_get_HasHandbrake, - racing_wheel_get_HasPatternShifter, - racing_wheel_get_MaxPatternShifterGear, - racing_wheel_get_MaxWheelAngle, - racing_wheel_get_WheelMotor, - racing_wheel_GetButtonLabel, - racing_wheel_GetCurrentReading, -}; +INTERFACE_VTBL_IRacingWheel( racing_wheel_IRacingWheel );
struct racing_wheel_statics { @@ -291,108 +177,21 @@ struct racing_wheel_statics IRacingWheelStatics IRacingWheelStatics_iface; IRacingWheelStatics2 IRacingWheelStatics2_iface; ICustomGameControllerFactory ICustomGameControllerFactory_iface; - LONG ref; + const WCHAR *class_name; };
-static inline struct racing_wheel_statics *impl_from_IActivationFactory( IActivationFactory *iface ) -{ - return CONTAINING_RECORD( iface, struct racing_wheel_statics, IActivationFactory_iface ); -} +INTERFACE_IMPL_STATIC_IActivationFactory( racing_wheel_statics, IRacingWheelStatics, IRacingWheelStatics2, + ICustomGameControllerFactory, END );
-static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) -{ - struct racing_wheel_statics *impl = impl_from_IActivationFactory( iface ); - - TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out ); - - if (IsEqualGUID( iid, &IID_IUnknown ) || - IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_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, -}; - -DEFINE_IINSPECTABLE( statics, IRacingWheelStatics, racing_wheel_statics, IActivationFactory_iface ) +INTERFACE_VTBL_IActivationFactory( racing_wheel_statics );
-static HRESULT WINAPI statics_add_RacingWheelAdded( IRacingWheelStatics *iface, IEventHandler_RacingWheel *handler, +static HRESULT WINAPI racing_wheel_statics_IRacingWheelStatics_add_RacingWheelAdded( IRacingWheelStatics *iface, IEventHandler_RacingWheel *handler, EventRegistrationToken *token ) { TRACE( "iface %p, handler %p, token %p.\n", iface, handler, token ); @@ -400,13 +199,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 +213,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 +232,11 @@ static HRESULT WINAPI statics_get_RacingWheels( IRacingWheelStatics *iface, IVec return hr; }
-static const struct IRacingWheelStaticsVtbl statics_vtbl = -{ - statics_QueryInterface, - statics_AddRef, - statics_Release, - /* IInspectable methods */ - statics_GetIids, - statics_GetRuntimeClassName, - statics_GetTrustLevel, - /* IRacingWheelStatics methods */ - statics_add_RacingWheelAdded, - statics_remove_RacingWheelAdded, - statics_add_RacingWheelRemoved, - statics_remove_RacingWheelRemoved, - statics_get_RacingWheels, -}; - -DEFINE_IINSPECTABLE( statics2, IRacingWheelStatics2, racing_wheel_statics, IActivationFactory_iface ) +INTERFACE_VTBL_IRacingWheelStatics( racing_wheel_statics_IRacingWheelStatics );
-static HRESULT WINAPI statics2_FromGameController( IRacingWheelStatics2 *iface, IGameController *game_controller, IRacingWheel **value ) +static HRESULT WINAPI racing_wheel_statics_IRacingWheelStatics2_FromGameController( IRacingWheelStatics2 *iface, IGameController *game_controller, IRacingWheel **value ) { - struct racing_wheel_statics *impl = impl_from_IRacingWheelStatics2( iface ); + struct racing_wheel_statics *impl = racing_wheel_statics_from_IRacingWheelStatics2( iface ); IGameController *controller; HRESULT hr;
@@ -470,22 +252,9 @@ static HRESULT WINAPI statics2_FromGameController( IRacingWheelStatics2 *iface, return hr; }
-static const struct IRacingWheelStatics2Vtbl statics2_vtbl = -{ - statics2_QueryInterface, - statics2_AddRef, - statics2_Release, - /* IInspectable methods */ - statics2_GetIids, - statics2_GetRuntimeClassName, - statics2_GetTrustLevel, - /* IRacingWheelStatics2 methods */ - statics2_FromGameController, -}; - -DEFINE_IINSPECTABLE( controller_factory, ICustomGameControllerFactory, racing_wheel_statics, IActivationFactory_iface ) +INTERFACE_VTBL_IRacingWheelStatics2( racing_wheel_statics_IRacingWheelStatics2 );
-static HRESULT WINAPI controller_factory_CreateGameController( ICustomGameControllerFactory *iface, IGameControllerProvider *provider, +static HRESULT WINAPI racing_wheel_statics_ICustomGameControllerFactory_CreateGameController( ICustomGameControllerFactory *iface, IGameControllerProvider *provider, IInspectable **value ) { struct racing_wheel *impl; @@ -493,10 +262,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 +274,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 +289,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 +323,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( racing_wheel_statics_ICustomGameControllerFactory );
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}, + RuntimeClass_Windows_Gaming_Input_RacingWheel, };
ICustomGameControllerFactory *racing_wheel_factory = &racing_wheel_statics.ICustomGameControllerFactory_iface; diff --git a/dlls/windows.gaming.input/ramp_effect.c b/dlls/windows.gaming.input/ramp_effect.c index fadcf151c04..d52914cf62c 100644 --- a/dlls/windows.gaming.input/ramp_effect.c +++ b/dlls/windows.gaming.input/ramp_effect.c @@ -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 ) -{ - struct ramp_effect *impl = impl_from_IRampForceEffect( iface ); - ULONG ref = InterlockedIncrement( &impl->ref ); - TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); - return ref; -} +IUNKNOWN_IMPL_ADDREF( ramp_effect, IRampForceEffect );
-static ULONG WINAPI effect_Release( IRampForceEffect *iface ) +static void ramp_effect_destroy( struct ramp_effect *impl ) { - struct ramp_effect *impl = impl_from_IRampForceEffect( iface ); - ULONG ref = InterlockedDecrement( &impl->ref ); - - TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); - - if (!ref) - { - /* guard against re-entry if inner releases an outer iface */ - InterlockedIncrement( &impl->ref ); - IWineForceFeedbackEffectImpl_Release( impl->IWineForceFeedbackEffectImpl_inner ); - free( impl ); - } - - return ref; + IWineForceFeedbackEffectImpl_Release( impl->IWineForceFeedbackEffectImpl_inner ); + free( impl ); }
-static HRESULT WINAPI effect_GetIids( IRampForceEffect *iface, ULONG *iid_count, IID **iids ) -{ - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; -} +IUNKNOWN_IMPL_RELEASE( ramp_effect, IRampForceEffect ); +IINSPECTABLE_IMPL( ramp_effect, IRampForceEffect );
-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,17 @@ 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; + 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, END );
-static HRESULT WINAPI activation_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) -{ - struct ramp_factory *impl = impl_from_IActivationFactory( iface ); - - TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out ); - - if (IsEqualGUID( iid, &IID_IUnknown ) || - IsEqualGUID( iid, &IID_IInspectable ) || - IsEqualGUID( iid, &IID_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 +126,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 +142,12 @@ 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 );
static struct ramp_factory ramp_statics = { - {&activation_vtbl}, - 1, + {&ramp_factory_vtbl}, + RuntimeClass_Windows_Gaming_Input_ForceFeedback_RampForceEffect, };
IInspectable *ramp_effect_factory = (IInspectable *)&ramp_statics.IActivationFactory_iface; diff --git a/dlls/windows.gaming.input/vector.c b/dlls/windows.gaming.input/vector.c index 201d6f2c756..9ed3d7e2f62 100644 --- a/dlls/windows.gaming.input/vector.c +++ b/dlls/windows.gaming.input/vector.c @@ -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 ) -{ - 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; -} - -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 ); +IUNKNOWN_IMPL_ADDREF( iterator, IIterator_IInspectable );
- if (!ref) - { - IVectorView_IInspectable_Release( impl->view ); - free( impl ); - } - - return ref; -} - -static HRESULT WINAPI iterator_GetIids( IIterator_IInspectable *iface, ULONG *iid_count, IID **iids ) +static void iterator_destroy( struct iterator *impl ) { - FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); - return E_NOTIMPL; + IVectorView_IInspectable_Release( impl->view ); + free( impl ); }
-static HRESULT WINAPI iterator_GetRuntimeClassName( IIterator_IInspectable *iface, HSTRING *class_name ) -{ - FIXME( "iface %p, class_name %p stub!\n", iface, class_name ); - return E_NOTIMPL; -} - -static HRESULT WINAPI iterator_GetTrustLevel( IIterator_IInspectable *iface, TrustLevel *trust_level ) -{ - FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); - return E_NOTIMPL; -} +IUNKNOWN_IMPL_RELEASE( iterator, IIterator_IInspectable ); +IINSPECTABLE_IMPL( iterator, IIterator_IInspectable );
static HRESULT WINAPI iterator_get_Current( IIterator_IInspectable *iface, IInspectable **value ) { - struct iterator *impl = impl_from_IIterator_IInspectable( iface ); + struct iterator *impl = iterator_from_IIterator_IInspectable( iface ); TRACE( "iface %p, value %p.\n", iface, value ); return IVectorView_IInspectable_GetAt( impl->view, impl->index, value ); }
static HRESULT WINAPI iterator_get_HasCurrent( IIterator_IInspectable *iface, boolean *value ) { - struct iterator *impl = impl_from_IIterator_IInspectable( iface ); + struct iterator *impl = iterator_from_IIterator_IInspectable( iface );
TRACE( "iface %p, value %p.\n", iface, value );
@@ -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 ) -{ - 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; -} - -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; -} +IUNKNOWN_IMPL_ADDREF( vector_view, IVectorView_IInspectable );
-static HRESULT WINAPI vector_view_GetRuntimeClassName( IVectorView_IInspectable *iface, HSTRING *class_name ) +static void vector_view_destroy( struct vector_view *impl ) { - FIXME( "iface %p, class_name %p stub!\n", iface, class_name ); - return E_NOTIMPL; + UINT i; + for (i = 0; i < impl->size; ++i) IInspectable_Release( impl->elements[i] ); + free( impl ); }
-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, vector_view, view_impl_from_IIterable_IInspectable, - IIterable_IInspectable_iface, (IInspectable *)&object->IVectorView_IInspectable_iface ) +INTERFACE_FWD_IIterable_IInspectable( vector_view, IVectorView_IInspectable, &object->IVectorView_IInspectable_iface );
-static HRESULT WINAPI iterable_view_First( IIterable_IInspectable *iface, IIterator_IInspectable **value ) +static HRESULT WINAPI vector_view_IIterable_IInspectable_First( IIterable_IInspectable *iface, IIterator_IInspectable **value ) { - struct vector_view *impl = view_impl_from_IIterable_IInspectable( iface ); + struct vector_view *impl = vector_view_from_IIterable_IInspectable( iface ); struct iterator *iter;
TRACE( "iface %p, value %p.\n", iface, value );
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 ) -{ - 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; -} +IUNKNOWN_IMPL_ADDREF( vector, IVector_IInspectable );
-static ULONG WINAPI vector_Release( IVector_IInspectable *iface ) +static void vector_destroy( struct vector *impl ) { - 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; + IVector_IInspectable_Clear( &impl->IVector_IInspectable_iface ); + free( impl ); }
-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, 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 );
I'd like to endorse this, and I hope this is considered; this seems like quite an improvement.
6/11 seems to have a functional change in it [adding IAgileObject], which may be correct but seems hidden and probably deserves a separate patch? Same with 11/11 apparently.