From 4bc1e172ecba43dd8a5eb341cdd8e705a314b44d Mon Sep 17 00:00:00 2001 From: Johann Frei Date: Tue, 6 Mar 2018 20:03:41 +0100 Subject: [PATCH] dinput: Implement X/Y axis granularity and add test. Signed-off-by: Johann Frei Signed-off-by: Alexandre Julliard --- dlls/dinput/mouse.c | 17 +++++++++++++++-- dlls/dinput/tests/mouse.c | 23 ++++++++++++++++++++++- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c index eaec6b17dc3..6d3eff5d525 100644 --- a/dlls/dinput/mouse.c +++ b/dlls/dinput/mouse.c @@ -616,8 +616,21 @@ static HRESULT WINAPI SysMouseWImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface, REF case (DWORD_PTR) DIPROP_GRANULARITY: { LPDIPROPDWORD pr = (LPDIPROPDWORD) pdiph; - /* We'll just assume that the app asks about the Z axis */ - pr->dwData = WHEEL_DELTA; + if ( + ((pdiph->dwHow == DIPH_BYOFFSET) && + ((pdiph->dwObj == DIMOFS_X) || + (pdiph->dwObj == DIMOFS_Y))) + || + ((pdiph->dwHow == DIPH_BYID) && + ((pdiph->dwObj == (DIDFT_MAKEINSTANCE(WINE_MOUSE_X_AXIS_INSTANCE) | DIDFT_RELAXIS)) || + (pdiph->dwObj == (DIDFT_MAKEINSTANCE(WINE_MOUSE_Y_AXIS_INSTANCE) | DIDFT_RELAXIS)))) + ){ + /* Set granularity of X/Y Axis to 1. See MSDN on DIPROP_GRANULARITY */ + pr->dwData = 1; + } else { + /* We'll just assume that the app asks about the Z axis */ + pr->dwData = WHEEL_DELTA; + } break; } diff --git a/dlls/dinput/tests/mouse.c b/dlls/dinput/tests/mouse.c index dac7d8df50c..c2d02264876 100644 --- a/dlls/dinput/tests/mouse.c +++ b/dlls/dinput/tests/mouse.c @@ -161,7 +161,7 @@ static void test_acquire(IDirectInputA *pDI, HWND hwnd) hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state), &mouse_state, &cnt, 0); ok(hr == S_OK && cnt > 0, "GetDeviceData() failed: %08x cnt:%d\n", hr, cnt); - /* Check for buffer owerflow */ + /* Check for buffer overflow */ for (i = 0; i < 6; i++) mouse_event(MOUSEEVENTF_MOVE, 10 + i, 10 + i, 0, 0); @@ -172,6 +172,27 @@ static void test_acquire(IDirectInputA *pDI, HWND hwnd) hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state), &mouse_state, &cnt, 0); ok(hr == DI_OK && cnt == 1, "GetDeviceData() failed: %08x cnt:%d\n", hr, cnt); + /* Check for granularity property using BYOFFSET */ + memset(&di_op, 0, sizeof(di_op)); + di_op.diph.dwHow = DIPH_BYOFFSET; + di_op.diph.dwObj = DIMOFS_Y; + di_op.diph.dwSize = sizeof(DIPROPDWORD); + di_op.diph.dwHeaderSize = sizeof(DIPROPHEADER); + hr = IDirectInputDevice_GetProperty(pMouse, DIPROP_GRANULARITY, &di_op.diph); + /* Granularity of Y axis should be 1! */ + ok(hr == S_OK && di_op.dwData == 1, "GetProperty(): %08x, dwData: %i but should be 1.\n", hr, di_op.dwData); + + /* Check for granularity property using BYID */ + memset(&di_op, 0, sizeof(di_op)); + di_op.diph.dwHow = DIPH_BYID; + /* WINE_MOUSE_Y_AXIS_INSTANCE := 1 */ + di_op.diph.dwObj = (DIDFT_MAKEINSTANCE(1) | DIDFT_RELAXIS); + di_op.diph.dwSize = sizeof(DIPROPDWORD); + di_op.diph.dwHeaderSize = sizeof(DIPROPHEADER); + hr = IDirectInputDevice_GetProperty(pMouse, DIPROP_GRANULARITY, &di_op.diph); + /* Granularity of Y axis should be 1! */ + ok(hr == S_OK && di_op.dwData == 1, "GetProperty(): %08x, dwData: %i but should be 1.\n", hr, di_op.dwData); + if (pMouse) IUnknown_Release(pMouse); DestroyWindow( hwnd2 ); -- 2.11.4.GIT