diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-12-16 19:49:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-16 19:49:47 +0100 |
commit | 9c9cc1b22258d21d2a5393847a587d2ce1584d82 (patch) | |
tree | 7175fca87110bea3c0dedb6d0549bc82004a3be0 /core | |
parent | bc2ac269640e46578442bb2299fe51451b899876 (diff) | |
parent | 313815f8184278dd2eabe1fbe05488dc527e4a0a (diff) |
Merge pull request #55978 from slouken/fix-switch-controller-event-spam
Fixed event spam when using the Nintendo Switch controller
Diffstat (limited to 'core')
-rw-r--r-- | core/input/input.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/core/input/input.cpp b/core/input/input.cpp index 3dfe73ab8e..9a6a2a2e15 100644 --- a/core/input/input.cpp +++ b/core/input/input.cpp @@ -922,7 +922,10 @@ void Input::joy_axis(int p_device, JoyAxis p_axis, const JoyAxisValue &p_value) Joypad &joy = joy_names[p_device]; - if (joy.last_axis[(size_t)p_axis] == p_value.value) { + // Make sure that we don't generate events for up to 5% jitter + // This is needed for Nintendo Switch Pro controllers, which jitter at rest + const float MIN_AXIS_CHANGE = 0.05f; + if (fabs(joy.last_axis[(size_t)p_axis] - p_value.value) < MIN_AXIS_CHANGE) { return; } |