Vitaliy Margolen : dinput: Implement GetDeviceStatus.

Alexandre Julliard julliard at winehq.org
Mon May 12 07:12:21 CDT 2008


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

Author: Vitaliy Margolen <wine-patches at kievinfo.com>
Date:   Sun May 11 13:33:17 2008 -0600

dinput: Implement GetDeviceStatus.

---

 dlls/dinput/dinput_main.c  |    9 ++++++++-
 dlls/dinput/tests/device.c |   21 ++++++++++++++++++---
 2 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c
index 5fa21f0..f28fe25 100644
--- a/dlls/dinput/dinput_main.c
+++ b/dlls/dinput/dinput_main.c
@@ -417,8 +417,15 @@ static HRESULT WINAPI IDirectInputWImpl_Initialize(LPDIRECTINPUT7W iface, HINSTA
 static HRESULT WINAPI IDirectInputAImpl_GetDeviceStatus(LPDIRECTINPUT7A iface, REFGUID rguid)
 {
     IDirectInputImpl *This = (IDirectInputImpl *)iface;
+    HRESULT hr;
+    LPDIRECTINPUTDEVICEA device;
 
-    FIXME( "(%p)->(%s): stub\n", This, debugstr_guid(rguid) );
+    TRACE( "(%p)->(%s)\n", This, debugstr_guid(rguid) );
+
+    hr = IDirectInput_CreateDevice( iface, rguid, &device, NULL );
+    if (hr != DI_OK) return DI_NOTATTACHED;
+
+    IUnknown_Release( device );
 
     return DI_OK;
 }
diff --git a/dlls/dinput/tests/device.c b/dlls/dinput/tests/device.c
index 0088d5b..3659530 100644
--- a/dlls/dinput/tests/device.c
+++ b/dlls/dinput/tests/device.c
@@ -124,10 +124,13 @@ static BOOL CALLBACK enum_devices(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef)
     LPDIRECTINPUTDEVICE device;
     HRESULT hr;
 
-    hr = IDirectInput_CreateDevice(data->pDI, &lpddi->guidInstance, &device, NULL);
-    ok(SUCCEEDED(hr), "IDirectInput_CreateDevice() failed: %s\n", DXGetErrorString8(hr));
-    if (SUCCEEDED(hr))
+    hr = IDirectInput_GetDeviceStatus(data->pDI, &lpddi->guidInstance);
+    ok(hr == DI_OK, "IDirectInput_GetDeviceStatus() failed: %s\n", DXGetErrorString8(hr));
+
+    if (hr == DI_OK)
     {
+        hr = IDirectInput_CreateDevice(data->pDI, &lpddi->guidInstance, &device, NULL);
+        ok(SUCCEEDED(hr), "IDirectInput_CreateDevice() failed: %s\n", DXGetErrorString8(hr));
         trace("Testing device \"%s\"\n", lpddi->tszInstanceName);
         test_object_info(device, data->hwnd);
         IUnknown_Release(device);
@@ -164,6 +167,18 @@ static void device_tests(void)
         hr = IDirectInput_EnumDevices(pDI, 0, enum_devices, &data, DIEDFL_ALLDEVICES);
         ok(SUCCEEDED(hr), "IDirectInput_EnumDevices() failed: %s\n", DXGetErrorString8(hr));
 
+
+        /* If GetDeviceStatus returns DI_OK the device must exist */
+        hr = IDirectInput_GetDeviceStatus(pDI, &GUID_Joystick);
+        if (hr == DI_OK)
+        {
+            LPDIRECTINPUTDEVICE device = NULL;
+
+            hr = IDirectInput_CreateDevice(pDI, &GUID_Joystick, &device, NULL);
+            ok(SUCCEEDED(hr), "IDirectInput_CreateDevice() failed: %s\n", DXGetErrorString8(hr));
+            if (device) IUnknown_Release(device);
+        }
+
         DestroyWindow(hwnd);
     }
     if (pDI) IUnknown_Release(pDI);




More information about the wine-cvs mailing list