mirror of
https://github.com/starr-dusT/yuzu-mainline
synced 2024-03-05 21:12:25 -08:00
Merge pull request #9617 from german77/off_by_one
core: hid: Fix stick minimum range
This commit is contained in:
commit
02ac593257
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
namespace Core::HID {
|
namespace Core::HID {
|
||||||
constexpr s32 HID_JOYSTICK_MAX = 0x7fff;
|
constexpr s32 HID_JOYSTICK_MAX = 0x7fff;
|
||||||
|
constexpr s32 HID_JOYSTICK_MIN = 0x7ffe;
|
||||||
constexpr s32 HID_TRIGGER_MAX = 0x7fff;
|
constexpr s32 HID_TRIGGER_MAX = 0x7fff;
|
||||||
// Use a common UUID for TAS and Virtual Gamepad
|
// Use a common UUID for TAS and Virtual Gamepad
|
||||||
constexpr Common::UUID TAS_UUID =
|
constexpr Common::UUID TAS_UUID =
|
||||||
@ -798,9 +799,16 @@ void EmulatedController::SetStick(const Common::Input::CallbackStatus& callback,
|
|||||||
return;
|
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{
|
const AnalogStickState stick{
|
||||||
.x = static_cast<s32>(controller.stick_values[index].x.value * HID_JOYSTICK_MAX),
|
.x = FloatToShort(controller.stick_values[index].x.value),
|
||||||
.y = static_cast<s32>(controller.stick_values[index].y.value * HID_JOYSTICK_MAX),
|
.y = FloatToShort(controller.stick_values[index].y.value),
|
||||||
};
|
};
|
||||||
|
|
||||||
switch (index) {
|
switch (index) {
|
||||||
|
Loading…
Reference in New Issue
Block a user