summaryrefslogtreecommitdiffstats
path: root/src/input_common
diff options
context:
space:
mode:
authorMorph <39850852+Morph1984@users.noreply.github.com>2020-12-08 03:30:21 +0100
committerGitHub <noreply@github.com>2020-12-08 03:30:21 +0100
commit607bb8d14b3713afde6ff25e87678842fc28c2eb (patch)
tree6dcdab147b659307276d64bd6ba6af6efc0f88bb /src/input_common
parentMerge pull request #5164 from lioncash/contains (diff)
parentDisable analog joystick from buttons by default (diff)
downloadyuzu-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-xsrc/input_common/analog_from_button.cpp22
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 {