- cleanup of mouse input code and removal of all magic factors.

Sensitivity scaling of both axes is now exposed as a raw factor to the user instead of obscuring it behind an unclear 'prescale' boolean.
This also consolidates the coordinate processing code to prevent such discrepancies as were present here from happening again.
Migration code for old config settings is present so that this change does not affect existing configurations.
This commit is contained in:
Christoph Oelckers 2020-09-28 21:13:34 +02:00
commit 51518d63a4
13 changed files with 139 additions and 187 deletions

View file

@ -447,47 +447,8 @@ CCMD(togglehud)
D_ToggleHud();
}
//==========================================================================
//
// D_PostEvent
//
// Called by the I/O functions when input is detected.
//
//==========================================================================
void D_PostEvent (const event_t *ev)
{
// Do not post duplicate consecutive EV_DeviceChange events.
if (ev->type == EV_DeviceChange && events[eventhead].type == EV_DeviceChange)
{
return;
}
events[eventhead] = *ev;
if (ev->type == EV_Mouse && menuactive == MENU_Off && ConsoleState != c_down && ConsoleState != c_falling && !primaryLevel->localEventManager->Responder(ev) && !paused)
{
if (buttonMap.ButtonDown(Button_Mlook) || freelook)
{
int look = int(ev->y * m_pitch * mouse_sensitivity * 16.0);
if (invertmouse)
look = -look;
G_AddViewPitch (look, true);
events[eventhead].y = 0;
}
if (!buttonMap.ButtonDown(Button_Strafe) && !lookstrafe)
{
int turn = int(ev->x * m_yaw * mouse_sensitivity * 8.0);
if (invertmousex)
turn = -turn;
G_AddViewAngle (turn, true);
events[eventhead].x = 0;
}
if ((events[eventhead].x | events[eventhead].y) == 0)
{
return;
}
}
eventhead = (eventhead+1)&(MAXEVENTS-1);
}
CVAR(Float, m_pitch, 1.f, CVAR_GLOBALCONFIG | CVAR_ARCHIVE) // Mouse speeds
CVAR(Float, m_yaw, 1.f, CVAR_GLOBALCONFIG | CVAR_ARCHIVE)
//==========================================================================
//
@ -2744,6 +2705,33 @@ bool System_WantLeftButton()
return (gamestate == GS_DEMOSCREEN || gamestate == GS_TITLELEVEL);
}
static bool System_DispatchEvent(event_t* ev)
{
if (ev->type == EV_Mouse && menuactive == MENU_Off && ConsoleState != c_down && ConsoleState != c_falling && !primaryLevel->localEventManager->Responder(ev) && !paused)
{
if (buttonMap.ButtonDown(Button_Mlook) || freelook)
{
int look = int(ev->y * m_pitch * 16.0);
if (invertmouse) look = -look;
G_AddViewPitch(look, true);
ev->y = 0;
}
if (!buttonMap.ButtonDown(Button_Strafe) && !lookstrafe)
{
int turn = int(ev->x * m_yaw * 8.0);
if (invertmousex)
turn = -turn;
G_AddViewAngle(turn, true);
ev->x = 0;
}
if ((ev->x | ev->y) == 0)
{
return true;
}
}
return false;
}
bool System_NetGame()
{
return netgame;
@ -3076,6 +3064,7 @@ static int D_DoomMain_Internal (void)
System_GetLocationDescription,
System_M_Dim,
System_GetPlayerName,
System_DispatchEvent,
};
sysCallbacks = &syscb;