[PATCH 2/2] windows.gaming.input: Always return S_OK from TryGetFactoryControllerFromGameController.

Rémi Bernon rbernon at codeweavers.com
Fri Mar 11 02:43:48 CST 2022


Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
 dlls/dinput/tests/hotplug.c            | 7 ++-----
 dlls/windows.gaming.input/controller.c | 3 ++-
 dlls/windows.gaming.input/gamepad.c    | 3 ++-
 dlls/windows.gaming.input/manager.c    | 2 +-
 4 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/dlls/dinput/tests/hotplug.c b/dlls/dinput/tests/hotplug.c
index 24f913dc140..a2072ca16de 100644
--- a/dlls/dinput/tests/hotplug.c
+++ b/dlls/dinput/tests/hotplug.c
@@ -1059,7 +1059,6 @@ static void test_windows_gaming_input(void)
 
     hr = IGameControllerFactoryManagerStatics2_TryGetFactoryControllerFromGameController( manager_statics2,
             &custom_factory.ICustomGameControllerFactory_iface, game_controller, &tmp_game_controller );
-    todo_wine
     ok( hr == S_OK, "TryGetFactoryControllerFromGameController returned %#lx\n", hr );
     ok( !tmp_game_controller, "got controller %p\n", tmp_game_controller );
 
@@ -1126,10 +1125,9 @@ static void test_windows_gaming_input(void)
 
     hr = IGameControllerFactoryManagerStatics2_TryGetFactoryControllerFromGameController( manager_statics2,
             &custom_factory.ICustomGameControllerFactory_iface, game_controller, &tmp_game_controller );
-    todo_wine
     ok( hr == S_OK, "TryGetFactoryControllerFromGameController returned %#lx\n", hr );
     ok( tmp_game_controller == custom_controller.IGameController_outer, "got controller %p\n", tmp_game_controller );
-    if (hr != S_OK) goto next;
+    if (!tmp_game_controller) goto next;
     hr = IGameController_QueryInterface( tmp_game_controller, &IID_IInspectable, (void **)&tmp_inspectable );
     ok( hr == S_OK, "QueryInterface returned %#lx\n", hr );
     ok( tmp_inspectable == (void *)tmp_game_controller, "got inspectable %p\n", tmp_inspectable );
@@ -1153,11 +1151,10 @@ static void test_windows_gaming_input(void)
 
 next:
     hr = IRawGameControllerStatics_FromGameController( statics, custom_controller.IGameController_outer, &tmp_raw_controller );
-    todo_wine
     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 (hr == S_OK) IRawGameController_Release( tmp_raw_controller );
+    if (tmp_raw_controller) IRawGameController_Release( tmp_raw_controller );
 
     IGameController_Release( game_controller );
     IRawGameController_Release( raw_controller );
diff --git a/dlls/windows.gaming.input/controller.c b/dlls/windows.gaming.input/controller.c
index 3e00da917e7..03a3ae398cf 100644
--- a/dlls/windows.gaming.input/controller.c
+++ b/dlls/windows.gaming.input/controller.c
@@ -459,9 +459,10 @@ static HRESULT WINAPI statics_FromGameController( IRawGameControllerStatics *ifa
 
     TRACE( "iface %p, game_controller %p, value %p.\n", iface, game_controller, value );
 
+    *value = NULL;
     hr = IGameControllerFactoryManagerStatics2_TryGetFactoryControllerFromGameController( manager_factory, &impl->ICustomGameControllerFactory_iface,
                                                                                           game_controller, &controller );
-    if (FAILED(hr)) return hr;
+    if (FAILED(hr) || !controller) return hr;
 
     hr = IGameController_QueryInterface( controller, &IID_IRawGameController, (void **)value );
     IGameController_Release( controller );
diff --git a/dlls/windows.gaming.input/gamepad.c b/dlls/windows.gaming.input/gamepad.c
index b815d5c0a13..7e72609a277 100644
--- a/dlls/windows.gaming.input/gamepad.c
+++ b/dlls/windows.gaming.input/gamepad.c
@@ -484,9 +484,10 @@ static HRESULT WINAPI statics2_FromGameController( IGamepadStatics2 *iface, IGam
 
     TRACE( "iface %p, game_controller %p, value %p.\n", iface, game_controller, value );
 
+    *value = NULL;
     hr = IGameControllerFactoryManagerStatics2_TryGetFactoryControllerFromGameController( manager_factory, &impl->ICustomGameControllerFactory_iface,
                                                                                           game_controller, &controller );
-    if (FAILED(hr)) return hr;
+    if (FAILED(hr) || !controller) return hr;
 
     hr = IGameController_QueryInterface( controller, &IID_IGamepad, (void **)value );
     IGameController_Release( controller );
diff --git a/dlls/windows.gaming.input/manager.c b/dlls/windows.gaming.input/manager.c
index 393b5a850c8..af15849c521 100644
--- a/dlls/windows.gaming.input/manager.c
+++ b/dlls/windows.gaming.input/manager.c
@@ -392,7 +392,7 @@ statics2_TryGetFactoryControllerFromGameController( IGameControllerFactoryManage
 
     LeaveCriticalSection( &manager_cs );
 
-    if (!found) return E_FAIL;
+    if (!found) *value = NULL;
     return S_OK;
 }
 
-- 
2.35.1




More information about the wine-devel mailing list