Merge pull request #55997 from slouken/3.x-fix-switch-controller-event-spam

[3.x] Fixed event spam when using the Nintendo Switch controller
This commit is contained in:
Rémi Verschelde 2021-12-16 19:51:19 +01:00 committed by GitHub
commit b61a93d86f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -811,7 +811,10 @@ void InputDefault::joy_axis(int p_device, int p_axis, const JoyAxis &p_value) {
Joypad &joy = joy_names[p_device]; Joypad &joy = joy_names[p_device];
if (joy.last_axis[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[p_axis] - p_value.value) < MIN_AXIS_CHANGE) {
return; return;
} }