diff options
author | Morph <39850852+Morph1984@users.noreply.github.com> | 2020-12-08 03:30:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-08 03:30:21 +0100 |
commit | 607bb8d14b3713afde6ff25e87678842fc28c2eb (patch) | |
tree | 6dcdab147b659307276d64bd6ba6af6efc0f88bb /src/input_common | |
parent | Merge pull request #5164 from lioncash/contains (diff) | |
parent | Disable analog joystick from buttons by default (diff) | |
download | yuzu-607bb8d14b3713afde6ff25e87678842fc28c2eb.tar yuzu-607bb8d14b3713afde6ff25e87678842fc28c2eb.tar.gz yuzu-607bb8d14b3713afde6ff25e87678842fc28c2eb.tar.bz2 yuzu-607bb8d14b3713afde6ff25e87678842fc28c2eb.tar.lz yuzu-607bb8d14b3713afde6ff25e87678842fc28c2eb.tar.xz yuzu-607bb8d14b3713afde6ff25e87678842fc28c2eb.tar.zst yuzu-607bb8d14b3713afde6ff25e87678842fc28c2eb.zip |
Diffstat (limited to 'src/input_common')
-rwxr-xr-x | src/input_common/analog_from_button.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/input_common/analog_from_button.cpp b/src/input_common/analog_from_button.cpp index d748c1c04..40b516f85 100755 --- a/src/input_common/analog_from_button.cpp +++ b/src/input_common/analog_from_button.cpp @@ -6,6 +6,7 @@ #include <cmath> #include <thread> #include "common/math_util.h" +#include "core/settings.h" #include "input_common/analog_from_button.h" namespace InputCommon { @@ -112,7 +113,26 @@ public: } std::tuple<float, float> GetStatus() const override { - return std::make_tuple(std::cos(angle) * amplitude, std::sin(angle) * amplitude); + if (Settings::values.emulate_analog_keyboard) { + return std::make_tuple(std::cos(angle) * amplitude, std::sin(angle) * amplitude); + } + constexpr float SQRT_HALF = 0.707106781f; + int x = 0, y = 0; + if (right->GetStatus()) { + ++x; + } + if (left->GetStatus()) { + --x; + } + if (up->GetStatus()) { + ++y; + } + if (down->GetStatus()) { + --y; + } + const float coef = modifier->GetStatus() ? modifier_scale : 1.0f; + return std::make_tuple(static_cast<float>(x) * coef * (y == 0 ? 1.0f : SQRT_HALF), + static_cast<float>(y) * coef * (x == 0 ? 1.0f : SQRT_HALF)); } bool GetAnalogDirectionStatus(Input::AnalogDirection direction) const override { |