From 2d81e51a05efa215dc465aa3e8d5b51e97a98e0b Mon Sep 17 00:00:00 2001 From: Jan Date: Fri, 27 Aug 2021 00:01:48 +0200 Subject: [PATCH] Fix gamepad updating stick trying to normalize zero vectors when no gamepad input is happening --- src/Components/Modules/Gamepad.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Components/Modules/Gamepad.cpp b/src/Components/Modules/Gamepad.cpp index 2c29c200..6e032929 100644 --- a/src/Components/Modules/Gamepad.cpp +++ b/src/Components/Modules/Gamepad.cpp @@ -635,8 +635,8 @@ namespace Components aaGlob.yawDelta = LinearTrack(yawDelta, aaGlob.yawDelta, accel, input->deltaTime); } - output->pitch = aaGlob.pitchDelta * input->deltaTime * pitchSign + output->pitch; - output->yaw = aaGlob.yawDelta * input->deltaTime * yawSign + output->yaw; + output->pitch += aaGlob.pitchDelta * input->deltaTime * pitchSign; + output->yaw += aaGlob.yawDelta * input->deltaTime * yawSign; } void Gamepad::AimAssist_UpdateGamePadInput(const Game::AimInput* input, Game::AimOutput* output) @@ -1108,6 +1108,13 @@ namespace Components void Gamepad::GPad_ConvertStickToFloat(const short x, const short y, float& outX, float& outY) { + if(x == 0 && y == 0) + { + outX = 0.0f; + outY = 0.0f; + return; + } + Game::vec2_t stickVec; stickVec[0] = static_cast(x) / static_cast(std::numeric_limits::max()); stickVec[1] = static_cast(y) / static_cast(std::numeric_limits::max());