mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-24 17:49:52 +01:00
tweak fallback solution for possible ClipCursor failure
This commit is contained in:
parent
ad07b46822
commit
1d83797a48
40
src/mouse.c
40
src/mouse.c
@ -47,21 +47,35 @@ BOOL WINAPI fake_GetCursorPos(LPPOINT lpPoint)
|
|||||||
{
|
{
|
||||||
//fallback solution for possible ClipCursor failure
|
//fallback solution for possible ClipCursor failure
|
||||||
int diffx = 0, diffy = 0;
|
int diffx = 0, diffy = 0;
|
||||||
|
int maxWidth = ddraw->adjmouse ? ddraw->render.viewport.width : ddraw->width;
|
||||||
|
int maxHeight = ddraw->adjmouse ? ddraw->render.viewport.height : ddraw->height;
|
||||||
|
|
||||||
if (pt.x < 0)
|
if (pt.x < 0)
|
||||||
{
|
{
|
||||||
diffx = abs(pt.x);
|
diffx = pt.x;
|
||||||
pt.x = 0;
|
pt.x = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pt.y < 0)
|
if (pt.y < 0)
|
||||||
{
|
{
|
||||||
diffy = abs(pt.y);
|
diffy = pt.y;
|
||||||
pt.y = 0;
|
pt.y = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pt.x > maxWidth)
|
||||||
|
{
|
||||||
|
diffx = pt.x - maxWidth;
|
||||||
|
pt.x = maxWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pt.y > maxHeight)
|
||||||
|
{
|
||||||
|
diffy = pt.y - maxHeight;
|
||||||
|
pt.y = maxHeight;
|
||||||
|
}
|
||||||
|
|
||||||
if (diffx || diffy)
|
if (diffx || diffy)
|
||||||
SetCursorPos(realpt.x + diffx, realpt.y + diffy);
|
SetCursorPos(realpt.x - diffx, realpt.y - diffy);
|
||||||
|
|
||||||
|
|
||||||
if(ddraw->adjmouse)
|
if(ddraw->adjmouse)
|
||||||
@ -75,26 +89,6 @@ BOOL WINAPI fake_GetCursorPos(LPPOINT lpPoint)
|
|||||||
ddraw->cursor.y = pt.y;
|
ddraw->cursor.y = pt.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
//fallback solution for possible ClipCursor failure
|
|
||||||
diffx = 0;
|
|
||||||
diffy = 0;
|
|
||||||
|
|
||||||
if (ddraw->cursor.x > ddraw->width)
|
|
||||||
{
|
|
||||||
diffx = ddraw->cursor.x - ddraw->width;
|
|
||||||
ddraw->cursor.x = ddraw->width;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ddraw->cursor.y > ddraw->height)
|
|
||||||
{
|
|
||||||
diffy = ddraw->cursor.y - ddraw->height;
|
|
||||||
ddraw->cursor.y = ddraw->height;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (diffx || diffy)
|
|
||||||
SetCursorPos(realpt.x - diffx, realpt.y - diffy);
|
|
||||||
|
|
||||||
|
|
||||||
if (ddraw->vhack && (ddraw->iscnc1 || ddraw->isredalert) && ddraw->incutscene)
|
if (ddraw->vhack && (ddraw->iscnc1 || ddraw->isredalert) && ddraw->incutscene)
|
||||||
{
|
{
|
||||||
diffx = 0;
|
diffx = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user