Module: wine Branch: master Commit: c0877844e7602dc542384c19c7b0e191daa2b3da URL: https://gitlab.winehq.org/wine/wine/-/commit/c0877844e7602dc542384c19c7b0e19...
Author: Rémi Bernon rbernon@codeweavers.com Date: Mon May 22 10:56:51 2023 +0200
windows.gaming.input: Query IGameController interface in TryGetFactoryControllerFromGameController.
---
dlls/dinput/tests/hotplug.c | 2 +- dlls/dinput/tests/joystick8.c | 3 +-- dlls/windows.gaming.input/manager.c | 9 ++++++++- 3 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/dlls/dinput/tests/hotplug.c b/dlls/dinput/tests/hotplug.c index cd21363770e..7187cf7dc38 100644 --- a/dlls/dinput/tests/hotplug.c +++ b/dlls/dinput/tests/hotplug.c @@ -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 ); diff --git a/dlls/dinput/tests/joystick8.c b/dlls/dinput/tests/joystick8.c index e336cc24c6d..191e5273e1d 100644 --- a/dlls/dinput/tests/joystick8.c +++ b/dlls/dinput/tests/joystick8.c @@ -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 ); diff --git a/dlls/windows.gaming.input/manager.c b/dlls/windows.gaming.input/manager.c index c2567a2fe3e..d54b01d92e3 100644 --- a/dlls/windows.gaming.input/manager.c +++ b/dlls/windows.gaming.input/manager.c @@ -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; }