Supersedes 163790.
Signed-off-by: Alistair Leslie-Hughes leslie_alistair@hotmail.com --- dlls/dinput/dinput_main.c | 50 ++++++++++++++++----------------------------- dlls/dinput/tests/dinput.c | 21 ++++--------------- dlls/dinput8/tests/dinput.c | 28 ++++++++----------------- 3 files changed, 30 insertions(+), 69 deletions(-)
diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c index 1b2020c..e32ccae 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 23b20d2..6451241 100644 --- a/dlls/dinput/tests/dinput.c +++ b/dlls/dinput/tests/dinput.c @@ -272,11 +272,10 @@ static void test_QueryInterface(void) static const struct { REFIID riid; - int test_todo; } no_interface_list[] = { - {&IID_IDirectInput8A, 1}, - {&IID_IDirectInput8W, 1}, + {&IID_IDirectInput8A}, + {&IID_IDirectInput8W}, {&IID_IDirectInputDeviceA}, {&IID_IDirectInputDeviceW}, {&IID_IDirectInputDevice2A}, @@ -324,20 +323,8 @@ static void test_QueryInterface(void) { 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); - } + 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 28b1bd5..d87f997 100644 --- a/dlls/dinput8/tests/dinput.c +++ b/dlls/dinput8/tests/dinput.c @@ -225,15 +225,14 @@ static void test_QueryInterface(void) static const struct { 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_IDirectInputA}, + {&IID_IDirectInputW}, + {&IID_IDirectInput2A}, + {&IID_IDirectInput2W}, + {&IID_IDirectInput7A}, + {&IID_IDirectInput7W}, {&IID_IDirectInputDeviceA}, {&IID_IDirectInputDeviceW}, {&IID_IDirectInputDevice2A}, @@ -293,20 +292,9 @@ static void test_QueryInterface(void) { 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);
- 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);