Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/windows.gaming.input/main.c | 14 +++++++++----- dlls/windows.gaming.input/tests/input.c | 18 ++++++++++++++++-- 2 files changed, 25 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..fa83261ffc4 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,20 @@ 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); + + gamepad = (IGamepad *)0xdeadbeef; + hr = IVectorView_Gamepad_GetAt(gamepads, size, &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; + gamepad = (IGamepad *)0xdeadbeef; + 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);
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/windows.gaming.input/main.c | 12 ++++++++---- dlls/windows.gaming.input/tests/input.c | 15 +++++++++------ 2 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/dlls/windows.gaming.input/main.c b/dlls/windows.gaming.input/main.c index d7a2f138a14..545a7acdbaf 100644 --- a/dlls/windows.gaming.input/main.c +++ b/dlls/windows.gaming.input/main.c @@ -321,28 +321,32 @@ 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; + if (!value) return E_INVALIDARG; + token->value = 0; + return S_OK; }
static HRESULT STDMETHODCALLTYPE gamepad_statics_remove_GamepadAdded( IGamepadStatics *iface, EventRegistrationToken token) { FIXME("iface %p, token %#I64x stub!\n", iface, token.value); - return E_NOTIMPL; + return S_OK; }
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; + if (!value) return E_INVALIDARG; + token->value = 0; + return S_OK; }
static HRESULT STDMETHODCALLTYPE gamepad_statics_remove_GamepadRemoved( IGamepadStatics *iface, EventRegistrationToken token) { FIXME("iface %p, token %#I64x stub!\n", iface, token.value); - return E_NOTIMPL; + return S_OK; }
static HRESULT STDMETHODCALLTYPE gamepad_statics_get_Gamepads( diff --git a/dlls/windows.gaming.input/tests/input.c b/dlls/windows.gaming.input/tests/input.c index fa83261ffc4..9462f3a4ed7 100644 --- a/dlls/windows.gaming.input/tests/input.c +++ b/dlls/windows.gaming.input/tests/input.c @@ -186,19 +186,22 @@ static void test_Gamepad(void)
token.value = 0xdeadbeef; hr = IGamepadStatics_add_GamepadAdded(gamepad_statics, &gamepad_event_handler.IEventHandler_Gamepad_iface, &token); - todo_wine ok(hr == S_OK, "IGamepadStatics_add_GamepadAdded failed, hr %#x\n", hr); - todo_wine ok(token.value != 0xdeadbeef, "IGamepadStatics_add_GamepadAdded returned token %#I64x\n", token.value); + ok(hr == S_OK, "IGamepadStatics_add_GamepadAdded failed, hr %#x\n", hr); + ok(token.value != 0xdeadbeef, "IGamepadStatics_add_GamepadAdded returned token %#I64x\n", token.value);
hr = IGamepadStatics_remove_GamepadAdded(gamepad_statics, token); - todo_wine ok(hr == S_OK, "IGamepadStatics_add_GamepadAdded failed, hr %#x\n", hr); + ok(hr == S_OK, "IGamepadStatics_add_GamepadAdded failed, hr %#x\n", hr);
token.value = 0xdeadbeef; IGamepadStatics_add_GamepadRemoved(gamepad_statics, &gamepad_event_handler.IEventHandler_Gamepad_iface, &token); - todo_wine ok(hr == S_OK, "IGamepadStatics_add_GamepadRemoved failed, hr %#x\n", hr); - todo_wine ok(token.value != 0xdeadbeef, "IGamepadStatics_add_GamepadRemoved returned token %#I64x\n", token.value); + ok(hr == S_OK, "IGamepadStatics_add_GamepadRemoved failed, hr %#x\n", hr); + ok(token.value != 0xdeadbeef, "IGamepadStatics_add_GamepadRemoved returned token %#I64x\n", token.value);
hr = IGamepadStatics_remove_GamepadRemoved(gamepad_statics, token); - todo_wine ok(hr == S_OK, "IGamepadStatics_add_GamepadAdded failed, hr %#x\n", hr); + ok(hr == S_OK, "IGamepadStatics_add_GamepadAdded failed, hr %#x\n", hr); + + hr = IGamepadStatics_add_GamepadAdded(gamepad_statics, NULL, &token); + ok(hr == E_INVALIDARG, "IGamepadStatics_add_GamepadAdded failed, hr %#x\n", hr);
IGamepadStatics_Release(gamepad_statics);
Signed-off-by: Jacek Caban jacek@codeweavers.com
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/windows.gaming.input/main.c | 116 ++++++++++++++++ dlls/windows.gaming.input/tests/input.c | 173 ++++++++++++++++++++++++ 2 files changed, 289 insertions(+)
diff --git a/dlls/windows.gaming.input/main.c b/dlls/windows.gaming.input/main.c index 545a7acdbaf..8a79d77858e 100644 --- a/dlls/windows.gaming.input/main.c +++ b/dlls/windows.gaming.input/main.c @@ -174,6 +174,7 @@ struct windows_gaming_input { IActivationFactory IActivationFactory_iface; IGamepadStatics IGamepadStatics_iface; + IRawGameControllerStatics IRawGameControllerStatics_iface; LONG ref; };
@@ -187,6 +188,11 @@ static inline struct windows_gaming_input *impl_from_IGamepadStatics(IGamepadSta return CONTAINING_RECORD(iface, struct windows_gaming_input, IGamepadStatics_iface); }
+static inline struct windows_gaming_input *impl_from_IRawGameControllerStatics(IRawGameControllerStatics *iface) +{ + return CONTAINING_RECORD(iface, struct windows_gaming_input, IRawGameControllerStatics_iface); +} + static HRESULT STDMETHODCALLTYPE windows_gaming_input_QueryInterface( IActivationFactory *iface, REFIID iid, void **out) { @@ -211,6 +217,13 @@ static HRESULT STDMETHODCALLTYPE windows_gaming_input_QueryInterface( return S_OK; }
+ if (IsEqualGUID(iid, &IID_IRawGameControllerStatics)) + { + IUnknown_AddRef(iface); + *out = &impl->IRawGameControllerStatics_iface; + return S_OK; + } + FIXME("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid)); *out = NULL; return E_NOINTERFACE; @@ -375,10 +388,113 @@ static const struct IGamepadStaticsVtbl gamepad_statics_vtbl = gamepad_statics_get_Gamepads, };
+static HRESULT STDMETHODCALLTYPE raw_game_controller_statics_QueryInterface( + IRawGameControllerStatics *iface, REFIID iid, void **out) +{ + struct windows_gaming_input *impl = impl_from_IRawGameControllerStatics(iface); + return windows_gaming_input_QueryInterface(&impl->IActivationFactory_iface, iid, out); +} + +static ULONG STDMETHODCALLTYPE raw_game_controller_statics_AddRef( + IRawGameControllerStatics *iface) +{ + struct windows_gaming_input *impl = impl_from_IRawGameControllerStatics(iface); + return windows_gaming_input_AddRef(&impl->IActivationFactory_iface); +} + +static ULONG STDMETHODCALLTYPE raw_game_controller_statics_Release( + IRawGameControllerStatics *iface) +{ + struct windows_gaming_input *impl = impl_from_IRawGameControllerStatics(iface); + return windows_gaming_input_Release(&impl->IActivationFactory_iface); +} + +static HRESULT STDMETHODCALLTYPE raw_game_controller_statics_GetIids( + IRawGameControllerStatics *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 raw_game_controller_statics_GetRuntimeClassName( + IRawGameControllerStatics *iface, HSTRING *class_name) +{ + FIXME("iface %p, class_name %p stub!\n", iface, class_name); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE raw_game_controller_statics_GetTrustLevel( + IRawGameControllerStatics *iface, TrustLevel *trust_level) +{ + FIXME("iface %p, trust_level %p stub!\n", iface, trust_level); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE raw_game_controller_statics_add_RawGameControllerAdded( + IRawGameControllerStatics *iface, IEventHandler_RawGameController *value, EventRegistrationToken* token) +{ + FIXME("iface %p, value %p, token %p stub!\n", iface, value, token); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE raw_game_controller_statics_remove_RawGameControllerAdded( + IRawGameControllerStatics *iface, EventRegistrationToken token) +{ + FIXME("iface %p, token %#I64x stub!\n", iface, token.value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE raw_game_controller_statics_add_RawGameControllerRemoved( + IRawGameControllerStatics *iface, IEventHandler_RawGameController *value, EventRegistrationToken* token) +{ + FIXME("iface %p, value %p, token %p stub!\n", iface, value, token); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE raw_game_controller_statics_remove_RawGameControllerRemoved( + IRawGameControllerStatics *iface, EventRegistrationToken token) +{ + FIXME("iface %p, token %#I64x stub!\n", iface, token.value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE raw_game_controller_statics_get_RawGameControllers( + IRawGameControllerStatics *iface, IVectorView_RawGameController **value) +{ + FIXME("iface %p, value %p stub!\n", iface, value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE raw_game_controller_statics_FromGameController( + IRawGameControllerStatics *iface, IGameController *game_controller, IRawGameController **value) +{ + FIXME("iface %p, game_controller %p, value %p stub!\n", iface, game_controller, value); + return E_NOTIMPL; +} + +static const struct IRawGameControllerStaticsVtbl raw_game_controller_statics_vtbl = +{ + raw_game_controller_statics_QueryInterface, + raw_game_controller_statics_AddRef, + raw_game_controller_statics_Release, + /* IInspectable methods */ + raw_game_controller_statics_GetIids, + raw_game_controller_statics_GetRuntimeClassName, + raw_game_controller_statics_GetTrustLevel, + /* IRawGameControllerStatics methods */ + raw_game_controller_statics_add_RawGameControllerAdded, + raw_game_controller_statics_remove_RawGameControllerAdded, + raw_game_controller_statics_add_RawGameControllerRemoved, + raw_game_controller_statics_remove_RawGameControllerRemoved, + raw_game_controller_statics_get_RawGameControllers, + raw_game_controller_statics_FromGameController, +}; + static struct windows_gaming_input windows_gaming_input = { {&activation_factory_vtbl}, {&gamepad_statics_vtbl}, + {&raw_game_controller_statics_vtbl}, 1 };
diff --git a/dlls/windows.gaming.input/tests/input.c b/dlls/windows.gaming.input/tests/input.c index 9462f3a4ed7..2f0cb1a1553 100644 --- a/dlls/windows.gaming.input/tests/input.c +++ b/dlls/windows.gaming.input/tests/input.c @@ -214,6 +214,178 @@ static void test_Gamepad(void) pRoUninitialize(); }
+struct controller_event_handler +{ + IEventHandler_RawGameController IEventHandler_RawGameController_iface; + LONG ref; +}; + +static inline struct controller_event_handler *impl_from_IEventHandler_RawGameController(IEventHandler_RawGameController *iface) +{ + return CONTAINING_RECORD(iface, struct controller_event_handler, IEventHandler_RawGameController_iface); +} + +static HRESULT STDMETHODCALLTYPE controller_event_handler_QueryInterface( + IEventHandler_RawGameController *iface, REFIID iid, void **out) +{ + if (IsEqualGUID(iid, &IID_IUnknown) || + IsEqualGUID(iid, &IID_IEventHandler_RawGameController)) + { + IUnknown_AddRef(iface); + *out = iface; + return S_OK; + } + + trace("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid)); + *out = NULL; + return E_NOINTERFACE; +} + +static ULONG STDMETHODCALLTYPE controller_event_handler_AddRef( + IEventHandler_RawGameController *iface) +{ + struct controller_event_handler *impl = impl_from_IEventHandler_RawGameController(iface); + ULONG ref = InterlockedIncrement(&impl->ref); + return ref; +} + +static ULONG STDMETHODCALLTYPE controller_event_handler_Release( + IEventHandler_RawGameController *iface) +{ + struct controller_event_handler *impl = impl_from_IEventHandler_RawGameController(iface); + ULONG ref = InterlockedDecrement(&impl->ref); + return ref; +} + +static HRESULT STDMETHODCALLTYPE controller_event_handler_Invoke( + IEventHandler_RawGameController *iface, IInspectable *sender, IRawGameController *args) +{ + trace("iface %p, sender %p, args %p\n", iface, sender, args); + return S_OK; +} + +static const IEventHandler_RawGameControllerVtbl controller_event_handler_vtbl = +{ + controller_event_handler_QueryInterface, + controller_event_handler_AddRef, + controller_event_handler_Release, + /*** IEventHandler<ABI::Windows::Gaming::Input::Gamepad* > methods ***/ + controller_event_handler_Invoke, +}; + +static void test_RawGameController(void) +{ + static const WCHAR *controller_name = L"Windows.Gaming.Input.RawGameController"; + + struct controller_event_handler controller_event_handler; + EventRegistrationToken token; + IVectorView_RawGameController *controllers = NULL; + IActivationFactory *factory = NULL; + IRawGameControllerStatics *controller_statics = NULL; + IInspectable *inspectable = NULL, *tmp_inspectable = NULL; + IAgileObject *agile_object = NULL, *tmp_agile_object = NULL; + IRawGameController *controller; + BOOLEAN found; + HSTRING str; + HRESULT hr; + ULONG size; + + controller_event_handler.IEventHandler_RawGameController_iface.lpVtbl = &controller_event_handler_vtbl; + + hr = pRoInitialize(RO_INIT_MULTITHREADED); + ok(hr == S_OK || hr == S_FALSE, "RoInitialize failed, hr %#x\n", hr); + + hr = pWindowsCreateString(controller_name, wcslen(controller_name), &str); + ok(hr == S_OK, "WindowsCreateString failed, hr %#x\n", hr); + + hr = pRoGetActivationFactory(str, &IID_IActivationFactory, (void **)&factory); + ok(hr == S_OK || broken(hr == REGDB_E_CLASSNOTREG), "RoGetActivationFactory failed, hr %#x\n", hr); + if (hr == REGDB_E_CLASSNOTREG) + { + win_skip("%s runtimeclass not registered, skipping tests.\n", wine_dbgstr_w(controller_name)); + return; + } + + hr = IActivationFactory_QueryInterface(factory, &IID_IInspectable, (void **)&inspectable); + ok(hr == S_OK, "IActivationFactory_QueryInterface IID_IInspectable failed, hr %#x\n", hr); + + hr = IActivationFactory_QueryInterface(factory, &IID_IAgileObject, (void **)&agile_object); + ok(hr == S_OK, "IActivationFactory_QueryInterface IID_IAgileObject failed, hr %#x\n", hr); + + hr = IActivationFactory_QueryInterface(factory, &IID_IRawGameControllerStatics, (void **)&controller_statics); + ok(hr == S_OK, "IActivationFactory_QueryInterface IID_IRawGameControllerStatics failed, hr %#x\n", hr); + + hr = IRawGameControllerStatics_QueryInterface(controller_statics, &IID_IInspectable, (void **)&tmp_inspectable); + ok(hr == S_OK, "IRawGameControllerStatics_QueryInterface IID_IInspectable failed, hr %#x\n", hr); + ok(tmp_inspectable == inspectable, "IRawGameControllerStatics_QueryInterface IID_IInspectable returned %p, expected %p\n", tmp_inspectable, inspectable); + IInspectable_Release(tmp_inspectable); + + hr = IRawGameControllerStatics_QueryInterface(controller_statics, &IID_IAgileObject, (void **)&tmp_agile_object); + ok(hr == S_OK, "IRawGameControllerStatics_QueryInterface IID_IAgileObject failed, hr %#x\n", hr); + ok(tmp_agile_object == agile_object, "IRawGameControllerStatics_QueryInterface IID_IAgileObject returned %p, expected %p\n", tmp_agile_object, agile_object); + IAgileObject_Release(tmp_agile_object); + + hr = IRawGameControllerStatics_get_RawGameControllers(controller_statics, &controllers); + todo_wine ok(hr == S_OK, "IRawGameControllerStatics_get_RawGameControllers failed, hr %#x\n", hr); + if (FAILED(hr)) goto done; + + hr = IVectorView_RawGameController_QueryInterface(controllers, &IID_IInspectable, (void **)&tmp_inspectable); + ok(hr == S_OK, "IVectorView_RawGameController_QueryInterface failed, hr %#x\n", hr); + ok(tmp_inspectable != inspectable, "IVectorView_RawGameController_QueryInterface returned %p, expected %p\n", tmp_inspectable, inspectable); + IInspectable_Release(tmp_inspectable); + + hr = IVectorView_RawGameController_QueryInterface(controllers, &IID_IAgileObject, (void **)&tmp_agile_object); + ok(hr == S_OK, "IVectorView_RawGameController_QueryInterface failed, hr %#x\n", hr); + ok(tmp_agile_object != agile_object, "IVectorView_RawGameController_QueryInterface IID_IAgileObject returned agile_object\n"); + IAgileObject_Release(tmp_agile_object); + + size = 0xdeadbeef; + hr = IVectorView_RawGameController_get_Size(controllers, &size); + ok(hr == S_OK, "IVectorView_RawGameController_get_Size failed, hr %#x\n", hr); + ok(size != 0xdeadbeef, "IVectorView_RawGameController_get_Size returned %u\n", size); + + controller = (IRawGameController *)0xdeadbeef; + hr = IVectorView_RawGameController_GetAt(controllers, size, &controller); + ok(hr == E_BOUNDS, "IVectorView_RawGameController_GetAt failed, hr %#x\n", hr); + ok(controller == NULL, "IVectorView_RawGameController_GetAt returned %p\n", controller); + + size = 0xdeadbeef; + found = TRUE; + controller = (IRawGameController *)0xdeadbeef; + hr = IVectorView_RawGameController_IndexOf(controllers, controller, &size, &found); + ok(hr == S_OK, "IVectorView_RawGameController_IndexOf failed, hr %#x\n", hr); + ok(size == 0 && found == FALSE, "IVectorView_RawGameController_IndexOf returned size %d, found %d\n", size, found); + + IVectorView_RawGameController_Release(controllers); + +done: + token.value = 0xdeadbeef; + hr = IRawGameControllerStatics_add_RawGameControllerAdded(controller_statics, &controller_event_handler.IEventHandler_RawGameController_iface, &token); + todo_wine ok(hr == S_OK, "IRawGameControllerStatics_add_RawGameControllerAdded failed, hr %#x\n", hr); + todo_wine ok(token.value != 0xdeadbeef, "IRawGameControllerStatics_add_RawGameControllerAdded returned token %#I64x\n", token.value); + + hr = IRawGameControllerStatics_remove_RawGameControllerAdded(controller_statics, token); + todo_wine ok(hr == S_OK, "IRawGameControllerStatics_add_RawGameControllerAdded failed, hr %#x\n", hr); + + token.value = 0xdeadbeef; + IRawGameControllerStatics_add_RawGameControllerRemoved(controller_statics, &controller_event_handler.IEventHandler_RawGameController_iface, &token); + todo_wine ok(hr == S_OK, "IRawGameControllerStatics_add_RawGameControllerRemoved failed, hr %#x\n", hr); + todo_wine ok(token.value != 0xdeadbeef, "IRawGameControllerStatics_add_RawGameControllerRemoved returned token %#I64x\n", token.value); + + hr = IRawGameControllerStatics_remove_RawGameControllerRemoved(controller_statics, token); + todo_wine ok(hr == S_OK, "IRawGameControllerStatics_add_RawGameControllerAdded failed, hr %#x\n", hr); + + IRawGameControllerStatics_Release(controller_statics); + + IAgileObject_Release(agile_object); + IInspectable_Release(inspectable); + IActivationFactory_Release(factory); + + pWindowsDeleteString(str); + + pRoUninitialize(); +} + START_TEST(input) { HMODULE combase; @@ -240,4 +412,5 @@ START_TEST(input) #undef LOAD_FUNCPTR
test_Gamepad(); + test_RawGameController(); }
Signed-off-by: Jacek Caban jacek@codeweavers.com
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/windows.gaming.input/main.c | 126 +++++++++++++++++++++++- dlls/windows.gaming.input/tests/input.c | 16 ++- 2 files changed, 131 insertions(+), 11 deletions(-)
diff --git a/dlls/windows.gaming.input/main.c b/dlls/windows.gaming.input/main.c index 8a79d77858e..69839e06558 100644 --- a/dlls/windows.gaming.input/main.c +++ b/dlls/windows.gaming.input/main.c @@ -170,6 +170,126 @@ static struct gamepad_vector gamepads = 0 };
+struct raw_game_controller_vector +{ + IVectorView_RawGameController IVectorView_RawGameController_iface; + LONG ref; +}; + +static inline struct raw_game_controller_vector *impl_from_IVectorView_RawGameController(IVectorView_RawGameController *iface) +{ + return CONTAINING_RECORD(iface, struct raw_game_controller_vector, IVectorView_RawGameController_iface); +} + +static HRESULT STDMETHODCALLTYPE vector_view_raw_game_controller_QueryInterface( + IVectorView_RawGameController *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_RawGameController)) + { + 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_raw_game_controller_AddRef( + IVectorView_RawGameController *iface) +{ + struct raw_game_controller_vector *impl = impl_from_IVectorView_RawGameController(iface); + ULONG ref = InterlockedIncrement(&impl->ref); + TRACE("iface %p, ref %u.\n", iface, ref); + return ref; +} + +static ULONG STDMETHODCALLTYPE vector_view_raw_game_controller_Release( + IVectorView_RawGameController *iface) +{ + struct raw_game_controller_vector *impl = impl_from_IVectorView_RawGameController(iface); + ULONG ref = InterlockedDecrement(&impl->ref); + TRACE("iface %p, ref %u.\n", iface, ref); + return ref; +} + +static HRESULT STDMETHODCALLTYPE vector_view_raw_game_controller_GetIids( + IVectorView_RawGameController *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_raw_game_controller_GetRuntimeClassName( + IVectorView_RawGameController *iface, HSTRING *class_name) +{ + FIXME("iface %p, class_name %p stub!\n", iface, class_name); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE vector_view_raw_game_controller_GetTrustLevel( + IVectorView_RawGameController *iface, TrustLevel *trust_level) +{ + FIXME("iface %p, trust_level %p stub!\n", iface, trust_level); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE vector_view_raw_game_controller_GetAt( + IVectorView_RawGameController *iface, ULONG index, IRawGameController **value) +{ + FIXME("iface %p, index %#x, value %p stub!\n", iface, index, value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE vector_view_raw_game_controller_get_Size( + IVectorView_RawGameController *iface, ULONG *value) +{ + FIXME("iface %p, value %p stub!\n", iface, value); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE vector_view_raw_game_controller_IndexOf( + IVectorView_RawGameController *iface, IRawGameController *element, ULONG *index, BOOLEAN *found) +{ + FIXME("iface %p, element %p, index %p, found %p stub!\n", iface, element, index, found); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE vector_view_raw_game_controller_GetMany( + IVectorView_RawGameController *iface, ULONG start_index, IRawGameController **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_RawGameControllerVtbl vector_view_raw_game_controller_vtbl = +{ + vector_view_raw_game_controller_QueryInterface, + vector_view_raw_game_controller_AddRef, + vector_view_raw_game_controller_Release, + /* IInspectable methods */ + vector_view_raw_game_controller_GetIids, + vector_view_raw_game_controller_GetRuntimeClassName, + vector_view_raw_game_controller_GetTrustLevel, + /* IVectorView<RawGameController> methods */ + vector_view_raw_game_controller_GetAt, + vector_view_raw_game_controller_get_Size, + vector_view_raw_game_controller_IndexOf, + vector_view_raw_game_controller_GetMany, +}; + +static struct raw_game_controller_vector raw_game_controllers = +{ + {&vector_view_raw_game_controller_vtbl}, + 0 +}; + struct windows_gaming_input { IActivationFactory IActivationFactory_iface; @@ -461,8 +581,10 @@ static HRESULT STDMETHODCALLTYPE raw_game_controller_statics_remove_RawGameContr static HRESULT STDMETHODCALLTYPE raw_game_controller_statics_get_RawGameControllers( IRawGameControllerStatics *iface, IVectorView_RawGameController **value) { - FIXME("iface %p, value %p stub!\n", iface, value); - return E_NOTIMPL; + TRACE("iface %p, value %p.\n", iface, value); + *value = &raw_game_controllers.IVectorView_RawGameController_iface; + IVectorView_RawGameController_AddRef(*value); + return S_OK; }
static HRESULT STDMETHODCALLTYPE raw_game_controller_statics_FromGameController( diff --git a/dlls/windows.gaming.input/tests/input.c b/dlls/windows.gaming.input/tests/input.c index 2f0cb1a1553..1344d885ecb 100644 --- a/dlls/windows.gaming.input/tests/input.c +++ b/dlls/windows.gaming.input/tests/input.c @@ -326,8 +326,7 @@ static void test_RawGameController(void) IAgileObject_Release(tmp_agile_object);
hr = IRawGameControllerStatics_get_RawGameControllers(controller_statics, &controllers); - todo_wine ok(hr == S_OK, "IRawGameControllerStatics_get_RawGameControllers failed, hr %#x\n", hr); - if (FAILED(hr)) goto done; + ok(hr == S_OK, "IRawGameControllerStatics_get_RawGameControllers failed, hr %#x\n", hr);
hr = IVectorView_RawGameController_QueryInterface(controllers, &IID_IInspectable, (void **)&tmp_inspectable); ok(hr == S_OK, "IVectorView_RawGameController_QueryInterface failed, hr %#x\n", hr); @@ -341,24 +340,23 @@ static void test_RawGameController(void)
size = 0xdeadbeef; hr = IVectorView_RawGameController_get_Size(controllers, &size); - ok(hr == S_OK, "IVectorView_RawGameController_get_Size failed, hr %#x\n", hr); - ok(size != 0xdeadbeef, "IVectorView_RawGameController_get_Size returned %u\n", size); + todo_wine ok(hr == S_OK, "IVectorView_RawGameController_get_Size failed, hr %#x\n", hr); + todo_wine ok(size != 0xdeadbeef, "IVectorView_RawGameController_get_Size returned %u\n", size);
controller = (IRawGameController *)0xdeadbeef; hr = IVectorView_RawGameController_GetAt(controllers, size, &controller); - ok(hr == E_BOUNDS, "IVectorView_RawGameController_GetAt failed, hr %#x\n", hr); - ok(controller == NULL, "IVectorView_RawGameController_GetAt returned %p\n", controller); + todo_wine ok(hr == E_BOUNDS, "IVectorView_RawGameController_GetAt failed, hr %#x\n", hr); + todo_wine ok(controller == NULL, "IVectorView_RawGameController_GetAt returned %p\n", controller);
size = 0xdeadbeef; found = TRUE; controller = (IRawGameController *)0xdeadbeef; hr = IVectorView_RawGameController_IndexOf(controllers, controller, &size, &found); - ok(hr == S_OK, "IVectorView_RawGameController_IndexOf failed, hr %#x\n", hr); - ok(size == 0 && found == FALSE, "IVectorView_RawGameController_IndexOf returned size %d, found %d\n", size, found); + todo_wine ok(hr == S_OK, "IVectorView_RawGameController_IndexOf failed, hr %#x\n", hr); + todo_wine ok(size == 0 && found == FALSE, "IVectorView_RawGameController_IndexOf returned size %d, found %d\n", size, found);
IVectorView_RawGameController_Release(controllers);
-done: token.value = 0xdeadbeef; hr = IRawGameControllerStatics_add_RawGameControllerAdded(controller_statics, &controller_event_handler.IEventHandler_RawGameController_iface, &token); todo_wine ok(hr == S_OK, "IRawGameControllerStatics_add_RawGameControllerAdded failed, hr %#x\n", hr);
Signed-off-by: Jacek Caban jacek@codeweavers.com
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/windows.gaming.input/main.c | 10 +++++++--- dlls/windows.gaming.input/tests/input.c | 12 ++++++------ 2 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/dlls/windows.gaming.input/main.c b/dlls/windows.gaming.input/main.c index 69839e06558..56c5ad20ab0 100644 --- a/dlls/windows.gaming.input/main.c +++ b/dlls/windows.gaming.input/main.c @@ -244,21 +244,25 @@ static HRESULT STDMETHODCALLTYPE vector_view_raw_game_controller_GetAt( IVectorView_RawGameController *iface, ULONG index, IRawGameController **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_raw_game_controller_get_Size( IVectorView_RawGameController *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_raw_game_controller_IndexOf( IVectorView_RawGameController *iface, IRawGameController *element, ULONG *index, BOOLEAN *found) { FIXME("iface %p, element %p, index %p, found %p stub!\n", iface, element, index, found); - return E_NOTIMPL; + *index = 0; + *found = FALSE; + return S_OK; }
static HRESULT STDMETHODCALLTYPE vector_view_raw_game_controller_GetMany( diff --git a/dlls/windows.gaming.input/tests/input.c b/dlls/windows.gaming.input/tests/input.c index 1344d885ecb..a359f225728 100644 --- a/dlls/windows.gaming.input/tests/input.c +++ b/dlls/windows.gaming.input/tests/input.c @@ -340,20 +340,20 @@ static void test_RawGameController(void)
size = 0xdeadbeef; hr = IVectorView_RawGameController_get_Size(controllers, &size); - todo_wine ok(hr == S_OK, "IVectorView_RawGameController_get_Size failed, hr %#x\n", hr); - todo_wine ok(size != 0xdeadbeef, "IVectorView_RawGameController_get_Size returned %u\n", size); + ok(hr == S_OK, "IVectorView_RawGameController_get_Size failed, hr %#x\n", hr); + ok(size != 0xdeadbeef, "IVectorView_RawGameController_get_Size returned %u\n", size);
controller = (IRawGameController *)0xdeadbeef; hr = IVectorView_RawGameController_GetAt(controllers, size, &controller); - todo_wine ok(hr == E_BOUNDS, "IVectorView_RawGameController_GetAt failed, hr %#x\n", hr); - todo_wine ok(controller == NULL, "IVectorView_RawGameController_GetAt returned %p\n", controller); + ok(hr == E_BOUNDS, "IVectorView_RawGameController_GetAt failed, hr %#x\n", hr); + ok(controller == NULL, "IVectorView_RawGameController_GetAt returned %p\n", controller);
size = 0xdeadbeef; found = TRUE; controller = (IRawGameController *)0xdeadbeef; hr = IVectorView_RawGameController_IndexOf(controllers, controller, &size, &found); - todo_wine ok(hr == S_OK, "IVectorView_RawGameController_IndexOf failed, hr %#x\n", hr); - todo_wine ok(size == 0 && found == FALSE, "IVectorView_RawGameController_IndexOf returned size %d, found %d\n", size, found); + ok(hr == S_OK, "IVectorView_RawGameController_IndexOf failed, hr %#x\n", hr); + ok(size == 0 && found == FALSE, "IVectorView_RawGameController_IndexOf returned size %d, found %d\n", size, found);
IVectorView_RawGameController_Release(controllers);
Signed-off-by: Jacek Caban jacek@codeweavers.com
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/windows.gaming.input/main.c | 12 ++++++++---- dlls/windows.gaming.input/tests/input.c | 15 +++++++++------ 2 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/dlls/windows.gaming.input/main.c b/dlls/windows.gaming.input/main.c index 56c5ad20ab0..c71374e34a3 100644 --- a/dlls/windows.gaming.input/main.c +++ b/dlls/windows.gaming.input/main.c @@ -558,28 +558,32 @@ static HRESULT STDMETHODCALLTYPE raw_game_controller_statics_add_RawGameControll IRawGameControllerStatics *iface, IEventHandler_RawGameController *value, EventRegistrationToken* token) { FIXME("iface %p, value %p, token %p stub!\n", iface, value, token); - return E_NOTIMPL; + if (!value) return E_INVALIDARG; + token->value = 0; + return S_OK; }
static HRESULT STDMETHODCALLTYPE raw_game_controller_statics_remove_RawGameControllerAdded( IRawGameControllerStatics *iface, EventRegistrationToken token) { FIXME("iface %p, token %#I64x stub!\n", iface, token.value); - return E_NOTIMPL; + return S_OK; }
static HRESULT STDMETHODCALLTYPE raw_game_controller_statics_add_RawGameControllerRemoved( IRawGameControllerStatics *iface, IEventHandler_RawGameController *value, EventRegistrationToken* token) { FIXME("iface %p, value %p, token %p stub!\n", iface, value, token); - return E_NOTIMPL; + if (!value) return E_INVALIDARG; + token->value = 0; + return S_OK; }
static HRESULT STDMETHODCALLTYPE raw_game_controller_statics_remove_RawGameControllerRemoved( IRawGameControllerStatics *iface, EventRegistrationToken token) { FIXME("iface %p, token %#I64x stub!\n", iface, token.value); - return E_NOTIMPL; + return S_OK; }
static HRESULT STDMETHODCALLTYPE raw_game_controller_statics_get_RawGameControllers( diff --git a/dlls/windows.gaming.input/tests/input.c b/dlls/windows.gaming.input/tests/input.c index a359f225728..62822b30c28 100644 --- a/dlls/windows.gaming.input/tests/input.c +++ b/dlls/windows.gaming.input/tests/input.c @@ -359,19 +359,22 @@ static void test_RawGameController(void)
token.value = 0xdeadbeef; hr = IRawGameControllerStatics_add_RawGameControllerAdded(controller_statics, &controller_event_handler.IEventHandler_RawGameController_iface, &token); - todo_wine ok(hr == S_OK, "IRawGameControllerStatics_add_RawGameControllerAdded failed, hr %#x\n", hr); - todo_wine ok(token.value != 0xdeadbeef, "IRawGameControllerStatics_add_RawGameControllerAdded returned token %#I64x\n", token.value); + ok(hr == S_OK, "IRawGameControllerStatics_add_RawGameControllerAdded failed, hr %#x\n", hr); + ok(token.value != 0xdeadbeef, "IRawGameControllerStatics_add_RawGameControllerAdded returned token %#I64x\n", token.value);
hr = IRawGameControllerStatics_remove_RawGameControllerAdded(controller_statics, token); - todo_wine ok(hr == S_OK, "IRawGameControllerStatics_add_RawGameControllerAdded failed, hr %#x\n", hr); + ok(hr == S_OK, "IRawGameControllerStatics_add_RawGameControllerAdded failed, hr %#x\n", hr);
token.value = 0xdeadbeef; IRawGameControllerStatics_add_RawGameControllerRemoved(controller_statics, &controller_event_handler.IEventHandler_RawGameController_iface, &token); - todo_wine ok(hr == S_OK, "IRawGameControllerStatics_add_RawGameControllerRemoved failed, hr %#x\n", hr); - todo_wine ok(token.value != 0xdeadbeef, "IRawGameControllerStatics_add_RawGameControllerRemoved returned token %#I64x\n", token.value); + ok(hr == S_OK, "IRawGameControllerStatics_add_RawGameControllerRemoved failed, hr %#x\n", hr); + ok(token.value != 0xdeadbeef, "IRawGameControllerStatics_add_RawGameControllerRemoved returned token %#I64x\n", token.value);
hr = IRawGameControllerStatics_remove_RawGameControllerRemoved(controller_statics, token); - todo_wine ok(hr == S_OK, "IRawGameControllerStatics_add_RawGameControllerAdded failed, hr %#x\n", hr); + ok(hr == S_OK, "IRawGameControllerStatics_add_RawGameControllerAdded failed, hr %#x\n", hr); + + hr = IRawGameControllerStatics_add_RawGameControllerAdded(controller_statics, NULL, &token); + ok(hr == E_INVALIDARG, "IRawGameControllerStatics_add_RawGameControllerAdded failed, hr %#x\n", hr);
IRawGameControllerStatics_Release(controller_statics);
Signed-off-by: Jacek Caban jacek@codeweavers.com