1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-15 06:04:49 +01:00

Add new ini option, adjmouse, enables mouse sensitivity scaling

This commit is contained in:
Toni Spets 2010-11-07 15:54:47 +02:00
parent 58001d9de3
commit 7ff0c285ba
3 changed files with 23 additions and 5 deletions

21
main.c
View File

@ -210,8 +210,16 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if(LOWORD(lParam) != ddraw->render->width / 2 || HIWORD(lParam) != ddraw->render->height / 2)
{
ddraw->cursor.x += LOWORD(lParam) - ddraw->render->width / 2;
ddraw->cursor.y += HIWORD(lParam) - ddraw->render->height / 2;
if(ddraw->adjmouse)
{
ddraw->cursor.x += (LOWORD(lParam) - ddraw->render->width / 2) * ((float)ddraw->width / ddraw->render->width);
ddraw->cursor.y += (HIWORD(lParam) - ddraw->render->height / 2) * ((float)ddraw->height / ddraw->render->height);
}
else
{
ddraw->cursor.x += LOWORD(lParam) - ddraw->render->width / 2;
ddraw->cursor.y += HIWORD(lParam) - ddraw->render->height / 2;
}
if(ddraw->cursor.x < 0) ddraw->cursor.x = 0;
if(ddraw->cursor.y < 0) ddraw->cursor.y = 0;
@ -509,6 +517,15 @@ HRESULT WINAPI DirectDrawCreate(GUID FAR* lpGUID, LPDIRECTDRAW FAR* lplpDD, IUnk
{
This->render->filter = 0;
}
GetPrivateProfileStringA("ddraw", "adjmouse", "TRUE", tmp, sizeof(tmp), ini_path);
if(tolower(tmp[0]) == 'y' || tolower(tmp[0]) == 't' || tmp[0] == '1')
{
This->adjmouse = TRUE;
}
else
{
This->adjmouse = FALSE;
}
This->render->Initialize();

3
main.h
View File

@ -65,10 +65,11 @@ typedef struct IDirectDrawImpl
HWND hWnd;
LRESULT CALLBACK (*WndProc)(HWND, UINT, WPARAM, LPARAM);
POINT winpos;
POINT cursor;
struct { float x; float y; } cursor;
POINT center;
RECT cursorclip;
BOOL locked;
BOOL adjmouse;
BOOL key_ctrl;
BOOL key_tab;

View File

@ -73,8 +73,8 @@ struct game games[] =
BOOL WINAPI fake_GetCursorPos(LPPOINT lpPoint)
{
lpPoint->x = ddraw->cursor.x;
lpPoint->y = ddraw->cursor.y;
lpPoint->x = (int)ddraw->cursor.x;
lpPoint->y = (int)ddraw->cursor.y;
return TRUE;
}