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