From b9225c6873811e39fe28eb761d4b7bcd3110cef9 Mon Sep 17 00:00:00 2001 From: Takayama Fumihiko Date: Sat, 3 Aug 2024 20:01:49 +0900 Subject: [PATCH] Update gamepad default formula --- .../details/profile/device.hpp | 76 ++++++++++++------- 1 file changed, 48 insertions(+), 28 deletions(-) diff --git a/src/share/core_configuration/details/profile/device.hpp b/src/share/core_configuration/details/profile/device.hpp index 47d902621..abecbdc39 100644 --- a/src/share/core_configuration/details/profile/device.hpp +++ b/src/share/core_configuration/details/profile/device.hpp @@ -103,33 +103,57 @@ class device final { helper_values_.push_back_value("game_pad_stick_x_formula", game_pad_stick_x_formula_, // The logical value range of Karabiner-DriverKit-VirtualHIDPointing is -127 ... 127. - "cos(radian) * delta_magnitude * 32;"); + pqrs::string::trim_copy(R"( + +var m:= 0; + +if (absolute_magnitude < 1.0) { + m := delta_magnitude * 8; +} else if (absolute_magnitude < 1.5) { + m := absolute_magnitude * 16; +} else { + m := absolute_magnitude * 32; +}; + +cos(radian) * m; + +)")); helper_values_.push_back_value("game_pad_stick_y_formula", game_pad_stick_y_formula_, // The logical value range of Karabiner-DriverKit-VirtualHIDPointing is -127 ... 127. - "sin(radian) * delta_magnitude * 32;"); + pqrs::string::trim_copy(R"( + +var m:= 0; + +if (absolute_magnitude < 1.0) { + m := delta_magnitude * 8; +} else if (absolute_magnitude < 1.5) { + m := absolute_magnitude * 16; +} else { + m := absolute_magnitude * 32; +}; + +sin(radian) * m; + +)")); helper_values_.push_back_value("game_pad_stick_vertical_wheel_formula", game_pad_stick_vertical_wheel_formula_, // The logical value range of Karabiner-DriverKit-VirtualHIDPointing is -127 ... 127. pqrs::string::trim_copy(R"( -if (abs(cos(radian)) >= abs(sin(radian))) { - 0; -} else { - var m := 0; +var m := 0; + +if (abs(cos(radian)) < abs(sin(radian))) { if (absolute_magnitude < 1.0) { - m := max(0.05, delta_magnitude * 5); + m := delta_magnitude; } else { - if (delta_magnitude > 0.3) { - m := 0.5; - } else { - m := 0.3; - } - } - sin(radian) * m; -} + m := absolute_magnitude * 0.1; + }; +}; + +sin(radian) * m; )")); @@ -138,21 +162,17 @@ if (abs(cos(radian)) >= abs(sin(radian))) { // The logical value range of Karabiner-DriverKit-VirtualHIDPointing is -127 ... 127. pqrs::string::trim_copy(R"( -if (abs(cos(radian)) <= abs(sin(radian))) { - 0; -} else { - var m := 0; +var m := 0; + +if (abs(cos(radian)) > abs(sin(radian))) { if (absolute_magnitude < 1.0) { - m := max(0.05, delta_magnitude * 5); + m := delta_magnitude; } else { - if (delta_magnitude > 0.3) { - m := 0.5; - } else { - m := 0.3; - } - } - cos(radian) * m; -} + m := absolute_magnitude * 0.1; + }; +}; + +cos(radian) * m; )"));