diff options
author | Garrett Brown <themagnificentmrb@gmail.com> | 2017-01-30 20:57:31 -0800 |
---|---|---|
committer | Garrett Brown <themagnificentmrb@gmail.com> | 2017-02-02 18:02:54 -0800 |
commit | 07196e3f18c231d425e9115a941d0052aff1dcbf (patch) | |
tree | c92dd3271fdbaafd5745fc9ce32a1e0601d4097a | |
parent | 3a0abaf08195d431c678d5709903c5bf812989de (diff) |
Fix discrete D-pad axes with a center that is slightly offset
When centered, the axis had a value of 0.007. This breaks some checks
for a centered axis.
-rw-r--r-- | xbmc/input/joysticks/DeadzoneFilter.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/xbmc/input/joysticks/DeadzoneFilter.cpp b/xbmc/input/joysticks/DeadzoneFilter.cpp index 8ee33e5942..0bf30738d0 100644 --- a/xbmc/input/joysticks/DeadzoneFilter.cpp +++ b/xbmc/input/joysticks/DeadzoneFilter.cpp @@ -24,10 +24,13 @@ #include "peripherals/devices/Peripheral.h" #include "utils/log.h" +#include <cmath> #include <vector> using namespace JOYSTICK; +#define AXIS_EPSILON 0.01f // Allowed noise for detecting discrete D-pads (value of 0.007 when centered has been observed) + // Settings for analog sticks #define SETTING_LEFT_STICK_DEADZONE "left_stick_deadzone" #define SETTING_RIGHT_STICK_DEADZONE "right_stick_deadzone" @@ -50,6 +53,10 @@ float CDeadzoneFilter::FilterAxis(unsigned int axisIndex, float axisValue) if (bSuccess) return ApplyDeadzone(axisValue, deadzone); + // Always filter noise about the center + if (std::abs(axisValue) < AXIS_EPSILON) + axisValue = 0.0f; + return axisValue; } |