From 0789923967c0821f5787f07935b4848ba6d42c3c Mon Sep 17 00:00:00 2001 From: Takayama Fumihiko Date: Sun, 4 Aug 2024 08:53:13 +0900 Subject: [PATCH] Stop continued_movement only when both the xy stick and wheels stick are not in the continued movement position --- .../game_pad_stick_converter.hpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/core/grabber/include/grabber/device_grabber_details/game_pad_stick_converter.hpp b/src/core/grabber/include/grabber/device_grabber_details/game_pad_stick_converter.hpp index fa4efe412..6c97ab526 100644 --- a/src/core/grabber/include/grabber/device_grabber_details/game_pad_stick_converter.hpp +++ b/src/core/grabber/include/grabber/device_grabber_details/game_pad_stick_converter.hpp @@ -137,6 +137,10 @@ class game_pad_stick_converter final : public pqrs::dispatcher::extra::dispatche update_values(); } + bool continued_movement(void) const { + return absolute_magnitude_ >= continued_movement_absolute_magnitude_threshold_; + } + std::chrono::milliseconds get_continued_movement_interval_milliseconds(void) const { if (continued_movement()) { return std::chrono::milliseconds(continued_movement_interval_milliseconds_); @@ -183,10 +187,6 @@ class game_pad_stick_converter final : public pqrs::dispatcher::extra::dispatche values_updated(); } - bool continued_movement(void) const { - return absolute_magnitude_ >= continued_movement_absolute_magnitude_threshold_; - } - stick_sensor horizontal_stick_sensor_; stick_sensor vertical_stick_sensor_; @@ -469,7 +469,8 @@ class game_pad_stick_converter final : public pqrs::dispatcher::extra::dispatche xy_radian_ = xy_.get_radian(); xy_delta_magnitude_ = xy_.get_delta_magnitude(); xy_absolute_magnitude_ = xy_.get_absolute_magnitude(); - if (continued_movement_mode_ == continued_movement_mode::xy) { + if (continued_movement_mode_ == continued_movement_mode::xy && + xy_.continued_movement()) { // Add secondary stick absolute magnitude to magnitudes; auto m = wheels_.get_absolute_magnitude(); xy_delta_magnitude_ += m; @@ -479,7 +480,8 @@ class game_pad_stick_converter final : public pqrs::dispatcher::extra::dispatche wheels_radian_ = wheels_.get_radian(); wheels_delta_magnitude_ = wheels_.get_delta_magnitude(); wheels_absolute_magnitude_ = wheels_.get_absolute_magnitude(); - if (continued_movement_mode_ == continued_movement_mode::wheels) { + if (continued_movement_mode_ == continued_movement_mode::wheels && + wheels_.continued_movement()) { auto m = xy_.get_absolute_magnitude(); wheels_delta_magnitude_ += m; wheels_absolute_magnitude_ += m; @@ -497,7 +499,10 @@ class game_pad_stick_converter final : public pqrs::dispatcher::extra::dispatche if (continued_movement_mode_ == continued_movement_mode::none) { post_event(mode); - } else if (continued_movement_mode_ == mode) { + } else if (continued_movement_mode_ == mode && + !xy_.continued_movement() && + !wheels_.continued_movement()) { + // Stop continued_movement when both the xy stick and wheels stick are not in the continued movement position.​ continued_movement_mode_ = continued_movement_mode::none; continued_movement_timer_.stop(); }