Commit 0036e438 authored by Alexandre Julliard's avatar Alexandre Julliard

dinput: Pass mouse messages through if the request to clip the cursor is rejected.

parent c52f4154
......@@ -66,6 +66,7 @@ struct SysMouseImpl
/* These are used in case of relative -> absolute transitions */
POINT org_coords;
POINT mapped_center;
BOOL clipped;
/* warping: whether we need to move mouse back to middle once we
* reach window borders (for e.g. shooters, "surface movement" games) */
BOOL need_warp;
......@@ -319,21 +320,20 @@ static int dinput_mouse_hook( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM
{
MSLLHOOKSTRUCT *hook = (MSLLHOOKSTRUCT *)lparam;
SysMouseImpl* This = impl_from_IDirectInputDevice8A(iface);
DWORD dwCoop;
int wdata = 0, inst_id = -1, ret;
TRACE("msg %lx @ (%d %d)\n", wparam, hook->pt.x, hook->pt.y);
EnterCriticalSection(&This->base.crit);
dwCoop = This->base.dwCoopLevel;
ret = dwCoop & DISCL_EXCLUSIVE;
ret = This->clipped;
switch(wparam) {
case WM_MOUSEMOVE:
{
POINT pt, pt1;
GetCursorPos(&pt);
if (This->clipped) pt = This->mapped_center;
else GetCursorPos(&pt);
This->m_state.lX += pt.x = hook->pt.x - pt.x;
This->m_state.lY += pt.y = hook->pt.y - pt.y;
......@@ -422,28 +422,29 @@ static int dinput_mouse_hook( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM
static HRESULT warp_check( SysMouseImpl* This, BOOL force )
{
DWORD now = GetCurrentTime();
const DWORD interval = (This->base.dwCoopLevel & DISCL_EXCLUSIVE) ? 500 : 10;
const DWORD interval = This->clipped ? 500 : 10;
if (force || (This->need_warp && (now - This->last_warped > interval)))
{
RECT rect;
RECT rect, new_rect;
This->last_warped = now;
This->need_warp = FALSE;
if (!GetWindowRect(This->base.win, &rect)) return DIERR_GENERIC;
This->mapped_center.x = (rect.left + rect.right) / 2;
This->mapped_center.y = (rect.top + rect.bottom) / 2;
if (!This->clipped)
{
TRACE("Warping mouse to %d - %d\n", This->mapped_center.x, This->mapped_center.y);
SetCursorPos( This->mapped_center.x, This->mapped_center.y );
}
if (This->base.dwCoopLevel & DISCL_EXCLUSIVE)
{
SetRect( &rect, This->mapped_center.x, This->mapped_center.y,
This->mapped_center.x + 1, This->mapped_center.y + 1 );
TRACE("Clipping mouse to %s\n", wine_dbgstr_rect( &rect ));
ClipCursor( &rect );
}
else
{
TRACE("Warping mouse to %d - %d\n", This->mapped_center.x, This->mapped_center.y);
SetCursorPos( This->mapped_center.x, This->mapped_center.y );
This->clipped = GetClipCursor( &new_rect ) && EqualRect( &rect, &new_rect );
}
}
return DI_OK;
......
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