diff options
| -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 @@ | |||
| 10 | 10 | ||
| 11 | namespace Core::HID { | 11 | namespace Core::HID { |
| 12 | constexpr s32 HID_JOYSTICK_MAX = 0x7fff; | 12 | constexpr s32 HID_JOYSTICK_MAX = 0x7fff; |
| 13 | constexpr s32 HID_JOYSTICK_MIN = 0x7ffe; | ||
| 13 | constexpr s32 HID_TRIGGER_MAX = 0x7fff; | 14 | constexpr s32 HID_TRIGGER_MAX = 0x7fff; |
| 14 | // Use a common UUID for TAS and Virtual Gamepad | 15 | // Use a common UUID for TAS and Virtual Gamepad |
| 15 | constexpr Common::UUID TAS_UUID = | 16 | constexpr Common::UUID TAS_UUID = |
| @@ -798,9 +799,16 @@ void EmulatedController::SetStick(const Common::Input::CallbackStatus& callback, | |||
| 798 | return; | 799 | return; |
| 799 | } | 800 | } |
| 800 | 801 | ||
| 802 | const auto FloatToShort = [](float a) { | ||
| 803 | if (a > 0) { | ||
| 804 | return static_cast<s32>(a * HID_JOYSTICK_MAX); | ||
| 805 | } | ||
| 806 | return static_cast<s32>(a * HID_JOYSTICK_MIN); | ||
| 807 | }; | ||
| 808 | |||
| 801 | const AnalogStickState stick{ | 809 | const AnalogStickState stick{ |
| 802 | .x = static_cast<s32>(controller.stick_values[index].x.value * HID_JOYSTICK_MAX), | 810 | .x = FloatToShort(controller.stick_values[index].x.value), |
| 803 | .y = static_cast<s32>(controller.stick_values[index].y.value * HID_JOYSTICK_MAX), | 811 | .y = FloatToShort(controller.stick_values[index].y.value), |
| 804 | }; | 812 | }; |
| 805 | 813 | ||
| 806 | switch (index) { | 814 | switch (index) { |