mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-15 06:04:49 +01:00
reinvent adjmouse
This commit is contained in:
parent
b579a258f8
commit
fcdc863ffa
8
ddraw.rc
8
ddraw.rc
@ -1,6 +1,6 @@
|
||||
1 VERSIONINFO
|
||||
FILEVERSION 1,1,5,1
|
||||
PRODUCTVERSION 1,1,5,1
|
||||
FILEVERSION 1,1,5,2
|
||||
PRODUCTVERSION 1,1,5,2
|
||||
{
|
||||
BLOCK "StringFileInfo"
|
||||
{
|
||||
@ -8,13 +8,13 @@ PRODUCTVERSION 1,1,5,1
|
||||
{
|
||||
VALUE "CompanyName", "cncnet.org"
|
||||
VALUE "FileDescription", "DirectDraw replacement for C&C95 and Red Alert"
|
||||
VALUE "FileVersion", "1.1.5.1"
|
||||
VALUE "FileVersion", "1.1.5.2"
|
||||
VALUE "InternalName", "ddraw"
|
||||
VALUE "LegalCopyright", "Copyright (c) 2010-2018"
|
||||
VALUE "LegalTrademarks", ""
|
||||
VALUE "OriginalFileName", "ddraw.dll"
|
||||
VALUE "ProductName", "DirectDraw replacement for C&C95 and Red Alert"
|
||||
VALUE "ProductVersion", "1.1.5.1"
|
||||
VALUE "ProductVersion", "1.1.5.2"
|
||||
VALUE "Comments", "https://cncnet.org"
|
||||
}
|
||||
}
|
||||
|
@ -75,6 +75,7 @@ typedef struct IDirectDrawImpl
|
||||
struct { float x; float y; } cursor;
|
||||
struct { int width; int height; } cursorclip;
|
||||
BOOL locked;
|
||||
BOOL adjmouse;
|
||||
BOOL devmode;
|
||||
BOOL vsync;
|
||||
BOOL vhack;
|
||||
|
25
src/main.c
25
src/main.c
@ -609,9 +609,18 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
case WM_MBUTTONDOWN:
|
||||
case WM_MOUSEMOVE:
|
||||
|
||||
if (!ddraw->devmode && !ddraw->locked)
|
||||
if (!ddraw->devmode)
|
||||
{
|
||||
return 0;
|
||||
if (!ddraw->locked)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(ddraw->adjmouse)
|
||||
{
|
||||
fake_GetCursorPos(NULL); /* update our own cursor */
|
||||
lParam = MAKELPARAM(ddraw->cursor.x, ddraw->cursor.y);
|
||||
}
|
||||
}
|
||||
|
||||
if (ddraw->devmode)
|
||||
@ -894,6 +903,8 @@ HRESULT WINAPI DirectDrawCreate(GUID FAR* lpGUID, LPDIRECTDRAW FAR* lplpDD, IUnk
|
||||
"vsync=false\n"
|
||||
"; scaling filter, nearest = sharp, linear = smooth (OpenGL only)\n"
|
||||
"filter=nearest\n"
|
||||
"; automatic mouse sensitivity scaling\n"
|
||||
"adjmouse=false\n"
|
||||
"; enable C&C video resize hack, auto = auto-detect game, true = forced, false = disabled\n"
|
||||
"vhack=false\n"
|
||||
"; switch between OpenGL (opengl) and software (gdi) renderers, latter supports less features but might be faster depending on the GPU\n"
|
||||
@ -988,6 +999,16 @@ HRESULT WINAPI DirectDrawCreate(GUID FAR* lpGUID, LPDIRECTDRAW FAR* lplpDD, IUnk
|
||||
This->render.filter = 0;
|
||||
}
|
||||
|
||||
GetPrivateProfileStringA("ddraw", "adjmouse", "FALSE", tmp, sizeof(tmp), SettingsIniPath);
|
||||
if (tolower(tmp[0]) == 'y' || tolower(tmp[0]) == 't' || tolower(tmp[0]) == 'e' || tmp[0] == '1')
|
||||
{
|
||||
This->adjmouse = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
This->adjmouse = FALSE;
|
||||
}
|
||||
|
||||
GetPrivateProfileStringA("ddraw", "devmode", "FALSE", tmp, sizeof(tmp), SettingsIniPath);
|
||||
if (tolower(tmp[0]) == 'y' || tolower(tmp[0]) == 't' || tolower(tmp[0]) == 'e' || tmp[0] == '1')
|
||||
{
|
||||
|
48
src/mouse.c
48
src/mouse.c
@ -35,19 +35,27 @@ struct hack
|
||||
|
||||
BOOL WINAPI fake_GetCursorPos(LPPOINT lpPoint)
|
||||
{
|
||||
if (lpPoint)
|
||||
POINT pt;
|
||||
|
||||
if (!GetCursorPos(&pt))
|
||||
return FALSE;
|
||||
|
||||
if(ddraw->locked && (!ddraw->windowed || ScreenToClient(ddraw->hWnd, &pt)))
|
||||
{
|
||||
POINT pt;
|
||||
|
||||
if (!GetCursorPos(&pt))
|
||||
return FALSE;
|
||||
|
||||
if(ddraw->locked && (!ddraw->windowed || ScreenToClient(ddraw->hWnd, &pt)))
|
||||
if(ddraw->adjmouse)
|
||||
{
|
||||
ddraw->cursor.x = pt.x * ((float)ddraw->width / ddraw->render.width);
|
||||
ddraw->cursor.y = pt.y * ((float)ddraw->height / ddraw->render.height);
|
||||
}
|
||||
else
|
||||
{
|
||||
ddraw->cursor.x = pt.x;
|
||||
ddraw->cursor.y = pt.y;
|
||||
}
|
||||
}
|
||||
|
||||
if (lpPoint)
|
||||
{
|
||||
lpPoint->x = (int)ddraw->cursor.x;
|
||||
lpPoint->y = (int)ddraw->cursor.y;
|
||||
}
|
||||
@ -169,9 +177,12 @@ void mouse_lock()
|
||||
// Get the window client area.
|
||||
GetClientRect(ddraw->hWnd, &rc);
|
||||
|
||||
// stretching fix
|
||||
rc.right -= (ddraw->render.width - ddraw->width);
|
||||
rc.bottom -= (ddraw->render.height - ddraw->height);
|
||||
if(!ddraw->adjmouse)
|
||||
{
|
||||
// stretching fix
|
||||
rc.right -= (ddraw->render.width - ddraw->width);
|
||||
rc.bottom -= (ddraw->render.height - ddraw->height);
|
||||
}
|
||||
|
||||
// Convert the client area to screen coordinates.
|
||||
POINT pt = { rc.left, rc.top };
|
||||
@ -181,10 +192,19 @@ void mouse_lock()
|
||||
|
||||
SetRect(&rc, pt.x, pt.y, pt2.x, pt2.y);
|
||||
|
||||
rc.bottom -= yAdjust * 2;
|
||||
rc.bottom -= (yAdjust * 2);
|
||||
|
||||
if(ddraw->adjmouse)
|
||||
{
|
||||
SetCursorPos(
|
||||
rc.left + (ddraw->cursor.x * ((float)ddraw->render.width / ddraw->width)),
|
||||
rc.top + ((ddraw->cursor.y - yAdjust) * ((float)ddraw->render.height / ddraw->height)));
|
||||
}
|
||||
else
|
||||
{
|
||||
SetCursorPos(rc.left + ddraw->cursor.x, rc.top + ddraw->cursor.y - yAdjust);
|
||||
}
|
||||
|
||||
SetCursorPos(rc.left + ddraw->cursor.x, rc.top + ddraw->cursor.y - yAdjust);
|
||||
|
||||
SetCapture(ddraw->hWnd);
|
||||
ClipCursor(&rc);
|
||||
|
||||
@ -229,7 +249,7 @@ void mouse_unlock()
|
||||
ReleaseCapture();
|
||||
|
||||
SetCursorPos(
|
||||
rc.left + (ddraw->cursor.x * ((float)ddraw->render.width / ddraw->width)),
|
||||
rc.left + (ddraw->cursor.x * ((float)ddraw->render.width / ddraw->width)),
|
||||
rc.top + ((ddraw->cursor.y + yAdjust) * ((float)ddraw->render.height / ddraw->height)));
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user