Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/device.c | 12 +++++++++--- dlls/dinput8/tests/hid.c | 1 - 2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index 2a3ed391919..11496640049 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -1118,6 +1118,7 @@ HRESULT WINAPI IDirectInputDevice2WImpl_SetDataFormat(LPDIRECTINPUTDEVICE8W ifac HRESULT WINAPI IDirectInputDevice2WImpl_SetCooperativeLevel(LPDIRECTINPUTDEVICE8W iface, HWND hwnd, DWORD dwflags) { IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface); + HRESULT hr;
TRACE("(%p) %p,0x%08x\n", This, hwnd, dwflags); _dump_cooperativelevel_DI(dwflags); @@ -1144,11 +1145,16 @@ HRESULT WINAPI IDirectInputDevice2WImpl_SetCooperativeLevel(LPDIRECTINPUTDEVICE8
/* Store the window which asks for the mouse */ EnterCriticalSection(&This->crit); - This->win = hwnd; - This->dwCoopLevel = dwflags; + if (This->acquired) hr = DIERR_ACQUIRED; + else + { + This->win = hwnd; + This->dwCoopLevel = dwflags; + hr = DI_OK; + } LeaveCriticalSection(&This->crit);
- return DI_OK; + return hr; }
/****************************************************************************** diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c index e017e048a30..c0f1b78160c 100644 --- a/dlls/dinput8/tests/hid.c +++ b/dlls/dinput8/tests/hid.c @@ -4082,7 +4082,6 @@ static void test_simple_joystick(void) hr = IDirectInputDevice8_Acquire( device ); ok( hr == DI_OK, "IDirectInputDevice8_Acquire returned: %#x\n", hr ); hr = IDirectInputDevice8_SetCooperativeLevel( device, hwnd, DISCL_FOREGROUND | DISCL_EXCLUSIVE ); - todo_wine ok( hr == DIERR_ACQUIRED, "IDirectInputDevice8_SetCooperativeLevel returned: %#x\n", hr ); hr = IDirectInputDevice8_Unacquire( device ); ok( hr == DI_OK, "IDirectInputDevice8_Unacquire returned: %#x\n", hr );