summaryrefslogtreecommitdiffstats
path: root/src/input_common/helpers/stick_from_buttons.cpp
diff options
context:
space:
mode:
authorNarr the Reg <juangerman-13@hotmail.com>2023-01-25 20:16:52 +0100
committerNarr the Reg <juangerman-13@hotmail.com>2023-01-25 20:52:50 +0100
commitcc821bfae1b02ec3e86b85097f71a2e38c12f8a5 (patch)
tree3da326ee41f9e5831f92a9bbbe6aa80f246aa39a /src/input_common/helpers/stick_from_buttons.cpp
parentMerge pull request #9662 from abouvier/cmake-llvm (diff)
downloadyuzu-cc821bfae1b02ec3e86b85097f71a2e38c12f8a5.tar
yuzu-cc821bfae1b02ec3e86b85097f71a2e38c12f8a5.tar.gz
yuzu-cc821bfae1b02ec3e86b85097f71a2e38c12f8a5.tar.bz2
yuzu-cc821bfae1b02ec3e86b85097f71a2e38c12f8a5.tar.lz
yuzu-cc821bfae1b02ec3e86b85097f71a2e38c12f8a5.tar.xz
yuzu-cc821bfae1b02ec3e86b85097f71a2e38c12f8a5.tar.zst
yuzu-cc821bfae1b02ec3e86b85097f71a2e38c12f8a5.zip
Diffstat (limited to 'src/input_common/helpers/stick_from_buttons.cpp')
-rw-r--r--src/input_common/helpers/stick_from_buttons.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/input_common/helpers/stick_from_buttons.cpp b/src/input_common/helpers/stick_from_buttons.cpp
index f3a0b3419..096c23b07 100644
--- a/src/input_common/helpers/stick_from_buttons.cpp
+++ b/src/input_common/helpers/stick_from_buttons.cpp
@@ -11,6 +11,11 @@ namespace InputCommon {
class Stick final : public Common::Input::InputDevice {
public:
+ // Some games such as EARTH DEFENSE FORCE: WORLD BROTHERS
+ // do not play nicely with the theoretical maximum range.
+ // Using a value one lower from the maximum emulates real stick behavior.
+ static constexpr float MAX_RANGE = 32766.0f / 32767.0f;
+
using Button = std::unique_ptr<Common::Input::InputDevice>;
Stick(Button up_, Button down_, Button left_, Button right_, Button modifier_, Button updater_,
@@ -196,7 +201,7 @@ public:
}
void UpdateStatus() {
- const float coef = modifier_status.value ? modifier_scale : 1.0f;
+ const float coef = modifier_status.value ? modifier_scale : MAX_RANGE;
bool r = right_status;
bool l = left_status;
@@ -290,7 +295,7 @@ public:
if (down_status) {
--y;
}
- const float coef = modifier_status.value ? modifier_scale : 1.0f;
+ const float coef = modifier_status.value ? modifier_scale : MAX_RANGE;
status.x.raw_value = static_cast<float>(x) * coef * (y == 0 ? 1.0f : SQRT_HALF);
status.y.raw_value = static_cast<float>(y) * coef * (x == 0 ? 1.0f : SQRT_HALF);
return status;