1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-24 17:49:52 +01:00

Improve devmode mouse handling so testing is faster

This commit is contained in:
Toni Spets 2012-08-09 14:35:28 +03:00
parent a24045e39d
commit 0a4aa43722
2 changed files with 26 additions and 6 deletions

16
main.c
View File

@ -349,6 +349,10 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
} }
return 0; return 0;
case WM_MOUSELEAVE:
mouse_unlock();
return 0;
case WM_ACTIVATEAPP: case WM_ACTIVATEAPP:
/* C&C and RA stop drawing when they receive this with FALSE wParam, disable in windowed mode */ /* C&C and RA stop drawing when they receive this with FALSE wParam, disable in windowed mode */
if (ddraw->windowed) if (ddraw->windowed)
@ -406,6 +410,13 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
fake_GetCursorPos(NULL); /* update our own cursor */ fake_GetCursorPos(NULL); /* update our own cursor */
lParam = MAKELPARAM(ddraw->cursor.x, ddraw->cursor.y); lParam = MAKELPARAM(ddraw->cursor.x, ddraw->cursor.y);
} }
if (ddraw->devmode)
{
mouse_lock();
ddraw->cursor.x = GET_X_LPARAM(lParam);
ddraw->cursor.y = GET_Y_LPARAM(lParam);
}
break; break;
/* make sure we redraw when WM_PAINT is requested */ /* make sure we redraw when WM_PAINT is requested */
@ -457,10 +468,7 @@ HRESULT __stdcall ddraw_SetCooperativeLevel(IDirectDrawImpl *This, HWND hWnd, DW
return DD_OK; return DD_OK;
} }
if(!This->devmode) SetWindowLong(This->hWnd, GWL_WNDPROC, (LONG)WndProc);
{
SetWindowLong(This->hWnd, GWL_WNDPROC, (LONG)WndProc);
}
if(!This->render.hDC) if(!This->render.hDC)
{ {

16
mouse.c
View File

@ -187,7 +187,13 @@ void mouse_lock()
{ {
RECT rc; RECT rc;
if(mouse_active && !ddraw->locked) if (ddraw->devmode)
{
while(ShowCursor(FALSE) > 0);
return;
}
if (mouse_active && !ddraw->locked)
{ {
GetWindowRect(ddraw->hWnd, &rc); GetWindowRect(ddraw->hWnd, &rc);
@ -208,6 +214,12 @@ void mouse_unlock()
RECT rc; RECT rc;
POINT pt; POINT pt;
if (ddraw->devmode)
{
while(ShowCursor(TRUE) < 0);
return;
}
if(!mouse_active) if(!mouse_active)
{ {
return; return;
@ -236,7 +248,7 @@ void mouse_unlock()
void mouse_init(HWND hWnd) void mouse_init(HWND hWnd)
{ {
if(ddraw->mhack) if(ddraw->mhack || ddraw->devmode)
{ {
hack_iat(&hacks[0]); hack_iat(&hacks[0]);
mouse_active = TRUE; mouse_active = TRUE;