Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jonatansberg
Created March 2, 2012 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonatansberg/1958584 to your computer and use it in GitHub Desktop.
Save jonatansberg/1958584 to your computer and use it in GitHub Desktop.
dinput: Applied old "force_edge" patch to 1.4-rc5.
diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c
index 7cac0fc..310aca8 100644
--- a/dlls/dinput/mouse.c
+++ b/dlls/dinput/mouse.c
@@ -55,7 +55,8 @@ typedef enum
{
WARP_DEFAULT,
WARP_DISABLE,
- WARP_FORCE_ON
+ WARP_FORCE_ON,
+ WARP_FORCE_EDGE
} WARP_MOUSE;
struct SysMouseImpl
@@ -222,6 +223,8 @@ static SysMouseImpl *alloc_device(REFGUID rguid, IDirectInputImpl *dinput)
newDevice->warp_override = WARP_DISABLE;
else if (!strcasecmp(buffer, "force"))
newDevice->warp_override = WARP_FORCE_ON;
+ else if (!strcasecmp(buffer, "force_edge"))
+ newDevice->warp_override = WARP_FORCE_EDGE;
}
if (appkey) RegCloseKey(appkey);
if (hkey) RegCloseKey(hkey);
@@ -320,6 +323,7 @@ static int dinput_mouse_hook( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM
MSLLHOOKSTRUCT *hook = (MSLLHOOKSTRUCT *)lparam;
SysMouseImpl* This = impl_from_IDirectInputDevice8A(iface);
int wdata = 0, inst_id = -1, ret = 0;
+ RECT rect;
TRACE("msg %lx @ (%d %d)\n", wparam, hook->pt.x, hook->pt.y);
@@ -355,13 +359,24 @@ static int dinput_mouse_hook( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM
inst_id = DIDFT_MAKEINSTANCE(WINE_MOUSE_Y_AXIS_INSTANCE) | DIDFT_RELAXIS;
wdata = pt1.y;
}
+
+ if (This->warp_override != WARP_DISABLE &&
+ (
+ ((pt.x || pt.y) && This->warp_override != WARP_FORCE_EDGE) ||
+ (
+ This->warp_override == WARP_FORCE_EDGE &&
+ GetClientRect(This->base.win, &rect) &&
+ (
+ hook->pt.x < 2 ||
+ hook->pt.y < 2 ||
+ hook->pt.x > (rect.left + rect.right - 2) ||
+ hook->pt.y > (rect.top + rect.bottom - 2)
+ )
+ )
+ ) &&
+ (This->base.dwCoopLevel & DISCL_EXCLUSIVE || This->warp_override >= WARP_FORCE_ON))
+ This->need_warp = TRUE;
- if (pt.x || pt.y)
- {
- if ((This->warp_override == WARP_FORCE_ON) ||
- (This->warp_override != WARP_DISABLE && (This->base.dwCoopLevel & DISCL_EXCLUSIVE)))
- This->need_warp = TRUE;
- }
break;
}
case WM_MOUSEWHEEL:
@@ -487,7 +502,7 @@ static HRESULT WINAPI SysMouseWImpl_Acquire(LPDIRECTINPUTDEVICE8W iface)
ShowCursor(FALSE); /* hide cursor */
warp_check( This, TRUE );
}
- else if (This->warp_override == WARP_FORCE_ON)
+ else if (This->warp_override >= WARP_FORCE_ON)
{
/* Need a window to warp mouse in. */
if (!This->base.win) This->base.win = GetDesktopWindow();
@@ -528,7 +543,7 @@ static HRESULT WINAPI SysMouseWImpl_Unacquire(LPDIRECTINPUTDEVICE8W iface)
}
/* And put the mouse cursor back where it was at acquire time */
- if (This->base.dwCoopLevel & DISCL_EXCLUSIVE || This->warp_override == WARP_FORCE_ON)
+ if (This->base.dwCoopLevel & DISCL_EXCLUSIVE || This->warp_override >= WARP_FORCE_ON)
{
TRACE(" warping mouse back to (%d , %d)\n", This->org_coords.x, This->org_coords.y);
SetCursorPos(This->org_coords.x, This->org_coords.y);
@zerdos
Copy link

zerdos commented Jan 31, 2019

But RCA2?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment