windows.gaming.input: Fake empty IGamepadStatics::Gamepads vector.
[wine/zf.git] / dlls / windows.gaming.input / main.c
blobd7a2f138a149da455adc543aa6745643102ae9c8
1 /* WinRT Windows.Gaming.Input implementation
3 * Copyright 2021 RĂ©mi Bernon for CodeWeavers
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include <stdarg.h>
22 #define COBJMACROS
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winstring.h"
26 #include "wine/debug.h"
27 #include "objbase.h"
29 #include "initguid.h"
30 #include "activation.h"
32 #define WIDL_using_Windows_Foundation
33 #define WIDL_using_Windows_Foundation_Collections
34 #include "windows.foundation.h"
35 #define WIDL_using_Windows_Gaming_Input
36 #include "windows.gaming.input.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(input);
40 static const char *debugstr_hstring(HSTRING hstr)
42 const WCHAR *str;
43 UINT32 len;
44 if (hstr && !((ULONG_PTR)hstr >> 16)) return "(invalid)";
45 str = WindowsGetStringRawBuffer(hstr, &len);
46 return wine_dbgstr_wn(str, len);
49 struct gamepad_vector
51 IVectorView_Gamepad IVectorView_Gamepad_iface;
52 LONG ref;
55 static inline struct gamepad_vector *impl_from_IVectorView_Gamepad(IVectorView_Gamepad *iface)
57 return CONTAINING_RECORD(iface, struct gamepad_vector, IVectorView_Gamepad_iface);
60 static HRESULT STDMETHODCALLTYPE vector_view_gamepad_QueryInterface(
61 IVectorView_Gamepad *iface, REFIID iid, void **out)
63 TRACE("iface %p, iid %s, out %p stub!\n", iface, debugstr_guid(iid), out);
65 if (IsEqualGUID(iid, &IID_IUnknown) ||
66 IsEqualGUID(iid, &IID_IInspectable) ||
67 IsEqualGUID(iid, &IID_IAgileObject) ||
68 IsEqualGUID(iid, &IID_IVectorView_Gamepad))
70 IUnknown_AddRef(iface);
71 *out = iface;
72 return S_OK;
75 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
76 *out = NULL;
77 return E_NOINTERFACE;
80 static ULONG STDMETHODCALLTYPE vector_view_gamepad_AddRef(
81 IVectorView_Gamepad *iface)
83 struct gamepad_vector *impl = impl_from_IVectorView_Gamepad(iface);
84 ULONG ref = InterlockedIncrement(&impl->ref);
85 TRACE("iface %p, ref %u.\n", iface, ref);
86 return ref;
89 static ULONG STDMETHODCALLTYPE vector_view_gamepad_Release(
90 IVectorView_Gamepad *iface)
92 struct gamepad_vector *impl = impl_from_IVectorView_Gamepad(iface);
93 ULONG ref = InterlockedDecrement(&impl->ref);
94 TRACE("iface %p, ref %u.\n", iface, ref);
95 return ref;
98 static HRESULT STDMETHODCALLTYPE vector_view_gamepad_GetIids(
99 IVectorView_Gamepad *iface, ULONG *iid_count, IID **iids)
101 FIXME("iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids);
102 return E_NOTIMPL;
105 static HRESULT STDMETHODCALLTYPE vector_view_gamepad_GetRuntimeClassName(
106 IVectorView_Gamepad *iface, HSTRING *class_name)
108 FIXME("iface %p, class_name %p stub!\n", iface, class_name);
109 return E_NOTIMPL;
112 static HRESULT STDMETHODCALLTYPE vector_view_gamepad_GetTrustLevel(
113 IVectorView_Gamepad *iface, TrustLevel *trust_level)
115 FIXME("iface %p, trust_level %p stub!\n", iface, trust_level);
116 return E_NOTIMPL;
119 static HRESULT STDMETHODCALLTYPE vector_view_gamepad_GetAt(
120 IVectorView_Gamepad *iface, ULONG index, IGamepad **value)
122 FIXME("iface %p, index %#x, value %p stub!\n", iface, index, value);
123 *value = NULL;
124 return E_BOUNDS;
127 static HRESULT STDMETHODCALLTYPE vector_view_gamepad_get_Size(
128 IVectorView_Gamepad *iface, ULONG *value)
130 FIXME("iface %p, value %p stub!\n", iface, value);
131 *value = 0;
132 return S_OK;
135 static HRESULT STDMETHODCALLTYPE vector_view_gamepad_IndexOf(
136 IVectorView_Gamepad *iface, IGamepad *element, ULONG *index, BOOLEAN *found)
138 FIXME("iface %p, element %p, index %p, found %p stub!\n", iface, element, index, found);
139 *index = 0;
140 *found = FALSE;
141 return S_OK;
144 static HRESULT STDMETHODCALLTYPE vector_view_gamepad_GetMany(
145 IVectorView_Gamepad *iface, ULONG start_index, IGamepad **items, UINT *value)
147 FIXME("iface %p, start_index %#x, items %p, value %p stub!\n", iface, start_index, items, value);
148 return E_NOTIMPL;
151 static const struct IVectorView_GamepadVtbl vector_view_gamepad_vtbl =
153 vector_view_gamepad_QueryInterface,
154 vector_view_gamepad_AddRef,
155 vector_view_gamepad_Release,
156 /* IInspectable methods */
157 vector_view_gamepad_GetIids,
158 vector_view_gamepad_GetRuntimeClassName,
159 vector_view_gamepad_GetTrustLevel,
160 /* IVectorView<VoiceInformation> methods */
161 vector_view_gamepad_GetAt,
162 vector_view_gamepad_get_Size,
163 vector_view_gamepad_IndexOf,
164 vector_view_gamepad_GetMany,
167 static struct gamepad_vector gamepads =
169 {&vector_view_gamepad_vtbl},
173 struct windows_gaming_input
175 IActivationFactory IActivationFactory_iface;
176 IGamepadStatics IGamepadStatics_iface;
177 LONG ref;
180 static inline struct windows_gaming_input *impl_from_IActivationFactory(IActivationFactory *iface)
182 return CONTAINING_RECORD(iface, struct windows_gaming_input, IActivationFactory_iface);
185 static inline struct windows_gaming_input *impl_from_IGamepadStatics(IGamepadStatics *iface)
187 return CONTAINING_RECORD(iface, struct windows_gaming_input, IGamepadStatics_iface);
190 static HRESULT STDMETHODCALLTYPE windows_gaming_input_QueryInterface(
191 IActivationFactory *iface, REFIID iid, void **out)
193 struct windows_gaming_input *impl = impl_from_IActivationFactory(iface);
195 TRACE("iface %p, iid %s, out %p stub!\n", iface, debugstr_guid(iid), out);
197 if (IsEqualGUID(iid, &IID_IUnknown) ||
198 IsEqualGUID(iid, &IID_IInspectable) ||
199 IsEqualGUID(iid, &IID_IAgileObject) ||
200 IsEqualGUID(iid, &IID_IActivationFactory))
202 IUnknown_AddRef(iface);
203 *out = iface;
204 return S_OK;
207 if (IsEqualGUID(iid, &IID_IGamepadStatics))
209 IUnknown_AddRef(iface);
210 *out = &impl->IGamepadStatics_iface;
211 return S_OK;
214 FIXME("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
215 *out = NULL;
216 return E_NOINTERFACE;
219 static ULONG STDMETHODCALLTYPE windows_gaming_input_AddRef(
220 IActivationFactory *iface)
222 struct windows_gaming_input *impl = impl_from_IActivationFactory(iface);
223 ULONG ref = InterlockedIncrement(&impl->ref);
224 TRACE("iface %p, ref %u.\n", iface, ref);
225 return ref;
228 static ULONG STDMETHODCALLTYPE windows_gaming_input_Release(
229 IActivationFactory *iface)
231 struct windows_gaming_input *impl = impl_from_IActivationFactory(iface);
232 ULONG ref = InterlockedDecrement(&impl->ref);
233 TRACE("iface %p, ref %u.\n", iface, ref);
234 return ref;
237 static HRESULT STDMETHODCALLTYPE windows_gaming_input_GetIids(
238 IActivationFactory *iface, ULONG *iid_count, IID **iids)
240 FIXME("iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids);
241 return E_NOTIMPL;
244 static HRESULT STDMETHODCALLTYPE windows_gaming_input_GetRuntimeClassName(
245 IActivationFactory *iface, HSTRING *class_name)
247 FIXME("iface %p, class_name %p stub!\n", iface, class_name);
248 return E_NOTIMPL;
251 static HRESULT STDMETHODCALLTYPE windows_gaming_input_GetTrustLevel(
252 IActivationFactory *iface, TrustLevel *trust_level)
254 FIXME("iface %p, trust_level %p stub!\n", iface, trust_level);
255 return E_NOTIMPL;
258 static HRESULT STDMETHODCALLTYPE windows_gaming_input_ActivateInstance(
259 IActivationFactory *iface, IInspectable **instance)
261 FIXME("iface %p, instance %p stub!\n", iface, instance);
262 return E_NOTIMPL;
265 static const struct IActivationFactoryVtbl activation_factory_vtbl =
267 windows_gaming_input_QueryInterface,
268 windows_gaming_input_AddRef,
269 windows_gaming_input_Release,
270 /* IInspectable methods */
271 windows_gaming_input_GetIids,
272 windows_gaming_input_GetRuntimeClassName,
273 windows_gaming_input_GetTrustLevel,
274 /* IActivationFactory methods */
275 windows_gaming_input_ActivateInstance,
278 static HRESULT STDMETHODCALLTYPE gamepad_statics_QueryInterface(
279 IGamepadStatics *iface, REFIID iid, void **out)
281 struct windows_gaming_input *impl = impl_from_IGamepadStatics(iface);
282 return windows_gaming_input_QueryInterface(&impl->IActivationFactory_iface, iid, out);
285 static ULONG STDMETHODCALLTYPE gamepad_statics_AddRef(
286 IGamepadStatics *iface)
288 struct windows_gaming_input *impl = impl_from_IGamepadStatics(iface);
289 return windows_gaming_input_AddRef(&impl->IActivationFactory_iface);
292 static ULONG STDMETHODCALLTYPE gamepad_statics_Release(
293 IGamepadStatics *iface)
295 struct windows_gaming_input *impl = impl_from_IGamepadStatics(iface);
296 return windows_gaming_input_Release(&impl->IActivationFactory_iface);
299 static HRESULT STDMETHODCALLTYPE gamepad_statics_GetIids(
300 IGamepadStatics *iface, ULONG *iid_count, IID **iids)
302 FIXME("iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids);
303 return E_NOTIMPL;
306 static HRESULT STDMETHODCALLTYPE gamepad_statics_GetRuntimeClassName(
307 IGamepadStatics *iface, HSTRING *class_name)
309 FIXME("iface %p, class_name %p stub!\n", iface, class_name);
310 return E_NOTIMPL;
313 static HRESULT STDMETHODCALLTYPE gamepad_statics_GetTrustLevel(
314 IGamepadStatics *iface, TrustLevel *trust_level)
316 FIXME("iface %p, trust_level %p stub!\n", iface, trust_level);
317 return E_NOTIMPL;
320 static HRESULT STDMETHODCALLTYPE gamepad_statics_add_GamepadAdded(
321 IGamepadStatics *iface, IEventHandler_Gamepad *value, EventRegistrationToken* token)
323 FIXME("iface %p, value %p, token %p stub!\n", iface, value, token);
324 return E_NOTIMPL;
327 static HRESULT STDMETHODCALLTYPE gamepad_statics_remove_GamepadAdded(
328 IGamepadStatics *iface, EventRegistrationToken token)
330 FIXME("iface %p, token %#I64x stub!\n", iface, token.value);
331 return E_NOTIMPL;
334 static HRESULT STDMETHODCALLTYPE gamepad_statics_add_GamepadRemoved(
335 IGamepadStatics *iface, IEventHandler_Gamepad *value, EventRegistrationToken* token)
337 FIXME("iface %p, value %p, token %p stub!\n", iface, value, token);
338 return E_NOTIMPL;
341 static HRESULT STDMETHODCALLTYPE gamepad_statics_remove_GamepadRemoved(
342 IGamepadStatics *iface, EventRegistrationToken token)
344 FIXME("iface %p, token %#I64x stub!\n", iface, token.value);
345 return E_NOTIMPL;
348 static HRESULT STDMETHODCALLTYPE gamepad_statics_get_Gamepads(
349 IGamepadStatics *iface, IVectorView_Gamepad **value)
351 TRACE("iface %p, value %p.\n", iface, value);
352 *value = &gamepads.IVectorView_Gamepad_iface;
353 IVectorView_Gamepad_AddRef(*value);
354 return S_OK;
357 static const struct IGamepadStaticsVtbl gamepad_statics_vtbl =
359 gamepad_statics_QueryInterface,
360 gamepad_statics_AddRef,
361 gamepad_statics_Release,
362 /* IInspectable methods */
363 gamepad_statics_GetIids,
364 gamepad_statics_GetRuntimeClassName,
365 gamepad_statics_GetTrustLevel,
366 /* IGamepadStatics methods */
367 gamepad_statics_add_GamepadAdded,
368 gamepad_statics_remove_GamepadAdded,
369 gamepad_statics_add_GamepadRemoved,
370 gamepad_statics_remove_GamepadRemoved,
371 gamepad_statics_get_Gamepads,
374 static struct windows_gaming_input windows_gaming_input =
376 {&activation_factory_vtbl},
377 {&gamepad_statics_vtbl},
381 HRESULT WINAPI DllCanUnloadNow(void)
383 return S_FALSE;
386 HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID riid, void **out)
388 FIXME("clsid %s, riid %s, out %p stub!\n", debugstr_guid(clsid), debugstr_guid(riid), out);
389 return CLASS_E_CLASSNOTAVAILABLE;
392 HRESULT WINAPI DllGetActivationFactory(HSTRING classid, IActivationFactory **factory)
394 TRACE("classid %s, factory %p.\n", debugstr_hstring(classid), factory);
395 *factory = &windows_gaming_input.IActivationFactory_iface;
396 IUnknown_AddRef(*factory);
397 return S_OK;