diff --git a/source/core/inputstate.cpp b/source/core/inputstate.cpp index c5716b7d7..b15969a20 100644 --- a/source/core/inputstate.cpp +++ b/source/core/inputstate.cpp @@ -64,8 +64,8 @@ CVAR(Float, m_side, 1.f, CVAR_GLOBALCONFIG | CVAR_ARCHIVE) void InputState::GetMouseDelta(ControlInfo * hidInput) { - hidInput->mouseturnx = g_mousePos.X * m_yaw * (1.f / 18.f); - hidInput->mouseturny = g_mousePos.Y * m_pitch * (1.f / 14.f); + hidInput->mouseturnx = g_mousePos.X * m_yaw * backendinputscale(); + hidInput->mouseturny = g_mousePos.Y * m_pitch * backendinputscale(); hidInput->mousemovex = g_mousePos.X * m_side; hidInput->mousemovey = g_mousePos.Y * m_forward; diff --git a/source/core/inputstate.h b/source/core/inputstate.h index a666e33a7..4fadf21bd 100644 --- a/source/core/inputstate.h +++ b/source/core/inputstate.h @@ -111,6 +111,11 @@ inline bool SyncInput() return gamesetinput || cl_syncinput; } +inline float backendinputscale() +{ + return (1.f / 16.f); +} + //--------------------------------------------------------------------------- // // Inline functions to help with edge cases where synchronised input is needed. diff --git a/source/games/duke/src/input.cpp b/source/games/duke/src/input.cpp index 8d58faec4..ac2fb243f 100644 --- a/source/games/duke/src/input.cpp +++ b/source/games/duke/src/input.cpp @@ -39,6 +39,9 @@ source as it is released. #include "v_video.h" #include "dukeactor.h" +EXTERN_CVAR(Float, m_sensitivity_x) +EXTERN_CVAR(Float, m_yaw) + BEGIN_DUKE_NS // State timer counters. @@ -733,6 +736,10 @@ static void processVehicleInput(player_struct *p, ControlInfo* const hidInput, I { bool const kbdLeft = buttonMap.ButtonDown(gamefunc_Turn_Left) || buttonMap.ButtonDown(gamefunc_Strafe_Left); bool const kbdRight = buttonMap.ButtonDown(gamefunc_Turn_Right) || buttonMap.ButtonDown(gamefunc_Strafe_Right); + + // Cancel out micro-movement + if (fabs(hidInput->mouseturnx) < (m_sensitivity_x * m_yaw * backendinputscale() * 2.f)) hidInput->mouseturnx = 0; + p->vehTurnLeft = kbdLeft || hidInput->mouseturnx < 0 || hidInput->dyaw < 0; p->vehTurnRight = kbdRight || hidInput->mouseturnx > 0 || hidInput->dyaw > 0; @@ -753,7 +760,7 @@ static void processVehicleInput(player_struct *p, ControlInfo* const hidInput, I input.avel = (float)boatApplyTurn(p, hidInput, kbdLeft, kbdRight, scaleAdjust); } - loc.fvel = (int16_t)clamp(xs_CRoundToInt(p->MotoSpeed), -(MAXVELMOTO >> 3), MAXVELMOTO); + loc.fvel = clamp(xs_CRoundToInt(p->MotoSpeed), -(MAXVELMOTO >> 3), MAXVELMOTO); input.avel *= BAngToDegree; loc.avel += input.avel; }