- keep mouse coordinates as floats for as long as possible.

This commit is contained in:
Christoph Oelckers 2020-09-28 22:12:44 +02:00
parent 3cfd19b2ef
commit 92d630eb45
5 changed files with 15 additions and 15 deletions

View file

@ -155,17 +155,17 @@ void PostMouseMove(int xx, int yy)
if (m_filter) if (m_filter)
{ {
ev.x = xs_CRoundToInt((x + lastx) / 2); ev.x = (x + lastx) / 2;
ev.y = xs_CRoundToInt((y + lasty) / 2); ev.y = (y + lasty) / 2;
} }
else else
{ {
ev.x = xs_CRoundToInt(x); ev.x = x;
ev.y = xs_CRoundToInt(y); ev.y = y;
} }
lastx = x; lastx = x;
lasty = y; lasty = y;
if (ev.x | ev.y) if (ev.x || ev.y)
{ {
ev.type = EV_Mouse; ev.type = EV_Mouse;
D_PostEvent(&ev); D_PostEvent(&ev);
@ -192,8 +192,8 @@ FInputEvent::FInputEvent(const event_t *ev)
KeyString = FString(char(ev->data1)); KeyString = FString(char(ev->data1));
break; break;
case EV_Mouse: case EV_Mouse:
MouseX = ev->x; MouseX = int(ev->x);
MouseY = ev->y; MouseY = int(ev->y);
break; break;
default: default:
break; // EV_DeviceChange = wat? break; // EV_DeviceChange = wat?

View file

@ -22,8 +22,8 @@ struct event_t
int16_t data1; // keys / mouse/joystick buttons int16_t data1; // keys / mouse/joystick buttons
int16_t data2; int16_t data2;
int16_t data3; int16_t data3;
int x; // mouse/joystick x move float x; // mouse/joystick x move
int y; // mouse/joystick y move float y; // mouse/joystick y move
}; };

View file

@ -2724,7 +2724,7 @@ static bool System_DispatchEvent(event_t* ev)
G_AddViewAngle(turn, true); G_AddViewAngle(turn, true);
ev->x = 0; ev->x = 0;
} }
if ((ev->x | ev->y) == 0) if (ev->x == 0 && ev->y == 0)
{ {
return true; return true;
} }

View file

@ -212,8 +212,8 @@ CVAR (Float, m_side, 2.f, CVAR_GLOBALCONFIG|CVAR_ARCHIVE)
int turnheld; // for accelerative turning int turnheld; // for accelerative turning
// mouse values are used once // mouse values are used once
int mousex; float mousex;
int mousey; float mousey;
FString savegamefile; FString savegamefile;
FString savedescription; FString savedescription;
@ -721,7 +721,7 @@ void G_BuildTiccmd (ticcmd_t *cmd)
// Handle mice. // Handle mice.
if (!buttonMap.ButtonDown(Button_Mlook) && !freelook) if (!buttonMap.ButtonDown(Button_Mlook) && !freelook)
{ {
forward += (int)((float)mousey * m_forward); forward += xs_CRoundToInt(mousey * m_forward);
} }
cmd->ucmd.pitch = LocalViewPitch >> 16; cmd->ucmd.pitch = LocalViewPitch >> 16;
@ -733,7 +733,7 @@ void G_BuildTiccmd (ticcmd_t *cmd)
} }
if (strafe || lookstrafe) if (strafe || lookstrafe)
side += (int)((float)mousex * m_side); side += xs_CRoundToInt(mousex * m_side);
mousex = mousey = 0; mousex = mousey = 0;

View file

@ -167,7 +167,7 @@ extern FString BackupSaveName;
bool savegamerestore; bool savegamerestore;
int finishstate = FINISH_NoHub; int finishstate = FINISH_NoHub;
extern int mousex, mousey; extern float mousex, mousey;
extern bool sendpause, sendsave, sendturn180, SendLand; extern bool sendpause, sendsave, sendturn180, SendLand;
void *statcopy; // for statistics driver void *statcopy; // for statistics driver