diff --git a/src/share/core_configuration/details/profile.hpp b/src/share/core_configuration/details/profile.hpp index 0aeedcaee..96e47d110 100644 --- a/src/share/core_configuration/details/profile.hpp +++ b/src/share/core_configuration/details/profile.hpp @@ -504,6 +504,52 @@ class profile final { } } + int get_device_game_pad_stick_release_detection_threshold_milliseconds(const device_identifiers& identifiers) const { + for (const auto& d : devices_) { + if (d.get_identifiers() == identifiers) { + if (auto value = d.get_game_pad_stick_release_detection_threshold_milliseconds()) { + return *value; + } + } + } + return device::game_pad_stick_release_detection_threshold_milliseconds_default_value; + } + + void set_device_game_pad_stick_release_detection_threshold_milliseconds(const device_identifiers& identifiers, + std::optional value) { + add_device(identifiers); + + for (auto&& device : devices_) { + if (device.get_identifiers() == identifiers) { + device.set_game_pad_stick_release_detection_threshold_milliseconds(value); + return; + } + } + } + + int get_device_game_pad_stick_stroke_acceleration_measurement_duration_milliseconds_(const device_identifiers& identifiers) const { + for (const auto& d : devices_) { + if (d.get_identifiers() == identifiers) { + if (auto value = d.get_game_pad_stick_stroke_acceleration_measurement_duration_milliseconds()) { + return *value; + } + } + } + return device::game_pad_stick_stroke_acceleration_measurement_duration_milliseconds_default_value; + } + + void set_device_game_pad_stick_stroke_acceleration_measurement_duration_milliseconds_(const device_identifiers& identifiers, + std::optional value) { + add_device(identifiers); + + for (auto&& device : devices_) { + if (device.get_identifiers() == identifiers) { + device.set_game_pad_stick_stroke_acceleration_measurement_duration_milliseconds(value); + return; + } + } + } + double get_device_game_pad_xy_stick_deadzone(const device_identifiers& identifiers) const { for (const auto& d : devices_) { if (d.get_identifiers() == identifiers) { diff --git a/src/share/core_configuration/details/profile/device.hpp b/src/share/core_configuration/details/profile/device.hpp index f6b5fe0a1..977f2a04e 100644 --- a/src/share/core_configuration/details/profile/device.hpp +++ b/src/share/core_configuration/details/profile/device.hpp @@ -10,6 +10,9 @@ namespace core_configuration { namespace details { class device final { public: + static constexpr int game_pad_stick_release_detection_threshold_milliseconds_default_value = 100; + static constexpr int game_pad_stick_stroke_acceleration_measurement_duration_milliseconds_default_value = 50; + static constexpr double game_pad_xy_stick_deadzone_default_value = 0.1; static constexpr double game_pad_wheels_stick_deadzone_default_value = 0.1; @@ -137,6 +140,16 @@ class device final { game_pad_swap_sticks_ = value.get(); + } else if (key == "game_pad_stick_release_detection_threshold_milliseconds") { + pqrs::json::requires_number(value, "`" + key + "`"); + + game_pad_stick_release_detection_threshold_milliseconds_ = value.get(); + + } else if (key == "game_pad_stick_stroke_acceleration_measurement_duration_milliseconds") { + pqrs::json::requires_number(value, "`" + key + "`"); + + game_pad_stick_stroke_acceleration_measurement_duration_milliseconds_ = value.get(); + } else if (key == "game_pad_xy_stick_deadzone") { pqrs::json::requires_number(value, "`" + key + "`"); @@ -239,6 +252,12 @@ class device final { j["mouse_swap_xy"] = mouse_swap_xy_; j["mouse_swap_wheels"] = mouse_swap_wheels_; j["game_pad_swap_sticks"] = game_pad_swap_sticks_; + if (game_pad_stick_release_detection_threshold_milliseconds_ != std::nullopt) { + j["game_pad_stick_release_detection_threshold_milliseconds"] = *game_pad_stick_release_detection_threshold_milliseconds_; + } + if (game_pad_stick_stroke_acceleration_measurement_duration_milliseconds_ != std::nullopt) { + j["game_pad_stick_stroke_acceleration_measurement_duration_milliseconds"] = *game_pad_stick_stroke_acceleration_measurement_duration_milliseconds_; + } if (game_pad_xy_stick_deadzone_ != std::nullopt) { j["game_pad_xy_stick_deadzone"] = *game_pad_xy_stick_deadzone_; } @@ -371,6 +390,24 @@ class device final { coordinate_between_properties(); } + std::optional get_game_pad_stick_release_detection_threshold_milliseconds(void) const { + return game_pad_stick_release_detection_threshold_milliseconds_; + } + void set_game_pad_stick_release_detection_threshold_milliseconds(std::optional value) { + game_pad_stick_release_detection_threshold_milliseconds_ = value; + + coordinate_between_properties(); + } + + std::optional get_game_pad_stick_stroke_acceleration_measurement_duration_milliseconds(void) const { + return game_pad_stick_stroke_acceleration_measurement_duration_milliseconds_; + } + void set_game_pad_stick_stroke_acceleration_measurement_duration_milliseconds(std::optional value) { + game_pad_stick_stroke_acceleration_measurement_duration_milliseconds_ = value; + + coordinate_between_properties(); + } + std::optional get_game_pad_xy_stick_deadzone(void) const { return game_pad_xy_stick_deadzone_; } @@ -525,6 +562,8 @@ class device final { bool mouse_swap_xy_; bool mouse_swap_wheels_; bool game_pad_swap_sticks_; + std::optional game_pad_stick_release_detection_threshold_milliseconds_; + std::optional game_pad_stick_stroke_acceleration_measurement_duration_milliseconds_; std::optional game_pad_xy_stick_deadzone_; std::optional game_pad_wheels_stick_deadzone_; std::optional game_pad_xy_stick_interval_milliseconds_formula_; diff --git a/tests/src/core_configuration/src/device_test.hpp b/tests/src/core_configuration/src/device_test.hpp index dcd81d6fc..64750ed38 100644 --- a/tests/src/core_configuration/src/device_test.hpp +++ b/tests/src/core_configuration/src/device_test.hpp @@ -351,6 +351,8 @@ void run_device_test(void) { {"mouse_flip_x", true}, {"mouse_swap_wheels", true}, {"game_pad_swap_sticks", true}, + {"game_pad_stick_release_detection_threshold_milliseconds", 200}, + {"game_pad_stick_stroke_acceleration_measurement_duration_milliseconds", 100}, {"game_pad_xy_stick_deadzone", 0.08}, {"game_pad_wheels_stick_deadzone", 0.08}, {"game_pad_xy_stick_interval_milliseconds_formula", "20"}, @@ -396,6 +398,8 @@ void run_device_test(void) { }}, {"ignore", true}, {"game_pad_swap_sticks", true}, + {"game_pad_stick_release_detection_threshold_milliseconds", 200}, + {"game_pad_stick_stroke_acceleration_measurement_duration_milliseconds", 100}, {"game_pad_xy_stick_deadzone", 0.08}, {"game_pad_wheels_stick_deadzone", 0.08}, {"game_pad_xy_stick_interval_milliseconds_formula", "20"},