Vitaliy Margolen : dinput: GetDeviceData always succeeds regardless if buffering is enabled or device is acquired .

Alexandre Julliard julliard at winehq.org
Fri Oct 14 14:14:47 CDT 2011


Module: wine
Branch: master
Commit: 157528eb0f826f1008488097e361ffc2872d640f
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=157528eb0f826f1008488097e361ffc2872d640f

Author: Vitaliy Margolen <wine-patches at kievinfo.com>
Date:   Thu Oct 13 21:22:26 2011 -0600

dinput: GetDeviceData always succeeds regardless if buffering is enabled or device is acquired.

---

 dlls/dinput/device.c       |    4 +---
 dlls/dinput/tests/device.c |   22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c
index a4052ea..83740c5 100644
--- a/dlls/dinput/device.c
+++ b/dlls/dinput/device.c
@@ -1286,10 +1286,8 @@ HRESULT WINAPI IDirectInputDevice2WImpl_GetDeviceData(LPDIRECTINPUTDEVICE8W ifac
     TRACE("(%p) %p -> %p(%d) x%d, 0x%08x\n",
           This, dod, entries, entries ? *entries : 0, dodsize, flags);
 
-    if (!This->acquired)
-        return DIERR_NOTACQUIRED;
     if (!This->queue_len)
-        return DIERR_NOTBUFFERED;
+        return DI_OK;
     if (dodsize < sizeof(DIDEVICEOBJECTDATA_DX3))
         return DIERR_INVALIDPARAM;
 
diff --git a/dlls/dinput/tests/device.c b/dlls/dinput/tests/device.c
index e79c564..2e4e4f8 100644
--- a/dlls/dinput/tests/device.c
+++ b/dlls/dinput/tests/device.c
@@ -103,6 +103,9 @@ static void test_object_info(LPDIRECTINPUTDEVICE device, HWND hwnd)
     hr = IDirectInputDevice_GetObjectInfo(device, &obj_info, 16, DIPH_BYOFFSET);
     if (SUCCEEDED(hr))
     {
+        DWORD cnt;
+        DIDEVICEOBJECTDATA buffer[5];
+
         /* No device supports per axis relative/absolute mode */
         memset(&dp, 0, sizeof(dp));
         dp.diph.dwSize = sizeof(DIPROPDWORD);
@@ -119,9 +122,28 @@ static void test_object_info(LPDIRECTINPUTDEVICE device, HWND hwnd)
         hr = IDirectInputDevice_SetProperty(device, DIPROP_AXISMODE, &dp.diph);
         ok(hr == DI_OK, "SetProperty() failed: %08x\n", hr);
 
+        dp.dwData = 0;
+        hr = IDirectInputDevice_SetProperty(device, DIPROP_BUFFERSIZE, (LPCDIPROPHEADER)&dp.diph);
+        ok(hr == DI_OK, "SetProperty() failed: %08x\n", hr);
+
+        cnt = 5;
+        hr = IDirectInputDevice_GetDeviceData(device, sizeof(buffer), buffer, &cnt, 0);
+        ok(hr == DI_OK && cnt == 5, "GetDeviceData() failed: %08x cnt: %d\n", hr, cnt);
+
+        dp.dwData = 20;
+        hr = IDirectInputDevice_SetProperty(device, DIPROP_BUFFERSIZE, (LPCDIPROPHEADER)&dp.diph);
+        ok(hr == DI_OK, "SetProperty() failed: %08x\n", hr);
+
+        cnt = 1;
+        hr = IDirectInputDevice_GetDeviceData(device, sizeof(buffer), buffer, &cnt, 0);
+        ok(hr == DI_OK, "GetDeviceData() failed: %08x\n", hr);
+
         /* Cannot change mode while acquired */
         hr = IDirectInputDevice_Acquire(device);
         ok(hr == DI_OK, "Acquire() failed: %08x\n", hr);
+        cnt = 1;
+        hr = IDirectInputDevice_GetDeviceData(device, sizeof(buffer), buffer, &cnt, 0);
+        ok(hr == DI_OK, "GetDeviceData() failed: %08x\n", hr);
         hr = IDirectInputDevice_SetProperty(device, DIPROP_AXISMODE, &dp.diph);
         ok(hr == DIERR_ACQUIRED, "SetProperty() returned: %08x\n", hr);
         hr = IDirectInputDevice_Unacquire(device);




More information about the wine-cvs mailing list