From: johann_frei@yahoo.de Subject: [PATCH] dinput: Implement X/Y axis granularity and add test. Message-Id: <20180306160103.23590-1-johann_frei@yahoo.de> Date: Tue, 6 Mar 2018 17:01:03 +0100 From: Johann Frei Fixes https://bugs.winehq.org/show_bug.cgi?id=13351 This commit adds extended handling and testing of getProperty calls regarding the GRANULARITY property on X/Y mouse movements. So far, it was just assumed that the application wants to retrieve the granularity ("step size") of the scroll wheel. However, it is possible to query the granularity of the X/Y axis of a mouse which is (more or less) defined to be fixed to value one, according to the MS documentation. See @ DIPROP_GRANULARITY: https://msdn.microsoft.com/en-us/library/windows/desktop/microsoft.directx_sdk.idirectinputdevice8.idirectinputdevice8.getproperty(v=vs.85).aspx Tested on Fedora 27, Windows XP and Windows 10. Although I tried to do everything as stated in the developer wiki, as this is my very first patch submission to the Wine project, I want to apologize for any unfulfilled requirements on how to hand in a new patch request. Signed-off-by: Johann Frei --- dlls/dinput/mouse.c | 19 +++++++++++++++++-- dlls/dinput/tests/mouse.c | 23 ++++++++++++++++++++++- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c index eaec6b17dc..5614aa201b 100644 --- a/dlls/dinput/mouse.c +++ b/dlls/dinput/mouse.c @@ -616,8 +616,23 @@ 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: https://msdn.microsoft.com/en-us/library/windows/desktop/microsoft.directx_sdk.idirectinputdevice8.idirectinputdevice8.getproperty(v=vs.85).aspx + 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 dac7d8df50..584c0a1ccd 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, (LPCDIPROPHEADER)&di_op); + /* 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, (LPCDIPROPHEADER)&di_op); + /* 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.14.3