From 92d630eb45e5967aa990796db20ce14e53773241 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 28 Sep 2020 22:12:44 +0200 Subject: [PATCH] - keep mouse coordinates as floats for as long as possible. --- src/common/engine/d_event.cpp | 14 +++++++------- src/common/engine/d_eventbase.h | 4 ++-- src/d_main.cpp | 2 +- src/g_game.cpp | 8 ++++---- src/g_level.cpp | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/common/engine/d_event.cpp b/src/common/engine/d_event.cpp index 1e705c67f2..9c612cf3dc 100644 --- a/src/common/engine/d_event.cpp +++ b/src/common/engine/d_event.cpp @@ -155,17 +155,17 @@ void PostMouseMove(int xx, int yy) if (m_filter) { - ev.x = xs_CRoundToInt((x + lastx) / 2); - ev.y = xs_CRoundToInt((y + lasty) / 2); + ev.x = (x + lastx) / 2; + ev.y = (y + lasty) / 2; } else { - ev.x = xs_CRoundToInt(x); - ev.y = xs_CRoundToInt(y); + ev.x = x; + ev.y = y; } lastx = x; lasty = y; - if (ev.x | ev.y) + if (ev.x || ev.y) { ev.type = EV_Mouse; D_PostEvent(&ev); @@ -192,8 +192,8 @@ FInputEvent::FInputEvent(const event_t *ev) KeyString = FString(char(ev->data1)); break; case EV_Mouse: - MouseX = ev->x; - MouseY = ev->y; + MouseX = int(ev->x); + MouseY = int(ev->y); break; default: break; // EV_DeviceChange = wat? diff --git a/src/common/engine/d_eventbase.h b/src/common/engine/d_eventbase.h index c2b994ae70..992a5f400c 100644 --- a/src/common/engine/d_eventbase.h +++ b/src/common/engine/d_eventbase.h @@ -22,8 +22,8 @@ struct event_t int16_t data1; // keys / mouse/joystick buttons int16_t data2; int16_t data3; - int x; // mouse/joystick x move - int y; // mouse/joystick y move + float x; // mouse/joystick x move + float y; // mouse/joystick y move }; diff --git a/src/d_main.cpp b/src/d_main.cpp index 7b82ee775b..8f27a9d56b 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -2724,7 +2724,7 @@ static bool System_DispatchEvent(event_t* ev) G_AddViewAngle(turn, true); ev->x = 0; } - if ((ev->x | ev->y) == 0) + if (ev->x == 0 && ev->y == 0) { return true; } diff --git a/src/g_game.cpp b/src/g_game.cpp index 7d247d28c4..d14054c0fd 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -212,8 +212,8 @@ CVAR (Float, m_side, 2.f, CVAR_GLOBALCONFIG|CVAR_ARCHIVE) int turnheld; // for accelerative turning // mouse values are used once -int mousex; -int mousey; +float mousex; +float mousey; FString savegamefile; FString savedescription; @@ -721,7 +721,7 @@ void G_BuildTiccmd (ticcmd_t *cmd) // Handle mice. if (!buttonMap.ButtonDown(Button_Mlook) && !freelook) { - forward += (int)((float)mousey * m_forward); + forward += xs_CRoundToInt(mousey * m_forward); } cmd->ucmd.pitch = LocalViewPitch >> 16; @@ -733,7 +733,7 @@ void G_BuildTiccmd (ticcmd_t *cmd) } if (strafe || lookstrafe) - side += (int)((float)mousex * m_side); + side += xs_CRoundToInt(mousex * m_side); mousex = mousey = 0; diff --git a/src/g_level.cpp b/src/g_level.cpp index ca99e9fa37..a8cb2ae4b6 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -167,7 +167,7 @@ extern FString BackupSaveName; bool savegamerestore; int finishstate = FINISH_NoHub; -extern int mousex, mousey; +extern float mousex, mousey; extern bool sendpause, sendsave, sendturn180, SendLand; void *statcopy; // for statistics driver