diff options
| author | bunnei <bunneidev@gmail.com> | 2020-02-01 14:02:41 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-01 14:02:41 -0500 |
| commit | 0058ae07f71c66c39ac30dc8a486af9ee83d92f7 (patch) | |
| tree | 4478c6e702785340b1d453ed55da23448d88e8f5 /src/input_common/sdl/sdl_impl.cpp | |
| parent | d1df3ef0789101b13e89af0eb99a10fc7266e27d (diff) | |
| parent | be576083ddc300ca3988fdd995658f011fb3cc5d (diff) | |
Merge pull request #3284 from CJBok/hid-fix
hid: Fix analog sticks directional states
Diffstat (limited to 'src/input_common/sdl/sdl_impl.cpp')
| -rw-r--r-- | src/input_common/sdl/sdl_impl.cpp | 16 |
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 d2e9d278fa..a2e0c0bd22 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; |
