mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 23:55:38 +00:00
Added separate controller deadzone values for the triggers and thumbsticks.
This commit is contained in:
parent
4dc6355a34
commit
3185083ca5
|
@ -374,12 +374,19 @@ bool InputManager::parseEvent(const SDL_Event& event, Window* window)
|
||||||
}
|
}
|
||||||
|
|
||||||
axisValue = event.caxis.value;
|
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.
|
// Check if the input value switched boundaries.
|
||||||
if ((abs(axisValue) > DEADZONE) != (abs(mPrevAxisValues[
|
if ((abs(axisValue) > deadzone) != (abs(mPrevAxisValues[
|
||||||
std::make_pair(event.caxis.which, event.caxis.axis)]) > DEADZONE)) {
|
std::make_pair(event.caxis.which, event.caxis.axis)]) > deadzone)) {
|
||||||
int normValue;
|
int normValue;
|
||||||
if (abs(axisValue) <= DEADZONE) {
|
if (abs(axisValue) <= deadzone) {
|
||||||
normValue = 0;
|
normValue = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -64,7 +64,8 @@ private:
|
||||||
void removeControllerByJoystickID(SDL_JoystickID joyID);
|
void removeControllerByJoystickID(SDL_JoystickID joyID);
|
||||||
|
|
||||||
static InputManager* sInstance;
|
static InputManager* sInstance;
|
||||||
static const int DEADZONE = 23000;
|
static const int DEADZONE_TRIGGERS = 18000;
|
||||||
|
static const int DEADZONE_THUMBSTICKS = 23000;
|
||||||
bool mConfigFileExists;
|
bool mConfigFileExists;
|
||||||
|
|
||||||
std::map<SDL_JoystickID, SDL_Joystick*> mJoysticks;
|
std::map<SDL_JoystickID, SDL_Joystick*> mJoysticks;
|
||||||
|
|
Loading…
Reference in a new issue