[PATCH v2 0/2] MR2873: windows.gaming.input: Query IGameController interface in TryGetFactoryControllerFromGameController.
-- v2: windows.gaming.input: Query IGameController interface in TryGetFactoryControllerFromGameController. dinput/tests: Test that FromGameController also works with IRawGameController. https://gitlab.winehq.org/wine/wine/-/merge_requests/2873
From: Rémi Bernon <rbernon(a)codeweavers.com> --- dlls/dinput/tests/joystick8.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dlls/dinput/tests/joystick8.c b/dlls/dinput/tests/joystick8.c index 60bee06479a..e336cc24c6d 100644 --- a/dlls/dinput/tests/joystick8.c +++ b/dlls/dinput/tests/joystick8.c @@ -5090,6 +5090,12 @@ static void test_windows_gaming_input(void) ok( tmp_raw_controller == raw_controller, "got unexpected IGameController interface\n" ); IRawGameController_Release( tmp_raw_controller ); + 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 ); + IGameController_Release( game_controller ); IRawGameController_Release( raw_controller ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/2873
From: Rémi Bernon <rbernon(a)codeweavers.com> --- 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; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/2873
v2: Avoid crashing on not implemented custom game controller factory tests. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/2873#note_33372
participants (1)
-
Rémi Bernon