From f973738e5ba268d2ca76bab2cb08b123a4c7aae1 Mon Sep 17 00:00:00 2001 From: Daryl Borth Date: Sun, 16 Feb 2020 17:52:18 -0700 Subject: [PATCH] set default calibration values for controllers that return invalid data --- source/gui/gui_trigger.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/gui/gui_trigger.cpp b/source/gui/gui_trigger.cpp index e918178..ff20557 100644 --- a/source/gui/gui_trigger.cpp +++ b/source/gui/gui_trigger.cpp @@ -137,6 +137,14 @@ s8 GuiTrigger::WPAD_Stick(u8 stick, int axis) return 0; } + // some 3rd party controllers return invalid analog sticks calibration data + if ((min >= center) || (max <= center)) { + // force default calibration settings + min = 0; + max = stick ? 32 : 64; + center = stick ? 16 : 32; + } + if (pos > max) return 127; if (pos < min) return -128;