Commit dd08ef40 authored by Bernhard Übelacker's avatar Bernhard Übelacker Committed by Alexandre Julliard

dinput: Fail in SetCooperativeLevel on invalid hwnd.

MotoGP 3 demo fails to accept key presses to control the driver. The game calls SetCooperativeLevel twice. First with an invalid hwnd (but not NULL) and later with the real hwnd. Signed-off-by: 's avatarBernhard Übelacker <bernhardu@vr-web.de> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent b22fa89d
......@@ -1028,10 +1028,10 @@ HRESULT WINAPI IDirectInputDevice2WImpl_SetCooperativeLevel(LPDIRECTINPUTDEVICE8
if (hwnd && GetWindowLongW(hwnd, GWL_STYLE) & WS_CHILD) return E_HANDLE;
if (dwflags == (DISCL_NONEXCLUSIVE | DISCL_BACKGROUND))
if (!hwnd && dwflags == (DISCL_NONEXCLUSIVE | DISCL_BACKGROUND))
hwnd = GetDesktopWindow();
if (!hwnd) return E_HANDLE;
if (!IsWindow(hwnd)) return E_HANDLE;
/* For security reasons native does not allow exclusive background level
for mouse and keyboard only */
......
......@@ -121,6 +121,12 @@ static const HRESULT SetCoop_null_window[16] = {
E_INVALIDARG, E_HANDLE, S_OK, E_INVALIDARG,
E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG};
static const HRESULT SetCoop_invalid_window[16] = {
E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG,
E_INVALIDARG, E_HANDLE, E_HANDLE, E_INVALIDARG,
E_INVALIDARG, E_HANDLE, E_HANDLE, E_INVALIDARG,
E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG};
static const HRESULT SetCoop_real_window[16] = {
E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG,
E_INVALIDARG, S_OK, S_OK, E_INVALIDARG,
......@@ -151,6 +157,11 @@ static void test_set_coop(IDirectInputA *pDI, HWND hwnd)
}
for (i=0; i<16; i++)
{
hr = IDirectInputDevice_SetCooperativeLevel(pKeyboard, (HWND)0x400000, i);
ok(hr == SetCoop_invalid_window[i], "SetCooperativeLevel(invalid, %d): %08x\n", i, hr);
}
for (i=0; i<16; i++)
{
hr = IDirectInputDevice_SetCooperativeLevel(pKeyboard, hwnd, i);
ok(hr == SetCoop_real_window[i], "SetCooperativeLevel(hwnd, %d): %08x\n", i, hr);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment