[PATCH 2/8] dinput: Check acquired state in IDirectInputDevice2WImpl_SetCooperativeLevel.
Rémi Bernon
rbernon at codeweavers.com
Thu Sep 23 03:51:35 CDT 2021
Signed-off-by: Rémi Bernon <rbernon at 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 );
--
2.33.0
More information about the wine-devel
mailing list