From: Józef Kucia Subject: [PATCH 5/7] ninput: Implement SetPropertyInteractionContext(). Message-Id: <20180621141946.13340-5-jkucia@codeweavers.com> Date: Thu, 21 Jun 2018 16:19:44 +0200 Signed-off-by: Józef Kucia --- dlls/ninput/main.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++ dlls/ninput/ninput.spec | 4 ++-- dlls/ninput/tests/ninput.c | 48 +++++++++++++++++++++++++++++++++++++ 3 files changed, 109 insertions(+), 2 deletions(-) diff --git a/dlls/ninput/main.c b/dlls/ninput/main.c index 932d159ab390..90f9e7e0c4ee 100644 --- a/dlls/ninput/main.c +++ b/dlls/ninput/main.c @@ -72,6 +72,65 @@ HRESULT WINAPI DestroyInteractionContext(HINTERACTIONCONTEXT handle) return S_OK; } +HRESULT WINAPI GetPropertyInteractionContext(HINTERACTIONCONTEXT handle, + INTERACTION_CONTEXT_PROPERTY property, UINT32 *value) +{ + struct interaction_context *context = context_from_handle(handle); + + TRACE("context %p, property %#x, value %p.\n", context, property, value); + + if (!context) + return E_HANDLE; + if (!value) + return E_POINTER; + + switch (property) + { + case INTERACTION_CONTEXT_PROPERTY_MEASUREMENT_UNITS: + case INTERACTION_CONTEXT_PROPERTY_INTERACTION_UI_FEEDBACK: + FIXME("Unhandled property %#x.\n", property); + *value = 0; + return E_NOTIMPL; + + case INTERACTION_CONTEXT_PROPERTY_FILTER_POINTERS: + *value = context->filter_pointers; + return S_OK; + + default: + WARN("Invalid property %#x.\n", property); + return E_INVALIDARG; + } +} + +HRESULT WINAPI SetPropertyInteractionContext(HINTERACTIONCONTEXT handle, + INTERACTION_CONTEXT_PROPERTY property, UINT32 value) +{ + struct interaction_context *context = context_from_handle(handle); + + TRACE("context %p, property %#x, value %#x.\n", context, property, value); + + if (!context) + return E_HANDLE; + + switch (property) + { + case INTERACTION_CONTEXT_PROPERTY_MEASUREMENT_UNITS: + case INTERACTION_CONTEXT_PROPERTY_INTERACTION_UI_FEEDBACK: + FIXME("Unhandled property %#x.\n", property); + return E_NOTIMPL; + + case INTERACTION_CONTEXT_PROPERTY_FILTER_POINTERS: + if (value != FALSE && value != TRUE) + return E_INVALIDARG; + context->filter_pointers = value; + return S_OK; + + default: + WARN("Invalid property %#x.\n", property); + return E_INVALIDARG; + } +} + HRESULT WINAPI ProcessInertiaInteractionContext(HINTERACTIONCONTEXT context) { FIXME("context %p: stub!\n", context); diff --git a/dlls/ninput/ninput.spec b/dlls/ninput/ninput.spec index fe7c6b3c53b3..166e3d1ec8c1 100644 --- a/dlls/ninput/ninput.spec +++ b/dlls/ninput/ninput.spec @@ -7,7 +7,7 @@ @ stub GetInertiaParameterInteractionContext @ stub GetInteractionConfigurationInteractionContext @ stub GetMouseWheelParameterInteractionContext -@ stub GetPropertyInteractionContext +@ stdcall GetPropertyInteractionContext(ptr long ptr) @ stub GetStateInteractionContext @ stub ProcessBufferedPacketsInteractionContext @ stdcall ProcessInertiaInteractionContext(ptr) @@ -20,5 +20,5 @@ @ stub SetInteractionConfigurationInteractionContext @ stub SetMouseWheelParameterInteractionContext @ stub SetPivotInteractionContext -@ stub SetPropertyInteractionContext +@ stdcall SetPropertyInteractionContext(ptr long long) @ stub StopInteractionContext diff --git a/dlls/ninput/tests/ninput.c b/dlls/ninput/tests/ninput.c index d894ab8a847a..156e3e898366 100644 --- a/dlls/ninput/tests/ninput.c +++ b/dlls/ninput/tests/ninput.c @@ -35,7 +35,55 @@ static void test_context(void) ok(hr == E_HANDLE, "Got hr %#x.\n", hr); } +static void test_properties(void) +{ + HINTERACTIONCONTEXT context; + UINT32 value; + HRESULT hr; + + hr = CreateInteractionContext(&context); + ok(hr == S_OK, "Failed to create context, hr %#x.\n", hr); + + hr = GetPropertyInteractionContext(context, INTERACTION_CONTEXT_PROPERTY_FILTER_POINTERS, &value); + ok(hr == S_OK, "Failed to get property, hr %#x.\n", hr); + ok(value == TRUE, "Got unexpected value %#x.\n", value); + + hr = SetPropertyInteractionContext(context, INTERACTION_CONTEXT_PROPERTY_FILTER_POINTERS, TRUE); + ok(hr == S_OK, "Failed to set property, hr %#x.\n", hr); + hr = GetPropertyInteractionContext(context, INTERACTION_CONTEXT_PROPERTY_FILTER_POINTERS, &value); + ok(hr == S_OK, "Failed to get property, hr %#x.\n", hr); + ok(value == TRUE, "Got unexpected value %#x.\n", value); + + hr = SetPropertyInteractionContext(context, INTERACTION_CONTEXT_PROPERTY_FILTER_POINTERS, FALSE); + ok(hr == S_OK, "Failed to set property, hr %#x.\n", hr); + hr = GetPropertyInteractionContext(context, INTERACTION_CONTEXT_PROPERTY_FILTER_POINTERS, &value); + ok(hr == S_OK, "Failed to get property, hr %#x.\n", hr); + ok(value == FALSE, "Got unexpected value %#x.\n", value); + + hr = SetPropertyInteractionContext(context, INTERACTION_CONTEXT_PROPERTY_FILTER_POINTERS, 2); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = SetPropertyInteractionContext(context, INTERACTION_CONTEXT_PROPERTY_FILTER_POINTERS, 3); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + + hr = SetPropertyInteractionContext(context, 0xdeadbeef, 0); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = GetPropertyInteractionContext(context, 0xdeadbeef, &value); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + + hr = GetPropertyInteractionContext(context, INTERACTION_CONTEXT_PROPERTY_FILTER_POINTERS, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + + hr = SetPropertyInteractionContext(NULL, INTERACTION_CONTEXT_PROPERTY_FILTER_POINTERS, FALSE); + ok(hr == E_HANDLE, "Got hr %#x.\n", hr); + hr = GetPropertyInteractionContext(NULL, INTERACTION_CONTEXT_PROPERTY_FILTER_POINTERS, &value); + ok(hr == E_HANDLE, "Got hr %#x.\n", hr); + + hr = DestroyInteractionContext(context); + ok(hr == S_OK, "Failed to destroy context, hr %#x.\n", hr); +} + START_TEST(ninput) { test_context(); + test_properties(); } -- 2.16.4