From 1a56be85be3f909aaede36b65b75f426ebd2bab7 Mon Sep 17 00:00:00 2001 From: Vitaliy Margolen Date: Thu, 13 Oct 2011 21:22:31 -0600 Subject: [PATCH] dinput: Acquire should not reset buffer position. --- dlls/dinput/device.c | 3 --- dlls/dinput/tests/mouse.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index 83740c57057..a9c7b878eca 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -791,10 +791,7 @@ HRESULT WINAPI IDirectInputDevice2WImpl_Acquire(LPDIRECTINPUTDEVICE8W iface) res = This->acquired ? S_FALSE : DI_OK; This->acquired = 1; if (res == DI_OK) - { - This->queue_head = This->queue_tail = This->overflow = 0; check_dinput_hooks(iface); - } LeaveCriticalSection(&This->crit); return res; diff --git a/dlls/dinput/tests/mouse.c b/dlls/dinput/tests/mouse.c index 25a9a5e85d1..db96a15fbfd 100644 --- a/dlls/dinput/tests/mouse.c +++ b/dlls/dinput/tests/mouse.c @@ -72,6 +72,9 @@ static void test_acquire(LPDIRECTINPUT pDI, HWND hwnd) LPDIRECTINPUTDEVICE pMouse = NULL; DIMOUSESTATE m_state; HWND hwnd2; + DIPROPDWORD di_op; + DIDEVICEOBJECTDATA mouse_state; + DWORD cnt; if (! SetForegroundWindow(hwnd)) { @@ -86,6 +89,14 @@ static void test_acquire(LPDIRECTINPUT pDI, HWND hwnd) hr = IDirectInputDevice_SetCooperativeLevel(pMouse, hwnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND); ok(hr == S_OK, "SetCooperativeLevel: %08x\n", hr); + memset(&di_op, 0, sizeof(di_op)); + di_op.dwData = 20; + di_op.diph.dwHow = DIPH_DEVICE; + di_op.diph.dwSize = sizeof(DIPROPDWORD); + di_op.diph.dwHeaderSize = sizeof(DIPROPHEADER); + hr = IDirectInputDevice_SetProperty(pMouse, DIPROP_BUFFERSIZE, (LPCDIPROPHEADER)&di_op); + ok(hr == S_OK, "SetProperty() failed: %08x\n", hr); + hr = IDirectInputDevice_SetDataFormat(pMouse, &c_dfDIMouse); ok(SUCCEEDED(hr), "IDirectInputDevice_SetDataFormat() failed: %08x\n", hr); hr = IDirectInputDevice_Unacquire(pMouse); @@ -113,6 +124,25 @@ static void test_acquire(LPDIRECTINPUT pDI, HWND hwnd) hr = IDirectInputDevice_Acquire(pMouse); ok(hr == S_OK, "Acquire() failed: %08x\n", hr); + mouse_event(MOUSEEVENTF_MOVE, 10, 10, 0, 0); + cnt = 1; + 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); + + mouse_event(MOUSEEVENTF_MOVE, 10, 10, 0, 0); + IDirectInputDevice_Unacquire(pMouse); + cnt = 1; + 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); + + IDirectInputDevice_Acquire(pMouse); + mouse_event(MOUSEEVENTF_MOVE, 10, 10, 0, 0); + IDirectInputDevice_Unacquire(pMouse); + IDirectInputDevice_Acquire(pMouse); + cnt = 1; + 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); + if (pMouse) IUnknown_Release(pMouse); DestroyWindow( hwnd2 ); -- 2.11.4.GIT