Skip to content

Commit

Permalink
style: 🎨 Remove braces on single line ifs in controller.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
ion098 committed Aug 23, 2024
1 parent 6b75be8 commit da5a563
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/gamepad/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,8 @@ void Button::update(const bool is_held) {
this->rising_edge = !this->is_pressed && is_held;
this->falling_edge = this->is_pressed && !is_held;
this->is_pressed = is_held;
if (is_held) {
this->time_held += pros::millis() - this->last_update_time;
} else {
this->time_released += pros::millis() - this->last_update_time;
}
if (is_held) this->time_held += pros::millis() - this->last_update_time;
else this->time_released += pros::millis() - this->last_update_time;

if (this->rising_edge) {
this->onPressEvent.fire();
Expand All @@ -59,10 +56,10 @@ void Button::update(const bool is_held) {
this->last_long_press_time = pros::millis();
} else if (this->falling_edge) {
this->onReleaseEvent.fire();
if (this->time_held < this->long_press_threshold) { this->onShortReleaseEvent.fire(); }
if (this->time_held < this->long_press_threshold) this->onShortReleaseEvent.fire();
}
if (this->rising_edge) { this->time_held = 0; }
if (this->falling_edge) { this->time_released = 0; }
if (this->rising_edge) this->time_held = 0;
if (this->falling_edge) this->time_released = 0;
this->last_update_time = pros::millis();
}

Expand Down

0 comments on commit da5a563

Please sign in to comment.