Signed-off-by: Rémi Bernon rbernon@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);
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 622da229e70..532af3ab72d 100644 --- a/dlls/windows.gaming.input/tests/input.c +++ b/dlls/windows.gaming.input/tests/input.c @@ -188,19 +188,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);
On 19.03.2021 10:15, Rémi Bernon wrote:
- 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);
- }
Could you just use size as an index so that you can always test an out of bounds call regardless of size value?
Jacek