void menu_main() { while (1) { char *options[] = {"Boot CFW", "Select Patches", "More options...", "Version info", "Power off"}; int result = draw_menu("CakesFW " CAKES_VERSION, 0, sizeof(options) / sizeof(char *), options); switch (result) { case 0: save_config(); boot_cfw(); break; case 1: menu_select_patches(); break; case 2: menu_more(); break; case 3: version_info(); break; case 4: i2cWriteRegister(I2C_DEV_MCU, 0x20, 1); while(1); // Won't break out of this one >:D } } }
void menu_main() { while (1) { char *options[] = {"Boot CFW", "Select Patches", "More options..."}; int result = draw_menu("CakesFW", 0, sizeof(options) / sizeof(char *), options); switch (result) { case 0: save_config(); boot_cfw(); break; case 1: menu_select_patches(); break; case 2: menu_more(); break; } } }
int menu_boot() { time_t start, end, elapsed; int boot_index = config->index; hidScanInput(); if (config->timeout < 0 || hidKeysHeld() & BIT(config->recovery)) { // disable autoboot timer = false; } else if (config->timeout == 0 && config->count > boot_index) { // autoboot return autoBootFix(boot_index); } time(&start); while (aptMainLoop()) { hidScanInput(); u32 kDown = hidKeysDown(); if (timer) { time(&end); elapsed = end - start; if (elapsed >= config->timeout && config->count > boot_index) { return autoBootFix(boot_index); } } if (kDown & KEY_DOWN) { timer = false; boot_index++; if (boot_index > config->count) boot_index = 0; } if (kDown & KEY_UP) { timer = false; boot_index--; if (boot_index < 0) boot_index = config->count; } if (kDown & KEY_A) { timer = false; if (boot_index == config->count) { if (menu_more() == 0) { break; } } else { if (load(config->entries[boot_index].path, config->entries[boot_index].offset) == 0) { break; } } } if (kDown & KEY_X) { timer = false; if (boot_index != config->count) { if (confirm(3, "Delete boot entry: \"%s\" ?\n", config->entries[boot_index].title)) { configRemoveEntry(boot_index); boot_index--; } } } gfxClear(); if (!timer) { gfxDrawText(GFX_TOP, GFX_LEFT, &fontTitle, "*** Grub for CTR beta ***", 120, 20); } else { gfxDrawTextf(GFX_TOP, GFX_LEFT, &fontTitle, 100, 20, "*** Booting %s in %i ***", config->entries[boot_index].title, config->timeout - elapsed); } int minX = 16, maxX = 400 - 16; int minY = 32, maxY = 240 - 8; drawRect(GFX_TOP, GFX_LEFT, minX, minY, maxX, maxY, 0xFF, 0xFF, 0xFF); minY += 20; int i; for (i = 0; i < config->count; i++) { if (i >= config->count) break; if (i == boot_index) { gfxDrawRectangle(GFX_TOP, GFX_LEFT, (u8[]) {0xDC, 0xDC, 0xDC}, minX + 4, minY + (16 * i), maxX - 23, 15); gfxDrawTextf(GFX_TOP, GFX_LEFT, &fontSelected, minX + 6, minY + (16 * i), "%s", config->entries[i].title); gfxDrawText(GFX_BOTTOM, GFX_LEFT, &fontTitle, "Informations", minX + 6, 20); gfxDrawTextf(GFX_BOTTOM, GFX_LEFT, &fontDefault, minX + 12, 40, "Name: %s\nPath: %s\nOffset: 0x%lx\n\n\nPress (A) to launch\nPress (X) to remove entry\n", config->entries[i].title, config->entries[i].path, config->entries[i].offset); } else gfxDrawText(GFX_TOP, GFX_LEFT, &fontDefault, config->entries[i].title, minX + 6, minY + (16 * i)); }