diff --git a/include/arm11/menu/menu_fb3ds.h b/include/arm11/menu/menu_fb3ds.h index e5f207c..29e3e5c 100644 --- a/include/arm11/menu/menu_fb3ds.h +++ b/include/arm11/menu/menu_fb3ds.h @@ -37,6 +37,22 @@ #define DESC_BOOT_FIRM1 "Boot the firmware in FIRM1." #define DESC_BOOT_SETUP "Change boot settings." +#define DESC_BOOT_SETUP_1 "Change boot settings for slot #1." +#define DESC_BOOT_SETUP_2 "Change boot settings for slot #2." +#define DESC_BOOT_SETUP_3 "Change boot settings for slot #3." + +#define DESC_SET_SLOT_1 "Change the firmware in boot slot #1." +#define DESC_SET_SLOT_2 "Change the firmware in boot slot #2." +#define DESC_SET_SLOT_3 "Change the firmware in boot slot #3." + +#define DESC_CLEAR_SLOT_1 "Reset boot slot #1 to empty state." +#define DESC_CLEAR_SLOT_2 "Reset boot slot #2 to empty state." +#define DESC_CLEAR_SLOT_3 "Reset boot slot #3 to empty state." + +#define DESC_KEYS_SLOT_1 "Change the keycombo used to boot slot #1." +#define DESC_KEYS_SLOT_2 "Change the keycombo used to boot slot #2." +#define DESC_KEYS_SLOT_3 "Change the keycombo used to boot slot #3." + #define DESC_CHANGE_SLOT "Setup fastboot3ds boot slots." #define DESC_CLEAR_SLOT "Choose & clear fastboot3ds boot slots." #define DESC_CHANGE_BOOT "Change fastboot3ds boot mode. This allows you to set up how your console boots." @@ -53,14 +69,6 @@ #define DESC_BOOT_QUICK "Set quick boot mode.\nIn quick boot mode, splash is displayed and the boot is continued via the first available boot slot. To enter fastboot3ds menu, hold a key combo." #define DESC_BOOT_QUIET "Set quiet boot mode.\nIn quiet boot mode, splash is not displayed and the boot is continued via the first available boot slot. To enter fastboot3ds menu, hold a key combo." -#define DESC_SET_SLOT_1 "Change the firmware in boot slot #1." -#define DESC_SET_SLOT_2 "Change the firmware in boot slot #2." -#define DESC_SET_SLOT_3 "Change the firmware in boot slot #3." - -#define DESC_CLEAR_SLOT_1 "Reset boot slot #1 to empty state." -#define DESC_CLEAR_SLOT_2 "Reset boot slot #2 to empty state." -#define DESC_CLEAR_SLOT_3 "Reset boot slot #3 to empty state." - #define DESC_ENABLE_CONTIG "Select to enable contiguous NAND backups." #define DESC_DISABLE_CONTIG "Select to disable contiguous NAND backups." @@ -76,8 +84,8 @@ { "Continue boot", DESC_CONTINUE, &DummyFunc, 0 }, { "Boot menu...", DESC_BOOT_MENU, NULL, 1 }, { "Boot from file...", DESC_BOOT_FILE, &DummyFunc, 2 }, - { "NAND tools...", DESC_NAND_TOOLS, NULL, 6 }, - { "Miscellaneous...", DESC_MISC, NULL, 7 } + { "NAND tools...", DESC_NAND_TOOLS, NULL, 7 }, + { "Miscellaneous...", DESC_MISC, NULL, 8 } } }, { // 1 @@ -92,30 +100,39 @@ } }, { // 2 - "Boot Setup", 3, NULL, 0, + "Boot Setup", 4, &menuPresetBootSlot, MENU_FLAG_SLOTS, { - { "Setup boot slots...", DESC_CHANGE_SLOT, NULL, 3 }, - { "Clear boot slots...", DESC_CLEAR_SLOT, NULL, 4 }, - { "Change boot mode...", DESC_CHANGE_BOOT, NULL, 5 } + { "Setup [slot 1]...", DESC_BOOT_SETUP_1, NULL, 3 }, + { "Setup [slot 2]...", DESC_BOOT_SETUP_2, NULL, 4 }, + { "Setup [slot 3]...", DESC_BOOT_SETUP_3, NULL, 5 }, + { "Change boot mode...", DESC_CHANGE_BOOT, NULL, 6 } } }, { // 3 - "Boot Slot Setup", 3, &menuPresetBootSlot, MENU_FLAG_SLOTS, + "Boot Slot #1 Setup", 3, NULL, 0, { - { "Setup [slot 1]...", DESC_SET_SLOT_1, &menuSetupBootSlot, 0x00 }, - { "Setup [slot 2]...", DESC_SET_SLOT_2, &menuSetupBootSlot, 0x01 }, - { "Setup [slot 3]...", DESC_SET_SLOT_3, &menuSetupBootSlot, 0x02 } + { "Select [slot 1] firm", DESC_SET_SLOT_1, &menuSetupBootSlot, 0x00 }, + { "Select [slot 1] buttons", DESC_KEYS_SLOT_1, &menuSetupBootKeys, 0x00 }, + { "Clear [slot 1]", DESC_CLEAR_SLOT_1, &menuSetupBootSlot, 0x10 } } }, { // 4 - "Boot Slot Clear", 3, &menuPresetBootSlot, MENU_FLAG_SLOTS, + "Boot Slot #2 Setup", 3, NULL, 0, { - { "Clear [slot 1]...", DESC_CLEAR_SLOT_1, &menuSetupBootSlot, 0x10 }, - { "Clear [slot 2]...", DESC_CLEAR_SLOT_2, &menuSetupBootSlot, 0x11 }, - { "Clear [slot 3]...", DESC_CLEAR_SLOT_3, &menuSetupBootSlot, 0x12 } + { "Select [slot 2] firm", DESC_SET_SLOT_2, &menuSetupBootSlot, 0x01 }, + { "Select [slot 2] buttons", DESC_KEYS_SLOT_2, &menuSetupBootKeys, 0x01 }, + { "Clear [slot 2]", DESC_CLEAR_SLOT_2, &menuSetupBootSlot, 0x11 } } }, { // 5 + "Boot Slot #3 Setup", 3, NULL, 0, + { + { "Select [slot 3] firm", DESC_SET_SLOT_3, &menuSetupBootSlot, 0x02 }, + { "Select [slot 3] buttons", DESC_KEYS_SLOT_3, &menuSetupBootKeys, 0x02 }, + { "Clear [slot 3]", DESC_CLEAR_SLOT_3, &menuSetupBootSlot, 0x12 } + } + }, + { // 6 "Boot Mode Setup", 3, &menuPresetBootMode, 0, { { "Set normal boot", DESC_BOOT_NORMAL, &menuSetBootMode, 0 }, @@ -123,7 +140,7 @@ { "Set quick boot", DESC_BOOT_QUICK, &menuSetBootMode, 2 } } }, - { // 6 + { // 7 "NAND Tools", 4, NULL, 0, { { "Backup NAND", DESC_NAND_BACKUP, &DummyFunc, 3 }, @@ -132,7 +149,7 @@ { "Flash firmware", DESC_FIRM_FLASH, &DummyFunc, 2 } } }, - { // 7 + { // 8 "Miscellaneous", 3, NULL, 0, { { "Update fastboot3DS", DESC_UPDATE, &DummyFunc, 1 }, diff --git a/include/arm11/menu/menu_func.h b/include/arm11/menu/menu_func.h index e17aaac..91442fd 100644 --- a/include/arm11/menu/menu_func.h +++ b/include/arm11/menu/menu_func.h @@ -24,6 +24,7 @@ u32 menuPresetBootSlot(void); u32 menuSetBootMode(PrintConsole* con, u32 param); u32 menuSetupBootSlot(PrintConsole* con, u32 param); +u32 menuSetupBootKeys(PrintConsole* con, u32 param); u32 DummyFunc(PrintConsole* con, u32 param); u32 SetView(PrintConsole* con, u32 param); u32 ShowCredits(PrintConsole* con, u32 param); diff --git a/source/arm11/menu/menu.c b/source/arm11/menu/menu.c index 23adfcc..3875581 100644 --- a/source/arm11/menu/menu.c +++ b/source/arm11/menu/menu.c @@ -17,6 +17,7 @@ */ #include +#include #include "types.h" #include "arm11/menu/menu.h" #include "arm11/menu/menu_util.h" @@ -51,7 +52,7 @@ return; } - // word wrap description string + // build description string // also handle MENU_FLAG_SLOTS flag char desc_ww[512]; if ((curr_menu->flags & MENU_FLAG_SLOTS) && (index < 3) && @@ -59,12 +60,23 @@ { char slot_path[24+1]; truncateString(slot_path, (char*) configGetData(KBootOption1 + index), 24, 8); - ee_snprintf(desc_ww, 512, "%s\nCurrent: %s", desc, slot_path); + if (configDataExist(KBootOption1Buttons + index)) + { + char* keycombo = (char*) configCopyText(KBootOption1Buttons + index); + ee_snprintf(desc_ww, 512, "%s\nCurrent: %s\nKeycombo: %s", desc, slot_path, keycombo); + free(keycombo); + } + else + { + ee_snprintf(desc_ww, 512, "%s\nCurrent: %s", desc, slot_path); + } } else { strncpy(desc_ww, desc, 512); } + + // wordwrap description string stringWordWrap(desc_ww, WORDWRAP_WIDTH); // get width, height diff --git a/source/arm11/menu/menu_fsel.c b/source/arm11/menu/menu_fsel.c index a923081..610dee0 100644 --- a/source/arm11/menu/menu_fsel.c +++ b/source/arm11/menu/menu_fsel.c @@ -282,7 +282,7 @@ consoleSetCursor(menu_con, brws_x, brws_y++); ee_printf("%-*.*s", BRWS_WIDTH, BRWS_WIDTH, "[A]:Choose [B]:Back"); consoleSetCursor(menu_con, brws_x, brws_y++); - ee_printf("%-*.*s", BRWS_WIDTH, BRWS_WIDTH, "[R]+[B] to cancel"); + ee_printf("%-*.*s", BRWS_WIDTH, BRWS_WIDTH, "[HOME] to cancel"); } @@ -384,8 +384,12 @@ hidScanInput(); const u32 kDown = hidKeysDown(); const u32 kHeld = hidKeysHeld(); - - if ((kDown & KEY_A) && n_entries) + if (kDown & KEY_HOME) + { + result = false; + break; + } + else if ((kDown & KEY_A) && n_entries) { // build new res_path char* name = &(res_path[strlen(res_path)]); @@ -398,26 +402,17 @@ lastname = NULL; break; } - else if (kDown & KEY_B) + else if ((kDown & KEY_B) && *res_path) { - // if R is held alongside: cancel - if (kHeld & KEY_R) - { - result = false; - break; - } - else if (*res_path) - { - // without R and not in root: return to previous path - // (the name of this path will be stored in lastname) - lastname = strrchr(res_path, '/'); - - if (lastname) - *(lastname++) = '\0'; - else - *res_path = '\0'; - break; - } + // if not in root: return to previous path + // (the name of this path will be stored in lastname) + lastname = strrchr(res_path, '/'); + + if (lastname) + *(lastname++) = '\0'; + else + *res_path = '\0'; + break; } else if (kHeld & (KEY_DDOWN|KEY_DUP|KEY_DLEFT|KEY_DRIGHT) && n_entries) { diff --git a/source/arm11/menu/menu_func.c b/source/arm11/menu/menu_func.c index 0b64834..ac29361 100644 --- a/source/arm11/menu/menu_func.c +++ b/source/arm11/menu/menu_func.c @@ -57,7 +57,7 @@ res |= 1 << i; } } - + return res; } @@ -93,6 +93,90 @@ return res; } +static const char * convTable[] = { + "A", "B", "SELECT", "START", "RIGHT", "LEFT", + "UP", "DOWN", "R", "L", "X", "Y" +}; + +u32 menuSetupBootKeys(PrintConsole* con, u32 param) +{ + const u32 y_center = 7; + const u32 y_instr = 21; + + hidScanInput(); + u32 kHeld = hidKeysHeld(); + + while (true) + { + // build button string + char button_str[80]; + char* ptr = button_str; + bool first = true; + for (u32 i = 0; i < 12; i++) + { + if (kHeld & (1<cursorY = y_center; + ee_printf_line_center("Hold button(s) to setup."); + ee_printf_line_center("Currently held buttons:"); + ee_printf_line_center(button_str); + + // draw instructions + con->cursorY = y_instr; + if (configDataExist(KBootOption1Buttons + param)) + { + char* currentSetting = + (char*) configCopyText(KBootOption1Buttons + param); + ee_printf_line_center("Current: %s", currentSetting); + free(currentSetting); + } + ee_printf_line_center("[HOME] to cancel"); + + // update screens + updateScreens(); + + // check hold duration + u32 vBlanks = 0; + u32 kHeldNew = 0; + do + { + GFX_waitForEvent(GFX_EVENT_PDC0, true); + hidScanInput(); + kHeldNew = hidKeysHeld(); + } while ((kHeld == kHeldNew) && (++vBlanks < 100)); + + // check keys + if (kHeldNew & KEY_HOME) + { + return 1; + } + else if ((kHeld == kHeldNew) && (kHeld & 0xfff)) + { + break; + } + + kHeld = kHeldNew; + } + + // if we arrive here, we have a button combo + u32 res = (configSetKeyData(KBootOption1Buttons + param, &kHeld)) ? 0 : 1; + writeConfigFile(); + + return res; +} + u32 DummyFunc(PrintConsole* con, u32 param) { // clear console