Skip to content

Commit

Permalink
Update gamepad default formula
Browse files Browse the repository at this point in the history
  • Loading branch information
tekezo committed Aug 3, 2024
1 parent f0eb59b commit b9225c6
Showing 1 changed file with 48 additions and 28 deletions.
76 changes: 48 additions & 28 deletions src/share/core_configuration/details/profile/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,33 +103,57 @@ class device final {
helper_values_.push_back_value<std::string>("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<std::string>("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<std::string>("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;
)"));

Expand All @@ -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;
)"));

Expand Down

0 comments on commit b9225c6

Please sign in to comment.