diff options
author | german77 <juangerman-13@hotmail.com> | 2023-01-14 18:53:43 +0100 |
---|---|---|
committer | german77 <juangerman-13@hotmail.com> | 2023-01-14 18:53:43 +0100 |
commit | 50c86b3c2ac55c474208681494ec458d24850ae7 (patch) | |
tree | fba0b624578adad571e81490e53ada1b14be363a /src/core | |
parent | Merge pull request #9605 from german77/mouse_mapping (diff) | |
download | yuzu-50c86b3c2ac55c474208681494ec458d24850ae7.tar yuzu-50c86b3c2ac55c474208681494ec458d24850ae7.tar.gz yuzu-50c86b3c2ac55c474208681494ec458d24850ae7.tar.bz2 yuzu-50c86b3c2ac55c474208681494ec458d24850ae7.tar.lz yuzu-50c86b3c2ac55c474208681494ec458d24850ae7.tar.xz yuzu-50c86b3c2ac55c474208681494ec458d24850ae7.tar.zst yuzu-50c86b3c2ac55c474208681494ec458d24850ae7.zip |
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/hid/emulated_controller.cpp | 12 |
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) { |