summaryrefslogtreecommitdiffstats
path: root/src/input_common/sdl/sdl_impl.cpp
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2020-02-01 20:02:41 +0100
committerGitHub <noreply@github.com>2020-02-01 20:02:41 +0100
commit69a6796de10357947d3e0411126b13c59628cb51 (patch)
tree4478c6e702785340b1d453ed55da23448d88e8f5 /src/input_common/sdl/sdl_impl.cpp
parentMerge pull request #3364 from lioncash/thread (diff)
parentMoved analog direction logic to sdl_impl (diff)
downloadyuzu-69a6796de10357947d3e0411126b13c59628cb51.tar
yuzu-69a6796de10357947d3e0411126b13c59628cb51.tar.gz
yuzu-69a6796de10357947d3e0411126b13c59628cb51.tar.bz2
yuzu-69a6796de10357947d3e0411126b13c59628cb51.tar.lz
yuzu-69a6796de10357947d3e0411126b13c59628cb51.tar.xz
yuzu-69a6796de10357947d3e0411126b13c59628cb51.tar.zst
yuzu-69a6796de10357947d3e0411126b13c59628cb51.zip
Diffstat (limited to 'src/input_common/sdl/sdl_impl.cpp')
-rw-r--r--src/input_common/sdl/sdl_impl.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/input_common/sdl/sdl_impl.cpp b/src/input_common/sdl/sdl_impl.cpp
index d2e9d278f..a2e0c0bd2 100644
--- a/src/input_common/sdl/sdl_impl.cpp
+++ b/src/input_common/sdl/sdl_impl.cpp
@@ -342,6 +342,22 @@ public:
return std::make_tuple<float, float>(0.0f, 0.0f);
}
+ bool GetAnalogDirectionStatus(Input::AnalogDirection direction) const override {
+ const auto [x, y] = GetStatus();
+ const float directional_deadzone = 0.4f;
+ switch (direction) {
+ case Input::AnalogDirection::RIGHT:
+ return x > directional_deadzone;
+ case Input::AnalogDirection::LEFT:
+ return x < -directional_deadzone;
+ case Input::AnalogDirection::UP:
+ return y > directional_deadzone;
+ case Input::AnalogDirection::DOWN:
+ return y < -directional_deadzone;
+ }
+ return false;
+ }
+
private:
std::shared_ptr<SDLJoystick> joystick;
const int axis_x;