Add + and - simultaneously to cancel and return to Hekate before install

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-02-14 15:03:58 +01:00
parent 89279e27d5
commit 4b124a9998

View File

@@ -400,33 +400,58 @@ void ipl_main(void) {
gfx_printf("Druecke A-Taste (rechter Joy-Con) oder Power-Taste,\n");
gfx_printf("um die Installation zu starten...\n");
set_color(COLOR_WHITE);
set_color(COLOR_CYAN);
gfx_printf("Druecke + und - gleichzeitig zum Abbrechen (zurueck zu Hekate).\n");
set_color(COLOR_WHITE);
// Wait for either A button or Power button
// Wait for A/Power to start, or +/- to cancel
bool button_pressed = false;
bool cancelled = false;
// First, wait for power button to be released if it's currently pressed
while (btn_read() & BTN_POWER) {
msleep(50);
}
while (!button_pressed) {
// Check power button - detect press (transition from not pressed to pressed)
while (!button_pressed && !cancelled) {
// Check power button
u8 btn_state = btn_read();
if (btn_state & BTN_POWER) {
button_pressed = true;
break;
}
// Check joycon A button
// Check joycon buttons
jc_gamepad_rpt_t *jc = joycon_poll();
if (jc && jc->a) {
button_pressed = true;
break;
if (jc) {
if (jc->a) {
button_pressed = true;
break;
}
// + and - simultaneously = cancel, return to hekate
if (jc->plus && jc->minus) {
cancelled = true;
break;
}
}
msleep(50); // Small delay to avoid busy-waiting
}
if (cancelled) {
gfx_printf("\n");
set_color(COLOR_YELLOW);
gfx_printf("Abgebrochen. Starte Hekate...\n");
set_color(COLOR_WHITE);
msleep(500);
if (file_exists(PAYLOAD_PATH)) {
launch_payload(PAYLOAD_PATH);
} else {
power_set_state(POWER_OFF_REBOOT);
}
return;
}
// Clear the prompt and start installation
gfx_clear_grey(0x1B);
gfx_con_setpos(0, 0);