Skip to content

Commit

Permalink
feat: ✨ actually impliment the handle_events interface
Browse files Browse the repository at this point in the history
  • Loading branch information
PA055 committed Nov 13, 2024
1 parent e27010e commit 0237fe8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/gamepad/gamepad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,18 @@ void Gamepad::updateScreens() {
this->last_update_time = pros::millis();
}

// Update all screens and note deltatime
// Get new button presses
std::set<pros::controller_digital_e_t> buttonUpdates;
for (int i = pros::E_CONTROLLER_DIGITAL_L1; i <= pros::E_CONTROLLER_DIGITAL_A; ++i) {
if ((this->*this->button_to_ptr(static_cast<pros::controller_digital_e_t>(i))).rising_edge) {
buttonUpdates.emplace(static_cast<pros::controller_id_e_t>(i));
}
}

// Update all screens, and send new button presses, also note deltatime
for (int i = 0; i < this->screens.size(); i++) {
this->screens[i]->update(pros::millis() - this->last_update_time);
this->screens[i]->handle_events(buttonUpdates);
}
this->last_update_time = pros::millis();

Expand Down

0 comments on commit 0237fe8

Please sign in to comment.