Skip to content

Commit

Permalink
Stop continued_movement only when both the xy stick and wheels stick …
Browse files Browse the repository at this point in the history
…are not in the continued movement position
  • Loading branch information
tekezo committed Aug 3, 2024
1 parent 2043a04 commit 0789923
Showing 1 changed file with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
Expand Down Expand Up @@ -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_;

Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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();
}
Expand Down

0 comments on commit 0789923

Please sign in to comment.