From 4b124a9998b60356abfc1c92f4ac272e41290ee4 Mon Sep 17 00:00:00 2001 From: niklascfw Date: Sat, 14 Feb 2026 15:03:58 +0100 Subject: [PATCH] Add + and - simultaneously to cancel and return to Hekate before install Co-authored-by: Cursor --- source/main.c | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/source/main.c b/source/main.c index 17f0778..d8c23db 100644 --- a/source/main.c +++ b/source/main.c @@ -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);