- Move invertmouse and invertmousex CVARs from gameinput.cpp to inputstate.cpp.

* Old setup was inverting the entire player's horz/avel, even for joystick input while not inverting `mousemovex` or `mousemovey` at all.
This commit is contained in:
Mitchell Richters 2022-06-11 17:24:14 +10:00
parent c68e112867
commit 78fcf2b4f0
2 changed files with 16 additions and 10 deletions

View file

@ -27,9 +27,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "serializer.h"
#include "build.h"
CVARD(Bool, invertmousex, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "invert horizontal mouse movement")
CVARD(Bool, invertmouse, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "invert vertical mouse movement")
//---------------------------------------------------------------------------
//
@ -205,12 +202,6 @@ void processMovement(InputPacket* const currInput, InputPacket* const inputBuffe
else
currInput->fvel -= int16_t(hidInput->mousemovey * mousevelscale * hidprescale);
if (invertmouse)
currInput->horz = -currInput->horz;
if (invertmousex)
currInput->avel = -currInput->avel;
// process remaining controller input.
currInput->horz -= float(scaleAdjust * hidInput->dpitch * hidspeed);
currInput->svel += int16_t(scaleAdjust * hidInput->dx * keymove * hidprescale);

View file

@ -51,10 +51,13 @@ static int dpad_lock = 0;
bool sendPause;
bool crouch_toggle;
CVAR(Float, m_pitch, 1.f, CVAR_GLOBALCONFIG | CVAR_ARCHIVE) // Mouse speeds
// Mouse speeds
CVAR(Float, m_pitch, 1.f, CVAR_GLOBALCONFIG | CVAR_ARCHIVE)
CVAR(Float, m_yaw, 1.f, CVAR_GLOBALCONFIG | CVAR_ARCHIVE)
CVAR(Float, m_forward, 1.f, CVAR_GLOBALCONFIG | CVAR_ARCHIVE)
CVAR(Float, m_side, 1.f, CVAR_GLOBALCONFIG | CVAR_ARCHIVE)
CVARD(Bool, invertmousex, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "invert horizontal mouse movement")
CVARD(Bool, invertmouse, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "invert vertical mouse movement")
//==========================================================================
//
@ -69,6 +72,18 @@ void InputState::GetMouseDelta(ControlInfo * hidInput)
hidInput->mousemovex = g_mousePos.X * m_side;
hidInput->mousemovey = g_mousePos.Y * m_forward;
if (invertmousex)
{
hidInput->mouseturnx = -hidInput->mouseturnx;
hidInput->mousemovex = -hidInput->mousemovex;
}
if (invertmouse)
{
hidInput->mouseturny = -hidInput->mouseturny;
hidInput->mousemovey = -hidInput->mousemovey;
}
g_mousePos = {};
}