[PATCH v3 1/2] windows.gaming.input: Fake empty IGamepadStatics::Gamepads vector.

Rémi Bernon rbernon at codeweavers.com
Fri Mar 19 04:15:21 CDT 2021


Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---

v3: Remove the IGamepadStatics_add_GamepadAdded test with NULL token,
    that crashes on some Windows versions.

 dlls/windows.gaming.input/main.c        | 14 +++++++++-----
 dlls/windows.gaming.input/tests/input.c | 20 ++++++++++++++++++--
 2 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/dlls/windows.gaming.input/main.c b/dlls/windows.gaming.input/main.c
index 5e349d98fab..d7a2f138a14 100644
--- a/dlls/windows.gaming.input/main.c
+++ b/dlls/windows.gaming.input/main.c
@@ -120,21 +120,25 @@ static HRESULT STDMETHODCALLTYPE vector_view_gamepad_GetAt(
     IVectorView_Gamepad *iface, ULONG index, IGamepad **value)
 {
     FIXME("iface %p, index %#x, value %p stub!\n", iface, index, value);
-    return E_NOTIMPL;
+    *value = NULL;
+    return E_BOUNDS;
 }
 
 static HRESULT STDMETHODCALLTYPE vector_view_gamepad_get_Size(
     IVectorView_Gamepad *iface, ULONG *value)
 {
     FIXME("iface %p, value %p stub!\n", iface, value);
-    return E_NOTIMPL;
+    *value = 0;
+    return S_OK;
 }
 
 static HRESULT STDMETHODCALLTYPE vector_view_gamepad_IndexOf(
-    IVectorView_Gamepad *iface, IGamepad *element, ULONG *index, BOOLEAN *value)
+    IVectorView_Gamepad *iface, IGamepad *element, ULONG *index, BOOLEAN *found)
 {
-    FIXME("iface %p, element %p, index %p, value %p stub!\n", iface, element, index, value);
-    return E_NOTIMPL;
+    FIXME("iface %p, element %p, index %p, found %p stub!\n", iface, element, index, found);
+    *index = 0;
+    *found = FALSE;
+    return S_OK;
 }
 
 static HRESULT STDMETHODCALLTYPE vector_view_gamepad_GetMany(
diff --git a/dlls/windows.gaming.input/tests/input.c b/dlls/windows.gaming.input/tests/input.c
index cfd814d5631..622da229e70 100644
--- a/dlls/windows.gaming.input/tests/input.c
+++ b/dlls/windows.gaming.input/tests/input.c
@@ -111,6 +111,8 @@ static void test_Gamepad(void)
     IGamepadStatics *gamepad_statics = NULL;
     IInspectable *inspectable = NULL, *tmp_inspectable = NULL;
     IAgileObject *agile_object = NULL, *tmp_agile_object = NULL;
+    IGamepad *gamepad;
+    BOOLEAN found;
     HSTRING str;
     HRESULT hr;
     ULONG size;
@@ -165,8 +167,22 @@ static void test_Gamepad(void)
 
     size = 0xdeadbeef;
     hr = IVectorView_Gamepad_get_Size(gamepads, &size);
-    todo_wine ok(hr == S_OK, "IVectorView_Gamepad_get_Size failed, hr %#x\n", hr);
-    todo_wine ok(size != 0xdeadbeef, "IVectorView_Gamepad_get_Size returned %u\n", size);
+    ok(hr == S_OK, "IVectorView_Gamepad_get_Size failed, hr %#x\n", hr);
+    ok(size != 0xdeadbeef, "IVectorView_Gamepad_get_Size returned %u\n", size);
+
+    if (size == 0)
+    {
+        gamepad = (IGamepad *)0xdeadbeef;
+        hr = IVectorView_Gamepad_GetAt(gamepads, 0, &gamepad);
+        ok(hr == E_BOUNDS, "IVectorView_Gamepad_GetAt failed, hr %#x\n", hr);
+        ok(gamepad == NULL, "IVectorView_Gamepad_GetAt returned %p\n", gamepad);
+
+        size = 0xdeadbeef;
+        found = TRUE;
+        hr = IVectorView_Gamepad_IndexOf(gamepads, gamepad, &size, &found);
+        ok(hr == S_OK, "IVectorView_Gamepad_IndexOf failed, hr %#x\n", hr);
+        ok(size == 0 && found == FALSE, "IVectorView_Gamepad_IndexOf returned size %d, found %d\n", size, found);
+    }
 
     IVectorView_Gamepad_Release(gamepads);
 
-- 
2.30.2




More information about the wine-devel mailing list