diff --git a/README.md b/README.md index 3b6600e..76d7a01 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,31 @@ Press Y on the autoboot menu to set autobooting to this titles. To revert it, fo - Boot into Wii U Menu, Homebrew Channel, vWii System Menu or vWii Homebrew Channel. - Full support of Quick Boot Menu of the Gamepad when coldbooting - Set a autoboot title +- Add your own vWii or Wii U titles to the menu + +## Custom boot entries +Create `bootOptions.cfg` next to `autoboot.cfg` (in the `[ENVIRONMENT]` folder) with one entry per line: a name, a comma, and the title's full 64-bit title id. + +``` +# vWii titles start with 00010001, Wii U titles with 00050000 +My vWii Channel,0x0001000152494654 +Mii Maker,0x000500101004A200 +``` + +The title id decides how the entry is launched: vWii titles through the vWii, Wii U titles directly. Entries whose title is not installed are left out of the menu. Up to 4 entries are shown, as many as fit: the menu has room for 7 rows in all. System applets (title ids starting with 00050030, like the Internet Browser) can't be custom entries. A custom entry can be set as the autoboot title like any other. + +### Menu order + +The menu normally shows the built-in entries first and custom entries after them. To choose the order, name built-in entries in `bootOptions.cfg` with an `@` line; entries then appear in the order of the lines: + +``` +My vWii Channel,0x0001000152494654 +@wiiu_menu +@vwii_homebrew_channel +@vwii_system_menu +``` + +The names are the ones `autoboot.cfg` uses: `@wiiu_menu`, `@homebrew_launcher`, `@vwii_system_menu` and `@vwii_homebrew_channel`. Built-in entries without a line follow the listed ones in the usual order, so none can disappear by accident, and an entry that isn't available (the Homebrew Launcher without its installer, the vWii Homebrew Channel without HBC) is still left out. Without `@` lines the menu keeps the usual order. With `@` lines and no autoboot entry, the cursor starts on the first entry instead of the Wii U Menu. ## Buildflags diff --git a/source/BootUtils.cpp b/source/BootUtils.cpp index 635800f..5444bb0 100644 --- a/source/BootUtils.cpp +++ b/source/BootUtils.cpp @@ -4,6 +4,7 @@ #include "logger.h" #include #include +#include #include #include #include @@ -116,9 +117,16 @@ void bootvWiiMenu() { launchvWiiTitle(0); } -uint64_t getVWiiHBLTitleId() { - // fall back to booting the vWii system menu if anything fails - uint64_t titleId = 0; +bool isVWiiTitle(uint64_t titleId) { + return (titleId >> 48) == 0x0001; +} + +bool isWiiUTitle(uint64_t titleId) { + return (titleId >> 48) == 0x0005; +} + +bool vWiiTitleExists(uint64_t titleId) { + bool exists = false; FSAInit(); auto client = FSAAddClient(nullptr); @@ -126,16 +134,12 @@ uint64_t getVWiiHBLTitleId() { if (Mocha_UnlockFSClientEx(client) == MOCHA_RESULT_SUCCESS) { // mount the slccmpt if (FSAMount(client, "/dev/slccmpt01", "/vol/storage_abm_slccmpt01", FSA_MOUNT_FLAG_GLOBAL_MOUNT, nullptr, 0) >= 0) { + // every installed title has a TMD; content file names depend on the title + char path[0x80]; + snprintf(path, sizeof(path), "/vol/storage_abm_slccmpt01/title/%08x/%08x/content/title.tmd", + (uint32_t) (titleId >> 32), (uint32_t) titleId); FSStat stat; - - // test if the OHBC or HBC is installed - if (FSAGetStat(client, "/vol/storage_abm_slccmpt01/title/00010001/4f484243/content/00000000.app", &stat) >= 0) { - titleId = 0x000100014F484243L; // 'OHBC' - } else if (FSAGetStat(client, "/vol/storage_abm_slccmpt01/title/00010001/4c554c5a/content/00000000.app", &stat) >= 0) { - titleId = 0x000100014C554C5AL; // 'LULZ' - } else { - DEBUG_FUNCTION_LINE("Cannot find HBC"); - } + exists = FSAGetStat(client, path, &stat) >= 0; FSAUnmount(client, "/vol/storage_abm_slccmpt01", FSA_UNMOUNT_FLAG_FORCE); } else { DEBUG_FUNCTION_LINE_ERR("Failed to mount slccmpt01"); @@ -147,7 +151,29 @@ uint64_t getVWiiHBLTitleId() { } else { DEBUG_FUNCTION_LINE_ERR("Failed to add FSAClient"); } - return titleId; + return exists; +} + +bool titleExists(uint64_t titleId) { + if (isVWiiTitle(titleId)) { + return vWiiTitleExists(titleId); + } + if (isWiiUTitle(titleId)) { + return SYSCheckTitleExists(titleId); + } + return false; +} + +uint64_t getVWiiHBLTitleId() { + // test if the OHBC or HBC is installed, fall back to booting the vWii system menu if anything fails + if (vWiiTitleExists(0x000100014F484243L)) { + return 0x000100014F484243L; // 'OHBC' + } + if (vWiiTitleExists(0x000100014C554C5AL)) { + return 0x000100014C554C5AL; // 'LULZ' + } + DEBUG_FUNCTION_LINE("Cannot find HBC"); + return 0; } void bootHomebrewChannel() { @@ -155,3 +181,14 @@ void bootHomebrewChannel() { DEBUG_FUNCTION_LINE("Launching vWii title %016llx", titleId); launchvWiiTitle(titleId); } + +void bootCustomTitle(uint64_t titleId) { + if (isVWiiTitle(titleId)) { + DEBUG_FUNCTION_LINE("Launching vWii title %016llx", titleId); + launchvWiiTitle(titleId); + } else { + handleAccountSelection(); + DEBUG_FUNCTION_LINE("Launching Wii U title %016llx", titleId); + _SYSLaunchTitleWithStdArgsInNoSplash(titleId, nullptr); + } +} diff --git a/source/BootUtils.h b/source/BootUtils.h index 6ac2121..a6da460 100644 --- a/source/BootUtils.h +++ b/source/BootUtils.h @@ -10,4 +10,16 @@ void bootvWiiMenu(); void bootHomebrewChannel(); -uint64_t getVWiiHBLTitleId(); \ No newline at end of file +uint64_t getVWiiHBLTitleId(); + +// vWii titles start with 0x0001, Wii U titles with 0x0005. +bool isVWiiTitle(uint64_t titleId); + +bool isWiiUTitle(uint64_t titleId); + +bool vWiiTitleExists(uint64_t titleId); + +bool titleExists(uint64_t titleId); + +// Launches a vWii or Wii U title; the title id decides which. +void bootCustomTitle(uint64_t titleId); diff --git a/source/DrawUtils.cpp b/source/DrawUtils.cpp index 2732435..37ab515 100644 --- a/source/DrawUtils.cpp +++ b/source/DrawUtils.cpp @@ -301,7 +301,7 @@ void DrawUtils::print(uint32_t x, uint32_t y, const char *string, bool alignRigh auto *buffer = new wchar_t[strlen(string) + 1]; size_t num = mbstowcs(buffer, string, strlen(string)); - if (num > 0) { + if (num > 0 && num != (size_t) -1) { // (size_t) -1: a byte mbstowcs can't convert buffer[num] = 0; } else { wchar_t *tmp = buffer; @@ -374,7 +374,7 @@ uint32_t DrawUtils::getTextWidth(const char *string) { auto *buffer = new wchar_t[strlen(string) + 1]; size_t num = mbstowcs(buffer, string, strlen(string)); - if (num > 0) { + if (num > 0 && num != (size_t) -1) { buffer[num] = 0; } else { wchar_t *tmp = buffer; diff --git a/source/MenuUtils.cpp b/source/MenuUtils.cpp index 832f10d..48f7090 100644 --- a/source/MenuUtils.cpp +++ b/source/MenuUtils.cpp @@ -1,5 +1,6 @@ #include "MenuUtils.h" #include "ACTAccountInfo.h" +#include "BootUtils.h" #include "DrawUtils.h" #include "InputUtils.h" #include "PairUtils.h" @@ -7,10 +8,13 @@ #include "main.h" #include "utils.h" #include "version.h" +#include #include #include #include #include +#include +#include #include #include #include @@ -18,6 +22,7 @@ #include #include #include +#include #include #include @@ -30,13 +35,144 @@ const char *autoboot_config_strings[] = { "vwii_homebrew_channel", }; -int32_t readAutobootOption(std::string &configPath) { +#define CUSTOM_AUTOBOOT_PREFIX "title_" + +static void trimInPlace(char *str) { + char *start = str; + while (*start && isspace((unsigned char) *start)) { + start++; + } + char *end = start + strlen(start); + while (end > start && isspace((unsigned char) end[-1])) { + end--; + } + *end = '\0'; + memmove(str, start, end - start + 1); +} + +// The built-in entry an "@" line names, by the same names autoboot.cfg uses, in any case; -1 if none. +static int32_t builtInOptionNamed(const char *name) { + for (uint32_t i = 0; i < sizeof(autoboot_config_strings) / sizeof(char *); i++) { + if (strcasecmp(autoboot_config_strings[i], name) == 0) { + return i; + } + } + return -1; +} + +std::vector readCustomBootOptions(const std::string &path, std::vector &menuOrder) { + std::vector result; + menuOrder.clear(); + FILE *f = fopen(path.c_str(), "r"); + if (!f) { + return result; + } + + // One entry per line: "Name,0x0001000152494654". The title id decides how it is launched. + // A line "@name" places a built-in entry ("@wiiu_menu") between them. + std::vector order; + bool namesBuiltIns = false; + bool tooMany = false; + char line[256]; + bool firstLine = true; + while (fgets(line, sizeof(line), f)) { + // Some editors start the file with a UTF-8 byte order mark. + if (firstLine && strncmp(line, "\xEF\xBB\xBF", 3) == 0) { + memmove(line, line + 3, strlen(line + 3) + 1); + } + firstLine = false; + trimInPlace(line); + if (line[0] == '\0' || line[0] == '#') { + continue; + } + + // A line with a comma is a custom entry, even if its name starts with @. + if (line[0] == '@' && !strchr(line, ',')) { + char *name = line + 1; + trimInPlace(name); + int32_t builtIn = builtInOptionNamed(name); + if (builtIn < 0) { + DEBUG_FUNCTION_LINE_WARN("bootOptions.cfg: \"%s\" is not a built-in entry", line); + continue; + } + order.push_back(builtIn); + namesBuiltIns = true; + continue; + } + + char *comma = strrchr(line, ','); + if (!comma) { + DEBUG_FUNCTION_LINE_WARN("bootOptions.cfg: no comma in \"%s\"", line); + continue; + } + *comma = '\0'; + + char *idStr = comma + 1; + trimInPlace(idStr); + char *idEnd = nullptr; + uint64_t titleId = strtoull(idStr, &idEnd, 16); + if (idEnd == idStr || *idEnd != '\0' || !(isVWiiTitle(titleId) || isWiiUTitle(titleId))) { + DEBUG_FUNCTION_LINE_WARN("bootOptions.cfg: \"%s\" is not a full vWii or Wii U title id", idStr); + continue; + } + + // System applets (the browser, the eShop, ...) need their own launch calls. + if ((titleId >> 32) == 0x00050030) { + DEBUG_FUNCTION_LINE_WARN("bootOptions.cfg: %016llx is a system applet, which can't be a custom entry", titleId); + continue; + } + + trimInPlace(line); + if (line[0] == '\0') { + DEBUG_FUNCTION_LINE_WARN("bootOptions.cfg: entry for %016llx has no name", titleId); + continue; + } + + bool duplicate = false; + for (auto &option : result) { + duplicate |= option.titleId == titleId; + } + if (duplicate) { + DEBUG_FUNCTION_LINE_WARN("bootOptions.cfg: %016llx is listed twice", titleId); + continue; + } + + if (result.size() >= MAX_CUSTOM_BOOT_OPTIONS) { + // Keep reading: "@" lines further down still count. + if (!tooMany) { + DEBUG_FUNCTION_LINE_WARN("bootOptions.cfg: only the first %d entries are used", MAX_CUSTOM_BOOT_OPTIONS); + tooMany = true; + } + continue; + } + order.push_back(BOOT_OPTION_CUSTOM_BASE + result.size()); + result.push_back({line, titleId}); + } + fclose(f); + if (namesBuiltIns) { + menuOrder = order; + } + return result; +} + +int32_t readAutobootOption(std::string &configPath, const std::vector &customOptions) { FILE *f = fopen(configPath.c_str(), "r"); if (f) { char buf[128]{}; fgets(buf, sizeof(buf), f); fclose(f); + // Custom entries are saved by title id, so renaming one keeps it selected. + if (strncmp(CUSTOM_AUTOBOOT_PREFIX, buf, strlen(CUSTOM_AUTOBOOT_PREFIX)) == 0) { + uint64_t titleId = strtoull(buf + strlen(CUSTOM_AUTOBOOT_PREFIX), nullptr, 16); + for (uint32_t i = 0; i < customOptions.size(); i++) { + if (customOptions[i].titleId == titleId) { + return BOOT_OPTION_CUSTOM_BASE + i; + } + } + return -1; + } + for (uint32_t i = 0; i < sizeof(autoboot_config_strings) / sizeof(char *); i++) { if (strncmp(autoboot_config_strings[i], buf, strlen(autoboot_config_strings[i])) == 0) { return i; @@ -46,10 +182,19 @@ int32_t readAutobootOption(std::string &configPath) { return -1; } -void writeAutobootOption(std::string &configPath, int32_t autobootOption) { +void writeAutobootOption(std::string &configPath, int32_t autobootOption, const std::vector &customOptions) { FILE *f = fopen(configPath.c_str(), "w"); if (f) { - if (autobootOption >= 0) { + if (autobootOption >= BOOT_OPTION_CUSTOM_BASE) { + uint32_t index = autobootOption - BOOT_OPTION_CUSTOM_BASE; + if (index < customOptions.size()) { + char buf[sizeof(CUSTOM_AUTOBOOT_PREFIX) + 16]; + snprintf(buf, sizeof(buf), CUSTOM_AUTOBOOT_PREFIX "%016llx", customOptions[index].titleId); + fputs(buf, f); + } else { + fputs("none", f); + } + } else if (autobootOption >= 0) { fputs(autoboot_config_strings[autobootOption], f); } else { fputs("none", f); @@ -59,7 +204,7 @@ void writeAutobootOption(std::string &configPath, int32_t autobootOption) { } } -void drawMenuScreen(const std::map &menu, uint32_t selectedIndex, uint32_t autobootIndex, bool updatesBlocked) { +void drawMenuScreen(const BootMenu &menu, uint32_t selectedIndex, uint32_t autobootIndex, bool updatesBlocked) { DrawUtils::beginDraw(); DrawUtils::clear(COLOR_BACKGROUND); @@ -108,7 +253,8 @@ void drawMenuScreen(const std::map &menu, uint32_t select DrawUtils::endDraw(); } -int32_t handleMenuScreen(std::string &configPath, int32_t autobootOptionInput, const std::map &menu) { +int32_t handleMenuScreen(std::string &configPath, int32_t autobootOptionInput, const BootMenu &menu, + const std::vector &customOptions, bool ordered) { auto screenBuffer = DrawUtils::InitOSScreen(); if (!screenBuffer) { OSFatal("AutobootModule: Failed to alloc memory for screen"); @@ -122,28 +268,25 @@ int32_t handleMenuScreen(std::string &configPath, int32_t autobootOptionInput, c OSFatal("AutobootModule: Failed to init font"); } - int32_t selectedIndex = autobootOptionInput > 0 ? autobootOptionInput : 0; - int autobootIndex = autobootOptionInput; - - // "Convert" id to index - int32_t offset = 0; - for (auto &item : menu) { - if ((uint32_t) selectedIndex == item.first) { - selectedIndex = offset; - break; - } - offset++; - } - if (autobootIndex > 0) { - offset = 0; - for (auto &item : menu) { - if ((uint32_t) autobootIndex == item.first) { - autobootIndex = offset; - break; + // Convert option ids to positions in the menu (-1 if not shown). With no + // autoboot option, the cursor starts on the first entry when bootOptions.cfg + // sets the order, else on the Wii U Menu. + auto indexOf = [&menu](int32_t id) { + for (uint32_t i = 0; i < menu.size(); i++) { + if ((int32_t) menu[i].first == id) { + return (int32_t) i; } - offset++; } + return -1; + }; + int autobootIndex = autobootOptionInput >= 0 ? indexOf(autobootOptionInput) : -1; + int32_t selectedIndex = autobootIndex >= 0 ? autobootIndex : (ordered ? 0 : indexOf(BOOT_OPTION_WII_U_MENU)); + if (selectedIndex < 0) { + selectedIndex = 0; } + // Set by X or Y: the saved choice is written even if it matches the input, so X can clear + // a saved custom entry whose title isn't installed (the menu gets -1 for it). + bool autobootChanged = false; { PairMenu pairMenu; @@ -175,9 +318,11 @@ int32_t handleMenuScreen(std::string &configPath, int32_t autobootOptionInput, c } else if (input.trigger & VPAD_BUTTON_A) { break; } else if (input.trigger & (VPAD_BUTTON_X | VPAD_BUTTON_MINUS)) { - autobootIndex = -1; + autobootIndex = -1; + autobootChanged = true; } else if (input.trigger & (VPAD_BUTTON_Y | VPAD_BUTTON_PLUS)) { - autobootIndex = selectedIndex; + autobootIndex = selectedIndex; + autobootChanged = true; } else if ((input.hold & (VPAD_BUTTON_PLUS | VPAD_BUTTON_MINUS)) == (VPAD_BUTTON_PLUS | VPAD_BUTTON_MINUS)) { if (holdUpdateBlockedForFrames++ > 50) { if (gUpdatesBlocked) { @@ -216,8 +361,8 @@ int32_t handleMenuScreen(std::string &configPath, int32_t autobootOptionInput, c autoboot = std::next(menu.begin(), autobootIndex)->first; } - if (autoboot != autobootOptionInput) { - writeAutobootOption(configPath, autoboot); + if (autobootChanged || autoboot != autobootOptionInput) { + writeAutobootOption(configPath, autoboot, customOptions); } return selected; diff --git a/source/MenuUtils.h b/source/MenuUtils.h index a99b2d1..0dc72db 100644 --- a/source/MenuUtils.h +++ b/source/MenuUtils.h @@ -6,6 +6,7 @@ #include #include #include +#include #include #define UPDATE_SKIP_PATH "fs:/vol/external01/wiiu/environments/skipUpdateWarn" @@ -28,11 +29,34 @@ enum { BOOT_OPTION_VWII_HOMEBREW_CHANNEL, }; -int32_t readAutobootOption(std::string &configPath); +// Entries from bootOptions.cfg use BOOT_OPTION_CUSTOM_BASE + their index in the file. +#define BOOT_OPTION_CUSTOM_BASE 0x100 +// At most this many custom entries, fewer if the menu runs out of rows. +#define MAX_CUSTOM_BOOT_OPTIONS 4 +// The menu doesn't scroll, and an eighth row would cover the update status line. +#define MAX_MENU_ROWS 7 -void writeAutobootOption(std::string &configPath, int32_t autobootOption); +// Boot menu entries (option id, name) in the order they are shown. +using BootMenu = std::vector>; -int32_t handleMenuScreen(std::string &configPath, int32_t autobootOptionInput, const std::map &menu); +struct CustomBootOption { + std::string name; + uint64_t titleId; +}; + +// Reads the custom entries from bootOptions.cfg. When the file also has "@" lines naming +// built-in entries, `menuOrder` gets every listed entry's option id in the file's order; +// without them it stays empty and the menu keeps the usual order. +std::vector readCustomBootOptions(const std::string &path, std::vector &menuOrder); + +int32_t readAutobootOption(std::string &configPath, const std::vector &customOptions); + +void writeAutobootOption(std::string &configPath, int32_t autobootOption, const std::vector &customOptions); + +// `ordered`: bootOptions.cfg sets the menu order; with no autoboot entry the cursor then +// starts on the first entry instead of the Wii U Menu. +int32_t handleMenuScreen(std::string &configPath, int32_t autobootOptionInput, const BootMenu &menu, + const std::vector &customOptions, bool ordered); nn::act::SlotNo handleAccountSelectScreen(const std::vector> &data); diff --git a/source/main.cpp b/source/main.cpp index 70e4110..4ccb75e 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -5,6 +5,7 @@ #include "QuickStartUtils.h" #include "StorageUtils.h" #include "logger.h" +#include #include #include #include @@ -85,11 +86,13 @@ int32_t main(int32_t argc, char **argv) { DEBUG_FUNCTION_LINE_ERR("Failed to create FSA Client"); } - bool showvHBL = getVWiiHBLTitleId() != 0; - bool showHBL = false; - std::string configPath = "fs:/vol/external01/wiiu/autoboot.cfg"; + bool showvHBL = getVWiiHBLTitleId() != 0; + bool showHBL = false; + std::string configPath = "fs:/vol/external01/wiiu/autoboot.cfg"; + std::string bootOptionsPath = "fs:/vol/external01/wiiu/bootOptions.cfg"; if (argc >= 1) { - configPath = std::string(argv[0]) + "/autoboot.cfg"; + configPath = std::string(argv[0]) + "/autoboot.cfg"; + bootOptionsPath = std::string(argv[0]) + "/bootOptions.cfg"; auto hblInstallerPath = std::string(argv[0]) + "/modules/setup/50_hbl_installer.rpx"; struct stat st {}; @@ -98,27 +101,83 @@ int32_t main(int32_t argc, char **argv) { } } - int32_t bootSelection = readAutobootOption(configPath); - - std::map menu; - menu[BOOT_OPTION_WII_U_MENU] = "Wii U Menu"; - if (showHBL) { - menu[BOOT_OPTION_HOMEBREW_LAUNCHER] = "Homebrew Launcher"; + std::vector menuOrder; + auto customOptions = readCustomBootOptions(bootOptionsPath, menuOrder); + const bool ordered = !menuOrder.empty(); + int32_t bootSelection = readAutobootOption(configPath, customOptions); + + // The usual order: the built-in entries, then the custom ones. Entries that bootOptions.cfg + // orders with "@" lines come first; the ones it doesn't list follow in the usual order. + menuOrder.insert(menuOrder.end(), {BOOT_OPTION_WII_U_MENU, BOOT_OPTION_HOMEBREW_LAUNCHER, + BOOT_OPTION_VWII_SYSTEM_MENU, BOOT_OPTION_VWII_HOMEBREW_CHANNEL}); + for (uint32_t i = 0; i < customOptions.size(); i++) { + menuOrder.push_back(BOOT_OPTION_CUSTOM_BASE + i); } - menu[BOOT_OPTION_VWII_SYSTEM_MENU] = "vWii System Menu"; - if (showvHBL) { - menu[BOOT_OPTION_VWII_HOMEBREW_CHANNEL] = "vWii Homebrew Channel"; + + BootMenu menu; + // Built-in entries always get their row; custom entries share what's left, in file order. + uint32_t customRows = MAX_MENU_ROWS - (2 + (showHBL ? 1 : 0) + (showvHBL ? 1 : 0)); + std::vector placed; + for (uint32_t id : menuOrder) { + if (std::find(placed.begin(), placed.end(), id) != placed.end()) { + continue; + } + placed.push_back(id); + switch (id) { + case BOOT_OPTION_WII_U_MENU: + menu.emplace_back(id, "Wii U Menu"); + break; + case BOOT_OPTION_HOMEBREW_LAUNCHER: + if (showHBL) { + menu.emplace_back(id, "Homebrew Launcher"); + } + break; + case BOOT_OPTION_VWII_SYSTEM_MENU: + menu.emplace_back(id, "vWii System Menu"); + break; + case BOOT_OPTION_VWII_HOMEBREW_CHANNEL: + if (showvHBL) { + menu.emplace_back(id, "vWii Homebrew Channel"); + } + break; + default: { + const CustomBootOption &option = customOptions[id - BOOT_OPTION_CUSTOM_BASE]; + // Only offer titles that are installed, so a stale entry can never be launched. + if (!titleExists(option.titleId)) { + DEBUG_FUNCTION_LINE_WARN("bootOptions.cfg: %016llx (%s) is not installed", option.titleId, option.name.c_str()); + } else if (customRows == 0) { + DEBUG_FUNCTION_LINE_WARN("bootOptions.cfg: no room in the menu for %016llx (%s)", option.titleId, option.name.c_str()); + } else { + menu.emplace_back(id, option.name); + customRows--; + } + break; + } + } } + auto inMenu = [&menu](int32_t id) { + for (auto &item : menu) { + if ((int32_t) item.first == id) { + return true; + } + } + return false; + }; if ((bootSelection == -1) || (bootSelection == BOOT_OPTION_HOMEBREW_LAUNCHER && !showHBL) || (bootSelection == BOOT_OPTION_VWII_HOMEBREW_CHANNEL && !showvHBL) || + (bootSelection >= BOOT_OPTION_CUSTOM_BASE && !inMenu(bootSelection)) || (buttons.hold & VPAD_BUTTON_PLUS)) { if (!AXIsInit()) { AXInit(); } - bootSelection = handleMenuScreen(configPath, bootSelection, menu); - hadMenu = true; + // A saved entry the menu doesn't show (a custom title that's gone, or a missing Homebrew + // Launcher or vWii Homebrew Channel) stays saved and comes back once it's available again, + // instead of being preselected or overwritten by the menu. + int32_t menuInput = (bootSelection >= 0 && !inMenu(bootSelection)) ? -1 : bootSelection; + bootSelection = handleMenuScreen(configPath, menuInput, menu, customOptions, ordered); + hadMenu = true; } if (bootSelection >= 0) { @@ -144,6 +203,10 @@ int32_t main(int32_t argc, char **argv) { bootHomebrewChannel(); break; default: + if (bootSelection >= BOOT_OPTION_CUSTOM_BASE && inMenu(bootSelection)) { + bootCustomTitle(customOptions[bootSelection - BOOT_OPTION_CUSTOM_BASE].titleId); + break; + } bootWiiUMenu(); break; }