Johann Frei : dinput: Implement X/Y axis granularity and add test.

Alexandre Julliard julliard at winehq.org
Thu Mar 8 15:18:42 CST 2018


Module: wine
Branch: master
Commit: 4bc1e172ecba43dd8a5eb341cdd8e705a314b44d
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=4bc1e172ecba43dd8a5eb341cdd8e705a314b44d

Author: Johann Frei <johann_frei at yahoo.de>
Date:   Tue Mar  6 20:03:41 2018 +0100

dinput: Implement X/Y axis granularity and add test.

Signed-off-by: Johann Frei <johann_frei at yahoo.de>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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 eaec6b1..6d3eff5 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 dac7d8d..c2d0226 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 );




More information about the wine-cvs mailing list