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

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


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

diff --git a/dlls/windows.gaming.input/main.c b/dlls/windows.gaming.input/main.c
index 05ef844893b..50d73a1adf4 100644
--- a/dlls/windows.gaming.input/main.c
+++ b/dlls/windows.gaming.input/main.c
@@ -29,7 +29,10 @@
 #include "initguid.h"
 #include "activation.h"
 
+#define WIDL_using_Windows_Foundation
+#define WIDL_using_Windows_Foundation_Collections
 #include "windows.foundation.h"
+#define WIDL_using_Windows_Gaming_Input
 #include "windows.gaming.input.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(input);
@@ -46,6 +49,7 @@ static const char *debugstr_hstring(HSTRING hstr)
 struct windows_gaming_input
 {
     IActivationFactory IActivationFactory_iface;
+    IGamepadStatics IGamepadStatics_iface;
     LONG ref;
 };
 
@@ -54,9 +58,16 @@ static inline struct windows_gaming_input *impl_from_IActivationFactory(IActivat
     return CONTAINING_RECORD(iface, struct windows_gaming_input, IActivationFactory_iface);
 }
 
+static inline struct windows_gaming_input *impl_from_IGamepadStatics(IGamepadStatics *iface)
+{
+    return CONTAINING_RECORD(iface, struct windows_gaming_input, IGamepadStatics_iface);
+}
+
 static HRESULT STDMETHODCALLTYPE windows_gaming_input_QueryInterface(
         IActivationFactory *iface, REFIID iid, void **out)
 {
+    struct windows_gaming_input *impl = impl_from_IActivationFactory(iface);
+
     TRACE("iface %p, iid %s, out %p stub!\n", iface, debugstr_guid(iid), out);
 
     if (IsEqualGUID(iid, &IID_IUnknown) ||
@@ -69,6 +80,13 @@ static HRESULT STDMETHODCALLTYPE windows_gaming_input_QueryInterface(
         return S_OK;
     }
 
+    if (IsEqualGUID(iid, &IID_IGamepadStatics))
+    {
+        IUnknown_AddRef(iface);
+        *out = &impl->IGamepadStatics_iface;
+        return S_OK;
+    }
+
     FIXME("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
     *out = NULL;
     return E_NOINTERFACE;
@@ -133,9 +151,104 @@ static const struct IActivationFactoryVtbl activation_factory_vtbl =
     windows_gaming_input_ActivateInstance,
 };
 
+static HRESULT STDMETHODCALLTYPE gamepad_statics_QueryInterface(
+        IGamepadStatics *iface, REFIID iid, void **out)
+{
+    struct windows_gaming_input *impl = impl_from_IGamepadStatics(iface);
+    return windows_gaming_input_QueryInterface(&impl->IActivationFactory_iface, iid, out);
+}
+
+static ULONG STDMETHODCALLTYPE gamepad_statics_AddRef(
+        IGamepadStatics *iface)
+{
+    struct windows_gaming_input *impl = impl_from_IGamepadStatics(iface);
+    return windows_gaming_input_AddRef(&impl->IActivationFactory_iface);
+}
+
+static ULONG STDMETHODCALLTYPE gamepad_statics_Release(
+        IGamepadStatics *iface)
+{
+    struct windows_gaming_input *impl = impl_from_IGamepadStatics(iface);
+    return windows_gaming_input_Release(&impl->IActivationFactory_iface);
+}
+
+static HRESULT STDMETHODCALLTYPE gamepad_statics_GetIids(
+        IGamepadStatics *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 gamepad_statics_GetRuntimeClassName(
+        IGamepadStatics *iface, HSTRING *class_name)
+{
+    FIXME("iface %p, class_name %p stub!\n", iface, class_name);
+    return E_NOTIMPL;
+}
+
+static HRESULT STDMETHODCALLTYPE gamepad_statics_GetTrustLevel(
+        IGamepadStatics *iface, TrustLevel *trust_level)
+{
+    FIXME("iface %p, trust_level %p stub!\n", iface, trust_level);
+    return E_NOTIMPL;
+}
+
+static HRESULT STDMETHODCALLTYPE gamepad_statics_add_GamepadAdded(
+    IGamepadStatics *iface, IEventHandler_Gamepad *value, EventRegistrationToken* token)
+{
+    FIXME("iface %p, value %p, token %p stub!\n", iface, value, token);
+    return E_NOTIMPL;
+}
+
+static HRESULT STDMETHODCALLTYPE gamepad_statics_remove_GamepadAdded(
+    IGamepadStatics *iface, EventRegistrationToken token)
+{
+    FIXME("iface %p, token %#I64x stub!\n", iface, token.value);
+    return E_NOTIMPL;
+}
+
+static HRESULT STDMETHODCALLTYPE gamepad_statics_add_GamepadRemoved(
+    IGamepadStatics *iface, IEventHandler_Gamepad *value, EventRegistrationToken* token)
+{
+    FIXME("iface %p, value %p, token %p stub!\n", iface, value, token);
+    return E_NOTIMPL;
+}
+
+static HRESULT STDMETHODCALLTYPE gamepad_statics_remove_GamepadRemoved(
+    IGamepadStatics *iface, EventRegistrationToken token)
+{
+    FIXME("iface %p, token %#I64x stub!\n", iface, token.value);
+    return E_NOTIMPL;
+}
+
+static HRESULT STDMETHODCALLTYPE gamepad_statics_get_Gamepads(
+    IGamepadStatics *iface, IVectorView_Gamepad **value)
+{
+    FIXME("iface %p, value %p stub!\n", iface, value);
+    return E_NOTIMPL;
+}
+
+static const struct IGamepadStaticsVtbl gamepad_statics_vtbl =
+{
+    gamepad_statics_QueryInterface,
+    gamepad_statics_AddRef,
+    gamepad_statics_Release,
+    /* IInspectable methods */
+    gamepad_statics_GetIids,
+    gamepad_statics_GetRuntimeClassName,
+    gamepad_statics_GetTrustLevel,
+    /* IGamepadStatics methods */
+    gamepad_statics_add_GamepadAdded,
+    gamepad_statics_remove_GamepadAdded,
+    gamepad_statics_add_GamepadRemoved,
+    gamepad_statics_remove_GamepadRemoved,
+    gamepad_statics_get_Gamepads,
+};
+
 static struct windows_gaming_input windows_gaming_input =
 {
     {&activation_factory_vtbl},
+    {&gamepad_statics_vtbl},
     1
 };
 
diff --git a/dlls/windows.gaming.input/tests/statics.c b/dlls/windows.gaming.input/tests/statics.c
index 8144a3fb8e8..de04bdf4cf3 100644
--- a/dlls/windows.gaming.input/tests/statics.c
+++ b/dlls/windows.gaming.input/tests/statics.c
@@ -75,8 +75,7 @@ static void test_Gamepad(void)
     ok(SUCCEEDED(hr), "IActivationFactory_QueryInterface IID_IAgileObject failed, hr %#x\n", hr);
 
     hr = IActivationFactory_QueryInterface(factory, &IID_IGamepadStatics, (void **)&gamepad_statics);
-    todo_wine ok(SUCCEEDED(hr), "IActivationFactory_QueryInterface IID_IGamepadStatics failed, hr %#x\n", hr);
-    if (FAILED(hr)) goto done;
+    ok(SUCCEEDED(hr), "IActivationFactory_QueryInterface IID_IGamepadStatics failed, hr %#x\n", hr);
 
     hr = IGamepadStatics_QueryInterface(gamepad_statics, &IID_IInspectable, (void **)&tmp_inspectable);
     ok(SUCCEEDED(hr), "IGamepadStatics_QueryInterface IID_IInspectable failed, hr %#x\n", hr);
@@ -89,7 +88,8 @@ static void test_Gamepad(void)
     IAgileObject_Release(tmp_agile_object);
 
     hr = IGamepadStatics_get_Gamepads(gamepad_statics, &gamepads);
-    ok(SUCCEEDED(hr), "IGamepadStatics_get_Gamepads failed, hr %#x\n", hr);
+    todo_wine ok(SUCCEEDED(hr), "IGamepadStatics_get_Gamepads failed, hr %#x\n", hr);
+    if (FAILED(hr)) goto done;
 
     hr = IVectorView_Gamepad_QueryInterface(gamepads, &IID_IInspectable, (void **)&tmp_inspectable);
     ok(SUCCEEDED(hr), "IVectorView_Gamepad_QueryInterface failed, hr %#x\n", hr);
@@ -109,9 +109,9 @@ static void test_Gamepad(void)
     rc = IVectorView_Gamepad_Release(gamepads);
     todo_wine ok(rc == 1, "IVectorView_Gamepad_Release returned unexpected refcount %d\n", rc);
 
+done:
     IGamepadStatics_Release(gamepad_statics);
 
-done:
     IAgileObject_Release(agile_object);
     IInspectable_Release(inspectable);
     IActivationFactory_Release(factory);
-- 
2.30.2




More information about the wine-devel mailing list