windows.gaming.input: Query IGameController interface in TryGetFactoryControllerFromGameController.

This commit is contained in:
Rémi Bernon 2023-05-22 10:56:51 +02:00 committed by Alexandre Julliard
parent eab7b95bab
commit c0877844e7
3 changed files with 10 additions and 4 deletions

View file

@ -1184,13 +1184,13 @@ static void test_windows_gaming_input(void)
IGameController_Release( tmp_game_controller );
next:
hr = IRawGameControllerStatics_FromGameController( statics, custom_controller.IGameController_outer, &tmp_raw_controller );
ok( hr == S_OK, "FromGameController returned %#lx\n", hr );
todo_wine
ok( tmp_raw_controller == raw_controller, "got controller %p\n", tmp_raw_controller );
if (tmp_raw_controller) IRawGameController_Release( tmp_raw_controller );
next:
IGameController_Release( game_controller );
IRawGameController_Release( raw_controller );
SetEvent( stop_event );

View file

@ -5092,9 +5092,8 @@ static void test_windows_gaming_input(void)
hr = IRawGameControllerStatics_FromGameController( controller_statics, (IGameController *)raw_controller, &tmp_raw_controller );
ok( hr == S_OK, "FromGameController returned %#lx\n", hr );
todo_wine
ok( tmp_raw_controller == raw_controller, "got unexpected IGameController interface\n" );
if (tmp_raw_controller) IRawGameController_Release( tmp_raw_controller );
IRawGameController_Release( tmp_raw_controller );
IGameController_Release( game_controller );
IRawGameController_Release( raw_controller );

View file

@ -372,14 +372,18 @@ statics2_TryGetFactoryControllerFromGameController( IGameControllerFactoryManage
IGameController *controller, IGameController **value )
{
struct controller *entry, *other;
IGameController *tmp_controller;
BOOL found = FALSE;
TRACE( "iface %p, factory %p, controller %p, value %p.\n", iface, factory, controller, value );
/* Spider Man Remastered passes a IRawGameController instead of IGameController, query the iface again */
if (FAILED(IGameController_QueryInterface( controller, &IID_IGameController, (void **)&tmp_controller ))) goto done;
EnterCriticalSection( &manager_cs );
LIST_FOR_EACH_ENTRY( entry, &controller_list, struct controller, entry )
if ((found = &entry->IGameController_iface == controller)) break;
if ((found = &entry->IGameController_iface == tmp_controller)) break;
if (!found) WARN( "Failed to find controller %p\n", controller );
else
@ -392,6 +396,9 @@ statics2_TryGetFactoryControllerFromGameController( IGameControllerFactoryManage
LeaveCriticalSection( &manager_cs );
IGameController_Release( tmp_controller );
done:
if (!found) *value = NULL;
return S_OK;
}