diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c index 1b2020c7110..e32ccae3dfe 100644 --- a/dlls/dinput/dinput_main.c +++ b/dlls/dinput/dinput_main.c @@ -566,53 +566,39 @@ static HRESULT WINAPI IDirectInputAImpl_QueryInterface(LPDIRECTINPUT7A iface, RE if (!riid || !ppobj) return E_POINTER; + *ppobj = NULL; + +#if DIRECTINPUT_VERSION == 0x0700 if (IsEqualGUID( &IID_IUnknown, riid ) || - IsEqualGUID( &IID_IDirectInputA, riid ) || - IsEqualGUID( &IID_IDirectInput2A, riid ) || - IsEqualGUID( &IID_IDirectInput7A, riid )) - { + IsEqualGUID( &IID_IDirectInputA, riid ) || + IsEqualGUID( &IID_IDirectInput2A, riid ) || + IsEqualGUID( &IID_IDirectInput7A, riid )) *ppobj = &This->IDirectInput7A_iface; - IUnknown_AddRef( (IUnknown*)*ppobj ); - - return DI_OK; - } - - if (IsEqualGUID( &IID_IDirectInputW, riid ) || - IsEqualGUID( &IID_IDirectInput2W, riid ) || - IsEqualGUID( &IID_IDirectInput7W, riid )) - { + else if (IsEqualGUID( &IID_IDirectInputW, riid ) || + IsEqualGUID( &IID_IDirectInput2W, riid ) || + IsEqualGUID( &IID_IDirectInput7W, riid )) *ppobj = &This->IDirectInput7W_iface; - IUnknown_AddRef( (IUnknown*)*ppobj ); - return DI_OK; - } - - if (IsEqualGUID( &IID_IDirectInput8A, riid )) - { +#else + if (IsEqualGUID( &IID_IUnknown, riid ) || + IsEqualGUID( &IID_IDirectInput8A, riid )) *ppobj = &This->IDirectInput8A_iface; - IUnknown_AddRef( (IUnknown*)*ppobj ); - return DI_OK; - } - - if (IsEqualGUID( &IID_IDirectInput8W, riid )) - { + else if (IsEqualGUID( &IID_IDirectInput8W, riid )) *ppobj = &This->IDirectInput8W_iface; - IUnknown_AddRef( (IUnknown*)*ppobj ); - return DI_OK; - } +#endif if (IsEqualGUID( &IID_IDirectInputJoyConfig8, riid )) - { *ppobj = &This->IDirectInputJoyConfig8_iface; - IUnknown_AddRef( (IUnknown*)*ppobj ); + if(*ppobj) + { + IUnknown_AddRef( (IUnknown*)*ppobj ); return DI_OK; } - FIXME( "Unsupported interface: %s\n", debugstr_guid(riid)); - *ppobj = NULL; + WARN( "Unsupported interface: %s\n", debugstr_guid(riid)); return E_NOINTERFACE; } diff --git a/dlls/dinput/tests/dinput.c b/dlls/dinput/tests/dinput.c index 23b20d2b9e8..abf849f859d 100644 --- a/dlls/dinput/tests/dinput.c +++ b/dlls/dinput/tests/dinput.c @@ -269,23 +269,19 @@ static void test_QueryInterface(void) &IID_IDirectInput2A, &IID_IDirectInput2W, &IID_IDirectInput7A, &IID_IDirectInput7W}; - static const struct + static const REFIID no_interface_list[] = { - REFIID riid; - int test_todo; - } no_interface_list[] = - { - {&IID_IDirectInput8A, 1}, - {&IID_IDirectInput8W, 1}, - {&IID_IDirectInputDeviceA}, - {&IID_IDirectInputDeviceW}, - {&IID_IDirectInputDevice2A}, - {&IID_IDirectInputDevice2W}, - {&IID_IDirectInputDevice7A}, - {&IID_IDirectInputDevice7W}, - {&IID_IDirectInputDevice8A}, - {&IID_IDirectInputDevice8W}, - {&IID_IDirectInputEffect}, + &IID_IDirectInput8A, + &IID_IDirectInput8W, + &IID_IDirectInputDeviceA, + &IID_IDirectInputDeviceW, + &IID_IDirectInputDevice2A, + &IID_IDirectInputDevice2W, + &IID_IDirectInputDevice7A, + &IID_IDirectInputDevice7W, + &IID_IDirectInputDevice8A, + &IID_IDirectInputDevice8W, + &IID_IDirectInputEffect, }; IDirectInputA *pDI; @@ -323,21 +319,9 @@ static void test_QueryInterface(void) for (i = 0; i < ARRAY_SIZE(no_interface_list); i++) { pUnk = (void *)0xdeadbeef; - hr = IDirectInput_QueryInterface(pDI, no_interface_list[i].riid, (void **)&pUnk); - if (no_interface_list[i].test_todo) - { - todo_wine - ok(hr == E_NOINTERFACE, "[%d] IDirectInput_QueryInterface returned 0x%08x\n", i, hr); - todo_wine - ok(pUnk == NULL, "[%d] Output interface pointer is %p\n", i, pUnk); - - if (pUnk) IUnknown_Release(pUnk); - } - else - { - 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); - } + 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); } IDirectInput_Release(pDI); diff --git a/dlls/dinput8/tests/dinput.c b/dlls/dinput8/tests/dinput.c index 28b1bd5e02f..594ba27e8ab 100644 --- a/dlls/dinput8/tests/dinput.c +++ b/dlls/dinput8/tests/dinput.c @@ -222,27 +222,23 @@ static void test_QueryInterface(void) { static REFIID iid_list[] = {&IID_IUnknown, &IID_IDirectInput8A, &IID_IDirectInput8W, &IID_IDirectInputJoyConfig8}; - static const struct + static const REFIID no_interface_list[] = { - REFIID riid; - int test_todo; - } no_interface_list[] = - { - {&IID_IDirectInputA, 1}, - {&IID_IDirectInputW, 1}, - {&IID_IDirectInput2A, 1}, - {&IID_IDirectInput2W, 1}, - {&IID_IDirectInput7A, 1}, - {&IID_IDirectInput7W, 1}, - {&IID_IDirectInputDeviceA}, - {&IID_IDirectInputDeviceW}, - {&IID_IDirectInputDevice2A}, - {&IID_IDirectInputDevice2W}, - {&IID_IDirectInputDevice7A}, - {&IID_IDirectInputDevice7W}, - {&IID_IDirectInputDevice8A}, - {&IID_IDirectInputDevice8W}, - {&IID_IDirectInputEffect}, + &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; @@ -292,21 +288,10 @@ static void test_QueryInterface(void) for (i = 0; i < ARRAY_SIZE(no_interface_list); i++) { pUnk = (void *)0xdeadbeef; - hr = IDirectInput8_QueryInterface(pDI, no_interface_list[i].riid, (void **)&pUnk); - if (no_interface_list[i].test_todo) - { - todo_wine - ok(hr == E_NOINTERFACE, "[%d] IDirectInput8_QueryInterface returned 0x%08x\n", i, hr); - todo_wine - ok(pUnk == NULL, "[%d] Output interface pointer is %p\n", i, pUnk); + hr = IDirectInput8_QueryInterface(pDI, no_interface_list[i], (void **)&pUnk); - if (pUnk) IUnknown_Release(pUnk); - } - else - { - 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); - } + 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);