diff --git a/source/core/gameinput.cpp b/source/core/gameinput.cpp index ccbc502e0..5f96211a7 100644 --- a/source/core/gameinput.cpp +++ b/source/core/gameinput.cpp @@ -148,19 +148,19 @@ void processMovement(HIDInput* const hidInput, InputPacket* const currInput, con { const float turndir = clamp(turning + strafing * !allowstrafe, -1.f, 1.f); const float turnspeed = float(getTicrateScale(YAW_TURNSPEEDS[keymove]) * turnscale * (isTurboTurnTime() ? 1. : YAW_PREAMBLESCALE)); - currInput->avel += hidInput->mousex * m_yaw - (hidInput->joyaxes[JOYAXIS_Yaw] * hidspeed - turndir * turnspeed) * scaleAdjustf; + currInput->avel += hidInput->mouse.X * m_yaw - (hidInput->joyaxes[JOYAXIS_Yaw] * hidspeed - turndir * turnspeed) * scaleAdjustf; if (turndir) updateTurnHeldAmt(scaleAdjust); else resetTurnHeldAmt(); } else { - currInput->svel += hidInput->mousex * m_side - (hidInput->joyaxes[JOYAXIS_Yaw] - turning) * keymove * scaleAdjustf; + currInput->svel += hidInput->mouse.X * m_side - (hidInput->joyaxes[JOYAXIS_Yaw] - turning) * keymove * scaleAdjustf; } // process player pitch input. if (!(inputBuffer.actions & SB_AIMMODE)) - currInput->horz -= hidInput->mousey * m_pitch + hidInput->joyaxes[JOYAXIS_Pitch] * hidspeed * scaleAdjustf; + currInput->horz -= hidInput->mouse.Y * m_pitch + hidInput->joyaxes[JOYAXIS_Pitch] * hidspeed * scaleAdjustf; else - currInput->fvel += hidInput->mousey * m_forward + hidInput->joyaxes[JOYAXIS_Pitch] * keymove * scaleAdjustf; + currInput->fvel += hidInput->mouse.Y * m_forward + hidInput->joyaxes[JOYAXIS_Pitch] * keymove * scaleAdjustf; // process movement input. currInput->fvel += moving * keymove; @@ -191,16 +191,16 @@ void processVehicleInput(HIDInput* const hidInput, InputPacket* const currInput, SB_AIM_UP | SB_AIM_DOWN | SB_AIMMODE | SB_LOOK_UP | SB_LOOK_DOWN | SB_LOOK_LEFT | SB_LOOK_RIGHT); // Cancel out micro-movement - if (fabs(hidInput->mousex) < (m_sensitivity_x * backendinputscale() * 2.f)) - hidInput->mousex = 0; + if (fabs(hidInput->mouse.X) < (m_sensitivity_x * backendinputscale() * 2.f)) + hidInput->mouse.X = 0; // Yes, we need all these bools... const auto kbdForwards = buttonMap.ButtonDown(gamefunc_Move_Forward) || buttonMap.ButtonDown(gamefunc_Strafe); const auto kbdBackward = buttonMap.ButtonDown(gamefunc_Move_Backward); const auto kbdLeft = buttonMap.ButtonDown(gamefunc_Turn_Left) || buttonMap.ButtonDown(gamefunc_Strafe_Left); const auto kbdRight = buttonMap.ButtonDown(gamefunc_Turn_Right) || buttonMap.ButtonDown(gamefunc_Strafe_Right); - const auto hidLeft = hidInput->mousex < 0 || hidInput->joyaxes[JOYAXIS_Yaw] > 0; - const auto hidRight = hidInput->mousex > 0 || hidInput->joyaxes[JOYAXIS_Yaw] < 0; + const auto hidLeft = hidInput->mouse.X < 0 || hidInput->joyaxes[JOYAXIS_Yaw] > 0; + const auto hidRight = hidInput->mouse.X > 0 || hidInput->joyaxes[JOYAXIS_Yaw] < 0; const auto turnDir = (kbdRight || hidRight) - (kbdLeft || hidLeft); if (canMove) @@ -226,9 +226,9 @@ void processVehicleInput(HIDInput* const hidInput, InputPacket* const currInput, resetTurnHeldAmt(); } - if (hidInput->mousex) + if (hidInput->mouse.X) { - currInput->avel += sqrtf(abs(vel * hidInput->mousex * m_yaw / (float)scaleAdjust) * (7.f / 20.f)) * Sgn(vel) * Sgn(hidInput->mousex); + currInput->avel += sqrtf(abs(vel * hidInput->mouse.X * m_yaw / (float)scaleAdjust) * (7.f / 20.f)) * Sgn(vel) * Sgn(hidInput->mouse.X); } currInput->avel *= (float)scaleAdjust; @@ -251,7 +251,7 @@ void processVehicleInput(HIDInput* const hidInput, InputPacket* const currInput, static void ApplyGlobalInput(HIDInput* const hidInput) { - inputState.GetMouseDelta(hidInput); + inputState.GetMouseDelta(hidInput->mouse); if (use_joystick) I_GetAxes(hidInput->joyaxes); if (WeaponToSend != 0) inputBuffer.setNewWeapon(WeaponToSend); diff --git a/source/core/inputstate.cpp b/source/core/inputstate.cpp index 2ca5161dd..ede340aed 100644 --- a/source/core/inputstate.cpp +++ b/source/core/inputstate.cpp @@ -54,20 +54,16 @@ CVARD(Bool, invertmouse, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "invert vertic // //========================================================================== -void InputState::GetMouseDelta(HIDInput * hidInput) +void InputState::GetMouseDelta(FVector2& hidInput) { - g_mousePos *= backendinputscale(); - - hidInput->mousex = g_mousePos.X; - hidInput->mousey = g_mousePos.Y; + hidInput = g_mousePos * backendinputscale(); + g_mousePos.Zero(); if (invertmousex) - hidInput->mousex = -hidInput->mousex; + hidInput.X = -hidInput.X; if (invertmouse) - hidInput->mousey = -hidInput->mousey; - - g_mousePos.Zero(); + hidInput.Y = -hidInput.Y; } //========================================================================== diff --git a/source/core/inputstate.h b/source/core/inputstate.h index 7a71245f7..2c983ebec 100644 --- a/source/core/inputstate.h +++ b/source/core/inputstate.h @@ -17,8 +17,7 @@ struct HIDInput { float joyaxes[NUM_JOYAXIS]; - float mousex; - float mousey; + FVector2 mouse; }; @@ -43,7 +42,7 @@ public: g_mousePos.Y += y; } - void GetMouseDelta(HIDInput* hidInput); + void GetMouseDelta(FVector2& hidInput); void ClearAllInput(); bool CheckAllInput()