From 3e53d1e895ce8763eea7b796a52b1b08b55cda14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 31 Dec 2023 16:47:26 +0100 Subject: [PATCH 1/2] Joystick input: Fix low-end radius (inverse deadzone) --- Core/ControlMapper.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Core/ControlMapper.cpp b/Core/ControlMapper.cpp index 57e5066a1294..17c8e9ff9e9e 100644 --- a/Core/ControlMapper.cpp +++ b/Core/ControlMapper.cpp @@ -109,13 +109,23 @@ static bool IsSignedAxis(int axis) { } // This is applied on the circular radius, not directly on the axes. +// TODO: Share logic with tilt? + static float MapAxisValue(float v) { const float deadzone = g_Config.fAnalogDeadzone; const float invDeadzone = g_Config.fAnalogInverseDeadzone; const float sensitivity = g_Config.fAnalogSensitivity; const float sign = v >= 0.0f ? 1.0f : -1.0f; - return sign * Clamp(invDeadzone + (fabsf(v) - deadzone) / (1.0f - deadzone) * (sensitivity - invDeadzone), 0.0f, 1.0f); + // Apply deadzone. + v = Clamp((fabsf(v) - deadzone) / (1.0f - deadzone), 0.0f, 1.0f); + + // Apply sensitivity and inverse deadzone. + if (v != 0.0f) { + v = Clamp(invDeadzone + v * (sensitivity - invDeadzone), 0.0f, 1.0f); + } + + return sign * v; } void ConvertAnalogStick(float x, float y, float *outX, float *outY) { From d841f115e0279049c395ed70e92b72661e214134 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 31 Dec 2023 16:48:44 +0100 Subject: [PATCH 2/2] Small unrelated fix in ManagedTexture --- Common/Render/ManagedTexture.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Common/Render/ManagedTexture.cpp b/Common/Render/ManagedTexture.cpp index 730fd291720d..6f410a133d56 100644 --- a/Common/Render/ManagedTexture.cpp +++ b/Common/Render/ManagedTexture.cpp @@ -229,6 +229,7 @@ void ManagedTexture::DeviceLost() { INFO_LOG(G3D, "ManagedTexture::DeviceLost(%s)", filename_.c_str()); if (taskWaitable_) { taskWaitable_->WaitAndRelease(); + taskWaitable_ = nullptr; pendingImage_.Free(); } if (texture_)