From 7e6d0e71ebf00e109055da7660c1043c2997b279 Mon Sep 17 00:00:00 2001 From: Vitaliy Margolen Date: Sun, 7 Oct 2007 10:30:02 -0600 Subject: [PATCH] dinput: Use ClipCursor() to keep mouse from leaving the window. --- dlls/dinput/mouse.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c index 8edfe0e7061..214bbd857a1 100644 --- a/dlls/dinput/mouse.c +++ b/dlls/dinput/mouse.c @@ -410,7 +410,18 @@ static HRESULT WINAPI SysMouseAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface) /* Install our mouse hook */ if (This->base.dwCoopLevel & DISCL_EXCLUSIVE) + { + RECT rc; + ShowCursor(FALSE); /* hide cursor */ + if (GetWindowRect(This->base.win, &rc)) + { + FIXME("Clipping cursor to %s\n", wine_dbgstr_rect( &rc )); + ClipCursor(&rc); + } + else + ERR("Failed to get RECT: %d\n", GetLastError()); + } /* Get the window dimension and find the center */ GetWindowRect(This->base.win, &rect); @@ -446,7 +457,10 @@ static HRESULT WINAPI SysMouseAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface) if ((res = IDirectInputDevice2AImpl_Unacquire(iface)) != DI_OK) return res; if (This->base.dwCoopLevel & DISCL_EXCLUSIVE) + { + ClipCursor(NULL); ShowCursor(TRUE); /* show cursor */ + } /* And put the mouse cursor back where it was at acquire time */ if (This->base.dwCoopLevel & DISCL_EXCLUSIVE)