From e048df42d74d4e02338e2dc41bbe41a3d7ecaec1 Mon Sep 17 00:00:00 2001 From: Toni Spets Date: Thu, 24 Mar 2011 19:42:36 +0200 Subject: [PATCH] Force mouse clip when using vhack --- main.h | 2 +- mouse.c | 6 +++--- render.c | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/main.h b/main.h index 7420f57..de98bcd 100644 --- a/main.h +++ b/main.h @@ -70,7 +70,7 @@ typedef struct IDirectDrawImpl LRESULT CALLBACK (*WndProc)(HWND, UINT, WPARAM, LPARAM); struct { float x; float y; } cursor; POINT center; - RECT cursorclip; + struct { int width; int height; } cursorclip; BOOL locked; BOOL adjmouse; BOOL mhack; diff --git a/mouse.c b/mouse.c index 87007b9..42eb851 100644 --- a/mouse.c +++ b/mouse.c @@ -59,15 +59,15 @@ BOOL WINAPI fake_GetCursorPos(LPPOINT lpPoint) if(ddraw->cursor.x < 0) ddraw->cursor.x = 0; if(ddraw->cursor.y < 0) ddraw->cursor.y = 0; - if(ddraw->cursor.x > ddraw->width-1) ddraw->cursor.x = ddraw->width-1; + if(ddraw->cursor.x > ddraw->cursorclip.width-1) ddraw->cursor.x = ddraw->cursorclip.width-1; - if(real_height) + if(real_height > 0 && real_height < ddraw->cursorclip.height) { if(ddraw->cursor.y > real_height-1) ddraw->cursor.y = real_height-1; } else { - if(ddraw->cursor.y > ddraw->height-1) ddraw->cursor.y = ddraw->height-1; + if(ddraw->cursor.y > ddraw->cursorclip.height-1) ddraw->cursor.y = ddraw->cursorclip.height-1; } if(pt.x != ddraw->center.x || pt.y != ddraw->center.y) diff --git a/render.c b/render.c index 733538f..cf39151 100644 --- a/render.c +++ b/render.c @@ -102,6 +102,24 @@ DWORD WINAPI render_main(void) { scale_w *= 640.0f / ddraw->width; scale_h *= 400.0f / ddraw->height; + + if (ddraw->cursorclip.width != 640 || ddraw->cursorclip.height != 400) + { + ddraw->cursorclip.width = 640; + ddraw->cursorclip.height = 400; + ddraw->cursor.x = 320; + ddraw->cursor.y = 200; + } + } + else + { + if (ddraw->cursorclip.width != ddraw->width || ddraw->cursorclip.height != ddraw->height) + { + ddraw->cursorclip.width = ddraw->width; + ddraw->cursorclip.height = ddraw->height; + ddraw->cursor.x = ddraw->width / 2; + ddraw->cursor.y = ddraw->height / 2; + } } for(i=0; iheight; i++)