dinput/tests: Initial tests for Action Mapping. Added some tests for the creation of a DirectInput8 Interface and a dummy call of EnumDevicesBySemantics.

Lucas Fialho Zawacki lfzawacki at gmail.com
Sun Apr 24 18:12:22 CDT 2011


---
 dlls/dinput/tests/device.c |   66 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 66 insertions(+), 0 deletions(-)

diff --git a/dlls/dinput/tests/device.c b/dlls/dinput/tests/device.c
index a8ff19b..de7e10c 100644
--- a/dlls/dinput/tests/device.c
+++ b/dlls/dinput/tests/device.c
@@ -151,6 +151,71 @@ static BOOL CALLBACK enum_devices(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef)
     return DIENUM_CONTINUE;
 }
 
+static BOOL CALLBACK enum_by_semantics(
+    LPCDIDEVICEINSTANCE lpddi,
+    LPDIRECTINPUTDEVICE8 lpdid,
+    DWORD dwFlags,
+    DWORD dwRemaining,
+    LPVOID pvRef)
+{
+    return DIENUM_CONTINUE;
+}
+
+
+static void test_action_mapping(void)
+{
+    HRESULT hr;
+    HINSTANCE hinst = GetModuleHandle(NULL);
+    LPDIRECTINPUT8 pDI = NULL;
+    DIACTIONFORMAT af;
+    /* This is a dummy GUID because EnumDevicesBySemantics seems to fail if the
+       DIACTIONFORMAT guid field is all zeroed */
+    const GUID ACTIONMAP_GUID = { 0x1, 0x2, 0x3, { 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb } };
+    DIACTION commands[]=
+    {
+      /* axis */
+      { 0, 0x01008A01 /* DIAXIS_DRIVINGR_STEER */ , 0, { "Steer" } },
+
+      /* button */
+      { 1, 0x01000C01 /* DIBUTTON_DRIVINGR_SHIFTUP */ , 0, { "Upshift" } }
+    };
+
+    hr = CoCreateInstance(&CLSID_DirectInput8, 0, 1, &IID_IDirectInput8A, (LPVOID*)&pDI);
+    if (hr == DIERR_OLDDIRECTINPUTVERSION ||
+        hr == DIERR_BETADIRECTINPUTVERSION ||
+        hr == REGDB_E_CLASSNOTREG)
+    {
+        skip("ActionMapping requires dinput8\n");
+        return;
+    }
+    ok(SUCCEEDED(hr), "DirectInput8 Create failed: hr=%08x\n", hr);
+    if (FAILED(hr)) return;
+
+    hr = IDirectInput8_Initialize(pDI,hinst, 0x0800 /* DirectInput8 */ );
+    if (hr == DIERR_OLDDIRECTINPUTVERSION || hr == DIERR_BETADIRECTINPUTVERSION)
+    {
+        skip("ActionMapping requires dinput8\n");
+        return;
+    }
+    ok(SUCCEEDED(hr), "DirectInput8 Initialize failed: hr=%08x\n", hr);
+    if (FAILED(hr)) return;
+
+    memset (&af, 0, sizeof(af));
+    af.dwSize = sizeof(af);
+    af.dwActionSize = sizeof(DIACTION);
+    af.dwDataSize = 4 * sizeof(commands) / sizeof(commands[0]);
+    af.dwNumActions = sizeof(commands) / sizeof(commands[0]);
+    af.rgoAction = commands;
+    af.guidActionMap = ACTIONMAP_GUID;
+    af.dwGenre = 0x01000000; /* DIVIRTUAL_DRIVING_RACE */
+
+    hr = IDirectInput8_EnumDevicesBySemantics(pDI,0, &af,
+        enum_by_semantics, 0, 0);
+
+    ok(SUCCEEDED(hr), "EnumDevicesBySemantics failed: hr=%08x\n",hr);
+
+}
+
 static void device_tests(void)
 {
     HRESULT hr;
@@ -210,6 +275,7 @@ START_TEST(device)
     CoInitialize(NULL);
 
     device_tests();
+    test_action_mapping();
 
     CoUninitialize();
 }
-- 
1.7.0.4




More information about the wine-patches mailing list