From 96649b8a28e21df2e13614d49f89b5c6e370d8b2 Mon Sep 17 00:00:00 2001 From: praydog Date: Sun, 24 Dec 2023 01:48:37 -0800 Subject: [PATCH] Input: Fix bug with mixing gamepad and motion controller stick inputs --- src/mods/VR.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mods/VR.cpp b/src/mods/VR.cpp index 1ebf1b1f..fd5558e3 100644 --- a/src/mods/VR.cpp +++ b/src/mods/VR.cpp @@ -837,11 +837,11 @@ void VR::on_xinput_get_state(uint32_t* retval, uint32_t user_index, XINPUT_STATE const auto left_joystick_axis = get_joystick_axis(m_left_joystick); const auto right_joystick_axis = get_joystick_axis(m_right_joystick); - state->Gamepad.sThumbLX = (int16_t)(left_joystick_axis.x * 32767.0f); - state->Gamepad.sThumbLY = (int16_t)(left_joystick_axis.y * 32767.0f); + state->Gamepad.sThumbLX = (int16_t)std::clamp(((float)state->Gamepad.sThumbLX + left_joystick_axis.x * 32767.0f), -32767.0f, 32767.0f); + state->Gamepad.sThumbLY = (int16_t)std::clamp(((float)state->Gamepad.sThumbLY + left_joystick_axis.y * 32767.0f), -32767.0f, 32767.0f); - state->Gamepad.sThumbRX = (int16_t)(right_joystick_axis.x * 32767.0f); - state->Gamepad.sThumbRY = (int16_t)(right_joystick_axis.y * 32767.0f); + state->Gamepad.sThumbRX = (int16_t)std::clamp(((float)state->Gamepad.sThumbRX + right_joystick_axis.x * 32767.0f), -32767.0f, 32767.0f); + state->Gamepad.sThumbRY = (int16_t)std::clamp(((float)state->Gamepad.sThumbRY + right_joystick_axis.y * 32767.0f), -32767.0f, 32767.0f); // Touching the thumbrest allows us to use the thumbstick as a dpad. Additional options are for controllers without capacitives/games that rely solely on DPad if (m_dpad_shifting->value()) {