summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorliamwhite <liamwhite@users.noreply.github.com>2023-01-22 19:14:10 +0100
committerGitHub <noreply@github.com>2023-01-22 19:14:10 +0100
commit02ac5932571d8a2c432d52af84dd353abd2ef2c2 (patch)
treef8f68367b2cf2849c6b8b3a23933b47c614418f3 /src
parentMerge pull request #9613 from Kelebek1/demangle (diff)
parentcore: hid: Fix stick minimum range (diff)
downloadyuzu-02ac5932571d8a2c432d52af84dd353abd2ef2c2.tar
yuzu-02ac5932571d8a2c432d52af84dd353abd2ef2c2.tar.gz
yuzu-02ac5932571d8a2c432d52af84dd353abd2ef2c2.tar.bz2
yuzu-02ac5932571d8a2c432d52af84dd353abd2ef2c2.tar.lz
yuzu-02ac5932571d8a2c432d52af84dd353abd2ef2c2.tar.xz
yuzu-02ac5932571d8a2c432d52af84dd353abd2ef2c2.tar.zst
yuzu-02ac5932571d8a2c432d52af84dd353abd2ef2c2.zip
Diffstat (limited to 'src')
-rw-r--r--src/core/hid/emulated_controller.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp
index 7a01f3f4c..a959c9db9 100644
--- a/src/core/hid/emulated_controller.cpp
+++ b/src/core/hid/emulated_controller.cpp
@@ -10,6 +10,7 @@
namespace Core::HID {
constexpr s32 HID_JOYSTICK_MAX = 0x7fff;
+constexpr s32 HID_JOYSTICK_MIN = 0x7ffe;
constexpr s32 HID_TRIGGER_MAX = 0x7fff;
// Use a common UUID for TAS and Virtual Gamepad
constexpr Common::UUID TAS_UUID =
@@ -798,9 +799,16 @@ void EmulatedController::SetStick(const Common::Input::CallbackStatus& callback,
return;
}
+ const auto FloatToShort = [](float a) {
+ if (a > 0) {
+ return static_cast<s32>(a * HID_JOYSTICK_MAX);
+ }
+ return static_cast<s32>(a * HID_JOYSTICK_MIN);
+ };
+
const AnalogStickState stick{
- .x = static_cast<s32>(controller.stick_values[index].x.value * HID_JOYSTICK_MAX),
- .y = static_cast<s32>(controller.stick_values[index].y.value * HID_JOYSTICK_MAX),
+ .x = FloatToShort(controller.stick_values[index].x.value),
+ .y = FloatToShort(controller.stick_values[index].y.value),
};
switch (index) {