Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
mjr4077au committed Jul 23, 2022
1 parent c68e112 commit 78fcf2b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
9 changes: 0 additions & 9 deletions source/core/gameinput.cpp
Expand Up @@ -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")


//---------------------------------------------------------------------------
//
Expand Down Expand Up @@ -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);
Expand Down
17 changes: 16 additions & 1 deletion source/core/inputstate.cpp
Expand Up @@ -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")

//==========================================================================
//
Expand All @@ -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 = {};
}

Expand Down

0 comments on commit 78fcf2b

Please sign in to comment.