[PATCH 6/7] windows.gaming.input: Implement IGamepadStatics::Gamepads stubs.

Rémi Bernon rbernon at codeweavers.com
Wed Mar 17 07:07:07 CDT 2021


Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
 dlls/windows.gaming.input/main.c          | 126 +++++++++++++++++++++-
 dlls/windows.gaming.input/tests/statics.c |   6 +-
 2 files changed, 126 insertions(+), 6 deletions(-)

diff --git a/dlls/windows.gaming.input/main.c b/dlls/windows.gaming.input/main.c
index 50d73a1adf4..5e349d98fab 100644
--- a/dlls/windows.gaming.input/main.c
+++ b/dlls/windows.gaming.input/main.c
@@ -46,6 +46,126 @@ static const char *debugstr_hstring(HSTRING hstr)
     return wine_dbgstr_wn(str, len);
 }
 
+struct gamepad_vector
+{
+    IVectorView_Gamepad IVectorView_Gamepad_iface;
+    LONG ref;
+};
+
+static inline struct gamepad_vector *impl_from_IVectorView_Gamepad(IVectorView_Gamepad *iface)
+{
+    return CONTAINING_RECORD(iface, struct gamepad_vector, IVectorView_Gamepad_iface);
+}
+
+static HRESULT STDMETHODCALLTYPE vector_view_gamepad_QueryInterface(
+        IVectorView_Gamepad *iface, REFIID iid, void **out)
+{
+    TRACE("iface %p, iid %s, out %p stub!\n", iface, debugstr_guid(iid), out);
+
+    if (IsEqualGUID(iid, &IID_IUnknown) ||
+        IsEqualGUID(iid, &IID_IInspectable) ||
+        IsEqualGUID(iid, &IID_IAgileObject) ||
+        IsEqualGUID(iid, &IID_IVectorView_Gamepad))
+    {
+        IUnknown_AddRef(iface);
+        *out = iface;
+        return S_OK;
+    }
+
+    WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
+    *out = NULL;
+    return E_NOINTERFACE;
+}
+
+static ULONG STDMETHODCALLTYPE vector_view_gamepad_AddRef(
+        IVectorView_Gamepad *iface)
+{
+    struct gamepad_vector *impl = impl_from_IVectorView_Gamepad(iface);
+    ULONG ref = InterlockedIncrement(&impl->ref);
+    TRACE("iface %p, ref %u.\n", iface, ref);
+    return ref;
+}
+
+static ULONG STDMETHODCALLTYPE vector_view_gamepad_Release(
+        IVectorView_Gamepad *iface)
+{
+    struct gamepad_vector *impl = impl_from_IVectorView_Gamepad(iface);
+    ULONG ref = InterlockedDecrement(&impl->ref);
+    TRACE("iface %p, ref %u.\n", iface, ref);
+    return ref;
+}
+
+static HRESULT STDMETHODCALLTYPE vector_view_gamepad_GetIids(
+        IVectorView_Gamepad *iface, ULONG *iid_count, IID **iids)
+{
+    FIXME("iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids);
+    return E_NOTIMPL;
+}
+
+static HRESULT STDMETHODCALLTYPE vector_view_gamepad_GetRuntimeClassName(
+        IVectorView_Gamepad *iface, HSTRING *class_name)
+{
+    FIXME("iface %p, class_name %p stub!\n", iface, class_name);
+    return E_NOTIMPL;
+}
+
+static HRESULT STDMETHODCALLTYPE vector_view_gamepad_GetTrustLevel(
+        IVectorView_Gamepad *iface, TrustLevel *trust_level)
+{
+    FIXME("iface %p, trust_level %p stub!\n", iface, trust_level);
+    return E_NOTIMPL;
+}
+
+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;
+}
+
+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;
+}
+
+static HRESULT STDMETHODCALLTYPE vector_view_gamepad_IndexOf(
+    IVectorView_Gamepad *iface, IGamepad *element, ULONG *index, BOOLEAN *value)
+{
+    FIXME("iface %p, element %p, index %p, value %p stub!\n", iface, element, index, value);
+    return E_NOTIMPL;
+}
+
+static HRESULT STDMETHODCALLTYPE vector_view_gamepad_GetMany(
+    IVectorView_Gamepad *iface, ULONG start_index, IGamepad **items, UINT *value)
+{
+    FIXME("iface %p, start_index %#x, items %p, value %p stub!\n", iface, start_index, items, value);
+    return E_NOTIMPL;
+}
+
+static const struct IVectorView_GamepadVtbl vector_view_gamepad_vtbl =
+{
+    vector_view_gamepad_QueryInterface,
+    vector_view_gamepad_AddRef,
+    vector_view_gamepad_Release,
+    /* IInspectable methods */
+    vector_view_gamepad_GetIids,
+    vector_view_gamepad_GetRuntimeClassName,
+    vector_view_gamepad_GetTrustLevel,
+    /* IVectorView<VoiceInformation> methods */
+    vector_view_gamepad_GetAt,
+    vector_view_gamepad_get_Size,
+    vector_view_gamepad_IndexOf,
+    vector_view_gamepad_GetMany,
+};
+
+static struct gamepad_vector gamepads =
+{
+    {&vector_view_gamepad_vtbl},
+    0
+};
+
 struct windows_gaming_input
 {
     IActivationFactory IActivationFactory_iface;
@@ -224,8 +344,10 @@ static HRESULT STDMETHODCALLTYPE gamepad_statics_remove_GamepadRemoved(
 static HRESULT STDMETHODCALLTYPE gamepad_statics_get_Gamepads(
     IGamepadStatics *iface, IVectorView_Gamepad **value)
 {
-    FIXME("iface %p, value %p stub!\n", iface, value);
-    return E_NOTIMPL;
+    TRACE("iface %p, value %p.\n", iface, value);
+    *value = &gamepads.IVectorView_Gamepad_iface;
+    IVectorView_Gamepad_AddRef(*value);
+    return S_OK;
 }
 
 static const struct IGamepadStaticsVtbl gamepad_statics_vtbl =
diff --git a/dlls/windows.gaming.input/tests/statics.c b/dlls/windows.gaming.input/tests/statics.c
index de04bdf4cf3..699cf6fc9f7 100644
--- a/dlls/windows.gaming.input/tests/statics.c
+++ b/dlls/windows.gaming.input/tests/statics.c
@@ -88,8 +88,7 @@ static void test_Gamepad(void)
     IAgileObject_Release(tmp_agile_object);
 
     hr = IGamepadStatics_get_Gamepads(gamepad_statics, &gamepads);
-    todo_wine ok(SUCCEEDED(hr), "IGamepadStatics_get_Gamepads failed, hr %#x\n", hr);
-    if (FAILED(hr)) goto done;
+    ok(SUCCEEDED(hr), "IGamepadStatics_get_Gamepads failed, hr %#x\n", hr);
 
     hr = IVectorView_Gamepad_QueryInterface(gamepads, &IID_IInspectable, (void **)&tmp_inspectable);
     ok(SUCCEEDED(hr), "IVectorView_Gamepad_QueryInterface failed, hr %#x\n", hr);
@@ -103,13 +102,12 @@ static void test_Gamepad(void)
 
     size = 0xdeadbeef;
     hr = IVectorView_Gamepad_get_Size(gamepads, &size);
-    ok(SUCCEEDED(hr), "IVectorView_Gamepad_QueryInterface failed, hr %#x\n", hr);
+    todo_wine ok(SUCCEEDED(hr), "IVectorView_Gamepad_QueryInterface failed, hr %#x\n", hr);
     todo_wine ok(size != 0xdeadbeef, "IVectorView_Gamepad_get_Size returned %u\n", size);
 
     rc = IVectorView_Gamepad_Release(gamepads);
     todo_wine ok(rc == 1, "IVectorView_Gamepad_Release returned unexpected refcount %d\n", rc);
 
-done:
     IGamepadStatics_Release(gamepad_statics);
 
     IAgileObject_Release(agile_object);
-- 
2.30.2




More information about the wine-devel mailing list