diff options
author | german <german@thesoftwareartisans.com> | 2020-11-27 03:56:06 +0100 |
---|---|---|
committer | german <german@thesoftwareartisans.com> | 2020-12-08 02:34:52 +0100 |
commit | b57ba7bfb6792e054033e828120b79b78587d58d (patch) | |
tree | 305f825655a9240b4283123d8904edb5b1de4f7c /src/input_common/analog_from_button.cpp | |
parent | Merge pull request #5016 from comex/xx-push (diff) | |
download | yuzu-b57ba7bfb6792e054033e828120b79b78587d58d.tar yuzu-b57ba7bfb6792e054033e828120b79b78587d58d.tar.gz yuzu-b57ba7bfb6792e054033e828120b79b78587d58d.tar.bz2 yuzu-b57ba7bfb6792e054033e828120b79b78587d58d.tar.lz yuzu-b57ba7bfb6792e054033e828120b79b78587d58d.tar.xz yuzu-b57ba7bfb6792e054033e828120b79b78587d58d.tar.zst yuzu-b57ba7bfb6792e054033e828120b79b78587d58d.zip |
Diffstat (limited to 'src/input_common/analog_from_button.cpp')
-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 { |