Support exiting GPU Test

This commit is contained in:
Jaby
2024-01-03 22:44:13 -06:00
committed by Jaby
parent d9e7455fba
commit cdf3511c19
5 changed files with 80 additions and 3 deletions

View File

@@ -2,6 +2,8 @@
#include <PSX/Periphery/periphery.hpp>
namespace Menu {
using DigitalButton = Periphery::GenericController::Button;
void SimpleMenu :: setup(Callback callback, const Entry* entries, size_t size) {
this->selection_callback = callback;
this->entries = entries;
@@ -10,7 +12,6 @@ namespace Menu {
}
void SimpleMenu :: update(JabyEngine::FontWriter& font_writer, State& cursor, const GPU::PositionI16& start) {
using DigitalButton = Periphery::GenericController::Button;
const auto& controller = Periphery::get_primary_controller_as<JabyEngine::Periphery::GenericController>();
if(controller.button.went_down(DigitalButton::Up) && this->cur_selection > 0) {
@@ -38,4 +39,40 @@ namespace Menu {
}
}
}
void BackMenu :: setup(JabyEngine::FontWriter* font_writer) {
this->font_writer = font_writer;
this->timeout.reset();
this->waiting = false;
}
bool BackMenu :: update(const GPU::PositionI16& position) {
const auto& controller = Periphery::get_primary_controller_as<JabyEngine::Periphery::GenericController>();
if(controller.button.is_down(DigitalButton::Circle)) {
this->waiting = true;
if(this->timeout.is_expired_for(2500_ms)) {
return true;
}
}
else {
this->waiting = false;
this->timeout.reset();
}
if(this->waiting) {
auto state = JabyEngine::State::create(position);
this->font_writer->write(state, "Press and hold ()\nto get back", GPU::Color24::Red());
}
else {
this->font_writer->clear();
}
return false;
}
void BackMenu :: render() {
this->font_writer->render();
}
}