windows.gaming.input: Implement IRawGameControllerStatics_FromGameController.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Rémi Bernon 2022-03-08 10:55:23 +01:00 committed by Alexandre Julliard
parent 09cb88e91b
commit d45a2a14cd
4 changed files with 42 additions and 10 deletions

View File

@ -174,8 +174,20 @@ static HRESULT WINAPI statics_get_RawGameControllers( IRawGameControllerStatics
static HRESULT WINAPI statics_FromGameController( IRawGameControllerStatics *iface, IGameController *game_controller, static HRESULT WINAPI statics_FromGameController( IRawGameControllerStatics *iface, IGameController *game_controller,
IRawGameController **value ) IRawGameController **value )
{ {
FIXME( "iface %p, game_controller %p, value %p stub!\n", iface, game_controller, value ); struct controller_statics *impl = impl_from_IRawGameControllerStatics( iface );
return E_NOTIMPL; 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_IRawGameController, (void **)value );
IGameController_Release( controller );
return hr;
} }
static const struct IRawGameControllerStaticsVtbl statics_vtbl = static const struct IRawGameControllerStaticsVtbl statics_vtbl =

View File

@ -169,7 +169,7 @@ HRESULT WINAPI DllGetActivationFactory( HSTRING class_str, IActivationFactory **
{ {
static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT; static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT;
const WCHAR *buffer = WindowsGetStringRawBuffer( class_str, NULL ); const WCHAR *buffer = WindowsGetStringRawBuffer( class_str, NULL );
HRESULT hr = S_OK; HRESULT hr = REGDB_E_CLASSNOTREG;
TRACE( "class %s, factory %p.\n", debugstr_w(buffer), factory ); TRACE( "class %s, factory %p.\n", debugstr_w(buffer), factory );
@ -182,10 +182,9 @@ HRESULT WINAPI DllGetActivationFactory( HSTRING class_str, IActivationFactory **
if (!wcscmp( buffer, RuntimeClass_Windows_Gaming_Input_Gamepad )) if (!wcscmp( buffer, RuntimeClass_Windows_Gaming_Input_Gamepad ))
hr = ICustomGameControllerFactory_QueryInterface( gamepad_factory, &IID_IActivationFactory, (void **)factory ); hr = ICustomGameControllerFactory_QueryInterface( gamepad_factory, &IID_IActivationFactory, (void **)factory );
if (!wcscmp( buffer, RuntimeClass_Windows_Gaming_Input_Custom_GameControllerFactoryManager )) if (!wcscmp( buffer, RuntimeClass_Windows_Gaming_Input_Custom_GameControllerFactoryManager ))
IActivationFactory_AddRef( (*factory = manager_factory) ); hr = IGameControllerFactoryManagerStatics2_QueryInterface( manager_factory, &IID_IActivationFactory, (void **)factory );
if (SUCCEEDED(hr) && *factory) return S_OK; return hr;
return REGDB_E_CLASSNOTREG;
} }
BOOL WINAPI DllMain( HINSTANCE instance, DWORD reason, void *reserved ) BOOL WINAPI DllMain( HINSTANCE instance, DWORD reason, void *reserved )

View File

@ -370,8 +370,29 @@ statics2_TryGetFactoryControllerFromGameController( IGameControllerFactoryManage
ICustomGameControllerFactory *factory, ICustomGameControllerFactory *factory,
IGameController *controller, IGameController **value ) IGameController *controller, IGameController **value )
{ {
FIXME( "iface %p, factory %p, controller %p, value %p stub!\n", iface, factory, controller, value ); struct controller *entry, *other;
return E_NOTIMPL; BOOL found = FALSE;
TRACE( "iface %p, factory %p, controller %p, value %p.\n", iface, factory, controller, value );
EnterCriticalSection( &manager_cs );
LIST_FOR_EACH_ENTRY( entry, &controller_list, struct controller, entry )
if ((found = &entry->IGameController_iface == controller)) break;
if (!found) WARN( "Failed to find controller %p\n", controller );
else
{
LIST_FOR_EACH_ENTRY( other, &controller_list, struct controller, entry )
if ((found = entry->provider == other->provider && other->factory == factory)) break;
if (!found) WARN( "Failed to find controller %p, factory %p\n", controller, factory );
else IGameController_AddRef( (*value = &other->IGameController_iface) );
}
LeaveCriticalSection( &manager_cs );
if (!found) return E_FAIL;
return S_OK;
} }
static const struct IGameControllerFactoryManagerStatics2Vtbl statics2_vtbl = static const struct IGameControllerFactoryManagerStatics2Vtbl statics2_vtbl =
@ -395,7 +416,7 @@ static struct manager_statics manager_statics =
1, 1,
}; };
IActivationFactory *manager_factory = &manager_statics.IActivationFactory_iface; IGameControllerFactoryManagerStatics2 *manager_factory = &manager_statics.IGameControllerFactoryManagerStatics2_iface;
static HRESULT controller_create( ICustomGameControllerFactory *factory, IGameControllerProvider *provider, static HRESULT controller_create( ICustomGameControllerFactory *factory, IGameControllerProvider *provider,
struct controller **out ) struct controller **out )

View File

@ -39,7 +39,7 @@
extern HINSTANCE windows_gaming_input; extern HINSTANCE windows_gaming_input;
extern ICustomGameControllerFactory *controller_factory; extern ICustomGameControllerFactory *controller_factory;
extern ICustomGameControllerFactory *gamepad_factory; extern ICustomGameControllerFactory *gamepad_factory;
extern IActivationFactory *manager_factory; extern IGameControllerFactoryManagerStatics2 *manager_factory;
extern HRESULT vector_create( REFIID iid, REFIID view_iid, void **out ); extern HRESULT vector_create( REFIID iid, REFIID view_iid, void **out );