Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/tests/Makefile.in | 1 - dlls/dinput/tests/dinput.c | 1110 ++++++++++++++++++++++----------- dlls/dinput/tests/dinput8.c | 728 --------------------- 3 files changed, 730 insertions(+), 1109 deletions(-) delete mode 100644 dlls/dinput/tests/dinput8.c
diff --git a/dlls/dinput/tests/Makefile.in b/dlls/dinput/tests/Makefile.in index 00295fed60f..b34afde882a 100644 --- a/dlls/dinput/tests/Makefile.in +++ b/dlls/dinput/tests/Makefile.in @@ -9,7 +9,6 @@ SOURCES = \ device.c \ device8.c \ dinput.c \ - dinput8.c \ driver_hid.c \ driver_hid.spec \ force_feedback.c \ diff --git a/dlls/dinput/tests/dinput.c b/dlls/dinput/tests/dinput.c index 10da888fdd4..795a9ed39c6 100644 --- a/dlls/dinput/tests/dinput.c +++ b/dlls/dinput/tests/dinput.c @@ -30,37 +30,53 @@
HINSTANCE hInstance;
-enum directinput_versions -{ - DIRECTINPUT_VERSION_300 = 0x0300, - DIRECTINPUT_VERSION_500 = 0x0500, - DIRECTINPUT_VERSION_50A = 0x050A, - DIRECTINPUT_VERSION_5B2 = 0x05B2, - DIRECTINPUT_VERSION_602 = 0x0602, - DIRECTINPUT_VERSION_61A = 0x061A, - DIRECTINPUT_VERSION_700 = 0x0700, -}; - -static const DWORD directinput_version_list[] = -{ - DIRECTINPUT_VERSION_300, - DIRECTINPUT_VERSION_500, - DIRECTINPUT_VERSION_50A, - DIRECTINPUT_VERSION_5B2, - DIRECTINPUT_VERSION_602, - DIRECTINPUT_VERSION_61A, - DIRECTINPUT_VERSION_700, -}; - static HRESULT (WINAPI *pDirectInputCreateEx)(HINSTANCE, DWORD, REFIID, LPVOID *, LPUNKNOWN);
+static const DWORD dinput_versions[] = +{ + 0x0300, + 0x0500, + 0x050A, + 0x05B2, + 0x0602, + 0x061A, + 0x0700, + 0x0800, +}; + +static REFIID dinput7_interfaces[] = +{ + &IID_IDirectInputA, + &IID_IDirectInputW, + &IID_IDirectInput2A, + &IID_IDirectInput2W, + &IID_IDirectInput7A, + &IID_IDirectInput7W, +}; + +static REFIID dinput8_interfaces[] = +{ + &IID_IDirectInput8A, + &IID_IDirectInput8W, + &IID_IDirectInputJoyConfig8, +}; + +static HRESULT direct_input_create( DWORD version, IDirectInputA **out ) +{ + HRESULT hr; + if (version < 0x800) hr = DirectInputCreateA( hInstance, version, out, NULL ); + else hr = DirectInput8Create( hInstance, version, &IID_IDirectInput8A, (void **)out, NULL ); + if (FAILED(hr)) win_skip( "Failed to instantiate a IDirectInput instance, hr %#x\n", hr ); + return hr; +} + static BOOL CALLBACK dummy_callback(const DIDEVICEINSTANCEA *instance, void *context) { ok(0, "Callback was invoked with parameters (%p, %p)\n", instance, context); return DIENUM_STOP; }
-static void test_preinitialization(void) +static void test_CoCreateInstance( DWORD version ) { static const struct { @@ -83,7 +99,6 @@ static void test_preinitialization(void) LPDIENUMDEVICESCALLBACKA lpCallback; DWORD dwFlags; HRESULT expected_hr; - int todo; } enum_devices_tests[] = { {0, NULL, 0, DIERR_INVALIDPARAM}, @@ -96,122 +111,159 @@ static void test_preinitialization(void) {0xdeadbeef, dummy_callback, ~0u, DIERR_INVALIDPARAM}, };
- IDirectInputA *pDI; + IDirectInputDeviceA *device; + IDirectInputA *dinput; HRESULT hr; + LONG ref; int i; - IDirectInputDeviceA *pDID;
- hr = CoCreateInstance(&CLSID_DirectInput, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectInputA, (void **)&pDI); + if (version < 0x800) hr = CoCreateInstance( &CLSID_DirectInput, NULL, CLSCTX_INPROC_SERVER, + &IID_IDirectInputA, (void **)&dinput ); + else hr = CoCreateInstance( &CLSID_DirectInput8, NULL, CLSCTX_INPROC_SERVER, + &IID_IDirectInput8A, (void **)&dinput ); if (FAILED(hr)) { - skip("Failed to instantiate a IDirectInputA instance: 0x%08x\n", hr); + win_skip( "Failed to instantiate a IDirectInput instance, hr %#x\n", hr ); return; }
for (i = 0; i < ARRAY_SIZE(create_device_tests); i++) { - if (create_device_tests[i].pdev) pDID = (void *)0xdeadbeef; - hr = IDirectInput_CreateDevice(pDI, create_device_tests[i].rguid, - create_device_tests[i].pdev ? &pDID : NULL, - NULL); - ok(hr == create_device_tests[i].expected_hr, "[%d] IDirectInput_CreateDevice returned 0x%08x\n", i, hr); - if (create_device_tests[i].pdev) - ok(pDID == NULL, "[%d] Output interface pointer is %p\n", i, pDID); + winetest_push_context( "%u", i ); + if (create_device_tests[i].pdev) device = (void *)0xdeadbeef; + hr = IDirectInput_CreateDevice( dinput, create_device_tests[i].rguid, + create_device_tests[i].pdev ? &device : NULL, NULL ); + ok( hr == create_device_tests[i].expected_hr, "CreateDevice returned %#x\n", hr ); + if (create_device_tests[i].pdev) ok( device == NULL, "got device %p\n", device ); + winetest_pop_context(); }
for (i = 0; i < ARRAY_SIZE(enum_devices_tests); i++) { - hr = IDirectInput_EnumDevices(pDI, enum_devices_tests[i].dwDevType, - enum_devices_tests[i].lpCallback, - NULL, - enum_devices_tests[i].dwFlags); - todo_wine_if(enum_devices_tests[i].todo) - ok(hr == enum_devices_tests[i].expected_hr, "[%d] IDirectInput_EnumDevice returned 0x%08x\n", i, hr); + winetest_push_context( "%u", i ); + hr = IDirectInput_EnumDevices( dinput, enum_devices_tests[i].dwDevType, + enum_devices_tests[i].lpCallback, NULL, enum_devices_tests[i].dwFlags ); + ok( hr == enum_devices_tests[i].expected_hr, "EnumDevice returned %#x\n", hr ); + winetest_pop_context(); }
- hr = IDirectInput_GetDeviceStatus(pDI, NULL); - ok(hr == E_POINTER, "IDirectInput_GetDeviceStatus returned 0x%08x\n", hr); + hr = IDirectInput_GetDeviceStatus( dinput, NULL ); + ok( hr == E_POINTER, "GetDeviceStatus returned %#x\n", hr );
- hr = IDirectInput_GetDeviceStatus(pDI, &GUID_Unknown); - ok(hr == DIERR_NOTINITIALIZED, "IDirectInput_GetDeviceStatus returned 0x%08x\n", hr); + hr = IDirectInput_GetDeviceStatus( dinput, &GUID_Unknown ); + ok( hr == DIERR_NOTINITIALIZED, "GetDeviceStatus returned %#x\n", hr );
- hr = IDirectInput_GetDeviceStatus(pDI, &GUID_SysMouse); - ok(hr == DIERR_NOTINITIALIZED, "IDirectInput_GetDeviceStatus returned 0x%08x\n", hr); + hr = IDirectInput_GetDeviceStatus( dinput, &GUID_SysMouse ); + ok( hr == DIERR_NOTINITIALIZED, "GetDeviceStatus returned %#x\n", hr );
- hr = IDirectInput_RunControlPanel(pDI, NULL, 0); - ok(hr == DIERR_NOTINITIALIZED, "IDirectInput_RunControlPanel returned 0x%08x\n", hr); + hr = IDirectInput_RunControlPanel( dinput, NULL, 0 ); + ok( hr == DIERR_NOTINITIALIZED, "RunControlPanel returned %#x\n", hr );
- hr = IDirectInput_RunControlPanel(pDI, NULL, ~0u); - ok(hr == DIERR_INVALIDPARAM, "IDirectInput_RunControlPanel returned 0x%08x\n", hr); + hr = IDirectInput_RunControlPanel( dinput, NULL, ~0u ); + ok( hr == DIERR_INVALIDPARAM, "RunControlPanel returned %#x\n", hr );
- hr = IDirectInput_RunControlPanel(pDI, (HWND)0xdeadbeef, 0); - ok(hr == E_HANDLE, "IDirectInput_RunControlPanel returned 0x%08x\n", hr); + hr = IDirectInput_RunControlPanel( dinput, (HWND)0xdeadbeef, 0 ); + ok( hr == E_HANDLE, "RunControlPanel returned %#x\n", hr );
- hr = IDirectInput_RunControlPanel(pDI, (HWND)0xdeadbeef, ~0u); - ok(hr == E_HANDLE, "IDirectInput_RunControlPanel returned 0x%08x\n", hr); + hr = IDirectInput_RunControlPanel( dinput, (HWND)0xdeadbeef, ~0u ); + ok( hr == E_HANDLE, "RunControlPanel returned %#x\n", hr );
- IDirectInput_Release(pDI); + ref = IDirectInput_Release( dinput ); + ok( ref == 0, "Release returned %d\n", ref ); }
-static void test_DirectInputCreateEx(void) +static void test_DirectInputCreate( DWORD version ) { - static const struct + IUnknown *unknown; + struct { - BOOL hinst; - DWORD dwVersion; - REFIID riid; - BOOL ppdi; + HMODULE instance; + DWORD version; + REFIID iid; + IUnknown **out; + IUnknown *expect_out; HRESULT expected_hr; - IUnknown *expected_ppdi; - } invalid_param_list[] = + } create_tests[] = { - {FALSE, 0, &IID_IUnknown, FALSE, DIERR_NOINTERFACE}, - {FALSE, 0, &IID_IUnknown, TRUE, DIERR_NOINTERFACE, (void *)0xdeadbeef}, - {FALSE, 0, &IID_IDirectInputA, FALSE, E_POINTER}, - {FALSE, 0, &IID_IDirectInputA, TRUE, DIERR_INVALIDPARAM, NULL}, - {FALSE, DIRECTINPUT_VERSION, &IID_IUnknown, FALSE, DIERR_NOINTERFACE}, - {FALSE, DIRECTINPUT_VERSION, &IID_IUnknown, TRUE, DIERR_NOINTERFACE, (void *)0xdeadbeef}, - {FALSE, DIRECTINPUT_VERSION, &IID_IDirectInputA, FALSE, E_POINTER}, - {FALSE, DIRECTINPUT_VERSION, &IID_IDirectInputA, TRUE, DIERR_INVALIDPARAM, NULL}, - {FALSE, DIRECTINPUT_VERSION - 1, &IID_IUnknown, FALSE, DIERR_NOINTERFACE}, - {FALSE, DIRECTINPUT_VERSION - 1, &IID_IUnknown, TRUE, DIERR_NOINTERFACE, (void *)0xdeadbeef}, - {FALSE, DIRECTINPUT_VERSION - 1, &IID_IDirectInputA, FALSE, E_POINTER}, - {FALSE, DIRECTINPUT_VERSION - 1, &IID_IDirectInputA, TRUE, DIERR_INVALIDPARAM, NULL}, - {FALSE, DIRECTINPUT_VERSION + 1, &IID_IUnknown, FALSE, DIERR_NOINTERFACE}, - {FALSE, DIRECTINPUT_VERSION + 1, &IID_IUnknown, TRUE, DIERR_NOINTERFACE, (void *)0xdeadbeef}, - {FALSE, DIRECTINPUT_VERSION + 1, &IID_IDirectInputA, FALSE, E_POINTER}, - {FALSE, DIRECTINPUT_VERSION + 1, &IID_IDirectInputA, TRUE, DIERR_INVALIDPARAM, NULL}, - {TRUE, 0, &IID_IUnknown, FALSE, DIERR_NOINTERFACE}, - {TRUE, 0, &IID_IUnknown, TRUE, DIERR_NOINTERFACE, (void *)0xdeadbeef}, - {TRUE, 0, &IID_IDirectInputA, FALSE, E_POINTER}, - {TRUE, 0, &IID_IDirectInputA, TRUE, DIERR_NOTINITIALIZED, NULL}, - {TRUE, DIRECTINPUT_VERSION, &IID_IUnknown, FALSE, DIERR_NOINTERFACE}, - {TRUE, DIRECTINPUT_VERSION, &IID_IUnknown, TRUE, DIERR_NOINTERFACE, (void *)0xdeadbeef}, - {TRUE, DIRECTINPUT_VERSION, &IID_IDirectInputA, FALSE, E_POINTER}, - {TRUE, DIRECTINPUT_VERSION - 1, &IID_IUnknown, FALSE, DIERR_NOINTERFACE}, - {TRUE, DIRECTINPUT_VERSION - 1, &IID_IUnknown, TRUE, DIERR_NOINTERFACE, (void *)0xdeadbeef}, - {TRUE, DIRECTINPUT_VERSION - 1, &IID_IDirectInputA, FALSE, E_POINTER}, - {TRUE, DIRECTINPUT_VERSION - 1, &IID_IDirectInputA, TRUE, DIERR_BETADIRECTINPUTVERSION, NULL}, - {TRUE, DIRECTINPUT_VERSION + 1, &IID_IUnknown, FALSE, DIERR_NOINTERFACE}, - {TRUE, DIRECTINPUT_VERSION + 1, &IID_IUnknown, TRUE, DIERR_NOINTERFACE, (void *)0xdeadbeef}, - {TRUE, DIRECTINPUT_VERSION + 1, &IID_IDirectInputA, FALSE, E_POINTER}, - {TRUE, DIRECTINPUT_VERSION + 1, &IID_IDirectInputA, TRUE, DIERR_OLDDIRECTINPUTVERSION, NULL}, + {NULL, 0, NULL, NULL, (void *)0xdeadbeef, E_POINTER}, + {NULL, 0, NULL, &unknown, NULL, DIERR_INVALIDPARAM}, + {NULL, version, NULL, NULL, (void *)0xdeadbeef, E_POINTER}, + {NULL, version, NULL, &unknown, NULL, version == 0x300 ? DI_OK : DIERR_INVALIDPARAM}, + {NULL, version - 1, NULL, NULL, (void *)0xdeadbeef, E_POINTER}, + {NULL, version - 1, NULL, &unknown, NULL, DIERR_INVALIDPARAM}, + {NULL, version + 1, NULL, NULL, (void *)0xdeadbeef, E_POINTER}, + {NULL, version + 1, NULL, &unknown, NULL, DIERR_INVALIDPARAM}, + {hInstance, 0, NULL, NULL, (void *)0xdeadbeef, E_POINTER}, + {hInstance, 0, NULL, &unknown, NULL, DIERR_NOTINITIALIZED}, + {hInstance, version, NULL, NULL, (void *)0xdeadbeef, E_POINTER}, + {hInstance, version - 1, NULL, NULL, (void *)0xdeadbeef, E_POINTER}, + {hInstance, version - 1, NULL, &unknown, NULL, version <= 0x700 ? DIERR_BETADIRECTINPUTVERSION : DIERR_OLDDIRECTINPUTVERSION}, + {hInstance, version + 1, NULL, NULL, (void *)0xdeadbeef, E_POINTER}, + {hInstance, version + 1, NULL, &unknown, NULL, version < 0x700 ? DIERR_BETADIRECTINPUTVERSION : DIERR_OLDDIRECTINPUTVERSION}, }; - - static REFIID no_interface_list[] = {&IID_IUnknown, &IID_IDirectInput8A, - &IID_IDirectInput8W, &IID_IDirectInputDeviceA, - &IID_IDirectInputDeviceW, &IID_IDirectInputDevice2A, - &IID_IDirectInputDevice2W, &IID_IDirectInputDevice7A, - &IID_IDirectInputDevice7W, &IID_IDirectInputDevice8A, - &IID_IDirectInputDevice8W, &IID_IDirectInputEffect}; - - static REFIID iid_list[] = {&IID_IDirectInputA, &IID_IDirectInputW, - &IID_IDirectInput2A, &IID_IDirectInput2W, - &IID_IDirectInput7A, &IID_IDirectInput7W}; - - int i, j; - IUnknown *pUnk; HRESULT hr; + int i; + + for (i = 0; i < ARRAY_SIZE(create_tests); i++) + { + winetest_push_context( "%u", i ); + unknown = (void *)0xdeadbeef; + hr = DirectInputCreateW( create_tests[i].instance, create_tests[i].version, (IDirectInputW **)create_tests[i].out, NULL ); + todo_wine_if(i == 3 && version == 0x300) + ok( hr == create_tests[i].expected_hr, "DirectInputCreateEx returned %#x\n", hr ); + if (SUCCEEDED(hr)) IUnknown_Release( unknown ); + else ok( unknown == create_tests[i].expect_out, "got IUnknown %p\n", unknown ); + winetest_pop_context(); + } +} + +static void test_DirectInputCreateEx( DWORD version ) +{ + IUnknown *unknown; + struct + { + HMODULE instance; + DWORD version; + REFIID iid; + IUnknown **out; + IUnknown *expect_out; + HRESULT expected_hr; + } create_tests[] = + { + {NULL, 0, &IID_IUnknown, NULL, (void *)0xdeadbeef, DIERR_NOINTERFACE}, + {NULL, 0, &IID_IUnknown, &unknown, (void *)0xdeadbeef, DIERR_NOINTERFACE}, + {NULL, 0, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER}, + {NULL, 0, &IID_IDirectInputA, &unknown, NULL, DIERR_INVALIDPARAM}, + {NULL, version, &IID_IUnknown, NULL, (void *)0xdeadbeef, DIERR_NOINTERFACE}, + {NULL, version, &IID_IUnknown, &unknown, (void *)0xdeadbeef, DIERR_NOINTERFACE}, + {NULL, version, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER}, + {NULL, version, &IID_IDirectInputA, &unknown, NULL, version == 0x300 ? DI_OK : DIERR_INVALIDPARAM}, + {NULL, version - 1, &IID_IUnknown, NULL, (void *)0xdeadbeef, DIERR_NOINTERFACE}, + {NULL, version - 1, &IID_IUnknown, &unknown, (void *)0xdeadbeef, DIERR_NOINTERFACE}, + {NULL, version - 1, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER}, + {NULL, version - 1, &IID_IDirectInputA, &unknown, NULL, DIERR_INVALIDPARAM}, + {NULL, version + 1, &IID_IUnknown, NULL, (void *)0xdeadbeef, DIERR_NOINTERFACE}, + {NULL, version + 1, &IID_IUnknown, &unknown, (void *)0xdeadbeef, DIERR_NOINTERFACE}, + {NULL, version + 1, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER}, + {NULL, version + 1, &IID_IDirectInputA, &unknown, NULL, DIERR_INVALIDPARAM}, + {hInstance, 0, &IID_IUnknown, NULL, (void *)0xdeadbeef, DIERR_NOINTERFACE}, + {hInstance, 0, &IID_IUnknown, &unknown, (void *)0xdeadbeef, DIERR_NOINTERFACE}, + {hInstance, 0, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER}, + {hInstance, 0, &IID_IDirectInputA, &unknown, NULL, DIERR_NOTINITIALIZED}, + {hInstance, version, &IID_IUnknown, NULL, (void *)0xdeadbeef, DIERR_NOINTERFACE}, + {hInstance, version, &IID_IUnknown, &unknown, (void *)0xdeadbeef, DIERR_NOINTERFACE}, + {hInstance, version, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER}, + {hInstance, version - 1, &IID_IUnknown, NULL, (void *)0xdeadbeef, DIERR_NOINTERFACE}, + {hInstance, version - 1, &IID_IUnknown, &unknown, (void *)0xdeadbeef, DIERR_NOINTERFACE}, + {hInstance, version - 1, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER}, + {hInstance, version - 1, &IID_IDirectInputA, &unknown, NULL, version <= 0x700 ? DIERR_BETADIRECTINPUTVERSION : DIERR_OLDDIRECTINPUTVERSION}, + {hInstance, version + 1, &IID_IUnknown, NULL, (void *)0xdeadbeef, DIERR_NOINTERFACE}, + {hInstance, version + 1, &IID_IUnknown, &unknown, (void *)0xdeadbeef, DIERR_NOINTERFACE}, + {hInstance, version + 1, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER}, + {hInstance, version + 1, &IID_IDirectInputA, &unknown, NULL, version < 0x700 ? DIERR_BETADIRECTINPUTVERSION : DIERR_OLDDIRECTINPUTVERSION}, + }; + HRESULT hr; + int i;
if (!pDirectInputCreateEx) { @@ -219,391 +271,485 @@ static void test_DirectInputCreateEx(void) return; }
- for (i = 0; i < ARRAY_SIZE(invalid_param_list); i++) + for (i = 0; i < ARRAY_SIZE(create_tests); i++) { - if (invalid_param_list[i].ppdi) pUnk = (void *)0xdeadbeef; - hr = pDirectInputCreateEx(invalid_param_list[i].hinst ? hInstance : NULL, - invalid_param_list[i].dwVersion, - invalid_param_list[i].riid, - invalid_param_list[i].ppdi ? (void **)&pUnk : NULL, - NULL); - ok(hr == invalid_param_list[i].expected_hr, "[%d] DirectInputCreateEx returned 0x%08x\n", i, hr); - if (invalid_param_list[i].ppdi) - ok(pUnk == invalid_param_list[i].expected_ppdi, "[%d] Output interface pointer is %p\n", i, pUnk); + winetest_push_context( "%u", i ); + unknown = (void *)0xdeadbeef; + hr = pDirectInputCreateEx( create_tests[i].instance, create_tests[i].version, create_tests[i].iid, + (void **)create_tests[i].out, NULL ); + todo_wine_if( version == 0x300 && i == 7 ) + ok( hr == create_tests[i].expected_hr, "DirectInputCreateEx returned %#x\n", hr ); + if (SUCCEEDED(hr)) IUnknown_Release( unknown ); + else ok( unknown == create_tests[i].expect_out, "got IUnknown %p\n", unknown ); + winetest_pop_context(); }
- for (i = 0; i < ARRAY_SIZE(no_interface_list); i++) + for (i = 0; i < ARRAY_SIZE(dinput8_interfaces); i++) { - pUnk = (void *)0xdeadbeef; - hr = pDirectInputCreateEx(hInstance, DIRECTINPUT_VERSION, no_interface_list[i], (void **)&pUnk, NULL); - ok(hr == DIERR_NOINTERFACE, "[%d] DirectInputCreateEx returned 0x%08x\n", i, hr); - ok(pUnk == (void *)0xdeadbeef, "[%d] Output interface pointer is %p\n", i, pUnk); + winetest_push_context( "%u", i ); + unknown = (void *)0xdeadbeef; + hr = pDirectInputCreateEx( hInstance, version, dinput8_interfaces[i], (void **)&unknown, NULL ); + ok( hr == DIERR_NOINTERFACE, "DirectInputCreateEx returned %#x\n", hr ); + ok( unknown == (void *)0xdeadbeef, "got IUnknown %p\n", unknown ); + winetest_pop_context(); }
- for (i = 0; i < ARRAY_SIZE(iid_list); i++) + for (i = 0; i < ARRAY_SIZE(dinput7_interfaces); i++) { - pUnk = NULL; - hr = pDirectInputCreateEx(hInstance, DIRECTINPUT_VERSION, iid_list[i], (void **)&pUnk, NULL); - ok(hr == DI_OK, "[%d] DirectInputCreateEx returned 0x%08x\n", i, hr); - ok(pUnk != NULL, "[%d] Output interface pointer is NULL\n", i); - if (pUnk) - IUnknown_Release(pUnk); - } - - /* Examine combinations of requested interfaces and version numbers. */ - for (i = 0; i < ARRAY_SIZE(directinput_version_list); i++) - { - for (j = 0; j < ARRAY_SIZE(iid_list); j++) - { - pUnk = NULL; - hr = pDirectInputCreateEx(hInstance, directinput_version_list[i], iid_list[j], (void **)&pUnk, NULL); - ok(hr == DI_OK, "[%d/%d] DirectInputCreateEx returned 0x%08x\n", i, j, hr); - ok(pUnk != NULL, "[%d] Output interface pointer is NULL\n", i); - if (pUnk) - IUnknown_Release(pUnk); - } + winetest_push_context( "%u", i ); + unknown = NULL; + hr = pDirectInputCreateEx( hInstance, version, dinput7_interfaces[i], (void **)&unknown, NULL ); + if (version < 0x800) ok( hr == DI_OK, "DirectInputCreateEx returned %#x\n", hr ); + else ok( hr == DIERR_OLDDIRECTINPUTVERSION, "DirectInputCreateEx returned %#x\n", hr ); + if (version < 0x800) ok( unknown != NULL, "got IUnknown NULL\n" ); + else ok( unknown == NULL, "got IUnknown %p\n", unknown ); + if (unknown) IUnknown_Release( unknown ); + winetest_pop_context(); } }
-static void test_QueryInterface(void) +static void test_DirectInput8Create( DWORD version ) { - static REFIID iid_list[] = {&IID_IUnknown, &IID_IDirectInputA, &IID_IDirectInputW, - &IID_IDirectInput2A, &IID_IDirectInput2W, - &IID_IDirectInput7A, &IID_IDirectInput7W}; - - static REFIID no_interface_list[] = + IUnknown *unknown; + struct { - &IID_IDirectInput8A, - &IID_IDirectInput8W, - &IID_IDirectInputDeviceA, - &IID_IDirectInputDeviceW, - &IID_IDirectInputDevice2A, - &IID_IDirectInputDevice2W, - &IID_IDirectInputDevice7A, - &IID_IDirectInputDevice7W, - &IID_IDirectInputDevice8A, - &IID_IDirectInputDevice8W, - &IID_IDirectInputEffect, + HMODULE instance; + DWORD version; + REFIID iid; + IUnknown **out; + IUnknown *expect_out; + HRESULT expected_hr; + } create_tests[] = + { + {NULL, 0, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER}, + {NULL, 0, &IID_IDirectInputA, &unknown, NULL, DIERR_NOINTERFACE}, + {NULL, 0, &IID_IDirectInput8A, NULL, (void *)0xdeadbeef, E_POINTER}, + {NULL, 0, &IID_IDirectInput8A, &unknown, NULL, DIERR_INVALIDPARAM}, + {NULL, version, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER}, + {NULL, version, &IID_IDirectInputA, &unknown, NULL, DIERR_NOINTERFACE}, + {NULL, version, &IID_IDirectInput8A, NULL, (void *)0xdeadbeef, E_POINTER}, + {NULL, version, &IID_IDirectInput8A, &unknown, NULL, DIERR_INVALIDPARAM}, + {NULL, version - 1, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER}, + {NULL, version - 1, &IID_IDirectInputA, &unknown, NULL, DIERR_NOINTERFACE}, + {NULL, version - 1, &IID_IDirectInput8A, NULL, (void *)0xdeadbeef, E_POINTER}, + {NULL, version - 1, &IID_IDirectInput8A, &unknown, NULL, DIERR_INVALIDPARAM}, + {NULL, version + 1, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER}, + {NULL, version + 1, &IID_IDirectInputA, &unknown, NULL, DIERR_NOINTERFACE}, + {NULL, version + 1, &IID_IDirectInput8A, NULL, (void *)0xdeadbeef, E_POINTER}, + {NULL, version + 1, &IID_IDirectInput8A, &unknown, NULL, DIERR_INVALIDPARAM}, + {hInstance, 0, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER}, + {hInstance, 0, &IID_IDirectInputA, &unknown, NULL, DIERR_NOINTERFACE}, + {hInstance, 0, &IID_IDirectInput8A, NULL, (void *)0xdeadbeef, E_POINTER}, + {hInstance, 0, &IID_IDirectInput8A, &unknown, NULL, DIERR_NOTINITIALIZED}, + {hInstance, version, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER}, + {hInstance, version, &IID_IDirectInputA, &unknown, NULL, DIERR_NOINTERFACE}, + {hInstance, version, &IID_IDirectInput8A, NULL, (void *)0xdeadbeef, E_POINTER}, + {hInstance, version - 1, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER}, + {hInstance, version - 1, &IID_IDirectInputA, &unknown, NULL, DIERR_NOINTERFACE}, + {hInstance, version - 1, &IID_IDirectInput8A, NULL, (void *)0xdeadbeef, E_POINTER}, + {hInstance, version - 1, &IID_IDirectInput8A, &unknown, NULL, DIERR_BETADIRECTINPUTVERSION}, + {hInstance, version + 1, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER}, + {hInstance, version + 1, &IID_IDirectInputA, &unknown, NULL, DIERR_NOINTERFACE}, + {hInstance, version + 1, &IID_IDirectInput8A, NULL, (void *)0xdeadbeef, E_POINTER}, + {hInstance, version + 1, &IID_IDirectInput8A, &unknown, NULL, version <= 0x700 ? DIERR_BETADIRECTINPUTVERSION : DIERR_OLDDIRECTINPUTVERSION}, }; - - IDirectInputA *pDI; HRESULT hr; - IUnknown *pUnk, *iface, *tmp_iface; int i;
- hr = DirectInputCreateA(hInstance, DIRECTINPUT_VERSION, &pDI, NULL); - if (FAILED(hr)) + for (i = 0; i < ARRAY_SIZE(create_tests); i++) { - win_skip("Failed to instantiate a IDirectInputA instance: 0x%08x\n", hr); - return; + winetest_push_context( "%u", i ); + unknown = (void *)0xdeadbeef; + hr = DirectInput8Create( create_tests[i].instance, create_tests[i].version, create_tests[i].iid, + (void **)create_tests[i].out, NULL ); + ok( hr == create_tests[i].expected_hr, "DirectInput8Create returned %#x\n", hr ); + if (SUCCEEDED(hr)) IUnknown_Release( unknown ); + else ok( unknown == create_tests[i].expect_out, "got IUnknown %p\n", unknown ); + winetest_pop_context(); }
- hr = IDirectInput_QueryInterface(pDI, NULL, NULL); - ok(hr == E_POINTER, "IDirectInput_QueryInterface returned 0x%08x\n", hr); - - pUnk = (void *)0xdeadbeef; - hr = IDirectInput_QueryInterface(pDI, NULL, (void **)&pUnk); - ok(hr == E_POINTER, "IDirectInput_QueryInterface returned 0x%08x\n", hr); - ok(pUnk == (void *)0xdeadbeef, "Output interface pointer is %p\n", pUnk); - - hr = IDirectInput_QueryInterface(pDI, &IID_IUnknown, NULL); - ok(hr == E_POINTER, "IDirectInput_QueryInterface returned 0x%08x\n", hr); - - for (i = 0; i < ARRAY_SIZE(iid_list); i++) + for (i = 0; i < ARRAY_SIZE(dinput7_interfaces); i++) { - pUnk = NULL; - hr = IDirectInput_QueryInterface(pDI, iid_list[i], (void **)&pUnk); - ok(hr == S_OK, "[%d] IDirectInput_QueryInterface returned 0x%08x\n", i, hr); - ok(pUnk != NULL, "[%d] Output interface pointer is NULL\n", i); - if (pUnk) IUnknown_Release(pUnk); + winetest_push_context( "%u", i ); + unknown = (void *)0xdeadbeef; + hr = DirectInput8Create( hInstance, version, dinput7_interfaces[i], (void **)&unknown, NULL ); + ok( hr == DIERR_NOINTERFACE, "DirectInput8Create returned %#x\n", hr ); + ok( unknown == NULL, "got IUnknown %p\n", unknown ); + winetest_pop_context(); }
- for (i = 0; i < ARRAY_SIZE(no_interface_list); i++) + for (i = 0; i < ARRAY_SIZE(dinput8_interfaces); i++) { - pUnk = (void *)0xdeadbeef; - hr = IDirectInput_QueryInterface(pDI, no_interface_list[i], (void **)&pUnk); - ok(hr == E_NOINTERFACE, "[%d] IDirectInput_QueryInterface returned 0x%08x\n", i, hr); - ok(pUnk == NULL, "[%d] Output interface pointer is %p\n", i, pUnk); + winetest_push_context( "%u", i ); + unknown = NULL; + hr = DirectInput8Create( hInstance, version, dinput8_interfaces[i], (void **)&unknown, NULL ); + if (i == 2) ok( hr == DIERR_NOINTERFACE, "DirectInput8Create returned %#x\n", hr ); + else if (version == 0x800) ok( hr == DI_OK, "DirectInput8Create returned %#x\n", hr ); + else ok( hr == DIERR_BETADIRECTINPUTVERSION, "DirectInput8Create returned %#x\n", hr ); + if (i == 2) ok( unknown == NULL, "got IUnknown %p\n", unknown ); + else if (version == 0x800) ok( unknown != NULL, "got NULL IUnknown\n" ); + else ok( unknown == NULL, "got IUnknown %p\n", unknown ); + if (unknown) IUnknown_Release( unknown ); + winetest_pop_context(); } - - hr = IUnknown_QueryInterface( pDI, &IID_IDirectInputA, (void **)&iface ); - ok( SUCCEEDED(hr), "IUnknown_QueryInterface(IID_IDirectInputA) failed: %08x\n", hr ); - hr = IUnknown_QueryInterface( pDI, &IID_IDirectInput2A, (void **)&tmp_iface ); - ok( SUCCEEDED(hr), "IUnknown_QueryInterface(IID_IDirectInput2A) failed: %08x\n", hr ); - ok( tmp_iface == iface, "IID_IDirectInput2A iface differs from IID_IDirectInputA\n" ); - IUnknown_Release( tmp_iface ); - hr = IUnknown_QueryInterface( pDI, &IID_IDirectInput7A, (void **)&tmp_iface ); - ok( SUCCEEDED(hr), "IUnknown_QueryInterface(IID_IDirectInput7A) failed: %08x\n", hr ); - ok( tmp_iface == iface, "IID_IDirectInput7A iface differs from IID_IDirectInputA\n" ); - IUnknown_Release( tmp_iface ); - IUnknown_Release( iface ); - - hr = IUnknown_QueryInterface( pDI, &IID_IUnknown, (void **)&iface ); - ok( SUCCEEDED(hr), "IUnknown_QueryInterface(IID_IUnknown) failed: %08x\n", hr ); - hr = IUnknown_QueryInterface( pDI, &IID_IDirectInputW, (void **)&tmp_iface ); - ok( SUCCEEDED(hr), "IUnknown_QueryInterface(IID_IDirectInputW) failed: %08x\n", hr ); - ok( tmp_iface == iface, "IID_IDirectInputW iface differs from IID_IUnknown\n" ); - IUnknown_Release( tmp_iface ); - hr = IUnknown_QueryInterface( pDI, &IID_IDirectInput2W, (void **)&tmp_iface ); - ok( SUCCEEDED(hr), "IUnknown_QueryInterface(IID_IDirectInput2W) failed: %08x\n", hr ); - ok( tmp_iface == iface, "IID_IDirectInput2W iface differs from IID_IUnknown\n" ); - IUnknown_Release( tmp_iface ); - hr = IUnknown_QueryInterface( pDI, &IID_IDirectInput7W, (void **)&tmp_iface ); - ok( SUCCEEDED(hr), "IUnknown_QueryInterface(IID_IDirectInput7W) failed: %08x\n", hr ); - ok( tmp_iface == iface, "IID_IDirectInput7W iface differs from IID_IUnknown\n" ); - IUnknown_Release( tmp_iface ); - IUnknown_Release( iface ); - - IDirectInput_Release(pDI); }
-static void test_CreateDevice(void) +static void test_QueryInterface( DWORD version ) { - IDirectInputA *pDI; + IUnknown *iface, *tmp_iface; + IDirectInputA *dinput; HRESULT hr; - IDirectInputDeviceA *pDID; + ULONG ref; + int i;
- hr = DirectInputCreateA(hInstance, DIRECTINPUT_VERSION, &pDI, NULL); - if (FAILED(hr)) + if (FAILED(hr = direct_input_create( version, &dinput ))) return; + + hr = IDirectInput_QueryInterface( dinput, NULL, NULL ); + ok( hr == E_POINTER, "QueryInterface returned 0x%08x\n", hr ); + + iface = (void *)0xdeadbeef; + hr = IDirectInput_QueryInterface( dinput, NULL, (void **)&iface ); + ok( hr == E_POINTER, "QueryInterface returned 0x%08x\n", hr ); + ok( iface == (void *)0xdeadbeef, "Output interface pointer is %p\n", iface ); + + hr = IDirectInput_QueryInterface( dinput, &IID_IUnknown, NULL ); + ok( hr == E_POINTER, "QueryInterface returned 0x%08x\n", hr ); + + hr = IDirectInput_QueryInterface( dinput, &IID_IUnknown, (void **)&iface ); + ok( hr == S_OK, "QueryInterface returned 0x%08x\n", hr ); + ok( iface != NULL, "got iface NULL\n" ); + ref = IUnknown_Release( iface ); + ok( ref == 1, "Release returned %u\n", ref ); + + for (i = 0; i < ARRAY_SIZE(dinput7_interfaces); i++) { - win_skip("Failed to instantiate a IDirectInputA instance: 0x%08x\n", hr); - return; + winetest_push_context("%u", i); + iface = (void *)0xdeadbeef; + hr = IDirectInput_QueryInterface( dinput, dinput7_interfaces[i], (void **)&iface ); + if (version >= 0x800) + { + ok( hr == E_NOINTERFACE, "QueryInterface returned 0x%08x\n", hr ); + ok( iface == NULL, "got iface %p\n", iface ); + } + else + { + ok( hr == S_OK, "QueryInterface returned 0x%08x\n", hr ); + ok( iface != NULL, "got iface NULL\n" ); + ref = IUnknown_Release( iface ); + ok( ref == 1, "Release returned %u\n", ref ); + } + winetest_pop_context(); }
- hr = IDirectInput_CreateDevice(pDI, NULL, NULL, NULL); - ok(hr == E_POINTER, "IDirectInput_CreateDevice returned 0x%08x\n", hr); + for (i = 0; i < ARRAY_SIZE(dinput8_interfaces); i++) + { + winetest_push_context("%u", i); + iface = (void *)0xdeadbeef; + hr = IDirectInput_QueryInterface( dinput, dinput8_interfaces[i], (void **)&iface ); + if (version < 0x800) + { + todo_wine_if(i == 2) + ok( hr == E_NOINTERFACE, "QueryInterface returned 0x%08x\n", hr ); + todo_wine_if(i == 2) + ok( iface == NULL, "got iface %p\n", iface ); + } + else + { + ok( hr == S_OK, "QueryInterface returned 0x%08x\n", hr ); + ok( iface != NULL, "got iface NULL\n" ); + ref = IUnknown_Release( iface ); + ok( ref == 1, "Release returned %u\n", ref ); + } + winetest_pop_context(); + }
- pDID = (void *)0xdeadbeef; - hr = IDirectInput_CreateDevice(pDI, NULL, &pDID, NULL); - ok(hr == E_POINTER, "IDirectInput_CreateDevice returned 0x%08x\n", hr); - ok(pDID == NULL, "Output interface pointer is %p\n", pDID); + if (version < 0x800) + { + hr = IUnknown_QueryInterface( dinput, &IID_IDirectInputA, (void **)&iface ); + ok( SUCCEEDED(hr), "IUnknown_QueryInterface(IID_IDirectInputA) failed: %08x\n", hr ); + hr = IUnknown_QueryInterface( dinput, &IID_IDirectInput2A, (void **)&tmp_iface ); + ok( SUCCEEDED(hr), "IUnknown_QueryInterface(IID_IDirectInput2A) failed: %08x\n", hr ); + ok( tmp_iface == iface, "IID_IDirectInput2A iface differs from IID_IDirectInputA\n" ); + IUnknown_Release( tmp_iface ); + hr = IUnknown_QueryInterface( dinput, &IID_IDirectInput7A, (void **)&tmp_iface ); + ok( SUCCEEDED(hr), "IUnknown_QueryInterface(IID_IDirectInput7A) failed: %08x\n", hr ); + ok( tmp_iface == iface, "IID_IDirectInput7A iface differs from IID_IDirectInputA\n" ); + IUnknown_Release( tmp_iface ); + IUnknown_Release( iface );
- hr = IDirectInput_CreateDevice(pDI, &GUID_Unknown, NULL, NULL); - ok(hr == E_POINTER, "IDirectInput_CreateDevice returned 0x%08x\n", hr); + hr = IUnknown_QueryInterface( dinput, &IID_IUnknown, (void **)&iface ); + ok( SUCCEEDED(hr), "IUnknown_QueryInterface(IID_IUnknown) failed: %08x\n", hr ); + hr = IUnknown_QueryInterface( dinput, &IID_IDirectInputW, (void **)&tmp_iface ); + ok( SUCCEEDED(hr), "IUnknown_QueryInterface(IID_IDirectInputW) failed: %08x\n", hr ); + ok( tmp_iface == iface, "IID_IDirectInputW iface differs from IID_IUnknown\n" ); + IUnknown_Release( tmp_iface ); + hr = IUnknown_QueryInterface( dinput, &IID_IDirectInput2W, (void **)&tmp_iface ); + ok( SUCCEEDED(hr), "IUnknown_QueryInterface(IID_IDirectInput2W) failed: %08x\n", hr ); + ok( tmp_iface == iface, "IID_IDirectInput2W iface differs from IID_IUnknown\n" ); + IUnknown_Release( tmp_iface ); + hr = IUnknown_QueryInterface( dinput, &IID_IDirectInput7W, (void **)&tmp_iface ); + ok( SUCCEEDED(hr), "IUnknown_QueryInterface(IID_IDirectInput7W) failed: %08x\n", hr ); + ok( tmp_iface == iface, "IID_IDirectInput7W iface differs from IID_IUnknown\n" ); + IUnknown_Release( tmp_iface ); + IUnknown_Release( iface ); + }
- pDID = (void *)0xdeadbeef; - hr = IDirectInput_CreateDevice(pDI, &GUID_Unknown, &pDID, NULL); - ok(hr == DIERR_DEVICENOTREG, "IDirectInput_CreateDevice returned 0x%08x\n", hr); - ok(pDID == NULL, "Output interface pointer is %p\n", pDID); + ref = IDirectInput_Release( dinput ); + todo_wine_if( version < 0x800 ) + ok( ref == 0, "Release returned %u\n", ref ); +}
- hr = IDirectInput_CreateDevice(pDI, &GUID_SysMouse, NULL, NULL); - ok(hr == E_POINTER, "IDirectInput_CreateDevice returned 0x%08x\n", hr); +static void test_CreateDevice( DWORD version ) +{ + IDirectInputDeviceA *device; + IDirectInputA *dinput; + HRESULT hr; + ULONG ref;
- hr = IDirectInput_CreateDevice(pDI, &GUID_SysMouse, &pDID, NULL); - ok(hr == DI_OK, "IDirectInput_CreateDevice returned 0x%08x\n", hr); + if (FAILED(hr = direct_input_create( version, &dinput ))) return;
- IDirectInputDevice_Release(pDID); - IDirectInput_Release(pDI); + hr = IDirectInput_CreateDevice( dinput, NULL, NULL, NULL ); + ok( hr == E_POINTER, "CreateDevice returned 0x%08x\n", hr ); + + device = (void *)0xdeadbeef; + hr = IDirectInput_CreateDevice( dinput, NULL, &device, NULL ); + ok( hr == E_POINTER, "CreateDevice returned 0x%08x\n", hr ); + ok( device == NULL, "Output interface pointer is %p\n", device ); + + hr = IDirectInput_CreateDevice( dinput, &GUID_Unknown, NULL, NULL ); + ok( hr == E_POINTER, "CreateDevice returned 0x%08x\n", hr ); + + device = (void *)0xdeadbeef; + hr = IDirectInput_CreateDevice( dinput, &GUID_Unknown, &device, NULL ); + ok( hr == DIERR_DEVICENOTREG, "CreateDevice returned 0x%08x\n", hr ); + ok( device == NULL, "Output interface pointer is %p\n", device ); + + hr = IDirectInput_CreateDevice( dinput, &GUID_SysMouse, NULL, NULL ); + ok( hr == E_POINTER, "CreateDevice returned 0x%08x\n", hr ); + + hr = IDirectInput_CreateDevice( dinput, &GUID_SysMouse, &device, NULL ); + ok( hr == DI_OK, "CreateDevice returned 0x%08x\n", hr ); + + ref = IDirectInputDevice_Release( device ); + ok( ref == 0, "Release returned %u\n", ref ); + ref = IDirectInput_Release( dinput ); + ok( ref == 0, "Release returned %u\n", ref ); }
struct enum_devices_test { unsigned int device_count; BOOL return_value; + DWORD version; };
+DEFINE_GUID( pidvid_product_guid, 0x00000000, 0x0000, 0x0000, 0x00, 0x00, 'P', 'I', 'D', 'V', 'I', 'D' ); + static BOOL CALLBACK enum_devices_callback(const DIDEVICEINSTANCEA *instance, void *context) { + BYTE type = GET_DIDEVICE_TYPE( instance->dwDevType ); struct enum_devices_test *enum_test = context;
- if ((instance->dwDevType & 0xff) == DIDEVTYPE_KEYBOARD || - (instance->dwDevType & 0xff) == DIDEVTYPE_MOUSE) { - const char *device = ((instance->dwDevType & 0xff) == - DIDEVTYPE_KEYBOARD) ? "Keyboard" : "Mouse"; - ok(IsEqualGUID(&instance->guidInstance, &instance->guidProduct), - "%s guidInstance (%s) does not match guidProduct (%s)\n", - device, wine_dbgstr_guid(&instance->guidInstance), - wine_dbgstr_guid(&instance->guidProduct)); + if (winetest_debug > 1) + { + trace( "---- Device Information ----\n" + "Product Name : %s\n" + "Instance Name : %s\n" + "devType : 0x%08x\n" + "GUID Product : %s\n" + "GUID Instance : %s\n" + "HID Page : 0x%04x\n" + "HID Usage : 0x%04x\n", + instance->tszProductName, instance->tszInstanceName, instance->dwDevType, + wine_dbgstr_guid( &instance->guidProduct ), + wine_dbgstr_guid( &instance->guidInstance ), instance->wUsagePage, instance->wUsage ); }
- if ((instance->dwDevType & 0xff) == DIDEVTYPE_KEYBOARD) - ok(IsEqualGUID(&instance->guidProduct, &GUID_SysKeyboard), - "Keyboard guidProduct (%s) does not match GUID_SysKeyboard (%s)\n", - wine_dbgstr_guid(&instance->guidProduct), - wine_dbgstr_guid(&GUID_SysMouse)); - else if ((instance->dwDevType & 0xff) == DIDEVTYPE_MOUSE) - ok(IsEqualGUID(&instance->guidProduct, &GUID_SysMouse), - "Mouse guidProduct (%s) does not match GUID_SysMouse (%s)\n", - wine_dbgstr_guid(&instance->guidProduct), - wine_dbgstr_guid(&GUID_SysMouse)); - else { - /* Non-keyboard/mouse devices use the "PIDVID" guidProduct */ - static const GUID pidvid_product_guid = { /* device_pidvid-0000-0000-0000-504944564944 "PIDVID" */ - 0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x50, 0x49, 0x44, 0x56, 0x49, 0x44} - }; + if (enum_test->version >= 0x800) + { + if (type == DI8DEVTYPE_KEYBOARD || type == DI8DEVTYPE_MOUSE) + { + const char *device = (type == DI8DEVTYPE_KEYBOARD) ? "Keyboard" : "Mouse"; + ok( IsEqualGUID( &instance->guidInstance, &instance->guidProduct ), + "%s guidInstance (%s) does not match guidProduct (%s)\n", device, + wine_dbgstr_guid( &instance->guidInstance ), wine_dbgstr_guid( &instance->guidProduct ) ); + } + } + else + { + if (type == DIDEVTYPE_KEYBOARD || type == DIDEVTYPE_MOUSE) + { + const char *device = (type == DIDEVTYPE_KEYBOARD) ? "Keyboard" : "Mouse"; + ok( IsEqualGUID( &instance->guidInstance, &instance->guidProduct ), + "%s guidInstance (%s) does not match guidProduct (%s)\n", device, + wine_dbgstr_guid( &instance->guidInstance ), wine_dbgstr_guid( &instance->guidProduct ) ); + }
- ok(instance->guidProduct.Data2 == pidvid_product_guid.Data2, - "guidProduct.Data2 is %04x\n", instance->guidProduct.Data2); - ok(instance->guidProduct.Data3 == pidvid_product_guid.Data3, - "guidProduct.Data3 is %04x\n", instance->guidProduct.Data3); - ok(!memcmp(instance->guidProduct.Data4, pidvid_product_guid.Data4, sizeof(pidvid_product_guid.Data4)), - "guidProduct.Data4 does not match: %s\n", wine_dbgstr_guid(&instance->guidProduct)); + if (type == DIDEVTYPE_KEYBOARD) + ok( IsEqualGUID( &instance->guidProduct, &GUID_SysKeyboard ), + "Keyboard guidProduct (%s) does not match GUID_SysKeyboard (%s)\n", + wine_dbgstr_guid( &instance->guidProduct ), wine_dbgstr_guid( &GUID_SysMouse ) ); + else if (type == DIDEVTYPE_MOUSE) + ok( IsEqualGUID( &instance->guidProduct, &GUID_SysMouse ), + "Mouse guidProduct (%s) does not match GUID_SysMouse (%s)\n", + wine_dbgstr_guid( &instance->guidProduct ), wine_dbgstr_guid( &GUID_SysMouse ) ); + else + { + ok( instance->guidProduct.Data2 == pidvid_product_guid.Data2, + "guidProduct.Data2 is %04x\n", instance->guidProduct.Data2 ); + ok( instance->guidProduct.Data3 == pidvid_product_guid.Data3, + "guidProduct.Data3 is %04x\n", instance->guidProduct.Data3 ); + ok( !memcmp( instance->guidProduct.Data4, pidvid_product_guid.Data4, + sizeof(pidvid_product_guid.Data4) ), + "guidProduct.Data4 does not match: %s\n", wine_dbgstr_guid( &instance->guidProduct ) ); + } }
enum_test->device_count++; return enum_test->return_value; }
-static void test_EnumDevices(void) +static void test_EnumDevices( DWORD version ) { - IDirectInputA *pDI; + struct enum_devices_test enum_test = {.version = version}, enum_test_return = {.version = version}; + IDirectInputA *dinput; HRESULT hr; - struct enum_devices_test enum_test, enum_test_return; + ULONG ref;
- hr = DirectInputCreateA(hInstance, DIRECTINPUT_VERSION, &pDI, NULL); - if (FAILED(hr)) - { - win_skip("Failed to instantiate a IDirectInputA instance: 0x%08x\n", hr); - return; - } + if (FAILED(hr = direct_input_create( version, &dinput ))) return;
- hr = IDirectInput_EnumDevices(pDI, 0, NULL, NULL, 0); - ok(hr == DIERR_INVALIDPARAM, "IDirectInput_EnumDevices returned 0x%08x\n", hr); + hr = IDirectInput_EnumDevices( dinput, 0, NULL, NULL, 0 ); + ok( hr == DIERR_INVALIDPARAM, "EnumDevices returned 0x%08x\n", hr );
- hr = IDirectInput_EnumDevices(pDI, 0, NULL, NULL, ~0u); - ok(hr == DIERR_INVALIDPARAM, "IDirectInput_EnumDevices returned 0x%08x\n", hr); + hr = IDirectInput_EnumDevices( dinput, 0, NULL, NULL, ~0u ); + ok( hr == DIERR_INVALIDPARAM, "EnumDevices returned 0x%08x\n", hr );
/* Test crashes on Wine. */ if (0) { - hr = IDirectInput_EnumDevices(pDI, 0, enum_devices_callback, NULL, ~0u); - ok(hr == DIERR_INVALIDPARAM, "IDirectInput_EnumDevices returned 0x%08x\n", hr); + hr = IDirectInput_EnumDevices( dinput, 0, enum_devices_callback, NULL, ~0u ); + ok( hr == DIERR_INVALIDPARAM, "EnumDevices returned 0x%08x\n", hr ); }
- hr = IDirectInput_EnumDevices(pDI, 0xdeadbeef, NULL, NULL, 0); - ok(hr == DIERR_INVALIDPARAM, "IDirectInput_EnumDevices returned 0x%08x\n", hr); + hr = IDirectInput_EnumDevices( dinput, 0xdeadbeef, NULL, NULL, 0 ); + ok( hr == DIERR_INVALIDPARAM, "EnumDevices returned 0x%08x\n", hr );
- hr = IDirectInput_EnumDevices(pDI, 0xdeadbeef, NULL, NULL, ~0u); - ok(hr == DIERR_INVALIDPARAM, "IDirectInput_EnumDevices returned 0x%08x\n", hr); + hr = IDirectInput_EnumDevices( dinput, 0xdeadbeef, NULL, NULL, ~0u ); + ok( hr == DIERR_INVALIDPARAM, "EnumDevices returned 0x%08x\n", hr );
- hr = IDirectInput_EnumDevices(pDI, 0xdeadbeef, enum_devices_callback, NULL, 0); - ok(hr == DIERR_INVALIDPARAM, "IDirectInput_EnumDevices returned 0x%08x\n", hr); + hr = IDirectInput_EnumDevices( dinput, 0xdeadbeef, enum_devices_callback, NULL, 0 ); + ok( hr == DIERR_INVALIDPARAM, "EnumDevices returned 0x%08x\n", hr );
- hr = IDirectInput_EnumDevices(pDI, 0xdeadbeef, enum_devices_callback, NULL, ~0u); - ok(hr == DIERR_INVALIDPARAM, "IDirectInput_EnumDevices returned 0x%08x\n", hr); + hr = IDirectInput_EnumDevices( dinput, 0xdeadbeef, enum_devices_callback, NULL, ~0u ); + ok( hr == DIERR_INVALIDPARAM, "EnumDevices returned 0x%08x\n", hr );
enum_test.device_count = 0; enum_test.return_value = DIENUM_CONTINUE; - hr = IDirectInput_EnumDevices(pDI, 0, enum_devices_callback, &enum_test, 0); - ok(hr == DI_OK, "IDirectInput_EnumDevices returned 0x%08x\n", hr); + hr = IDirectInput_EnumDevices( dinput, 0, enum_devices_callback, &enum_test, 0 ); + ok( hr == DI_OK, "EnumDevices returned 0x%08x\n", hr ); ok(enum_test.device_count != 0, "Device count is %u\n", enum_test.device_count);
/* Enumeration only stops with an explicit DIENUM_STOP. */ enum_test_return.device_count = 0; enum_test_return.return_value = 42; - hr = IDirectInput_EnumDevices(pDI, 0, enum_devices_callback, &enum_test_return, 0); - ok(hr == DI_OK, "IDirectInput_EnumDevices returned 0x%08x\n", hr); + hr = IDirectInput_EnumDevices( dinput, 0, enum_devices_callback, &enum_test_return, 0 ); + ok( hr == DI_OK, "EnumDevices returned 0x%08x\n", hr ); ok(enum_test_return.device_count == enum_test.device_count, "Device count is %u vs. %u\n", enum_test_return.device_count, enum_test.device_count);
enum_test.device_count = 0; enum_test.return_value = DIENUM_STOP; - hr = IDirectInput_EnumDevices(pDI, 0, enum_devices_callback, &enum_test, 0); - ok(hr == DI_OK, "IDirectInput_EnumDevices returned 0x%08x\n", hr); + hr = IDirectInput_EnumDevices( dinput, 0, enum_devices_callback, &enum_test, 0 ); + ok( hr == DI_OK, "EnumDevices returned 0x%08x\n", hr ); ok(enum_test.device_count == 1, "Device count is %u\n", enum_test.device_count);
- IDirectInput_Release(pDI); + ref = IDirectInput_Release( dinput ); + ok( ref == 0, "Release returned %u\n", ref ); }
-static void test_GetDeviceStatus(void) +static void test_GetDeviceStatus( DWORD version ) { - IDirectInputA *pDI; + IDirectInputA *dinput; HRESULT hr; + ULONG ref;
- hr = DirectInputCreateA(hInstance, DIRECTINPUT_VERSION, &pDI, NULL); - if (FAILED(hr)) - { - win_skip("Failed to instantiate a IDirectInputA instance: 0x%08x\n", hr); - return; - } + if (FAILED(hr = direct_input_create( version, &dinput ))) return;
- hr = IDirectInput_GetDeviceStatus(pDI, NULL); - ok(hr == E_POINTER, "IDirectInput_GetDeviceStatus returned 0x%08x\n", hr); + hr = IDirectInput_GetDeviceStatus( dinput, NULL ); + ok( hr == E_POINTER, "GetDeviceStatus returned %#x\n", hr );
- hr = IDirectInput_GetDeviceStatus(pDI, &GUID_Unknown); + hr = IDirectInput_GetDeviceStatus( dinput, &GUID_Unknown ); todo_wine - ok(hr == DIERR_DEVICENOTREG, "IDirectInput_GetDeviceStatus returned 0x%08x\n", hr); + ok( hr == DIERR_DEVICENOTREG, "GetDeviceStatus returned %#x\n", hr );
- hr = IDirectInput_GetDeviceStatus(pDI, &GUID_SysMouse); - ok(hr == DI_OK, "IDirectInput_GetDeviceStatus returned 0x%08x\n", hr); + hr = IDirectInput_GetDeviceStatus( dinput, &GUID_SysMouse ); + ok( hr == DI_OK, "GetDeviceStatus returned %#x\n", hr );
- IDirectInput_Release(pDI); + ref = IDirectInput_Release( dinput ); + ok( ref == 0, "Release returned %u\n", ref ); }
-static void test_Initialize(void) +static void test_Initialize( DWORD version ) { - IDirectInputA *pDI; + IDirectInputA *dinput; HRESULT hr; - int i; + ULONG ref;
- hr = CoCreateInstance(&CLSID_DirectInput, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectInputA, (void **)&pDI); - if (FAILED(hr)) - { - win_skip("Failed to instantiate a IDirectInputA instance: 0x%08x\n", hr); - return; - } + if (FAILED(hr = direct_input_create( version, &dinput ))) return;
- hr = IDirectInput_Initialize(pDI, NULL, 0); - ok(hr == DIERR_INVALIDPARAM, "IDirectInput_Initialize returned 0x%08x\n", hr); + hr = IDirectInput_Initialize( dinput, NULL, 0 ); + ok( hr == DIERR_INVALIDPARAM, "Initialize returned %#x\n", hr );
- hr = IDirectInput_Initialize(pDI, NULL, DIRECTINPUT_VERSION); - ok(hr == DIERR_INVALIDPARAM, "IDirectInput_Initialize returned 0x%08x\n", hr); + hr = IDirectInput_Initialize( dinput, NULL, version ); + if (version == 0x300) todo_wine ok( hr == S_OK, "Initialize returned %#x\n", hr ); + else ok( hr == DIERR_INVALIDPARAM, "Initialize returned %#x\n", hr );
- hr = IDirectInput_Initialize(pDI, hInstance, 0); - ok(hr == DIERR_NOTINITIALIZED, "IDirectInput_Initialize returned 0x%08x\n", hr); + hr = IDirectInput_Initialize( dinput, hInstance, 0 ); + ok( hr == DIERR_NOTINITIALIZED, "Initialize returned %#x\n", hr );
- /* Invalid DirectInput versions less than 0x0700 yield DIERR_BETADIRECTINPUTVERSION. */ - hr = IDirectInput_Initialize(pDI, hInstance, 0x0123); - ok(hr == DIERR_BETADIRECTINPUTVERSION, "IDirectInput_Initialize returned 0x%08x\n", hr); + hr = IDirectInput_Initialize( dinput, hInstance, version - 1 ); + ok( hr == DIERR_BETADIRECTINPUTVERSION, "Initialize returned %#x\n", hr );
- /* Invalid DirectInput versions greater than 0x0700 yield DIERR_BETADIRECTINPUTVERSION. */ - hr = IDirectInput_Initialize(pDI, hInstance, 0xcafe); - ok(hr == DIERR_OLDDIRECTINPUTVERSION, "IDirectInput_Initialize returned 0x%08x\n", hr); - - for (i = 0; i < ARRAY_SIZE(directinput_version_list); i++) - { - hr = IDirectInput_Initialize(pDI, hInstance, directinput_version_list[i]); - ok(hr == DI_OK, "IDirectInput_Initialize returned 0x%08x\n", hr); - } + hr = IDirectInput_Initialize( dinput, hInstance, version + 1 ); + if (version >= 0x700) ok( hr == DIERR_OLDDIRECTINPUTVERSION, "Initialize returned %#x\n", hr ); + else ok( hr == DIERR_BETADIRECTINPUTVERSION, "Initialize returned %#x\n", hr );
/* Parameters are still validated after successful initialization. */ - hr = IDirectInput_Initialize(pDI, hInstance, 0); - ok(hr == DIERR_NOTINITIALIZED, "IDirectInput_Initialize returned 0x%08x\n", hr); + hr = IDirectInput_Initialize( dinput, hInstance, 0 ); + ok( hr == DIERR_NOTINITIALIZED, "Initialize returned %#x\n", hr );
- IDirectInput_Release(pDI); + ref = IDirectInput_Release( dinput ); + ok( ref == 0, "Release returned %u\n", ref ); }
-static void test_RunControlPanel(void) +static void test_RunControlPanel( DWORD version ) { - IDirectInputA *pDI; + IDirectInputA *dinput; HRESULT hr; + ULONG ref;
- hr = DirectInputCreateA(hInstance, DIRECTINPUT_VERSION, &pDI, NULL); - if (FAILED(hr)) - { - win_skip("Failed to instantiate a IDirectInputA instance: 0x%08x\n", hr); - return; - } + if (FAILED(hr = direct_input_create( version, &dinput ))) return;
if (winetest_interactive) { - hr = IDirectInput_RunControlPanel(pDI, NULL, 0); - ok(hr == S_OK, "IDirectInput_RunControlPanel returned 0x%08x\n", hr); + hr = IDirectInput_RunControlPanel( dinput, NULL, 0 ); + ok( hr == S_OK, "RunControlPanel returned %#x\n", hr );
- hr = IDirectInput_RunControlPanel(pDI, GetDesktopWindow(), 0); - ok(hr == S_OK, "IDirectInput_RunControlPanel returned 0x%08x\n", hr); + hr = IDirectInput_RunControlPanel( dinput, GetDesktopWindow(), 0 ); + ok( hr == S_OK, "RunControlPanel returned %#x\n", hr ); }
- hr = IDirectInput_RunControlPanel(pDI, NULL, ~0u); - ok(hr == DIERR_INVALIDPARAM, "IDirectInput_RunControlPanel returned 0x%08x\n", hr); + hr = IDirectInput_RunControlPanel( dinput, NULL, ~0u ); + ok( hr == DIERR_INVALIDPARAM, "RunControlPanel returned %#x\n", hr );
- hr = IDirectInput_RunControlPanel(pDI, (HWND)0xdeadbeef, 0); - ok(hr == E_HANDLE, "IDirectInput_RunControlPanel returned 0x%08x\n", hr); + hr = IDirectInput_RunControlPanel( dinput, (HWND)0xdeadbeef, 0 ); + ok( hr == E_HANDLE, "RunControlPanel returned %#x\n", hr );
- hr = IDirectInput_RunControlPanel(pDI, (HWND)0xdeadbeef, ~0u); - ok(hr == E_HANDLE, "IDirectInput_RunControlPanel returned 0x%08x\n", hr); + hr = IDirectInput_RunControlPanel( dinput, (HWND)0xdeadbeef, ~0u ); + ok( hr == E_HANDLE, "RunControlPanel returned %#x\n", hr );
- IDirectInput_Release(pDI); + ref = IDirectInput_Release( dinput ); + ok( ref == 0, "Release returned %u\n", ref ); }
static void test_DirectInputJoyConfig8(void) @@ -644,7 +790,7 @@ static void test_DirectInputJoyConfig8(void) if (SUCCEEDED(hr)) { hr = IDirectInput_CreateDevice(pDI, &info.guidInstance, &pDID, NULL); - ok (SUCCEEDED(hr), "IDirectInput_CreateDevice failed with guid from GetConfig hr = 0x%08x\n", hr); + ok( SUCCEEDED(hr), "CreateDevice failed with guid from GetConfig hr = 0x%08x\n", hr ); IDirectInputDevice_Release(pDID); } } @@ -653,23 +799,227 @@ static void test_DirectInputJoyConfig8(void) IDirectInput_Release(pDI); }
+struct enum_semantics_test +{ + unsigned int device_count; + DWORD first_remaining; + BOOL mouse; + BOOL keyboard; + DIACTIONFORMATA *action_format; + const char *username; +}; + +static DIACTIONA actionMapping[] = { + /* axis */ + {0, 0x01008A01 /* DIAXIS_DRIVINGR_STEER */, 0, {"Steer.\0"}}, + /* button */ + {1, 0x01000C01 /* DIBUTTON_DRIVINGR_SHIFTUP */, 0, {"Upshift.\0"}}, + /* keyboard key */ + {2, DIKEYBOARD_SPACE, 0, {"Missile.\0"}}, + /* mouse button */ + {3, DIMOUSE_BUTTON0, 0, {"Select\0"}}, + /* mouse axis */ + {4, DIMOUSE_YAXIS, 0, {"Y Axis\0"}}}; +/* By placing the memory pointed to by lptszActionName right before memory with PAGE_NOACCESS + * one can find out that the regular ansi string termination is not respected by + * EnumDevicesBySemantics. Adding a double termination, making it a valid wide string termination, + * made the test succeed. Therefore it looks like ansi version of EnumDevicesBySemantics forwards + * the string to the wide variant without conversation. */ + +static BOOL CALLBACK enum_semantics_callback( const DIDEVICEINSTANCEA *lpddi, IDirectInputDevice8A *lpdid, + DWORD dwFlags, DWORD dwRemaining, void *context ) +{ + struct enum_semantics_test *data = context; + + if (context == NULL) return DIENUM_STOP; + + if (!data->device_count) + { + data->first_remaining = dwRemaining; + } + ok( dwRemaining == data->first_remaining - data->device_count, + "enum semantics remaining devices is wrong, expected %d, had %d\n", + data->first_remaining - data->device_count, dwRemaining ); + data->device_count++; + + if (IsEqualGUID( &lpddi->guidInstance, &GUID_SysKeyboard )) data->keyboard = TRUE; + + if (IsEqualGUID( &lpddi->guidInstance, &GUID_SysMouse )) data->mouse = TRUE; + + return DIENUM_CONTINUE; +} + +static BOOL CALLBACK set_action_map_callback( const DIDEVICEINSTANCEA *lpddi, IDirectInputDevice8A *lpdid, + DWORD dwFlags, DWORD dwRemaining, void *context ) +{ + HRESULT hr; + struct enum_semantics_test *data = context; + + /* Building and setting an action map */ + /* It should not use any pre-stored mappings so we use DIDBAM_INITIALIZE */ + hr = IDirectInputDevice8_BuildActionMap( lpdid, data->action_format, NULL, DIDBAM_INITIALIZE ); + ok( SUCCEEDED(hr), "BuildActionMap failed hr=%08x\n", hr ); + + hr = IDirectInputDevice8_SetActionMap( lpdid, data->action_format, data->username, 0 ); + ok( SUCCEEDED(hr), "SetActionMap failed hr=%08x\n", hr ); + + return DIENUM_CONTINUE; +} + +static void test_EnumDevicesBySemantics(void) +{ + DIACTIONFORMATA action_format; + const GUID ACTION_MAPPING_GUID = {0x1, 0x2, 0x3, {0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb}}; + struct enum_semantics_test data = {0, 0, FALSE, FALSE, &action_format, NULL}; + IDirectInput8A *dinput; + int device_total = 0; + HRESULT hr; + + hr = DirectInput8Create( hInstance, 0x800, &IID_IDirectInput8A, (void **)&dinput, NULL ); + if (FAILED(hr)) + { + win_skip( "Failed to instantiate a IDirectInputA instance: 0x%08x\n", hr ); + return; + } + + memset( &action_format, 0, sizeof(action_format) ); + action_format.dwSize = sizeof(action_format); + action_format.dwActionSize = sizeof(DIACTIONA); + action_format.dwNumActions = ARRAY_SIZE(actionMapping); + action_format.dwDataSize = 4 * action_format.dwNumActions; + action_format.rgoAction = actionMapping; + action_format.guidActionMap = ACTION_MAPPING_GUID; + action_format.dwGenre = 0x01000000; /* DIVIRTUAL_DRIVING_RACE */ + action_format.dwBufferSize = 32; + + /* Test enumerating all attached and installed devices */ + data.keyboard = FALSE; + data.mouse = FALSE; + data.device_count = 0; + hr = IDirectInput8_EnumDevicesBySemantics( dinput, NULL, &action_format, enum_semantics_callback, + &data, DIEDBSFL_ATTACHEDONLY ); + ok( data.device_count > 0, "EnumDevicesBySemantics did not call the callback hr=%08x\n", hr ); + ok( data.keyboard, "EnumDevicesBySemantics should enumerate the keyboard\n" ); + ok( data.mouse, "EnumDevicesBySemantics should enumerate the mouse\n" ); + + /* Enumerate Force feedback devices. We should get no mouse nor keyboard */ + data.keyboard = FALSE; + data.mouse = FALSE; + data.device_count = 0; + hr = IDirectInput8_EnumDevicesBySemantics( dinput, NULL, &action_format, enum_semantics_callback, + &data, DIEDBSFL_FORCEFEEDBACK ); + ok( SUCCEEDED(hr), "EnumDevicesBySemantics failed hr=%08x\n", hr ); + ok( !data.keyboard, "Keyboard should not be enumerated when asking for forcefeedback\n" ); + ok( !data.mouse, "Mouse should not be enumerated when asking for forcefeedback\n" ); + + /* Enumerate available devices. That is devices not owned by any user. + Before setting the action map for all devices we still have them available. */ + data.device_count = 0; + hr = IDirectInput8_EnumDevicesBySemantics( dinput, NULL, &action_format, enum_semantics_callback, + &data, DIEDBSFL_AVAILABLEDEVICES ); + ok( SUCCEEDED(hr), "EnumDevicesBySemantics failed hr=%08x\n", hr ); + ok( data.device_count > 0, + "There should be devices available before action mapping available=%d\n", data.device_count ); + + /* Keep the device total */ + device_total = data.device_count; + + /* There should be no devices for any user. No device should be enumerated with DIEDBSFL_THISUSER. + MSDN defines that all unowned devices are also enumerated but this doesn't seem to be happening. */ + data.device_count = 0; + hr = IDirectInput8_EnumDevicesBySemantics( dinput, "Sh4d0w M4g3", &action_format, + enum_semantics_callback, &data, DIEDBSFL_THISUSER ); + ok( SUCCEEDED(hr), "EnumDevicesBySemantics failed hr=%08x\n", hr ); + ok( data.device_count == 0, "No devices should be assigned for this user assigned=%d\n", data.device_count ); + + /* This enumeration builds and sets the action map for all devices with a NULL username */ + hr = IDirectInput8_EnumDevicesBySemantics( dinput, NULL, &action_format, set_action_map_callback, + &data, DIEDBSFL_ATTACHEDONLY ); + ok( SUCCEEDED(hr), "EnumDevicesBySemantics failed: hr=%08x\n", hr ); + + /* After a successful action mapping we should have no devices available */ + data.device_count = 0; + hr = IDirectInput8_EnumDevicesBySemantics( dinput, NULL, &action_format, enum_semantics_callback, + &data, DIEDBSFL_AVAILABLEDEVICES ); + ok( SUCCEEDED(hr), "EnumDevicesBySemantics failed hr=%08x\n", hr ); + ok( data.device_count == 0, "No device should be available after action mapping available=%d\n", + data.device_count ); + + /* Now we'll give all the devices to a specific user */ + data.username = "Sh4d0w M4g3"; + hr = IDirectInput8_EnumDevicesBySemantics( dinput, NULL, &action_format, set_action_map_callback, + &data, DIEDBSFL_ATTACHEDONLY ); + ok( SUCCEEDED(hr), "EnumDevicesBySemantics failed: hr=%08x\n", hr ); + + /* Testing with the default user, DIEDBSFL_THISUSER has no effect */ + data.device_count = 0; + hr = IDirectInput8_EnumDevicesBySemantics( dinput, NULL, &action_format, + enum_semantics_callback, &data, DIEDBSFL_THISUSER ); + ok( SUCCEEDED(hr), "EnumDevicesBySemantics failed hr=%08x\n", hr ); + ok( data.device_count == device_total, "THISUSER has no effect with NULL username owned=%d, expected=%d\n", + data.device_count, device_total ); + + /* Using an empty user string is the same as passing NULL, DIEDBSFL_THISUSER has no effect */ + data.device_count = 0; + hr = IDirectInput8_EnumDevicesBySemantics( dinput, "", &action_format, enum_semantics_callback, &data, DIEDBSFL_THISUSER ); + ok( SUCCEEDED(hr), "EnumDevicesBySemantics failed hr=%08x\n", hr ); + ok( data.device_count == device_total, "THISUSER has no effect with "" as username owned=%d, expected=%d\n", + data.device_count, device_total ); + + /* Testing with a user with no ownership of the devices */ + data.device_count = 0; + hr = IDirectInput8_EnumDevicesBySemantics( dinput, "Ninja Brian", &action_format, + enum_semantics_callback, &data, DIEDBSFL_THISUSER ); + ok( SUCCEEDED(hr), "EnumDevicesBySemantics failed hr=%08x\n", hr ); + ok( data.device_count == 0, "This user should own no devices owned=%d\n", data.device_count ); + + /* Sh4d0w M4g3 has ownership of all devices */ + data.device_count = 0; + hr = IDirectInput8_EnumDevicesBySemantics( dinput, "Sh4d0w M4g3", &action_format, + enum_semantics_callback, &data, DIEDBSFL_THISUSER ); + ok( SUCCEEDED(hr), "EnumDevicesBySemantics failed hr=%08x\n", hr ); + ok( data.device_count == device_total, "This user should own %d devices owned=%d\n", + device_total, data.device_count ); + + /* The call fails with a zeroed GUID */ + memset( &action_format.guidActionMap, 0, sizeof(GUID) ); + data.device_count = 0; + hr = IDirectInput8_EnumDevicesBySemantics( dinput, NULL, &action_format, enum_semantics_callback, NULL, 0 ); + todo_wine + ok( FAILED(hr), "EnumDevicesBySemantics succeeded with invalid GUID hr=%08x\n", hr ); + + IDirectInput8_Release( dinput ); +} + START_TEST(dinput) { HMODULE dinput_mod = GetModuleHandleA("dinput.dll"); + DWORD i;
hInstance = GetModuleHandleA(NULL);
pDirectInputCreateEx = (void *)GetProcAddress(dinput_mod, "DirectInputCreateEx");
- CoInitialize(NULL); - test_preinitialization(); - test_DirectInputCreateEx(); - test_QueryInterface(); - test_CreateDevice(); - test_EnumDevices(); - test_GetDeviceStatus(); - test_Initialize(); - test_RunControlPanel(); - test_DirectInputJoyConfig8(); + CoInitialize( NULL ); + test_CoCreateInstance( 0x700 ); + test_CoCreateInstance( 0x800 ); CoUninitialize(); + + for (i = 0; i < ARRAY_SIZE(dinput_versions); i++) + { + winetest_push_context( "%#x", dinput_versions[i] ); + test_DirectInputCreate( dinput_versions[i] ); + test_DirectInputCreateEx( dinput_versions[i] ); + test_DirectInput8Create( dinput_versions[i] ); + test_QueryInterface( dinput_versions[i] ); + test_CreateDevice( dinput_versions[i] ); + test_EnumDevices( dinput_versions[i] ); + test_GetDeviceStatus( dinput_versions[i] ); + test_RunControlPanel( dinput_versions[i] ); + test_Initialize( dinput_versions[i] ); + winetest_pop_context(); + } + + test_DirectInputJoyConfig8(); + test_EnumDevicesBySemantics(); } diff --git a/dlls/dinput/tests/dinput8.c b/dlls/dinput/tests/dinput8.c deleted file mode 100644 index 81aeb8191f6..00000000000 --- a/dlls/dinput/tests/dinput8.c +++ /dev/null @@ -1,728 +0,0 @@ -/* - * Copyright (c) 2011 Andrew Nguyen - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#define DIRECTINPUT_VERSION 0x0800 - -#define COBJMACROS -#include <windows.h> -#include <objidl.h> - -#include <dinput.h> -#include <dinputd.h> - -#include "wine/test.h" - -static HINSTANCE hInstance; - -static BOOL CALLBACK dummy_callback(const DIDEVICEINSTANCEA *instance, void *context) -{ - ok(0, "Callback was invoked with parameters (%p, %p)\n", instance, context); - return DIENUM_STOP; -} - -static void test_preinitialization(void) -{ - static const struct - { - REFGUID rguid; - BOOL pdev; - HRESULT expected_hr; - } create_device_tests[] = - { - {NULL, FALSE, E_POINTER}, - {NULL, TRUE, E_POINTER}, - {&GUID_Unknown, FALSE, E_POINTER}, - {&GUID_Unknown, TRUE, DIERR_NOTINITIALIZED}, - {&GUID_SysMouse, FALSE, E_POINTER}, - {&GUID_SysMouse, TRUE, DIERR_NOTINITIALIZED}, - }; - - static const struct - { - DWORD dwDevType; - LPDIENUMDEVICESCALLBACKA lpCallback; - DWORD dwFlags; - HRESULT expected_hr; - int todo; - } enum_devices_tests[] = - { - {0, NULL, 0, DIERR_INVALIDPARAM}, - {0, NULL, ~0u, DIERR_INVALIDPARAM}, - {0, dummy_callback, 0, DIERR_NOTINITIALIZED}, - {0, dummy_callback, ~0u, DIERR_INVALIDPARAM}, - {0xdeadbeef, NULL, 0, DIERR_INVALIDPARAM}, - {0xdeadbeef, NULL, ~0u, DIERR_INVALIDPARAM}, - {0xdeadbeef, dummy_callback, 0, DIERR_INVALIDPARAM}, - {0xdeadbeef, dummy_callback, ~0u, DIERR_INVALIDPARAM}, - }; - - IDirectInput8A *pDI; - HRESULT hr; - int i; - IDirectInputDevice8A *pDID; - - hr = CoCreateInstance(&CLSID_DirectInput8, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectInput8A, (void **)&pDI); - if (FAILED(hr)) - { - skip("Failed to instantiate a IDirectInputA instance: 0x%08x\n", hr); - return; - } - - for (i = 0; i < ARRAY_SIZE(create_device_tests); i++) - { - if (create_device_tests[i].pdev) pDID = (void *)0xdeadbeef; - hr = IDirectInput8_CreateDevice(pDI, create_device_tests[i].rguid, - create_device_tests[i].pdev ? &pDID : NULL, - NULL); - ok(hr == create_device_tests[i].expected_hr, "[%d] IDirectInput8_CreateDevice returned 0x%08x\n", i, hr); - if (create_device_tests[i].pdev) - ok(pDID == NULL, "[%d] Output interface pointer is %p\n", i, pDID); - } - - for (i = 0; i < ARRAY_SIZE(enum_devices_tests); i++) - { - hr = IDirectInput8_EnumDevices(pDI, enum_devices_tests[i].dwDevType, - enum_devices_tests[i].lpCallback, - NULL, - enum_devices_tests[i].dwFlags); - todo_wine_if(enum_devices_tests[i].todo) - ok(hr == enum_devices_tests[i].expected_hr, "[%d] IDirectInput8_EnumDevice returned 0x%08x\n", i, hr); - } - - hr = IDirectInput8_GetDeviceStatus(pDI, NULL); - ok(hr == E_POINTER, "IDirectInput8_GetDeviceStatus returned 0x%08x\n", hr); - - hr = IDirectInput8_GetDeviceStatus(pDI, &GUID_Unknown); - ok(hr == DIERR_NOTINITIALIZED, "IDirectInput8_GetDeviceStatus returned 0x%08x\n", hr); - - hr = IDirectInput8_GetDeviceStatus(pDI, &GUID_SysMouse); - ok(hr == DIERR_NOTINITIALIZED, "IDirectInput8_GetDeviceStatus returned 0x%08x\n", hr); - - hr = IDirectInput8_RunControlPanel(pDI, NULL, 0); - ok(hr == DIERR_NOTINITIALIZED, "IDirectInput8_RunControlPanel returned 0x%08x\n", hr); - - hr = IDirectInput8_RunControlPanel(pDI, NULL, ~0u); - ok(hr == DIERR_INVALIDPARAM, "IDirectInput8_RunControlPanel returned 0x%08x\n", hr); - - hr = IDirectInput8_RunControlPanel(pDI, (HWND)0xdeadbeef, 0); - ok(hr == E_HANDLE, "IDirectInput8_RunControlPanel returned 0x%08x\n", hr); - - hr = IDirectInput8_RunControlPanel(pDI, (HWND)0xdeadbeef, ~0u); - ok(hr == E_HANDLE, "IDirectInput8_RunControlPanel returned 0x%08x\n", hr); - - IDirectInput8_Release(pDI); -} - -static void test_DirectInput8Create(void) -{ - static const struct - { - BOOL hinst; - DWORD dwVersion; - REFIID riid; - BOOL ppdi; - HRESULT expected_hr; - } invalid_param_list[] = - { - {FALSE, 0, &IID_IDirectInputA, FALSE, E_POINTER}, - {FALSE, 0, &IID_IDirectInputA, TRUE, DIERR_NOINTERFACE}, - {FALSE, 0, &IID_IDirectInput8A, FALSE, E_POINTER}, - {FALSE, 0, &IID_IDirectInput8A, TRUE, DIERR_INVALIDPARAM}, - {FALSE, DIRECTINPUT_VERSION, &IID_IDirectInputA, FALSE, E_POINTER}, - {FALSE, DIRECTINPUT_VERSION, &IID_IDirectInputA, TRUE, DIERR_NOINTERFACE}, - {FALSE, DIRECTINPUT_VERSION, &IID_IDirectInput8A, FALSE, E_POINTER}, - {FALSE, DIRECTINPUT_VERSION, &IID_IDirectInput8A, TRUE, DIERR_INVALIDPARAM}, - {FALSE, DIRECTINPUT_VERSION - 1, &IID_IDirectInputA, FALSE, E_POINTER}, - {FALSE, DIRECTINPUT_VERSION - 1, &IID_IDirectInputA, TRUE, DIERR_NOINTERFACE}, - {FALSE, DIRECTINPUT_VERSION - 1, &IID_IDirectInput8A, FALSE, E_POINTER}, - {FALSE, DIRECTINPUT_VERSION - 1, &IID_IDirectInput8A, TRUE, DIERR_INVALIDPARAM}, - {FALSE, DIRECTINPUT_VERSION + 1, &IID_IDirectInputA, FALSE, E_POINTER}, - {FALSE, DIRECTINPUT_VERSION + 1, &IID_IDirectInputA, TRUE, DIERR_NOINTERFACE}, - {FALSE, DIRECTINPUT_VERSION + 1, &IID_IDirectInput8A, FALSE, E_POINTER}, - {FALSE, DIRECTINPUT_VERSION + 1, &IID_IDirectInput8A, TRUE, DIERR_INVALIDPARAM}, - {TRUE, 0, &IID_IDirectInputA, FALSE, E_POINTER}, - {TRUE, 0, &IID_IDirectInputA, TRUE, DIERR_NOINTERFACE}, - {TRUE, 0, &IID_IDirectInput8A, FALSE, E_POINTER}, - {TRUE, 0, &IID_IDirectInput8A, TRUE, DIERR_NOTINITIALIZED}, - {TRUE, DIRECTINPUT_VERSION, &IID_IDirectInputA, FALSE, E_POINTER}, - {TRUE, DIRECTINPUT_VERSION, &IID_IDirectInputA, TRUE, DIERR_NOINTERFACE}, - {TRUE, DIRECTINPUT_VERSION, &IID_IDirectInput8A, FALSE, E_POINTER}, - {TRUE, DIRECTINPUT_VERSION - 1, &IID_IDirectInputA, FALSE, E_POINTER}, - {TRUE, DIRECTINPUT_VERSION - 1, &IID_IDirectInputA, TRUE, DIERR_NOINTERFACE}, - {TRUE, DIRECTINPUT_VERSION - 1, &IID_IDirectInput8A, FALSE, E_POINTER}, - {TRUE, DIRECTINPUT_VERSION - 1, &IID_IDirectInput8A, TRUE, DIERR_BETADIRECTINPUTVERSION}, - {TRUE, DIRECTINPUT_VERSION + 1, &IID_IDirectInputA, FALSE, E_POINTER}, - {TRUE, DIRECTINPUT_VERSION + 1, &IID_IDirectInputA, TRUE, DIERR_NOINTERFACE}, - {TRUE, DIRECTINPUT_VERSION + 1, &IID_IDirectInput8A, FALSE, E_POINTER}, - {TRUE, DIRECTINPUT_VERSION + 1, &IID_IDirectInput8A, TRUE, DIERR_OLDDIRECTINPUTVERSION}, - }; - - static REFIID no_interface_list[] = {&IID_IDirectInputA, &IID_IDirectInputW, - &IID_IDirectInput2A, &IID_IDirectInput2W, - &IID_IDirectInput7A, &IID_IDirectInput7W, - &IID_IDirectInputDeviceA, &IID_IDirectInputDeviceW, - &IID_IDirectInputDevice2A, &IID_IDirectInputDevice2W, - &IID_IDirectInputDevice7A, &IID_IDirectInputDevice7W, - &IID_IDirectInputDevice8A, &IID_IDirectInputDevice8W, - &IID_IDirectInputEffect}; - - static REFIID iid_list[] = {&IID_IUnknown, &IID_IDirectInput8A, &IID_IDirectInput8W}; - - int i; - IUnknown *pUnk; - HRESULT hr; - - for (i = 0; i < ARRAY_SIZE(invalid_param_list); i++) - { - if (invalid_param_list[i].ppdi) pUnk = (void *)0xdeadbeef; - hr = DirectInput8Create(invalid_param_list[i].hinst ? hInstance : NULL, - invalid_param_list[i].dwVersion, - invalid_param_list[i].riid, - invalid_param_list[i].ppdi ? (void **)&pUnk : NULL, - NULL); - ok(hr == invalid_param_list[i].expected_hr, "[%d] DirectInput8Create returned 0x%08x\n", i, hr); - if (invalid_param_list[i].ppdi) - ok(pUnk == NULL, "[%d] Output interface pointer is %p\n", i, pUnk); - } - - for (i = 0; i < ARRAY_SIZE(no_interface_list); i++) - { - pUnk = (void *)0xdeadbeef; - hr = DirectInput8Create(hInstance, DIRECTINPUT_VERSION, no_interface_list[i], (void **)&pUnk, NULL); - ok(hr == DIERR_NOINTERFACE, "[%d] DirectInput8Create returned 0x%08x\n", i, hr); - ok(pUnk == NULL, "[%d] Output interface pointer is %p\n", i, pUnk); - } - - for (i = 0; i < ARRAY_SIZE(iid_list); i++) - { - pUnk = NULL; - hr = DirectInput8Create(hInstance, DIRECTINPUT_VERSION, iid_list[i], (void **)&pUnk, NULL); - ok(hr == DI_OK, "[%d] DirectInput8Create returned 0x%08x\n", i, hr); - ok(pUnk != NULL, "[%d] Output interface pointer is NULL\n", i); - if (pUnk) - IUnknown_Release(pUnk); - } -} - -static void test_QueryInterface(void) -{ - static REFIID iid_list[] = {&IID_IUnknown, &IID_IDirectInput8A, &IID_IDirectInput8W, &IID_IDirectInputJoyConfig8}; - - static REFIID no_interface_list[] = - { - &IID_IDirectInputA, - &IID_IDirectInputW, - &IID_IDirectInput2A, - &IID_IDirectInput2W, - &IID_IDirectInput7A, - &IID_IDirectInput7W, - &IID_IDirectInputDeviceA, - &IID_IDirectInputDeviceW, - &IID_IDirectInputDevice2A, - &IID_IDirectInputDevice2W, - &IID_IDirectInputDevice7A, - &IID_IDirectInputDevice7W, - &IID_IDirectInputDevice8A, - &IID_IDirectInputDevice8W, - &IID_IDirectInputEffect, - }; - - IDirectInput8A *pDI; - HRESULT hr; - IUnknown *pUnk; - int i; - - hr = DirectInput8Create(hInstance, DIRECTINPUT_VERSION, &IID_IDirectInput8A, (void **)&pDI, NULL); - if (FAILED(hr)) - { - win_skip("Failed to instantiate a IDirectInputA instance: 0x%08x\n", hr); - return; - } - - hr = IDirectInput8_QueryInterface(pDI, NULL, NULL); - ok(hr == E_POINTER, "IDirectInput8_QueryInterface returned 0x%08x\n", hr); - - pUnk = (void *)0xdeadbeef; - hr = IDirectInput8_QueryInterface(pDI, NULL, (void **)&pUnk); - ok(hr == E_POINTER, "IDirectInput8_QueryInterface returned 0x%08x\n", hr); - ok(pUnk == (void *)0xdeadbeef, "Output interface pointer is %p\n", pUnk); - - hr = IDirectInput8_QueryInterface(pDI, &IID_IUnknown, NULL); - ok(hr == E_POINTER, "IDirectInput8_QueryInterface returned 0x%08x\n", hr); - - for (i = 0; i < ARRAY_SIZE(iid_list); i++) - { - pUnk = NULL; - hr = IDirectInput8_QueryInterface(pDI, iid_list[i], (void **)&pUnk); - ok(hr == S_OK, "[%d] IDirectInput8_QueryInterface returned 0x%08x\n", i, hr); - ok(pUnk != NULL, "[%d] Output interface pointer is NULL\n", i); - if (pUnk) - { - int j; - for (j = 0; j < ARRAY_SIZE(iid_list); j++) - { - IUnknown *pUnk1 = NULL; - hr = IDirectInput8_QueryInterface(pUnk, iid_list[j], (void **)&pUnk1); - ok(hr == S_OK, "[%d] IDirectInput8_QueryInterface(pUnk) returned 0x%08x\n", j, hr); - ok(pUnk1 != NULL, "[%d] Output interface pointer is NULL\n", i); - if (pUnk1) IUnknown_Release(pUnk1); - } - IUnknown_Release(pUnk); - } - } - - for (i = 0; i < ARRAY_SIZE(no_interface_list); i++) - { - pUnk = (void *)0xdeadbeef; - hr = IDirectInput8_QueryInterface(pDI, no_interface_list[i], (void **)&pUnk); - - ok(hr == E_NOINTERFACE, "[%d] IDirectInput8_QueryInterface returned 0x%08x\n", i, hr); - ok(pUnk == NULL, "[%d] Output interface pointer is %p\n", i, pUnk); - } - - IDirectInput8_Release(pDI); -} - -static void test_CreateDevice(void) -{ - IDirectInput8A *pDI; - HRESULT hr; - IDirectInputDevice8A *pDID; - - hr = DirectInput8Create(hInstance, DIRECTINPUT_VERSION, &IID_IDirectInput8A, (void **)&pDI, NULL); - if (FAILED(hr)) - { - win_skip("Failed to instantiate a IDirectInputA instance: 0x%08x\n", hr); - return; - } - - hr = IDirectInput8_CreateDevice(pDI, NULL, NULL, NULL); - ok(hr == E_POINTER, "IDirectInput8_CreateDevice returned 0x%08x\n", hr); - - pDID = (void *)0xdeadbeef; - hr = IDirectInput8_CreateDevice(pDI, NULL, &pDID, NULL); - ok(hr == E_POINTER, "IDirectInput8_CreateDevice returned 0x%08x\n", hr); - ok(pDID == NULL, "Output interface pointer is %p\n", pDID); - - hr = IDirectInput8_CreateDevice(pDI, &GUID_Unknown, NULL, NULL); - ok(hr == E_POINTER, "IDirectInput8_CreateDevice returned 0x%08x\n", hr); - - pDID = (void *)0xdeadbeef; - hr = IDirectInput8_CreateDevice(pDI, &GUID_Unknown, &pDID, NULL); - ok(hr == DIERR_DEVICENOTREG, "IDirectInput8_CreateDevice returned 0x%08x\n", hr); - ok(pDID == NULL, "Output interface pointer is %p\n", pDID); - - hr = IDirectInput8_CreateDevice(pDI, &GUID_SysMouse, NULL, NULL); - ok(hr == E_POINTER, "IDirectInput8_CreateDevice returned 0x%08x\n", hr); - - hr = IDirectInput8_CreateDevice(pDI, &GUID_SysMouse, &pDID, NULL); - ok(hr == DI_OK, "IDirectInput8_CreateDevice returned 0x%08x\n", hr); - - IDirectInputDevice_Release(pDID); - IDirectInput8_Release(pDI); -} - -struct enum_devices_test -{ - unsigned int device_count; - BOOL return_value; -}; - -static BOOL CALLBACK enum_devices_callback(const DIDEVICEINSTANCEA *instance, void *context) -{ - struct enum_devices_test *enum_test = context; - - trace("---- Device Information ----\n" - "Product Name : %s\n" - "Instance Name : %s\n" - "devType : 0x%08x\n" - "GUID Product : %s\n" - "GUID Instance : %s\n" - "HID Page : 0x%04x\n" - "HID Usage : 0x%04x\n", - instance->tszProductName, - instance->tszInstanceName, - instance->dwDevType, - wine_dbgstr_guid(&instance->guidProduct), - wine_dbgstr_guid(&instance->guidInstance), - instance->wUsagePage, - instance->wUsage); - - if ((instance->dwDevType & 0xff) == DI8DEVTYPE_KEYBOARD || - (instance->dwDevType & 0xff) == DI8DEVTYPE_MOUSE) { - const char *device = ((instance->dwDevType & 0xff) == - DI8DEVTYPE_KEYBOARD) ? "Keyboard" : "Mouse"; - ok(IsEqualGUID(&instance->guidInstance, &instance->guidProduct), - "%s guidInstance (%s) does not match guidProduct (%s)\n", - device, wine_dbgstr_guid(&instance->guidInstance), - wine_dbgstr_guid(&instance->guidProduct)); - } - - enum_test->device_count++; - return enum_test->return_value; -} - -static void test_EnumDevices(void) -{ - IDirectInput8A *pDI; - HRESULT hr; - struct enum_devices_test enum_test, enum_test_return; - - hr = DirectInput8Create(hInstance, DIRECTINPUT_VERSION, &IID_IDirectInput8A, (void **)&pDI, NULL); - if (FAILED(hr)) - { - win_skip("Failed to instantiate a IDirectInputA instance: 0x%08x\n", hr); - return; - } - - hr = IDirectInput8_EnumDevices(pDI, 0, NULL, NULL, 0); - ok(hr == DIERR_INVALIDPARAM, "IDirectInput8_EnumDevices returned 0x%08x\n", hr); - - hr = IDirectInput8_EnumDevices(pDI, 0, NULL, NULL, ~0u); - ok(hr == DIERR_INVALIDPARAM, "IDirectInput8_EnumDevices returned 0x%08x\n", hr); - - /* Test crashes on Wine. */ - if (0) - { - hr = IDirectInput8_EnumDevices(pDI, 0, enum_devices_callback, NULL, ~0u); - ok(hr == DIERR_INVALIDPARAM, "IDirectInput8_EnumDevices returned 0x%08x\n", hr); - } - - hr = IDirectInput8_EnumDevices(pDI, 0xdeadbeef, NULL, NULL, 0); - ok(hr == DIERR_INVALIDPARAM, "IDirectInput8_EnumDevices returned 0x%08x\n", hr); - - hr = IDirectInput8_EnumDevices(pDI, 0xdeadbeef, NULL, NULL, ~0u); - ok(hr == DIERR_INVALIDPARAM, "IDirectInput8_EnumDevices returned 0x%08x\n", hr); - - hr = IDirectInput8_EnumDevices(pDI, 0xdeadbeef, enum_devices_callback, NULL, 0); - ok(hr == DIERR_INVALIDPARAM, "IDirectInput8_EnumDevices returned 0x%08x\n", hr); - - hr = IDirectInput8_EnumDevices(pDI, 0xdeadbeef, enum_devices_callback, NULL, ~0u); - ok(hr == DIERR_INVALIDPARAM, "IDirectInput8_EnumDevices returned 0x%08x\n", hr); - - enum_test.device_count = 0; - enum_test.return_value = DIENUM_CONTINUE; - hr = IDirectInput8_EnumDevices(pDI, 0, enum_devices_callback, &enum_test, 0); - ok(hr == DI_OK, "IDirectInput8_EnumDevices returned 0x%08x\n", hr); - ok(enum_test.device_count != 0, "Device count is %u\n", enum_test.device_count); - - /* Enumeration only stops with an explicit DIENUM_STOP. */ - enum_test_return.device_count = 0; - enum_test_return.return_value = 42; - hr = IDirectInput8_EnumDevices(pDI, 0, enum_devices_callback, &enum_test_return, 0); - ok(hr == DI_OK, "IDirectInput8_EnumDevices returned 0x%08x\n", hr); - ok(enum_test_return.device_count == enum_test.device_count, - "Device count is %u vs. %u\n", enum_test_return.device_count, enum_test.device_count); - - enum_test.device_count = 0; - enum_test.return_value = DIENUM_STOP; - hr = IDirectInput8_EnumDevices(pDI, 0, enum_devices_callback, &enum_test, 0); - ok(hr == DI_OK, "IDirectInput8_EnumDevices returned 0x%08x\n", hr); - ok(enum_test.device_count == 1, "Device count is %u\n", enum_test.device_count); - - IDirectInput8_Release(pDI); -} - -struct enum_semantics_test -{ - unsigned int device_count; - DWORD first_remaining; - BOOL mouse; - BOOL keyboard; - DIACTIONFORMATA *lpdiaf; - const char* username; -}; - -static DIACTIONA actionMapping[]= -{ - /* axis */ - { 0, 0x01008A01 /* DIAXIS_DRIVINGR_STEER */, 0, { "Steer.\0" } }, - /* button */ - { 1, 0x01000C01 /* DIBUTTON_DRIVINGR_SHIFTUP */, 0, { "Upshift.\0" } }, - /* keyboard key */ - { 2, DIKEYBOARD_SPACE, 0, { "Missile.\0" } }, - /* mouse button */ - { 3, DIMOUSE_BUTTON0, 0, { "Select\0" } }, - /* mouse axis */ - { 4, DIMOUSE_YAXIS, 0, { "Y Axis\0" } } -}; -/* By placing the memory pointed to by lptszActionName right before memory with PAGE_NOACCESS - * one can find out that the regular ansi string termination is not respected by EnumDevicesBySemantics. - * Adding a double termination, making it a valid wide string termination, made the test succeed. - * Therefore it looks like ansi version of EnumDevicesBySemantics forwards the string to - * the wide variant without conversation. */ - -static BOOL CALLBACK enum_semantics_callback(const DIDEVICEINSTANCEA *lpddi, IDirectInputDevice8A *lpdid, DWORD dwFlags, DWORD dwRemaining, void *context) -{ - struct enum_semantics_test *data = context; - - if (context == NULL) return DIENUM_STOP; - - if (!data->device_count) { - data->first_remaining = dwRemaining; - } - ok (dwRemaining == data->first_remaining - data->device_count, - "enum semantics remaining devices is wrong, expected %d, had %d\n", - data->first_remaining - data->device_count, dwRemaining); - data->device_count++; - - if (IsEqualGUID(&lpddi->guidInstance, &GUID_SysKeyboard)) data->keyboard = TRUE; - - if (IsEqualGUID(&lpddi->guidInstance, &GUID_SysMouse)) data->mouse = TRUE; - - return DIENUM_CONTINUE; -} - -static BOOL CALLBACK set_action_map_callback(const DIDEVICEINSTANCEA *lpddi, IDirectInputDevice8A *lpdid, DWORD dwFlags, DWORD dwRemaining, void *context) -{ - HRESULT hr; - struct enum_semantics_test *data = context; - - /* Building and setting an action map */ - /* It should not use any pre-stored mappings so we use DIDBAM_INITIALIZE */ - hr = IDirectInputDevice8_BuildActionMap(lpdid, data->lpdiaf, NULL, DIDBAM_INITIALIZE); - ok (SUCCEEDED(hr), "BuildActionMap failed hr=%08x\n", hr); - - hr = IDirectInputDevice8_SetActionMap(lpdid, data->lpdiaf, data->username, 0); - ok (SUCCEEDED(hr), "SetActionMap failed hr=%08x\n", hr); - - return DIENUM_CONTINUE; -} - -static void test_EnumDevicesBySemantics(void) -{ - IDirectInput8A *pDI; - HRESULT hr; - DIACTIONFORMATA diaf; - const GUID ACTION_MAPPING_GUID = { 0x1, 0x2, 0x3, { 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb } }; - struct enum_semantics_test data = { 0, 0, FALSE, FALSE, &diaf, NULL }; - int device_total = 0; - - hr = DirectInput8Create(hInstance, DIRECTINPUT_VERSION, &IID_IDirectInput8A, (void **)&pDI, NULL); - if (FAILED(hr)) - { - win_skip("Failed to instantiate a IDirectInputA instance: 0x%08x\n", hr); - return; - } - - memset (&diaf, 0, sizeof(diaf)); - diaf.dwSize = sizeof(diaf); - diaf.dwActionSize = sizeof(DIACTIONA); - diaf.dwNumActions = ARRAY_SIZE(actionMapping); - diaf.dwDataSize = 4 * diaf.dwNumActions; - diaf.rgoAction = actionMapping; - diaf.guidActionMap = ACTION_MAPPING_GUID; - diaf.dwGenre = 0x01000000; /* DIVIRTUAL_DRIVING_RACE */ - diaf.dwBufferSize = 32; - - /* Test enumerating all attached and installed devices */ - data.keyboard = FALSE; - data.mouse = FALSE; - data.device_count = 0; - hr = IDirectInput8_EnumDevicesBySemantics(pDI, NULL, &diaf, enum_semantics_callback, &data, DIEDBSFL_ATTACHEDONLY); - ok (data.device_count > 0, "EnumDevicesBySemantics did not call the callback hr=%08x\n", hr); - ok (data.keyboard, "EnumDevicesBySemantics should enumerate the keyboard\n"); - ok (data.mouse, "EnumDevicesBySemantics should enumerate the mouse\n"); - - /* Enumerate Force feedback devices. We should get no mouse nor keyboard */ - data.keyboard = FALSE; - data.mouse = FALSE; - data.device_count = 0; - hr = IDirectInput8_EnumDevicesBySemantics(pDI, NULL, &diaf, enum_semantics_callback, &data, DIEDBSFL_FORCEFEEDBACK); - ok (SUCCEEDED(hr), "EnumDevicesBySemantics failed hr=%08x\n", hr); - ok (!data.keyboard, "Keyboard should not be enumerated when asking for forcefeedback\n"); - ok (!data.mouse, "Mouse should not be enumerated when asking for forcefeedback\n"); - - /* Enumerate available devices. That is devices not owned by any user. - Before setting the action map for all devices we still have them available. */ - data.device_count = 0; - hr = IDirectInput8_EnumDevicesBySemantics(pDI, NULL, &diaf, enum_semantics_callback, &data, DIEDBSFL_AVAILABLEDEVICES); - ok (SUCCEEDED(hr), "EnumDevicesBySemantics failed hr=%08x\n", hr); - ok (data.device_count > 0, "There should be devices available before action mapping available=%d\n", data.device_count); - - /* Keep the device total */ - device_total = data.device_count; - - /* There should be no devices for any user. No device should be enumerated with DIEDBSFL_THISUSER. - MSDN defines that all unowned devices are also enumerated but this doesn't seem to be happening. */ - data.device_count = 0; - hr = IDirectInput8_EnumDevicesBySemantics(pDI, "Sh4d0w M4g3", &diaf, enum_semantics_callback, &data, DIEDBSFL_THISUSER); - ok (SUCCEEDED(hr), "EnumDevicesBySemantics failed hr=%08x\n", hr); - ok (data.device_count == 0, "No devices should be assigned for this user assigned=%d\n", data.device_count); - - /* This enumeration builds and sets the action map for all devices with a NULL username */ - hr = IDirectInput8_EnumDevicesBySemantics(pDI, NULL, &diaf, set_action_map_callback, &data, DIEDBSFL_ATTACHEDONLY); - ok (SUCCEEDED(hr), "EnumDevicesBySemantics failed: hr=%08x\n", hr); - - /* After a successful action mapping we should have no devices available */ - data.device_count = 0; - hr = IDirectInput8_EnumDevicesBySemantics(pDI, NULL, &diaf, enum_semantics_callback, &data, DIEDBSFL_AVAILABLEDEVICES); - ok (SUCCEEDED(hr), "EnumDevicesBySemantics failed hr=%08x\n", hr); - ok (data.device_count == 0, "No device should be available after action mapping available=%d\n", data.device_count); - - /* Now we'll give all the devices to a specific user */ - data.username = "Sh4d0w M4g3"; - hr = IDirectInput8_EnumDevicesBySemantics(pDI, NULL, &diaf, set_action_map_callback, &data, DIEDBSFL_ATTACHEDONLY); - ok (SUCCEEDED(hr), "EnumDevicesBySemantics failed: hr=%08x\n", hr); - - /* Testing with the default user, DIEDBSFL_THISUSER has no effect */ - data.device_count = 0; - hr = IDirectInput8_EnumDevicesBySemantics(pDI, NULL, &diaf, enum_semantics_callback, &data, DIEDBSFL_THISUSER); - ok (SUCCEEDED(hr), "EnumDevicesBySemantics failed hr=%08x\n", hr); - ok (data.device_count == device_total, "THISUSER has no effect with NULL username owned=%d, expected=%d\n", data.device_count, device_total); - - /* Using an empty user string is the same as passing NULL, DIEDBSFL_THISUSER has no effect */ - data.device_count = 0; - hr = IDirectInput8_EnumDevicesBySemantics(pDI, "", &diaf, enum_semantics_callback, &data, DIEDBSFL_THISUSER); - ok (SUCCEEDED(hr), "EnumDevicesBySemantics failed hr=%08x\n", hr); - ok (data.device_count == device_total, "THISUSER has no effect with "" as username owned=%d, expected=%d\n", data.device_count, device_total); - - /* Testing with a user with no ownership of the devices */ - data.device_count = 0; - hr = IDirectInput8_EnumDevicesBySemantics(pDI, "Ninja Brian", &diaf, enum_semantics_callback, &data, DIEDBSFL_THISUSER); - ok (SUCCEEDED(hr), "EnumDevicesBySemantics failed hr=%08x\n", hr); - ok (data.device_count == 0, "This user should own no devices owned=%d\n", data.device_count); - - /* Sh4d0w M4g3 has ownership of all devices */ - data.device_count = 0; - hr = IDirectInput8_EnumDevicesBySemantics(pDI, "Sh4d0w M4g3", &diaf, enum_semantics_callback, &data, DIEDBSFL_THISUSER); - ok (SUCCEEDED(hr), "EnumDevicesBySemantics failed hr=%08x\n", hr); - ok (data.device_count == device_total, "This user should own %d devices owned=%d\n", device_total, data.device_count); - - /* The call fails with a zeroed GUID */ - memset(&diaf.guidActionMap, 0, sizeof(GUID)); - data.device_count = 0; - hr = IDirectInput8_EnumDevicesBySemantics(pDI, NULL, &diaf, enum_semantics_callback, NULL, 0); - todo_wine ok(FAILED(hr), "EnumDevicesBySemantics succeeded with invalid GUID hr=%08x\n", hr); - - IDirectInput8_Release(pDI); -} - -static void test_GetDeviceStatus(void) -{ - IDirectInput8A *pDI; - HRESULT hr; - - hr = DirectInput8Create(hInstance, DIRECTINPUT_VERSION, &IID_IDirectInput8A, (void **)&pDI, NULL); - if (FAILED(hr)) - { - win_skip("Failed to instantiate a IDirectInputA instance: 0x%08x\n", hr); - return; - } - - hr = IDirectInput8_GetDeviceStatus(pDI, NULL); - ok(hr == E_POINTER, "IDirectInput8_GetDeviceStatus returned 0x%08x\n", hr); - - hr = IDirectInput8_GetDeviceStatus(pDI, &GUID_Unknown); - todo_wine - ok(hr == DIERR_DEVICENOTREG, "IDirectInput8_GetDeviceStatus returned 0x%08x\n", hr); - - hr = IDirectInput8_GetDeviceStatus(pDI, &GUID_SysMouse); - ok(hr == DI_OK, "IDirectInput8_GetDeviceStatus returned 0x%08x\n", hr); - - IDirectInput8_Release(pDI); -} - -static void test_RunControlPanel(void) -{ - IDirectInput8A *pDI; - HRESULT hr; - - hr = DirectInput8Create(hInstance, DIRECTINPUT_VERSION, &IID_IDirectInput8A, (void **)&pDI, NULL); - if (FAILED(hr)) - { - win_skip("Failed to instantiate a IDirectInputA instance: 0x%08x\n", hr); - return; - } - - if (winetest_interactive) - { - hr = IDirectInput8_RunControlPanel(pDI, NULL, 0); - ok(hr == S_OK, "IDirectInput8_RunControlPanel returned 0x%08x\n", hr); - - hr = IDirectInput8_RunControlPanel(pDI, GetDesktopWindow(), 0); - ok(hr == S_OK, "IDirectInput8_RunControlPanel returned 0x%08x\n", hr); - } - - hr = IDirectInput8_RunControlPanel(pDI, NULL, ~0u); - ok(hr == DIERR_INVALIDPARAM, "IDirectInput8_RunControlPanel returned 0x%08x\n", hr); - - hr = IDirectInput8_RunControlPanel(pDI, (HWND)0xdeadbeef, 0); - ok(hr == E_HANDLE, "IDirectInput8_RunControlPanel returned 0x%08x\n", hr); - - hr = IDirectInput8_RunControlPanel(pDI, (HWND)0xdeadbeef, ~0u); - ok(hr == E_HANDLE, "IDirectInput8_RunControlPanel returned 0x%08x\n", hr); - - IDirectInput8_Release(pDI); -} - -static void test_Initialize(void) -{ - IDirectInput8A *pDI; - HRESULT hr; - - hr = DirectInput8Create(hInstance, DIRECTINPUT_VERSION, &IID_IDirectInput8A, (void **)&pDI, NULL); - if (FAILED(hr)) - { - win_skip("Failed to instantiate a IDirectInputA instance: 0x%08x\n", hr); - return; - } - - hr = IDirectInput8_Initialize(pDI, NULL, 0); - ok(hr == DIERR_INVALIDPARAM, "IDirectInput8_Initialize returned 0x%08x\n", hr); - - hr = IDirectInput8_Initialize(pDI, NULL, DIRECTINPUT_VERSION); - ok(hr == DIERR_INVALIDPARAM, "IDirectInput8_Initialize returned 0x%08x\n", hr); - - hr = IDirectInput8_Initialize(pDI, hInstance, 0); - ok(hr == DIERR_NOTINITIALIZED, "IDirectInput8_Initialize returned 0x%08x\n", hr); - - /* Invalid DirectInput versions less than DIRECTINPUT_VERSION yield DIERR_BETADIRECTINPUTVERSION. */ - hr = IDirectInput8_Initialize(pDI, hInstance, DIRECTINPUT_VERSION - 1); - ok(hr == DIERR_BETADIRECTINPUTVERSION, "IDirectInput8_Initialize returned 0x%08x\n", hr); - - /* Invalid DirectInput versions greater than DIRECTINPUT_VERSION yield DIERR_BETADIRECTINPUTVERSION. */ - hr = IDirectInput8_Initialize(pDI, hInstance, DIRECTINPUT_VERSION + 1); - ok(hr == DIERR_OLDDIRECTINPUTVERSION, "IDirectInput8_Initialize returned 0x%08x\n", hr); - - hr = IDirectInput8_Initialize(pDI, hInstance, DIRECTINPUT_VERSION); - ok(hr == DI_OK, "IDirectInput8_Initialize returned 0x%08x\n", hr); - - /* Parameters are still validated after successful initialization. */ - hr = IDirectInput8_Initialize(pDI, hInstance, 0); - ok(hr == DIERR_NOTINITIALIZED, "IDirectInput8_Initialize returned 0x%08x\n", hr); - - IDirectInput8_Release(pDI); -} - -START_TEST(dinput8) -{ - hInstance = GetModuleHandleA(NULL); - - CoInitialize(NULL); - test_preinitialization(); - test_DirectInput8Create(); - test_QueryInterface(); - test_CreateDevice(); - test_EnumDevices(); - test_EnumDevicesBySemantics(); - test_GetDeviceStatus(); - test_RunControlPanel(); - test_Initialize(); - CoUninitialize(); -}
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/tests/dinput.c | 67 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+)
diff --git a/dlls/dinput/tests/dinput.c b/dlls/dinput/tests/dinput.c index 795a9ed39c6..a2c7f5dbd8d 100644 --- a/dlls/dinput/tests/dinput.c +++ b/dlls/dinput/tests/dinput.c @@ -76,6 +76,41 @@ static BOOL CALLBACK dummy_callback(const DIDEVICEINSTANCEA *instance, void *con return DIENUM_STOP; }
+static HRESULT WINAPI outer_QueryInterface( IUnknown *iface, REFIID iid, void **obj ) +{ + ok( 0, "unexpected call %s\n", debugstr_guid( iid ) ); + + if (IsEqualGUID( iid, &IID_IUnknown )) + { + *obj = (IUnknown *)iface; + return S_OK; + } + + ok( 0, "unexpected call %s\n", debugstr_guid( iid ) ); + return E_NOINTERFACE; +} + +static ULONG WINAPI outer_AddRef( IUnknown *iface ) +{ + ok( 0, "unexpected call\n" ); + return 2; +} + +static ULONG WINAPI outer_Release( IUnknown *iface ) +{ + ok( 0, "unexpected call\n" ); + return 1; +} + +static IUnknownVtbl outer_vtbl = +{ + outer_QueryInterface, + outer_AddRef, + outer_Release, +}; + +static IUnknown outer = {&outer_vtbl}; + static void test_CoCreateInstance( DWORD version ) { static const struct @@ -113,6 +148,7 @@ static void test_CoCreateInstance( DWORD version )
IDirectInputDeviceA *device; IDirectInputA *dinput; + IUnknown *unknown; HRESULT hr; LONG ref; int i; @@ -127,6 +163,14 @@ static void test_CoCreateInstance( DWORD version ) return; }
+ if (version < 0x800) hr = CoCreateInstance( &CLSID_DirectInput, &outer, CLSCTX_INPROC_SERVER, + &IID_IDirectInputA, (void **)&unknown ); + else hr = CoCreateInstance( &CLSID_DirectInput8, &outer, CLSCTX_INPROC_SERVER, + &IID_IDirectInput8A, (void **)&unknown ); + todo_wine + ok( hr == CLASS_E_NOAGGREGATION, "CoCreateInstance returned %#x\n", hr ); + if (SUCCEEDED( hr )) IUnknown_Release( unknown ); + for (i = 0; i < ARRAY_SIZE(create_device_tests); i++) { winetest_push_context( "%u", i ); @@ -204,6 +248,14 @@ static void test_DirectInputCreate( DWORD version ) HRESULT hr; int i;
+ unknown = (void *)0xdeadbeef; + hr = DirectInputCreateW( hInstance, version, (IDirectInputW **)&unknown, &outer ); + todo_wine_if(version == 0x800) + ok( hr == DI_OK, "DirectInputCreateW returned %#x\n", hr ); + todo_wine_if(version <= 0x700) + ok( unknown == NULL, "got IUnknown %p\n", unknown ); + if (unknown) IUnknown_Release( unknown ); + for (i = 0; i < ARRAY_SIZE(create_tests); i++) { winetest_push_context( "%u", i ); @@ -271,6 +323,14 @@ static void test_DirectInputCreateEx( DWORD version ) return; }
+ unknown = (void *)0xdeadbeef; + hr = pDirectInputCreateEx( hInstance, version, &IID_IDirectInputW, (void **)&unknown, &outer ); + todo_wine_if(version == 0x800) + ok( hr == DI_OK, "DirectInputCreateW returned %#x\n", hr ); + todo_wine_if(version <= 0x700) + ok( unknown == NULL, "got IUnknown %p\n", unknown ); + if (unknown) IUnknown_Release( unknown ); + for (i = 0; i < ARRAY_SIZE(create_tests); i++) { winetest_push_context( "%u", i ); @@ -356,6 +416,13 @@ static void test_DirectInput8Create( DWORD version ) HRESULT hr; int i;
+ unknown = (void *)0xdeadbeef; + hr = DirectInput8Create( hInstance, version, &IID_IDirectInput8W, (void **)&unknown, &outer ); + ok( hr == DI_OK, "DirectInputCreateW returned %#x\n", hr ); + todo_wine + ok( unknown == NULL, "got IUnknown %p\n", unknown ); + if (unknown) IUnknown_Release( unknown ); + for (i = 0; i < ARRAY_SIZE(create_tests); i++) { winetest_push_context( "%u", i );
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/dinput_main.c | 155 +++++++++++++++++++------------------ dlls/dinput/tests/dinput.c | 1 - 2 files changed, 80 insertions(+), 76 deletions(-)
diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c index dbb727c3c43..2172eb32ee9 100644 --- a/dlls/dinput/dinput_main.c +++ b/dlls/dinput/dinput_main.c @@ -1089,90 +1089,95 @@ static const IDirectInputJoyConfig8Vtbl JoyConfig8vt = JoyConfig8Impl_OpenAppStatusKey };
-/******************************************************************************* - * DirectInput ClassFactory - */ -typedef struct +struct class_factory { - /* IUnknown fields */ IClassFactory IClassFactory_iface; - LONG ref; -} IClassFactoryImpl; - -static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface) -{ - return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface); -} - -static HRESULT WINAPI DICF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) { - IClassFactoryImpl *This = impl_from_IClassFactory(iface); - - FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj); - return E_NOINTERFACE; -} - -static ULONG WINAPI DICF_AddRef(LPCLASSFACTORY iface) { - IClassFactoryImpl *This = impl_from_IClassFactory(iface); - return InterlockedIncrement(&(This->ref)); -} - -static ULONG WINAPI DICF_Release(LPCLASSFACTORY iface) { - IClassFactoryImpl *This = impl_from_IClassFactory(iface); - /* static class, won't be freed */ - return InterlockedDecrement(&(This->ref)); -} - -static HRESULT WINAPI DICF_CreateInstance( - LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj -) { - IClassFactoryImpl *This = impl_from_IClassFactory(iface); - - TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj); - if ( IsEqualGUID( &IID_IUnknown, riid ) || - IsEqualGUID( &IID_IDirectInputA, riid ) || - IsEqualGUID( &IID_IDirectInputW, riid ) || - IsEqualGUID( &IID_IDirectInput2A, riid ) || - IsEqualGUID( &IID_IDirectInput2W, riid ) || - IsEqualGUID( &IID_IDirectInput7A, riid ) || - IsEqualGUID( &IID_IDirectInput7W, riid ) || - IsEqualGUID( &IID_IDirectInput8A, riid ) || - IsEqualGUID( &IID_IDirectInput8W, riid ) ) - { - return create_directinput_instance(riid, ppobj, NULL); - } - - FIXME("(%p,%p,%s,%p) Interface not found!\n",This,pOuter,debugstr_guid(riid),ppobj); - return E_NOINTERFACE; -} - -static HRESULT WINAPI DICF_LockServer(LPCLASSFACTORY iface,BOOL dolock) { - IClassFactoryImpl *This = impl_from_IClassFactory(iface); - FIXME("(%p)->(%d),stub!\n",This,dolock); - return S_OK; -} - -static const IClassFactoryVtbl DICF_Vtbl = { - DICF_QueryInterface, - DICF_AddRef, - DICF_Release, - DICF_CreateInstance, - DICF_LockServer }; -static IClassFactoryImpl DINPUT_CF = {{&DICF_Vtbl}, 1 }; + +static inline struct class_factory *impl_from_IClassFactory( IClassFactory *iface ) +{ + return CONTAINING_RECORD( iface, struct class_factory, IClassFactory_iface ); +} + +static HRESULT WINAPI class_factory_QueryInterface( IClassFactory *iface, REFIID iid, void **out ) +{ + struct class_factory *impl = impl_from_IClassFactory(iface); + + TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out); + + if (IsEqualGUID(iid, &IID_IUnknown) || + IsEqualGUID(iid, &IID_IClassFactory)) + *out = &impl->IClassFactory_iface; + else + { + *out = NULL; + WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid)); + return E_NOINTERFACE; + } + + IUnknown_AddRef((IUnknown *)*out); + return S_OK; +} + +static ULONG WINAPI class_factory_AddRef( IClassFactory *iface ) +{ + return 2; +} + +static ULONG WINAPI class_factory_Release( IClassFactory *iface ) +{ + return 1; +} + +static HRESULT WINAPI class_factory_CreateInstance( IClassFactory *iface, IUnknown *outer, REFIID iid, void **out ) +{ + IUnknown *unknown; + HRESULT hr; + + TRACE( "iface %p, outer %p, iid %s, out %p.\n", iface, outer, debugstr_guid( iid ), out ); + + if (outer) return CLASS_E_NOAGGREGATION; + + if (FAILED(hr = create_directinput_instance( &IID_IUnknown, (void **)&unknown, NULL ))) return hr; + hr = IUnknown_QueryInterface( unknown, iid, out ); + IUnknown_Release( unknown ); + + return hr; +} + +static HRESULT WINAPI class_factory_LockServer( IClassFactory *iface, BOOL lock ) +{ + FIXME( "iface %p, lock %d stub!\n", iface, lock ); + return S_OK; +} + +static const IClassFactoryVtbl class_factory_vtbl = +{ + class_factory_QueryInterface, + class_factory_AddRef, + class_factory_Release, + class_factory_CreateInstance, + class_factory_LockServer, +}; + +static struct class_factory class_factory = {{&class_factory_vtbl}};
/*********************************************************************** * DllGetClassObject (DINPUT.@) */ -HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) +HRESULT WINAPI DllGetClassObject( REFCLSID clsid, REFIID iid, void **out ) { - TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv); - if ( IsEqualCLSID( &IID_IClassFactory, riid ) ) { - *ppv = &DINPUT_CF; - IClassFactory_AddRef((IClassFactory*)*ppv); - return S_OK; - } + TRACE( "clsid %s, iid %s, out %p.\n", debugstr_guid( clsid ), debugstr_guid( iid ), out );
- FIXME("(%s,%s,%p): no interface found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv); +#if DIRECTINPUT_VERSION == 0x0700 + if (IsEqualCLSID( &CLSID_DirectInput, clsid )) + return IClassFactory_QueryInterface( &class_factory.IClassFactory_iface, iid, out ); +#else + if (IsEqualCLSID( &CLSID_DirectInput8, clsid )) + return IClassFactory_QueryInterface( &class_factory.IClassFactory_iface, iid, out ); +#endif + + WARN( "%s not implemented, returning CLASS_E_CLASSNOTAVAILABLE.\n", debugstr_guid( clsid ) ); return CLASS_E_CLASSNOTAVAILABLE; }
diff --git a/dlls/dinput/tests/dinput.c b/dlls/dinput/tests/dinput.c index a2c7f5dbd8d..0b3ce276e52 100644 --- a/dlls/dinput/tests/dinput.c +++ b/dlls/dinput/tests/dinput.c @@ -167,7 +167,6 @@ static void test_CoCreateInstance( DWORD version ) &IID_IDirectInputA, (void **)&unknown ); else hr = CoCreateInstance( &CLSID_DirectInput8, &outer, CLSCTX_INPROC_SERVER, &IID_IDirectInput8A, (void **)&unknown ); - todo_wine ok( hr == CLASS_E_NOAGGREGATION, "CoCreateInstance returned %#x\n", hr ); if (SUCCEEDED( hr )) IUnknown_Release( unknown );
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/dinput_main.c | 135 +++++++++++++++++++------------------- 1 file changed, 69 insertions(+), 66 deletions(-)
diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c index 2172eb32ee9..0be9c23cd75 100644 --- a/dlls/dinput/dinput_main.c +++ b/dlls/dinput/dinput_main.c @@ -57,7 +57,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(dinput);
static const IDirectInput7WVtbl ddi7wvt; static const IDirectInput8WVtbl ddi8wvt; -static const IDirectInputJoyConfig8Vtbl JoyConfig8vt; +static const IDirectInputJoyConfig8Vtbl joy_config_vtbl;
static inline IDirectInputImpl *impl_from_IDirectInput7W( IDirectInput7W *iface ) { @@ -149,7 +149,7 @@ static HRESULT create_directinput_instance(REFIID riid, LPVOID *ppDI, IDirectInp This->IDirectInput7W_iface.lpVtbl = &ddi7wvt; This->IDirectInput8A_iface.lpVtbl = &dinput8_a_vtbl; This->IDirectInput8W_iface.lpVtbl = &ddi8wvt; - This->IDirectInputJoyConfig8_iface.lpVtbl = &JoyConfig8vt; + This->IDirectInputJoyConfig8_iface.lpVtbl = &joy_config_vtbl;
hr = IDirectInput_QueryInterface( &This->IDirectInput7A_iface, riid, ppDI ); if (FAILED(hr)) @@ -894,70 +894,72 @@ static inline IDirectInputImpl *impl_from_IDirectInputJoyConfig8(IDirectInputJoy return CONTAINING_RECORD( iface, IDirectInputImpl, IDirectInputJoyConfig8_iface ); }
-static HRESULT WINAPI JoyConfig8Impl_QueryInterface(IDirectInputJoyConfig8 *iface, REFIID riid, void** ppobj) +static HRESULT WINAPI joy_config_QueryInterface( IDirectInputJoyConfig8 *iface, REFIID iid, void **out ) { - IDirectInputImpl *This = impl_from_IDirectInputJoyConfig8( iface ); - return IDirectInput_QueryInterface( &This->IDirectInput7W_iface, riid, ppobj ); + IDirectInputImpl *impl = impl_from_IDirectInputJoyConfig8( iface ); + return IDirectInput7_QueryInterface( &impl->IDirectInput7W_iface, iid, out ); }
-static ULONG WINAPI JoyConfig8Impl_AddRef(IDirectInputJoyConfig8 *iface) +static ULONG WINAPI joy_config_AddRef( IDirectInputJoyConfig8 *iface ) { - IDirectInputImpl *This = impl_from_IDirectInputJoyConfig8( iface ); - return IDirectInput_AddRef( &This->IDirectInput7W_iface ); + IDirectInputImpl *impl = impl_from_IDirectInputJoyConfig8( iface ); + return IDirectInput7_AddRef( &impl->IDirectInput7W_iface ); }
-static ULONG WINAPI JoyConfig8Impl_Release(IDirectInputJoyConfig8 *iface) +static ULONG WINAPI joy_config_Release( IDirectInputJoyConfig8 *iface ) { - IDirectInputImpl *This = impl_from_IDirectInputJoyConfig8( iface ); - return IDirectInput_Release( &This->IDirectInput7W_iface ); + IDirectInputImpl *impl = impl_from_IDirectInputJoyConfig8( iface ); + return IDirectInput7_Release( &impl->IDirectInput7W_iface ); }
-static HRESULT WINAPI JoyConfig8Impl_Acquire(IDirectInputJoyConfig8 *iface) +static HRESULT WINAPI joy_config_Acquire( IDirectInputJoyConfig8 *iface ) { - FIXME( "(%p): stub!\n", iface ); + FIXME( "iface %p stub!\n", iface ); return E_NOTIMPL; }
-static HRESULT WINAPI JoyConfig8Impl_Unacquire(IDirectInputJoyConfig8 *iface) +static HRESULT WINAPI joy_config_Unacquire( IDirectInputJoyConfig8 *iface ) { - FIXME( "(%p): stub!\n", iface ); + FIXME( "iface %p stub!\n", iface ); return E_NOTIMPL; }
-static HRESULT WINAPI JoyConfig8Impl_SetCooperativeLevel(IDirectInputJoyConfig8 *iface, HWND hwnd, DWORD flags) +static HRESULT WINAPI joy_config_SetCooperativeLevel( IDirectInputJoyConfig8 *iface, HWND hwnd, DWORD flags ) { - FIXME( "(%p)->(%p, 0x%08x): stub!\n", iface, hwnd, flags ); + FIXME( "iface %p, hwnd %p, flags %#x stub!\n", iface, hwnd, flags ); return E_NOTIMPL; }
-static HRESULT WINAPI JoyConfig8Impl_SendNotify(IDirectInputJoyConfig8 *iface) +static HRESULT WINAPI joy_config_SendNotify( IDirectInputJoyConfig8 *iface ) { - FIXME( "(%p): stub!\n", iface ); + FIXME( "iface %p stub!\n", iface ); return E_NOTIMPL; }
-static HRESULT WINAPI JoyConfig8Impl_EnumTypes(IDirectInputJoyConfig8 *iface, LPDIJOYTYPECALLBACK cb, void *ref) +static HRESULT WINAPI joy_config_EnumTypes( IDirectInputJoyConfig8 *iface, LPDIJOYTYPECALLBACK callback, void *context ) { - FIXME( "(%p)->(%p, %p): stub!\n", iface, cb, ref ); + FIXME( "iface %p, callback %p, context %p stub!\n", iface, callback, context ); return E_NOTIMPL; }
-static HRESULT WINAPI JoyConfig8Impl_GetTypeInfo(IDirectInputJoyConfig8 *iface, LPCWSTR name, LPDIJOYTYPEINFO info, DWORD flags) +static HRESULT WINAPI joy_config_GetTypeInfo( IDirectInputJoyConfig8 *iface, const WCHAR *name, + DIJOYTYPEINFO *info, DWORD flags ) { - FIXME( "(%p)->(%s, %p, 0x%08x): stub!\n", iface, debugstr_w(name), info, flags ); + FIXME( "iface %p, name %s, info %p, flags %#x stub!\n", iface, debugstr_w(name), info, flags ); return E_NOTIMPL; }
-static HRESULT WINAPI JoyConfig8Impl_SetTypeInfo(IDirectInputJoyConfig8 *iface, LPCWSTR name, LPCDIJOYTYPEINFO info, DWORD flags, - LPWSTR new_name) +static HRESULT WINAPI joy_config_SetTypeInfo( IDirectInputJoyConfig8 *iface, const WCHAR *name, + const DIJOYTYPEINFO *info, DWORD flags, WCHAR *new_name ) { - FIXME( "(%p)->(%s, %p, 0x%08x, %s): stub!\n", iface, debugstr_w(name), info, flags, debugstr_w(new_name) ); + FIXME( "iface %p, name %s, info %p, flags %#x, new_name %s stub!\n", + iface, debugstr_w(name), info, flags, debugstr_w(new_name) ); return E_NOTIMPL; }
-static HRESULT WINAPI JoyConfig8Impl_DeleteType(IDirectInputJoyConfig8 *iface, LPCWSTR name) +static HRESULT WINAPI joy_config_DeleteType( IDirectInputJoyConfig8 *iface, const WCHAR *name ) { - FIXME( "(%p)->(%s): stub!\n", iface, debugstr_w(name) ); + FIXME( "iface %p, name %s stub!\n", iface, debugstr_w(name) ); return E_NOTIMPL; }
@@ -975,13 +977,13 @@ static BOOL CALLBACK find_device_from_index( const DIDEVICEINSTANCEW *instance, return DIENUM_CONTINUE; }
-static HRESULT WINAPI JoyConfig8Impl_GetConfig(IDirectInputJoyConfig8 *iface, UINT id, LPDIJOYCONFIG info, DWORD flags) +static HRESULT WINAPI joy_config_GetConfig( IDirectInputJoyConfig8 *iface, UINT id, DIJOYCONFIG *info, DWORD flags ) { - IDirectInputImpl *di = impl_from_IDirectInputJoyConfig8(iface); + IDirectInputImpl *impl = impl_from_IDirectInputJoyConfig8( iface ); struct find_device_from_index_params params = {.index = id}; HRESULT hr;
- FIXME("(%p)->(%d, %p, 0x%08x): semi-stub!\n", iface, id, info, flags); + FIXME( "iface %p, id %u, info %p, flags %#x stub!\n", iface, id, info, flags );
#define X(x) if (flags & x) FIXME("\tflags |= "#x"\n"); X(DIJC_GUIDINSTANCE) @@ -990,52 +992,53 @@ static HRESULT WINAPI JoyConfig8Impl_GetConfig(IDirectInputJoyConfig8 *iface, UI X(DIJC_CALLOUT) #undef X
- hr = IDirectInput8_EnumDevices( &di->IDirectInput8W_iface, DI8DEVCLASS_GAMECTRL, find_device_from_index, ¶ms, 0 ); + hr = IDirectInput8_EnumDevices( &impl->IDirectInput8W_iface, DI8DEVCLASS_GAMECTRL, + find_device_from_index, ¶ms, 0 ); if (FAILED(hr)) return hr; if (params.index != ~0) return DIERR_NOMOREITEMS; if (flags & DIJC_GUIDINSTANCE) info->guidInstance = params.instance.guidInstance; return DI_OK; }
-static HRESULT WINAPI JoyConfig8Impl_SetConfig(IDirectInputJoyConfig8 *iface, UINT id, LPCDIJOYCONFIG info, DWORD flags) +static HRESULT WINAPI joy_config_SetConfig( IDirectInputJoyConfig8 *iface, UINT id, const DIJOYCONFIG *info, DWORD flags ) { - FIXME( "(%p)->(%d, %p, 0x%08x): stub!\n", iface, id, info, flags ); + FIXME( "iface %p, id %u, info %p, flags %#x stub!\n", iface, id, info, flags ); return E_NOTIMPL; }
-static HRESULT WINAPI JoyConfig8Impl_DeleteConfig(IDirectInputJoyConfig8 *iface, UINT id) +static HRESULT WINAPI joy_config_DeleteConfig( IDirectInputJoyConfig8 *iface, UINT id ) { - FIXME( "(%p)->(%d): stub!\n", iface, id ); + FIXME( "iface %p, id %u stub!\n", iface, id ); return E_NOTIMPL; }
-static HRESULT WINAPI JoyConfig8Impl_GetUserValues(IDirectInputJoyConfig8 *iface, LPDIJOYUSERVALUES info, DWORD flags) +static HRESULT WINAPI joy_config_GetUserValues( IDirectInputJoyConfig8 *iface, DIJOYUSERVALUES *info, DWORD flags ) { - FIXME( "(%p)->(%p, 0x%08x): stub!\n", iface, info, flags ); + FIXME( "iface %p, info %p, flags %#x stub!\n", iface, info, flags ); return E_NOTIMPL; }
-static HRESULT WINAPI JoyConfig8Impl_SetUserValues(IDirectInputJoyConfig8 *iface, LPCDIJOYUSERVALUES info, DWORD flags) +static HRESULT WINAPI joy_config_SetUserValues( IDirectInputJoyConfig8 *iface, const DIJOYUSERVALUES *info, DWORD flags ) { - FIXME( "(%p)->(%p, 0x%08x): stub!\n", iface, info, flags ); + FIXME( "iface %p, info %p, flags %#x stub!\n", iface, info, flags ); return E_NOTIMPL; }
-static HRESULT WINAPI JoyConfig8Impl_AddNewHardware(IDirectInputJoyConfig8 *iface, HWND hwnd, REFGUID guid) +static HRESULT WINAPI joy_config_AddNewHardware( IDirectInputJoyConfig8 *iface, HWND hwnd, const GUID *guid ) { - FIXME( "(%p)->(%p, %s): stub!\n", iface, hwnd, debugstr_guid(guid) ); + FIXME( "iface %p, hwnd %p, guid %s stub!\n", iface, hwnd, debugstr_guid( guid ) ); return E_NOTIMPL; }
-static HRESULT WINAPI JoyConfig8Impl_OpenTypeKey(IDirectInputJoyConfig8 *iface, LPCWSTR name, DWORD security, PHKEY key) +static HRESULT WINAPI joy_config_OpenTypeKey( IDirectInputJoyConfig8 *iface, const WCHAR *name, DWORD security, HKEY *key ) { - FIXME( "(%p)->(%s, 0x%08x, %p): stub!\n", iface, debugstr_w(name), security, key ); + FIXME( "iface %p, name %s, security %u, key %p stub!\n", iface, debugstr_w(name), security, key ); return E_NOTIMPL; }
-static HRESULT WINAPI JoyConfig8Impl_OpenAppStatusKey(IDirectInputJoyConfig8 *iface, PHKEY key) +static HRESULT WINAPI joy_config_OpenAppStatusKey( IDirectInputJoyConfig8 *iface, HKEY *key ) { - FIXME( "(%p)->(%p): stub!\n", iface, key ); + FIXME( "iface %p, key %p stub!\n", iface, key ); return E_NOTIMPL; }
@@ -1066,27 +1069,27 @@ static const IDirectInput8WVtbl ddi8wvt = { IDirectInput8WImpl_ConfigureDevices };
-static const IDirectInputJoyConfig8Vtbl JoyConfig8vt = +static const IDirectInputJoyConfig8Vtbl joy_config_vtbl = { - JoyConfig8Impl_QueryInterface, - JoyConfig8Impl_AddRef, - JoyConfig8Impl_Release, - JoyConfig8Impl_Acquire, - JoyConfig8Impl_Unacquire, - JoyConfig8Impl_SetCooperativeLevel, - JoyConfig8Impl_SendNotify, - JoyConfig8Impl_EnumTypes, - JoyConfig8Impl_GetTypeInfo, - JoyConfig8Impl_SetTypeInfo, - JoyConfig8Impl_DeleteType, - JoyConfig8Impl_GetConfig, - JoyConfig8Impl_SetConfig, - JoyConfig8Impl_DeleteConfig, - JoyConfig8Impl_GetUserValues, - JoyConfig8Impl_SetUserValues, - JoyConfig8Impl_AddNewHardware, - JoyConfig8Impl_OpenTypeKey, - JoyConfig8Impl_OpenAppStatusKey + joy_config_QueryInterface, + joy_config_AddRef, + joy_config_Release, + joy_config_Acquire, + joy_config_Unacquire, + joy_config_SetCooperativeLevel, + joy_config_SendNotify, + joy_config_EnumTypes, + joy_config_GetTypeInfo, + joy_config_SetTypeInfo, + joy_config_DeleteType, + joy_config_GetConfig, + joy_config_SetConfig, + joy_config_DeleteConfig, + joy_config_GetUserValues, + joy_config_SetUserValues, + joy_config_AddNewHardware, + joy_config_OpenTypeKey, + joy_config_OpenAppStatusKey, };
struct class_factory
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/dinput_main.c | 184 ++++++++++++++++++-------------------- 1 file changed, 86 insertions(+), 98 deletions(-)
diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c index 0be9c23cd75..28b40c9e3e0 100644 --- a/dlls/dinput/dinput_main.c +++ b/dlls/dinput/dinput_main.c @@ -55,7 +55,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(dinput);
-static const IDirectInput7WVtbl ddi7wvt; +static const IDirectInput7WVtbl dinput7_vtbl; static const IDirectInput8WVtbl ddi8wvt; static const IDirectInputJoyConfig8Vtbl joy_config_vtbl;
@@ -146,7 +146,7 @@ static HRESULT create_directinput_instance(REFIID riid, LPVOID *ppDI, IDirectInp return E_OUTOFMEMORY;
This->IDirectInput7A_iface.lpVtbl = &dinput7_a_vtbl; - This->IDirectInput7W_iface.lpVtbl = &ddi7wvt; + This->IDirectInput7W_iface.lpVtbl = &dinput7_vtbl; This->IDirectInput8A_iface.lpVtbl = &dinput8_a_vtbl; This->IDirectInput8W_iface.lpVtbl = &ddi8wvt; This->IDirectInputJoyConfig8_iface.lpVtbl = &joy_config_vtbl; @@ -321,12 +321,12 @@ __ASM_GLOBAL_FUNC( enum_callback_wrapper, /****************************************************************************** * IDirectInputW_EnumDevices */ -static HRESULT WINAPI IDirectInputWImpl_EnumDevices( IDirectInput7W *iface, DWORD type, LPDIENUMDEVICESCALLBACKW callback, - void *context, DWORD flags ) +static HRESULT WINAPI dinput7_EnumDevices( IDirectInput7W *iface, DWORD type, LPDIENUMDEVICESCALLBACKW callback, + void *context, DWORD flags ) { IDirectInputImpl *impl = impl_from_IDirectInput7W( iface );
- TRACE( "iface %p, type %#x, callback %p, context %p, flags %#x\n", iface, type, callback, context, flags ); + TRACE( "iface %p, type %#x, callback %p, context %p, flags %#x.\n", iface, type, callback, context, flags );
if (!callback) return DIERR_INVALIDPARAM;
@@ -337,73 +337,70 @@ static HRESULT WINAPI IDirectInputWImpl_EnumDevices( IDirectInput7W *iface, DWOR return IDirectInput8_EnumDevices( &impl->IDirectInput8W_iface, type, callback, context, flags ); }
-static ULONG WINAPI IDirectInputWImpl_AddRef( IDirectInput7W *iface ) +static ULONG WINAPI dinput7_AddRef( IDirectInput7W *iface ) { - IDirectInputImpl *This = impl_from_IDirectInput7W( iface ); - ULONG ref = InterlockedIncrement(&This->ref); - - TRACE( "(%p) ref %d\n", This, ref ); + IDirectInputImpl *impl = impl_from_IDirectInput7W( iface ); + ULONG ref = InterlockedIncrement( &impl->ref ); + TRACE( "iface %p increasing refcount to %u.\n", iface, ref ); return ref; }
-static ULONG WINAPI IDirectInputWImpl_Release( IDirectInput7W *iface ) +static ULONG WINAPI dinput7_Release( IDirectInput7W *iface ) { - IDirectInputImpl *This = impl_from_IDirectInput7W( iface ); - ULONG ref = InterlockedDecrement( &This->ref ); + IDirectInputImpl *impl = impl_from_IDirectInput7W( iface ); + ULONG ref = InterlockedDecrement( &impl->ref );
- TRACE( "(%p) ref %d\n", This, ref ); + TRACE( "iface %p decreasing refcount to %u.\n", iface, ref );
if (ref == 0) { - uninitialize_directinput_instance( This ); - free( This ); + uninitialize_directinput_instance( impl ); + free( impl ); }
return ref; }
-static HRESULT WINAPI IDirectInputWImpl_QueryInterface( IDirectInput7W *iface, REFIID riid, LPVOID *ppobj ) +static HRESULT WINAPI dinput7_QueryInterface( IDirectInput7W *iface, REFIID iid, void **out ) { - IDirectInputImpl *This = impl_from_IDirectInput7W( iface ); + IDirectInputImpl *impl = impl_from_IDirectInput7W( iface );
- TRACE( "(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppobj ); + TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out );
- if (!riid || !ppobj) - return E_POINTER; + if (!iid || !out) return E_POINTER;
- *ppobj = NULL; + *out = NULL;
#if DIRECTINPUT_VERSION == 0x0700 - if (IsEqualGUID( &IID_IDirectInputA, riid ) || - IsEqualGUID( &IID_IDirectInput2A, riid ) || - IsEqualGUID( &IID_IDirectInput7A, riid )) - *ppobj = &This->IDirectInput7A_iface; - else if (IsEqualGUID( &IID_IUnknown, riid ) || - IsEqualGUID( &IID_IDirectInputW, riid ) || - IsEqualGUID( &IID_IDirectInput2W, riid ) || - IsEqualGUID( &IID_IDirectInput7W, riid )) - *ppobj = &This->IDirectInput7W_iface; + if (IsEqualGUID( &IID_IDirectInputA, iid ) || + IsEqualGUID( &IID_IDirectInput2A, iid ) || + IsEqualGUID( &IID_IDirectInput7A, iid )) + *out = &impl->IDirectInput7A_iface; + else if (IsEqualGUID( &IID_IUnknown, iid ) || + IsEqualGUID( &IID_IDirectInputW, iid ) || + IsEqualGUID( &IID_IDirectInput2W, iid ) || + IsEqualGUID( &IID_IDirectInput7W, iid )) + *out = &impl->IDirectInput7W_iface;
#else - if (IsEqualGUID( &IID_IDirectInput8A, riid )) - *ppobj = &This->IDirectInput8A_iface; - - else if (IsEqualGUID( &IID_IUnknown, riid ) || - IsEqualGUID( &IID_IDirectInput8W, riid )) - *ppobj = &This->IDirectInput8W_iface; + if (IsEqualGUID( &IID_IDirectInput8A, iid )) + *out = &impl->IDirectInput8A_iface; + else if (IsEqualGUID( &IID_IUnknown, iid ) || + IsEqualGUID( &IID_IDirectInput8W, iid )) + *out = &impl->IDirectInput8W_iface;
#endif
- if (IsEqualGUID( &IID_IDirectInputJoyConfig8, riid )) - *ppobj = &This->IDirectInputJoyConfig8_iface; + if (IsEqualGUID( &IID_IDirectInputJoyConfig8, iid )) + *out = &impl->IDirectInputJoyConfig8_iface;
- if(*ppobj) + if (*out) { - IUnknown_AddRef( (IUnknown*)*ppobj ); + IUnknown_AddRef( (IUnknown *)*out ); return DI_OK; }
- WARN( "Unsupported interface: %s\n", debugstr_guid(riid)); + WARN( "Unsupported interface: %s\n", debugstr_guid( iid ) ); return E_NOINTERFACE; }
@@ -453,32 +450,31 @@ static void unregister_di_em_win_class(void) WARN( "Unable to unregister message window class\n" ); }
-static HRESULT initialize_directinput_instance(IDirectInputImpl *This, DWORD dwVersion) +static HRESULT initialize_directinput_instance( IDirectInputImpl *impl, DWORD version ) { - if (!This->initialized) + if (!impl->initialized) { - This->dwVersion = dwVersion; - This->evsequence = 1; + impl->dwVersion = version; + impl->evsequence = 1;
- list_init( &This->device_players ); + list_init( &impl->device_players );
- This->initialized = TRUE; + impl->initialized = TRUE; }
return DI_OK; }
-static void uninitialize_directinput_instance(IDirectInputImpl *This) +static void uninitialize_directinput_instance( IDirectInputImpl *impl ) { - if (This->initialized) + if (impl->initialized) { struct DevicePlayer *device_player, *device_player2;
- LIST_FOR_EACH_ENTRY_SAFE( device_player, device_player2, - &This->device_players, struct DevicePlayer, entry ) + LIST_FOR_EACH_ENTRY_SAFE ( device_player, device_player2, &impl->device_players, struct DevicePlayer, entry ) free( device_player );
- This->initialized = FALSE; + impl->initialized = FALSE; } }
@@ -493,11 +489,11 @@ enum directinput_versions DIRECTINPUT_VERSION_700 = 0x0700, };
-static HRESULT WINAPI IDirectInputWImpl_Initialize( IDirectInput7W *iface, HINSTANCE hinst, DWORD version ) +static HRESULT WINAPI dinput7_Initialize( IDirectInput7W *iface, HINSTANCE hinst, DWORD version ) { - IDirectInputImpl *This = impl_from_IDirectInput7W( iface ); + IDirectInputImpl *impl = impl_from_IDirectInput7W( iface );
- TRACE("(%p)->(%p, 0x%04x)\n", This, hinst, version); + TRACE( "iface %p, hinst %p, version %#x.\n", iface, hinst, version );
if (!hinst) return DIERR_INVALIDPARAM; @@ -511,22 +507,21 @@ static HRESULT WINAPI IDirectInputWImpl_Initialize( IDirectInput7W *iface, HINST version != DIRECTINPUT_VERSION_700 && version != DIRECTINPUT_VERSION) return DIERR_BETADIRECTINPUTVERSION;
- return initialize_directinput_instance(This, version); + return initialize_directinput_instance( impl, version ); }
-static HRESULT WINAPI IDirectInputWImpl_GetDeviceStatus( IDirectInput7W *iface, REFGUID rguid ) +static HRESULT WINAPI dinput7_GetDeviceStatus( IDirectInput7W *iface, const GUID *guid ) { - IDirectInputImpl *This = impl_from_IDirectInput7W( iface ); + IDirectInputImpl *impl = impl_from_IDirectInput7W( iface ); HRESULT hr; IDirectInputDeviceW *device;
- TRACE( "(%p)->(%s)\n", This, debugstr_guid(rguid) ); + TRACE( "iface %p, guid %s.\n", iface, debugstr_guid( guid ) );
- if (!rguid) return E_POINTER; - if (!This->initialized) - return DIERR_NOTINITIALIZED; + if (!guid) return E_POINTER; + if (!impl->initialized) return DIERR_NOTINITIALIZED;
- hr = IDirectInput_CreateDevice( iface, rguid, &device, NULL ); + hr = IDirectInput_CreateDevice( iface, guid, &device, NULL ); if (hr != DI_OK) return DI_NOTATTACHED;
IUnknown_Release( device ); @@ -534,23 +529,18 @@ static HRESULT WINAPI IDirectInputWImpl_GetDeviceStatus( IDirectInput7W *iface, return DI_OK; }
-static HRESULT WINAPI IDirectInputWImpl_RunControlPanel( IDirectInput7W *iface, HWND hwndOwner, DWORD dwFlags ) +static HRESULT WINAPI dinput7_RunControlPanel( IDirectInput7W *iface, HWND owner, DWORD flags ) { - IDirectInputImpl *This = impl_from_IDirectInput7W( iface ); + IDirectInputImpl *impl = impl_from_IDirectInput7W( iface ); WCHAR control_exe[] = {L"control.exe"}; STARTUPINFOW si = {0}; PROCESS_INFORMATION pi;
- TRACE( "(%p)->(%p, %08x)\n", This, hwndOwner, dwFlags ); + TRACE( "iface %p, owner %p, flags %#x.\n", iface, owner, flags );
- if (hwndOwner && !IsWindow(hwndOwner)) - return E_HANDLE; - - if (dwFlags) - return DIERR_INVALIDPARAM; - - if (!This->initialized) - return DIERR_NOTINITIALIZED; + if (owner && !IsWindow( owner )) return E_HANDLE; + if (flags) return DIERR_INVALIDPARAM; + if (!impl->initialized) return DIERR_NOTINITIALIZED;
if (!CreateProcessW( NULL, control_exe, NULL, NULL, FALSE, DETACHED_PROCESS, NULL, NULL, &si, &pi )) return HRESULT_FROM_WIN32(GetLastError()); @@ -558,24 +548,21 @@ static HRESULT WINAPI IDirectInputWImpl_RunControlPanel( IDirectInput7W *iface, return DI_OK; }
-static HRESULT WINAPI IDirectInput2WImpl_FindDevice(LPDIRECTINPUT7W iface, REFGUID rguid, - LPCWSTR pszName, LPGUID pguidInstance) +static HRESULT WINAPI dinput7_FindDevice( IDirectInput7W *iface, const GUID *guid, const WCHAR *name, GUID *instance_guid ) { - IDirectInputImpl *This = impl_from_IDirectInput7W( iface ); - - FIXME( "(%p)->(%s, %s, %p): stub\n", This, debugstr_guid(rguid), debugstr_w(pszName), pguidInstance ); - + FIXME( "iface %p, guid %s, name %s, instance_guid %s stub!\n", iface, debugstr_guid( guid ), + debugstr_w(name), debugstr_guid( instance_guid ) ); return DI_OK; }
-static HRESULT WINAPI IDirectInput7WImpl_CreateDeviceEx( IDirectInput7W *iface, const GUID *guid, - const GUID *iid, void **out, IUnknown *outer ) +static HRESULT WINAPI dinput7_CreateDeviceEx( IDirectInput7W *iface, const GUID *guid, + REFIID iid, void **out, IUnknown *outer ) { IDirectInputImpl *impl = impl_from_IDirectInput7W( iface ); IDirectInputDevice8W *device; HRESULT hr;
- TRACE( "iface %p, guid %s, iid %s, out %p, outer %p\n", iface, debugstr_guid( guid ), + TRACE( "iface %p, guid %s, iid %s, out %p, outer %p.\n", iface, debugstr_guid( guid ), debugstr_guid( iid ), out, outer );
if (!out) return E_POINTER; @@ -594,10 +581,10 @@ static HRESULT WINAPI IDirectInput7WImpl_CreateDeviceEx( IDirectInput7W *iface, return hr; }
-static HRESULT WINAPI IDirectInputWImpl_CreateDevice(LPDIRECTINPUT7W iface, REFGUID rguid, - LPDIRECTINPUTDEVICEW* pdev, LPUNKNOWN punk) +static HRESULT WINAPI dinput7_CreateDevice( IDirectInput7W *iface, const GUID *guid, + IDirectInputDeviceW **out, IUnknown *outer ) { - return IDirectInput7_CreateDeviceEx( iface, rguid, &IID_IDirectInputDeviceW, (LPVOID *)pdev, punk ); + return IDirectInput7_CreateDeviceEx( iface, guid, &IID_IDirectInputDeviceW, (void **)out, outer ); }
/******************************************************************************* @@ -1042,17 +1029,18 @@ static HRESULT WINAPI joy_config_OpenAppStatusKey( IDirectInputJoyConfig8 *iface return E_NOTIMPL; }
-static const IDirectInput7WVtbl ddi7wvt = { - IDirectInputWImpl_QueryInterface, - IDirectInputWImpl_AddRef, - IDirectInputWImpl_Release, - IDirectInputWImpl_CreateDevice, - IDirectInputWImpl_EnumDevices, - IDirectInputWImpl_GetDeviceStatus, - IDirectInputWImpl_RunControlPanel, - IDirectInputWImpl_Initialize, - IDirectInput2WImpl_FindDevice, - IDirectInput7WImpl_CreateDeviceEx +static const IDirectInput7WVtbl dinput7_vtbl = +{ + dinput7_QueryInterface, + dinput7_AddRef, + dinput7_Release, + dinput7_CreateDevice, + dinput7_EnumDevices, + dinput7_GetDeviceStatus, + dinput7_RunControlPanel, + dinput7_Initialize, + dinput7_FindDevice, + dinput7_CreateDeviceEx, };
static const IDirectInput8WVtbl ddi8wvt = {
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/dinput_main.c | 157 ++++++++++++++++++-------------------- 1 file changed, 76 insertions(+), 81 deletions(-)
diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c index 28b40c9e3e0..d3d5206a1e4 100644 --- a/dlls/dinput/dinput_main.c +++ b/dlls/dinput/dinput_main.c @@ -56,7 +56,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(dinput);
static const IDirectInput7WVtbl dinput7_vtbl; -static const IDirectInput8WVtbl ddi8wvt; +static const IDirectInput8WVtbl dinput8_vtbl; static const IDirectInputJoyConfig8Vtbl joy_config_vtbl;
static inline IDirectInputImpl *impl_from_IDirectInput7W( IDirectInput7W *iface ) @@ -148,7 +148,7 @@ static HRESULT create_directinput_instance(REFIID riid, LPVOID *ppDI, IDirectInp This->IDirectInput7A_iface.lpVtbl = &dinput7_a_vtbl; This->IDirectInput7W_iface.lpVtbl = &dinput7_vtbl; This->IDirectInput8A_iface.lpVtbl = &dinput8_a_vtbl; - This->IDirectInput8W_iface.lpVtbl = &ddi8wvt; + This->IDirectInput8W_iface.lpVtbl = &dinput8_vtbl; This->IDirectInputJoyConfig8_iface.lpVtbl = &joy_config_vtbl;
hr = IDirectInput_QueryInterface( &This->IDirectInput7A_iface, riid, ppDI ); @@ -591,29 +591,30 @@ static HRESULT WINAPI dinput7_CreateDevice( IDirectInput7W *iface, const GUID *g * DirectInput8 */
-static ULONG WINAPI IDirectInput8WImpl_AddRef(LPDIRECTINPUT8W iface) +static ULONG WINAPI dinput8_AddRef( IDirectInput8W *iface ) { - IDirectInputImpl *This = impl_from_IDirectInput8W( iface ); - return IDirectInput_AddRef( &This->IDirectInput7W_iface ); + IDirectInputImpl *impl = impl_from_IDirectInput8W( iface ); + return IDirectInput7_AddRef( &impl->IDirectInput7W_iface ); }
-static HRESULT WINAPI IDirectInput8WImpl_QueryInterface(LPDIRECTINPUT8W iface, REFIID riid, LPVOID *ppobj) +static HRESULT WINAPI dinput8_QueryInterface( IDirectInput8W *iface, REFIID iid, void **out ) { - IDirectInputImpl *This = impl_from_IDirectInput8W( iface ); - return IDirectInput_QueryInterface( &This->IDirectInput7W_iface, riid, ppobj ); + IDirectInputImpl *impl = impl_from_IDirectInput8W( iface ); + return IDirectInput7_QueryInterface( &impl->IDirectInput7W_iface, iid, out ); }
-static ULONG WINAPI IDirectInput8WImpl_Release(LPDIRECTINPUT8W iface) +static ULONG WINAPI dinput8_Release( IDirectInput8W *iface ) { - IDirectInputImpl *This = impl_from_IDirectInput8W( iface ); - return IDirectInput_Release( &This->IDirectInput7W_iface ); + IDirectInputImpl *impl = impl_from_IDirectInput8W( iface ); + return IDirectInput7_Release( &impl->IDirectInput7W_iface ); }
-static HRESULT WINAPI IDirectInput8WImpl_CreateDevice(LPDIRECTINPUT8W iface, REFGUID rguid, - LPDIRECTINPUTDEVICE8W* pdev, LPUNKNOWN punk) +static HRESULT WINAPI dinput8_CreateDevice( IDirectInput8W *iface, const GUID *guid, + IDirectInputDevice8W **out, IUnknown *outer ) { - IDirectInputImpl *This = impl_from_IDirectInput8W( iface ); - return IDirectInput7_CreateDeviceEx( &This->IDirectInput7W_iface, rguid, &IID_IDirectInputDevice8W, (LPVOID *)pdev, punk ); + IDirectInputImpl *impl = impl_from_IDirectInput8W( iface ); + return IDirectInput7_CreateDeviceEx( &impl->IDirectInput7W_iface, guid, + &IID_IDirectInputDevice8W, (void **)out, outer ); }
static BOOL try_enum_device( DWORD type, LPDIENUMDEVICESCALLBACKW callback, @@ -625,8 +626,8 @@ static BOOL try_enum_device( DWORD type, LPDIENUMDEVICESCALLBACKW callback, return enum_callback_wrapper( callback, instance, context ); }
-static HRESULT WINAPI IDirectInput8WImpl_EnumDevices( IDirectInput8W *iface, DWORD type, LPDIENUMDEVICESCALLBACKW callback, - void *context, DWORD flags ) +static HRESULT WINAPI dinput8_EnumDevices( IDirectInput8W *iface, DWORD type, LPDIENUMDEVICESCALLBACKW callback, void *context, + DWORD flags ) { DIDEVICEINSTANCEW instance = {.dwSize = sizeof(DIDEVICEINSTANCEW)}; IDirectInputImpl *impl = impl_from_IDirectInput8W( iface ); @@ -634,7 +635,7 @@ static HRESULT WINAPI IDirectInput8WImpl_EnumDevices( IDirectInput8W *iface, DWO unsigned int i = 0; HRESULT hr;
- TRACE( "iface %p, type %#x, callback %p, context %p, flags %#x\n", iface, type, callback, context, flags ); + TRACE( "iface %p, type %#x, callback %p, context %p, flags %#x.\n", iface, type, callback, context, flags );
if (!callback) return DIERR_INVALIDPARAM;
@@ -676,23 +677,23 @@ static HRESULT WINAPI IDirectInput8WImpl_EnumDevices( IDirectInput8W *iface, DWO return DI_OK; }
-static HRESULT WINAPI IDirectInput8WImpl_GetDeviceStatus(LPDIRECTINPUT8W iface, REFGUID rguid) +static HRESULT WINAPI dinput8_GetDeviceStatus( IDirectInput8W *iface, const GUID *guid ) { - IDirectInputImpl *This = impl_from_IDirectInput8W( iface ); - return IDirectInput_GetDeviceStatus( &This->IDirectInput7W_iface, rguid ); + IDirectInputImpl *impl = impl_from_IDirectInput8W( iface ); + return IDirectInput7_GetDeviceStatus( &impl->IDirectInput7W_iface, guid ); }
-static HRESULT WINAPI IDirectInput8WImpl_RunControlPanel(LPDIRECTINPUT8W iface, HWND hwndOwner, DWORD dwFlags) +static HRESULT WINAPI dinput8_RunControlPanel( IDirectInput8W *iface, HWND owner, DWORD flags ) { - IDirectInputImpl *This = impl_from_IDirectInput8W( iface ); - return IDirectInput_RunControlPanel( &This->IDirectInput7W_iface, hwndOwner, dwFlags ); + IDirectInputImpl *impl = impl_from_IDirectInput8W( iface ); + return IDirectInput7_RunControlPanel( &impl->IDirectInput7W_iface, owner, flags ); }
-static HRESULT WINAPI IDirectInput8WImpl_Initialize( IDirectInput8W *iface, HINSTANCE hinst, DWORD version ) +static HRESULT WINAPI dinput8_Initialize( IDirectInput8W *iface, HINSTANCE hinst, DWORD version ) { - IDirectInputImpl *This = impl_from_IDirectInput8W( iface ); + IDirectInputImpl *impl = impl_from_IDirectInput8W( iface );
- TRACE("(%p)->(%p, 0x%04x)\n", This, hinst, version); + TRACE( "iface %p, hinst %p, version %#x.\n", iface, hinst, version );
if (!hinst) return DIERR_INVALIDPARAM; @@ -703,23 +704,22 @@ static HRESULT WINAPI IDirectInput8WImpl_Initialize( IDirectInput8W *iface, HINS else if (version > DIRECTINPUT_VERSION) return DIERR_OLDDIRECTINPUTVERSION;
- return initialize_directinput_instance(This, version); + return initialize_directinput_instance( impl, version ); }
-static HRESULT WINAPI IDirectInput8WImpl_FindDevice(LPDIRECTINPUT8W iface, REFGUID rguid, LPCWSTR pszName, LPGUID pguidInstance) +static HRESULT WINAPI dinput8_FindDevice( IDirectInput8W *iface, const GUID *guid, const WCHAR *name, GUID *instance_guid ) { - IDirectInputImpl *This = impl_from_IDirectInput8W( iface ); - return IDirectInput2_FindDevice( &This->IDirectInput7W_iface, rguid, pszName, pguidInstance ); + IDirectInputImpl *impl = impl_from_IDirectInput8W( iface ); + return IDirectInput7_FindDevice( &impl->IDirectInput7W_iface, guid, name, instance_guid ); }
-static BOOL should_enumerate_device(const WCHAR *username, DWORD dwFlags, - struct list *device_players, REFGUID guid) +static BOOL should_enumerate_device( const WCHAR *username, DWORD flags, struct list *device_players, const GUID *guid ) { BOOL should_enumerate = TRUE; struct DevicePlayer *device_player;
- /* Check if user owns this device */ - if (dwFlags & DIEDBSFL_THISUSER && username && *username) + /* Check if user owns impl device */ + if (flags & DIEDBSFL_THISUSER && username && *username) { should_enumerate = FALSE; LIST_FOR_EACH_ENTRY(device_player, device_players, struct DevicePlayer, entry) @@ -733,8 +733,9 @@ static BOOL should_enumerate_device(const WCHAR *username, DWORD dwFlags, } }
- /* Check if this device is not owned by anyone */ - if (dwFlags & DIEDBSFL_AVAILABLEDEVICES) { + /* Check if impl device is not owned by anyone */ + if (flags & DIEDBSFL_AVAILABLEDEVICES) + { BOOL found = FALSE; should_enumerate = FALSE; LIST_FOR_EACH_ENTRY(device_player, device_players, struct DevicePlayer, entry) @@ -766,9 +767,9 @@ struct enum_device_by_semantics_params static BOOL CALLBACK enum_device_by_semantics( const DIDEVICEINSTANCEW *instance, void *context ) { struct enum_device_by_semantics_params *params = context; - IDirectInputImpl *This = impl_from_IDirectInput8W( params->iface ); + IDirectInputImpl *impl = impl_from_IDirectInput8W( params->iface );
- if (should_enumerate_device( params->username, params->flags, &This->device_players, &instance->guidInstance )) + if (should_enumerate_device( params->username, params->flags, &impl->device_players, &instance->guidInstance )) { params->instance_count++; params->instances = realloc( params->instances, sizeof(DIDEVICEINSTANCEW) * params->instance_count ); @@ -778,29 +779,26 @@ static BOOL CALLBACK enum_device_by_semantics( const DIDEVICEINSTANCEW *instance return DIENUM_CONTINUE; }
-static HRESULT WINAPI IDirectInput8WImpl_EnumDevicesBySemantics( - LPDIRECTINPUT8W iface, LPCWSTR ptszUserName, LPDIACTIONFORMATW lpdiActionFormat, - LPDIENUMDEVICESBYSEMANTICSCBW lpCallback, - LPVOID pvRef, DWORD dwFlags -) +static HRESULT WINAPI dinput8_EnumDevicesBySemantics( IDirectInput8W *iface, const WCHAR *username, DIACTIONFORMATW *action_format, + LPDIENUMDEVICESBYSEMANTICSCBW callback, void *context, DWORD flags ) { - struct enum_device_by_semantics_params params = {.iface = iface, .username = ptszUserName, .flags = dwFlags}; - DWORD callbackFlags, enum_flags = DIEDFL_ATTACHEDONLY | (dwFlags & DIEDFL_FORCEFEEDBACK); - static REFGUID guids[2] = { &GUID_SysKeyboard, &GUID_SysMouse }; + struct enum_device_by_semantics_params params = {.iface = iface, .username = username, .flags = flags}; + DWORD callbackFlags, enum_flags = DIEDFL_ATTACHEDONLY | (flags & DIEDFL_FORCEFEEDBACK); + static const GUID *guids[2] = {&GUID_SysKeyboard, &GUID_SysMouse}; static const DWORD actionMasks[] = { DIKEYBOARD_MASK, DIMOUSE_MASK }; - IDirectInputImpl *This = impl_from_IDirectInput8W(iface); + IDirectInputImpl *impl = impl_from_IDirectInput8W( iface ); DIDEVICEINSTANCEW didevi; - LPDIRECTINPUTDEVICE8W lpdid; + IDirectInputDevice8W *lpdid; unsigned int i = 0; HRESULT hr; int remain;
- FIXME("(this=%p,%s,%p,%p,%p,%04x): semi-stub\n", This, debugstr_w(ptszUserName), lpdiActionFormat, - lpCallback, pvRef, dwFlags); + FIXME( "iface %p, username %s, action_format %p, callback %p, context %p, flags %#x stub!\n", + iface, debugstr_w(username), action_format, callback, context, flags );
didevi.dwSize = sizeof(didevi);
- hr = IDirectInput8_EnumDevices( &This->IDirectInput8W_iface, DI8DEVCLASS_GAMECTRL, + hr = IDirectInput8_EnumDevices( &impl->IDirectInput8W_iface, DI8DEVCLASS_GAMECTRL, enum_device_by_semantics, ¶ms, enum_flags ); if (FAILED(hr)) { @@ -810,21 +808,20 @@ static HRESULT WINAPI IDirectInput8WImpl_EnumDevicesBySemantics(
remain = params.instance_count; /* Add keyboard and mouse to remaining device count */ - if (!(dwFlags & DIEDBSFL_FORCEFEEDBACK)) + if (!(flags & DIEDBSFL_FORCEFEEDBACK)) { for (i = 0; i < ARRAY_SIZE(guids); i++) { - if (should_enumerate_device(ptszUserName, dwFlags, &This->device_players, guids[i])) - remain++; + if (should_enumerate_device( username, flags, &impl->device_players, guids[i] )) remain++; } }
for (i = 0; i < params.instance_count; i++) { - callbackFlags = diactionformat_priorityW(lpdiActionFormat, lpdiActionFormat->dwGenre); + callbackFlags = diactionformat_priorityW( action_format, action_format->dwGenre ); IDirectInput_CreateDevice( iface, ¶ms.instances[i].guidInstance, &lpdid, NULL );
- if (lpCallback( ¶ms.instances[i], lpdid, callbackFlags, --remain, pvRef ) == DIENUM_STOP) + if (callback( ¶ms.instances[i], lpdid, callbackFlags, --remain, context ) == DIENUM_STOP) { free( params.instances ); IDirectInputDevice_Release(lpdid); @@ -835,19 +832,19 @@ static HRESULT WINAPI IDirectInput8WImpl_EnumDevicesBySemantics(
free( params.instances );
- if (dwFlags & DIEDBSFL_FORCEFEEDBACK) return DI_OK; + if (flags & DIEDBSFL_FORCEFEEDBACK) return DI_OK;
/* Enumerate keyboard and mouse */ for (i = 0; i < ARRAY_SIZE(guids); i++) { - if (should_enumerate_device(ptszUserName, dwFlags, &This->device_players, guids[i])) + if (should_enumerate_device( username, flags, &impl->device_players, guids[i] )) { - callbackFlags = diactionformat_priorityW(lpdiActionFormat, actionMasks[i]); + callbackFlags = diactionformat_priorityW( action_format, actionMasks[i] );
IDirectInput_CreateDevice(iface, guids[i], &lpdid, NULL); IDirectInputDevice_GetDeviceInfo(lpdid, &didevi);
- if (lpCallback(&didevi, lpdid, callbackFlags, --remain, pvRef) == DIENUM_STOP) + if (callback( &didevi, lpdid, callbackFlags, --remain, context ) == DIENUM_STOP) { IDirectInputDevice_Release(lpdid); return DI_OK; @@ -859,17 +856,14 @@ static HRESULT WINAPI IDirectInput8WImpl_EnumDevicesBySemantics( return DI_OK; }
-static HRESULT WINAPI IDirectInput8WImpl_ConfigureDevices( - LPDIRECTINPUT8W iface, LPDICONFIGUREDEVICESCALLBACK lpdiCallback, - LPDICONFIGUREDEVICESPARAMSW lpdiCDParams, DWORD dwFlags, LPVOID pvRefData -) +static HRESULT WINAPI dinput8_ConfigureDevices( IDirectInput8W *iface, LPDICONFIGUREDEVICESCALLBACK callback, + DICONFIGUREDEVICESPARAMSW *params, DWORD flags, void *context ) { - IDirectInputImpl *This = impl_from_IDirectInput8W(iface); - - FIXME("(this=%p,%p,%p,%04x,%p): stub\n", This, lpdiCallback, lpdiCDParams, dwFlags, pvRefData); + FIXME( "iface %p, callback %p, params %p, flags %#x, context %p stub!\n", iface, callback, + params, flags, context );
/* Call helper function in config.c to do the real work */ - return _configure_devices(iface, lpdiCallback, lpdiCDParams, dwFlags, pvRefData); + return _configure_devices( iface, callback, params, flags, context ); }
/***************************************************************************** @@ -1043,18 +1037,19 @@ static const IDirectInput7WVtbl dinput7_vtbl = dinput7_CreateDeviceEx, };
-static const IDirectInput8WVtbl ddi8wvt = { - IDirectInput8WImpl_QueryInterface, - IDirectInput8WImpl_AddRef, - IDirectInput8WImpl_Release, - IDirectInput8WImpl_CreateDevice, - IDirectInput8WImpl_EnumDevices, - IDirectInput8WImpl_GetDeviceStatus, - IDirectInput8WImpl_RunControlPanel, - IDirectInput8WImpl_Initialize, - IDirectInput8WImpl_FindDevice, - IDirectInput8WImpl_EnumDevicesBySemantics, - IDirectInput8WImpl_ConfigureDevices +static const IDirectInput8WVtbl dinput8_vtbl = +{ + dinput8_QueryInterface, + dinput8_AddRef, + dinput8_Release, + dinput8_CreateDevice, + dinput8_EnumDevices, + dinput8_GetDeviceStatus, + dinput8_RunControlPanel, + dinput8_Initialize, + dinput8_FindDevice, + dinput8_EnumDevicesBySemantics, + dinput8_ConfigureDevices, };
static const IDirectInputJoyConfig8Vtbl joy_config_vtbl =