From 3185083ca54950917e0dd8598ac8ad9521223f9d Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Thu, 1 Jul 2021 17:39:08 +0200 Subject: [PATCH] Added separate controller deadzone values for the triggers and thumbsticks. --- es-core/src/InputManager.cpp | 13 ++++++++++--- es-core/src/InputManager.h | 3 ++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/es-core/src/InputManager.cpp b/es-core/src/InputManager.cpp index 688fb0dbf..b7c5e7d49 100644 --- a/es-core/src/InputManager.cpp +++ b/es-core/src/InputManager.cpp @@ -374,12 +374,19 @@ bool InputManager::parseEvent(const SDL_Event& event, Window* window) } axisValue = event.caxis.value; + int deadzone = 0; + + if (event.caxis.axis == SDL_CONTROLLER_AXIS_TRIGGERLEFT || + event.caxis.axis == SDL_CONTROLLER_AXIS_TRIGGERRIGHT) + deadzone = DEADZONE_TRIGGERS; + else + deadzone = DEADZONE_THUMBSTICKS; // Check if the input value switched boundaries. - if ((abs(axisValue) > DEADZONE) != (abs(mPrevAxisValues[ - std::make_pair(event.caxis.which, event.caxis.axis)]) > DEADZONE)) { + if ((abs(axisValue) > deadzone) != (abs(mPrevAxisValues[ + std::make_pair(event.caxis.which, event.caxis.axis)]) > deadzone)) { int normValue; - if (abs(axisValue) <= DEADZONE) { + if (abs(axisValue) <= deadzone) { normValue = 0; } else { diff --git a/es-core/src/InputManager.h b/es-core/src/InputManager.h index f4bacd01d..399a21aec 100644 --- a/es-core/src/InputManager.h +++ b/es-core/src/InputManager.h @@ -64,7 +64,8 @@ private: void removeControllerByJoystickID(SDL_JoystickID joyID); static InputManager* sInstance; - static const int DEADZONE = 23000; + static const int DEADZONE_TRIGGERS = 18000; + static const int DEADZONE_THUMBSTICKS = 23000; bool mConfigFileExists; std::map mJoysticks;