From da745fee16faa2fac785d841d2368f8d6cbf9b5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Tue, 8 Mar 2022 10:55:26 +0100 Subject: [PATCH] windows.gaming.input: Implement IGamepadStatics2_FromGameController. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: RĂ©mi Bernon Signed-off-by: Alexandre Julliard --- dlls/windows.gaming.input/gamepad.c | 40 +++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/dlls/windows.gaming.input/gamepad.c b/dlls/windows.gaming.input/gamepad.c index 3793021d22c..50008541281 100644 --- a/dlls/windows.gaming.input/gamepad.c +++ b/dlls/windows.gaming.input/gamepad.c @@ -27,6 +27,7 @@ struct gamepad_statics { IActivationFactory IActivationFactory_iface; IGamepadStatics IGamepadStatics_iface; + IGamepadStatics2 IGamepadStatics2_iface; ICustomGameControllerFactory ICustomGameControllerFactory_iface; LONG ref; }; @@ -57,6 +58,12 @@ static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID 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) ); @@ -188,6 +195,38 @@ static const struct IGamepadStaticsVtbl statics_vtbl = statics_get_Gamepads, }; +DEFINE_IINSPECTABLE( statics2, IGamepadStatics2, struct gamepad_statics, IActivationFactory_iface ) + +static HRESULT WINAPI statics2_FromGameController( IGamepadStatics2 *iface, IGameController *game_controller, IGamepad **value ) +{ + struct gamepad_statics *impl = impl_from_IGamepadStatics2( iface ); + IGameController *controller; + HRESULT hr; + + TRACE( "iface %p, game_controller %p, value %p.\n", iface, game_controller, value ); + + hr = IGameControllerFactoryManagerStatics2_TryGetFactoryControllerFromGameController( manager_factory, &impl->ICustomGameControllerFactory_iface, + game_controller, &controller ); + if (FAILED(hr)) return hr; + + hr = IGameController_QueryInterface( controller, &IID_IGamepad, (void **)value ); + IGameController_Release( controller ); + 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, struct gamepad_statics, IActivationFactory_iface ) static HRESULT WINAPI controller_factory_CreateGameController( ICustomGameControllerFactory *iface, IGameControllerProvider *provider, @@ -228,6 +267,7 @@ static struct gamepad_statics gamepad_statics = { {&factory_vtbl}, {&statics_vtbl}, + {&statics2_vtbl}, {&controller_factory_vtbl}, 1, };