From 12017b379755a4fed73ced8a680e528169c6dfd8 Mon Sep 17 00:00:00 2001 From: Grant <27168728+grantendo@users.noreply.github.com> Date: Tue, 13 Oct 2026 09:39:02 -0500 Subject: [PATCH 01/22] Add custom boot entries from bootOptions.cfg MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reads up to 4 entries ("Name,0x<64-bit title id>") from bootOptions.cfg next to autoboot.cfg and adds the installed ones to the boot menu. The title id decides the launch path: 0x0001... titles launch on vWii via mocha and CMPTLaunchTitle, 0x0005... titles via _SYSLaunchTitleWithStdArgsInNoSplash after account selection. A custom autoboot choice is saved by title id, so renaming an entry keeps it. If the saved title is no longer installed, the menu opens without overwriting the choice. Builds on wiiu-env/AutobootModule#25 by Romulo Leitão (razor85), which introduced bootOptions.cfg and the custom entries, and follows the review there: full title ids, no vWii/Wii U string field, and fgets/strtoull instead of streams. The installed-title check now looks for title.tmd, which every installed title has. Co-authored-by: Romulo Leitão --- README.md | 12 +++++ source/BootUtils.cpp | 63 ++++++++++++++++++++------ source/BootUtils.h | 14 +++++- source/MenuUtils.cpp | 104 ++++++++++++++++++++++++++++++++++++++++--- source/MenuUtils.h | 19 ++++++-- source/main.cpp | 27 +++++++++-- 6 files changed, 213 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 3b6600e..027f967 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,18 @@ 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. A custom entry can be set as the autoboot title like any other. ## Buildflags diff --git a/source/BootUtils.cpp b/source/BootUtils.cpp index 635800f..c3c5eec 100644 --- a/source/BootUtils.cpp +++ b/source/BootUtils.cpp @@ -13,6 +13,7 @@ #include #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/MenuUtils.cpp b/source/MenuUtils.cpp index 832f10d..7f0c5ee 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" @@ -11,6 +12,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -30,13 +34,95 @@ 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); +} + +std::vector readCustomBootOptions(const std::string &path) { + std::vector result; + 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. + char line[256]; + while (fgets(line, sizeof(line), f)) { + trimInPlace(line); + if (line[0] == '\0' || line[0] == '#') { + 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; + } + + 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) { + DEBUG_FUNCTION_LINE_WARN("bootOptions.cfg: only the first %d entries are used", MAX_CUSTOM_BOOT_OPTIONS); + break; + } + result.push_back({line, titleId}); + } + fclose(f); + 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 +132,17 @@ 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()) { + fprintf(f, CUSTOM_AUTOBOOT_PREFIX "%016llx", customOptions[index].titleId); + } else { + fputs("none", f); + } + } else if (autobootOption >= 0) { fputs(autoboot_config_strings[autobootOption], f); } else { fputs("none", f); @@ -108,7 +201,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 std::map &menu, + const std::vector &customOptions) { auto screenBuffer = DrawUtils::InitOSScreen(); if (!screenBuffer) { OSFatal("AutobootModule: Failed to alloc memory for screen"); @@ -217,7 +311,7 @@ int32_t handleMenuScreen(std::string &configPath, int32_t autobootOptionInput, c } if (autoboot != autobootOptionInput) { - writeAutobootOption(configPath, autoboot); + writeAutobootOption(configPath, autoboot, customOptions); } return selected; diff --git a/source/MenuUtils.h b/source/MenuUtils.h index a99b2d1..ae47b1c 100644 --- a/source/MenuUtils.h +++ b/source/MenuUtils.h @@ -28,11 +28,24 @@ 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 +// The menu has no scrolling; with the built-in options this still fits on screen. +#define MAX_CUSTOM_BOOT_OPTIONS 4 + +struct CustomBootOption { + std::string name; + uint64_t titleId; +}; + +std::vector readCustomBootOptions(const std::string &path); + +int32_t readAutobootOption(std::string &configPath, const std::vector &customOptions); -void writeAutobootOption(std::string &configPath, int32_t autobootOption); +void writeAutobootOption(std::string &configPath, int32_t autobootOption, const std::vector &customOptions); -int32_t handleMenuScreen(std::string &configPath, int32_t autobootOptionInput, const std::map &menu); +int32_t handleMenuScreen(std::string &configPath, int32_t autobootOptionInput, const std::map &menu, + const std::vector &customOptions); nn::act::SlotNo handleAccountSelectScreen(const std::vector> &data); diff --git a/source/main.cpp b/source/main.cpp index 70e4110..ba2cf3b 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -87,9 +87,11 @@ int32_t main(int32_t argc, char **argv) { bool showvHBL = getVWiiHBLTitleId() != 0; bool showHBL = false; - std::string configPath = "fs:/vol/external01/wiiu/autoboot.cfg"; + 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,7 +100,8 @@ int32_t main(int32_t argc, char **argv) { } } - int32_t bootSelection = readAutobootOption(configPath); + auto customOptions = readCustomBootOptions(bootOptionsPath); + int32_t bootSelection = readAutobootOption(configPath, customOptions); std::map menu; menu[BOOT_OPTION_WII_U_MENU] = "Wii U Menu"; @@ -109,15 +112,27 @@ int32_t main(int32_t argc, char **argv) { if (showvHBL) { menu[BOOT_OPTION_VWII_HOMEBREW_CHANNEL] = "vWii Homebrew Channel"; } + for (uint32_t i = 0; i < customOptions.size(); i++) { + // Only offer titles that are installed, so a stale entry can never be launched. + if (titleExists(customOptions[i].titleId)) { + menu[BOOT_OPTION_CUSTOM_BASE + i] = customOptions[i].name; + } else { + DEBUG_FUNCTION_LINE_WARN("bootOptions.cfg: %016llx (%s) is not installed", customOptions[i].titleId, customOptions[i].name.c_str()); + } + } if ((bootSelection == -1) || (bootSelection == BOOT_OPTION_HOMEBREW_LAUNCHER && !showHBL) || (bootSelection == BOOT_OPTION_VWII_HOMEBREW_CHANNEL && !showvHBL) || + (bootSelection >= BOOT_OPTION_CUSTOM_BASE && menu.count(bootSelection) == 0) || (buttons.hold & VPAD_BUTTON_PLUS)) { if (!AXIsInit()) { AXInit(); } - bootSelection = handleMenuScreen(configPath, bootSelection, menu); + // A saved custom entry whose title is gone stays saved (it comes back once the title + // is reinstalled) instead of being preselected or overwritten by the menu. + int32_t menuInput = (bootSelection >= BOOT_OPTION_CUSTOM_BASE && menu.count(bootSelection) == 0) ? -1 : bootSelection; + bootSelection = handleMenuScreen(configPath, menuInput, menu, customOptions); hadMenu = true; } @@ -144,6 +159,10 @@ int32_t main(int32_t argc, char **argv) { bootHomebrewChannel(); break; default: + if (bootSelection >= BOOT_OPTION_CUSTOM_BASE && menu.count(bootSelection) != 0) { + bootCustomTitle(customOptions[bootSelection - BOOT_OPTION_CUSTOM_BASE].titleId); + break; + } bootWiiUMenu(); break; } From b33e9db4140b9b8ee8b08b5487d40f1528004b77 Mon Sep 17 00:00:00 2001 From: Grant <27168728+grantendo@users.noreply.github.com> Date: Tue, 13 Oct 2026 09:59:33 -0500 Subject: [PATCH 02/22] Write the custom autoboot entry with snprintf, apply clang-format fprintf pulled in about 4.8 KB of formatting code that snprintf, already linked, covers. The branch now builds 4.4 KB larger than main. Formatted with clang-format 13.0.1, which leaves main unchanged. --- source/BootUtils.cpp | 2 +- source/MenuUtils.cpp | 6 ++++-- source/main.cpp | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/source/BootUtils.cpp b/source/BootUtils.cpp index c3c5eec..5444bb0 100644 --- a/source/BootUtils.cpp +++ b/source/BootUtils.cpp @@ -4,6 +4,7 @@ #include "logger.h" #include #include +#include #include #include #include @@ -13,7 +14,6 @@ #include #include #include -#include #include #include #include diff --git a/source/MenuUtils.cpp b/source/MenuUtils.cpp index 7f0c5ee..61f2a16 100644 --- a/source/MenuUtils.cpp +++ b/source/MenuUtils.cpp @@ -8,11 +8,11 @@ #include "main.h" #include "utils.h" #include "version.h" +#include #include #include #include #include -#include #include #include #include @@ -138,7 +138,9 @@ void writeAutobootOption(std::string &configPath, int32_t autobootOption, const if (autobootOption >= BOOT_OPTION_CUSTOM_BASE) { uint32_t index = autobootOption - BOOT_OPTION_CUSTOM_BASE; if (index < customOptions.size()) { - fprintf(f, CUSTOM_AUTOBOOT_PREFIX "%016llx", customOptions[index].titleId); + 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); } diff --git a/source/main.cpp b/source/main.cpp index ba2cf3b..f59330a 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -85,8 +85,8 @@ int32_t main(int32_t argc, char **argv) { DEBUG_FUNCTION_LINE_ERR("Failed to create FSA Client"); } - bool showvHBL = getVWiiHBLTitleId() != 0; - bool showHBL = false; + 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) { @@ -133,7 +133,7 @@ int32_t main(int32_t argc, char **argv) { // is reinstalled) instead of being preselected or overwritten by the menu. int32_t menuInput = (bootSelection >= BOOT_OPTION_CUSTOM_BASE && menu.count(bootSelection) == 0) ? -1 : bootSelection; bootSelection = handleMenuScreen(configPath, menuInput, menu, customOptions); - hadMenu = true; + hadMenu = true; } if (bootSelection >= 0) { From 9a0dbff0e915f05128dca4dca8bd48640deb58cc Mon Sep 17 00:00:00 2001 From: patapovich Date: Sat, 29 Aug 2026 10:35:59 +0300 Subject: [PATCH 03/22] Force TV-only screen type for vWii launch Works around vWii autoboot hanging on a black screen when the GamePad is powered off (wiiu-env/AutobootModule#67). The BOTH/DRC screen-state probing succeeds even with no GamePad connected, after which the vWii transition waits on the DRC forever. Claude-Session: https://claude.ai/code/session_01PE4DJqPCXQzkGorJSUDrGv (cherry picked from commit f8eacbf of patapovich/AutobootModule; the same change is in his pull request wiiu-env/AutobootModule#69) --- source/BootUtils.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/source/BootUtils.cpp b/source/BootUtils.cpp index 635800f..485a962 100644 --- a/source/BootUtils.cpp +++ b/source/BootUtils.cpp @@ -89,14 +89,9 @@ static void launchvWiiTitle(uint64_t titleId) { // we need to init kpad for cmpt KPADInit(); - // Try to find a screen type that works - CMPTAcctSetScreenType(CMPT_SCREEN_TYPE_BOTH); - if (CMPTCheckScreenState() < 0) { - CMPTAcctSetScreenType(CMPT_SCREEN_TYPE_DRC); - if (CMPTCheckScreenState() < 0) { - CMPTAcctSetScreenType(CMPT_SCREEN_TYPE_TV); - } - } + // Force TV-only output so autoboot works with the GamePad powered off, + // see https://github.com/wiiu-env/AutobootModule/issues/67 + CMPTAcctSetScreenType(CMPT_SCREEN_TYPE_TV); uint32_t dataSize = 0; CMPTGetDataSize(&dataSize); From 895a19e32f577ae0a9d25e56c02bf914cf7f0724 Mon Sep 17 00:00:00 2001 From: patapovich Date: Sat, 29 Aug 2026 10:43:21 +0300 Subject: [PATCH 04/22] Disable DRC control for vWii launch CMPTAcctSetScreenType alone does not prevent the hang: the Wii U Menu additionally calls CMPTAcctSetDrcCtrlEnabled (nn_cmpt.rpl export, undeclared in wut) before launching vWii titles. Without it the vWii transition waits on a GamePad connection (wiiu-env/AutobootModule#67). Claude-Session: https://claude.ai/code/session_01PE4DJqPCXQzkGorJSUDrGv (cherry picked from commit 474b98e of patapovich/AutobootModule; the same change is in his pull request wiiu-env/AutobootModule#69) --- source/BootUtils.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/BootUtils.cpp b/source/BootUtils.cpp index 485a962..b2bd9be 100644 --- a/source/BootUtils.cpp +++ b/source/BootUtils.cpp @@ -85,12 +85,18 @@ void handleAccountSelection() { nn::act::Finalize(); } +// Exported by nn_cmpt.rpl but not declared in wut's cmpt.h; the Wii U Menu +// calls this before launching vWii titles to signal GamePad support. +extern "C" int32_t CMPTAcctSetDrcCtrlEnabled(int32_t enabled); + static void launchvWiiTitle(uint64_t titleId) { // we need to init kpad for cmpt KPADInit(); - // Force TV-only output so autoboot works with the GamePad powered off, + // Disable the GamePad and force TV-only output so autoboot works with + // the GamePad powered off, // see https://github.com/wiiu-env/AutobootModule/issues/67 + CMPTAcctSetDrcCtrlEnabled(0); CMPTAcctSetScreenType(CMPT_SCREEN_TYPE_TV); uint32_t dataSize = 0; From 9ba82543896c1ec4140467089b0118395491e8a9 Mon Sep 17 00:00:00 2001 From: patapovich Date: Sat, 29 Aug 2026 12:03:55 +0300 Subject: [PATCH 05/22] Wait for the compat subsystem before launching vWii titles On autoboot the launch runs much earlier than a manual selection from the boot menu, and launching before the compat subsystem is ready gives a black screen. Wait for CMPTCheckScreenState, launching anyway after 5s. From patapovich's wiiu-env/AutobootModule#69 (commit 653bf27), which adds this wait to the two earlier commits above: its author found the screen type and DRC changes alone did not fix the black screen with the GamePad off. --- source/BootUtils.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/source/BootUtils.cpp b/source/BootUtils.cpp index b2bd9be..8e35d3c 100644 --- a/source/BootUtils.cpp +++ b/source/BootUtils.cpp @@ -4,6 +4,8 @@ #include "logger.h" #include #include +#include +#include #include #include #include @@ -99,6 +101,13 @@ static void launchvWiiTitle(uint64_t titleId) { CMPTAcctSetDrcCtrlEnabled(0); CMPTAcctSetScreenType(CMPT_SCREEN_TYPE_TV); + // On autoboot this code runs much earlier than a manual selection from + // the boot menu, and launching before the compat subsystem is ready + // results in a black screen. Wait for it, but launch anyway after 5s. + for (int i = 0; i < 50 && CMPTCheckScreenState() < 0; i++) { + OSSleepTicks(OSMillisecondsToTicks(100)); + } + uint32_t dataSize = 0; CMPTGetDataSize(&dataSize); From 6a5cb850d6fbb1b019d7ba29d33a42944e5884c4 Mon Sep 17 00:00:00 2001 From: Grant <27168728+grantendo@users.noreply.github.com> Date: Tue, 20 Oct 2026 10:21:29 -0500 Subject: [PATCH 06/22] Give the GamePad pipe a mode before a vWii launch without a GamePad With the GamePad off, CMPTLaunchTitle and CMPTLaunchMenu return -512: avm's AVMSetDCWiiCompat, which switches the TV to Wii mode, also reprograms the GamePad's display pipe from avm's GamePad settings, and with no GamePad those say "off" (what GX2SetDRCBuffer with GX2_DRC_RENDER_MODE_DISABLE stores), which dc rejects. Set the GamePad display to 854x480 first, the call GX2SetDRCBuffer makes for GX2_DRC_RENDER_MODE_SINGLE: AVMSetDRCBufferAttr(2, 1, 896), found with OSDynLoad. --- source/BootUtils.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/source/BootUtils.cpp b/source/BootUtils.cpp index 8e35d3c..bf61cbf 100644 --- a/source/BootUtils.cpp +++ b/source/BootUtils.cpp @@ -3,6 +3,7 @@ #include "MenuUtils.h" #include "logger.h" #include +#include #include #include #include @@ -91,6 +92,25 @@ void handleAccountSelection() { // calls this before launching vWii titles to signal GamePad support. extern "C" int32_t CMPTAcctSetDrcCtrlEnabled(int32_t enabled); +// With the GamePad off, nn_cmpt refuses vWii launches (-512): its switch of the +// TV to Wii mode (AVMSetDCWiiCompat) also reprograms the GamePad's display pipe +// from avm.rpl's GamePad settings, and with no GamePad those say "off" (what +// GX2SetDRCBuffer with GX2_DRC_RENDER_MODE_DISABLE stores), which dc.rpl rejects +// (DCGetBufferRequirement = -2). Give the GamePad pipe a normal 854x480 mode +// first, with the call GX2SetDRCBuffer makes for GX2_DRC_RENDER_MODE_SINGLE and +// double buffering: AVMSetDRCBufferAttr(bufferingMode, mode, pitch). +static void setDrcModeForWiiMode() { + OSDynLoad_Module avm = nullptr; + void *setDrcBufferAttr = nullptr; + if (OSDynLoad_Acquire("avm.rpl", &avm) != OS_DYNLOAD_OK || + OSDynLoad_FindExport(avm, OS_DYNLOAD_EXPORT_FUNC, "AVMSetDRCBufferAttr", &setDrcBufferAttr) != OS_DYNLOAD_OK) { + DEBUG_FUNCTION_LINE_ERR("AVMSetDRCBufferAttr not found"); + return; + } + [[maybe_unused]] int32_t result = ((int32_t(*)(int32_t, int32_t, int32_t)) setDrcBufferAttr)(2, 1, 896); + DEBUG_FUNCTION_LINE("AVMSetDRCBufferAttr(2, 1, 896) = %d", result); +} + static void launchvWiiTitle(uint64_t titleId) { // we need to init kpad for cmpt KPADInit(); @@ -111,6 +131,8 @@ static void launchvWiiTitle(uint64_t titleId) { uint32_t dataSize = 0; CMPTGetDataSize(&dataSize); + setDrcModeForWiiMode(); + void *dataBuffer = memalign(0x40, dataSize); if (titleId == 0) { From db5afe095a0add5ce7628b4f006654086a309d7e Mon Sep 17 00:00:00 2001 From: Grant <27168728+grantendo@users.noreply.github.com> Date: Tue, 20 Oct 2026 10:22:21 -0500 Subject: [PATCH 07/22] Launch vWii titles for the TV alone only when no GamePad is connected The fixes for issue #67 forced TV-only output and turned GamePad control off for every vWii launch, which would cost GamePad users the vWii on their GamePad. Ask VPADRead whether a GamePad is connected (for up to half a second, as one switched on with the console may still be connecting at autoboot): if one is, launch exactly as before, trying both screens, then the GamePad, then the TV; if none is, take the TV-only path with the compat wait and the GamePad pipe mode. --- source/BootUtils.cpp | 57 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 45 insertions(+), 12 deletions(-) diff --git a/source/BootUtils.cpp b/source/BootUtils.cpp index bf61cbf..0841efd 100644 --- a/source/BootUtils.cpp +++ b/source/BootUtils.cpp @@ -20,6 +20,7 @@ #include #include #include +#include void handleAccountSelection(); @@ -111,27 +112,59 @@ static void setDrcModeForWiiMode() { DEBUG_FUNCTION_LINE("AVMSetDRCBufferAttr(2, 1, 896) = %d", result); } +// Whether a GamePad is connected: VPADRead reports VPAD_READ_INVALID_CONTROLLER while none is. +// Asked for up to half a second, as a GamePad switched on with the console may still be +// connecting when autoboot gets here. +static bool isGamePadConnected() { + for (int i = 0; i < 10; i++) { + VPADStatus status{}; + VPADReadError error = VPAD_READ_UNINITIALIZED; + VPADRead(VPAD_CHAN_0, &status, 1, &error); + if (error == VPAD_READ_SUCCESS || error == VPAD_READ_NO_SAMPLES) { + return true; + } + OSSleepTicks(OSMillisecondsToTicks(50)); + } + return false; +} + static void launchvWiiTitle(uint64_t titleId) { // we need to init kpad for cmpt KPADInit(); - // Disable the GamePad and force TV-only output so autoboot works with - // the GamePad powered off, - // see https://github.com/wiiu-env/AutobootModule/issues/67 - CMPTAcctSetDrcCtrlEnabled(0); - CMPTAcctSetScreenType(CMPT_SCREEN_TYPE_TV); - - // On autoboot this code runs much earlier than a manual selection from - // the boot menu, and launching before the compat subsystem is ready - // results in a black screen. Wait for it, but launch anyway after 5s. - for (int i = 0; i < 50 && CMPTCheckScreenState() < 0; i++) { - OSSleepTicks(OSMillisecondsToTicks(100)); + // With a GamePad connected, launch as before: the vWii can show on both screens. Without + // one, the launch hangs on a black screen or is refused, see + // https://github.com/wiiu-env/AutobootModule/issues/67, so launch for the TV alone. + const bool gamePadConnected = isGamePadConnected(); + if (gamePadConnected) { + // Try to find a screen type that works + CMPTAcctSetScreenType(CMPT_SCREEN_TYPE_BOTH); + if (CMPTCheckScreenState() < 0) { + CMPTAcctSetScreenType(CMPT_SCREEN_TYPE_DRC); + if (CMPTCheckScreenState() < 0) { + CMPTAcctSetScreenType(CMPT_SCREEN_TYPE_TV); + } + } + } else { + DEBUG_FUNCTION_LINE("No GamePad connected: launching the vWii for the TV only"); + // GamePad control off and the TV as the only screen + CMPTAcctSetDrcCtrlEnabled(0); + CMPTAcctSetScreenType(CMPT_SCREEN_TYPE_TV); + + // On autoboot this code runs much earlier than a manual selection from + // the boot menu, and launching before the compat subsystem is ready + // results in a black screen. Wait for it, but launch anyway after 5s. + for (int i = 0; i < 50 && CMPTCheckScreenState() < 0; i++) { + OSSleepTicks(OSMillisecondsToTicks(100)); + } } uint32_t dataSize = 0; CMPTGetDataSize(&dataSize); - setDrcModeForWiiMode(); + if (!gamePadConnected) { + setDrcModeForWiiMode(); + } void *dataBuffer = memalign(0x40, dataSize); From dd815eb7189b54f3bfeb24d1bff76413c994f1b0 Mon Sep 17 00:00:00 2001 From: Grant <27168728+grantendo@users.noreply.github.com> Date: Wed, 21 Oct 2026 14:59:02 -0500 Subject: [PATCH 08/22] Say "no GamePad connected" in the pipe-mode comment, as the GamePad check does --- source/BootUtils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/BootUtils.cpp b/source/BootUtils.cpp index 0841efd..aeaf17e 100644 --- a/source/BootUtils.cpp +++ b/source/BootUtils.cpp @@ -93,7 +93,7 @@ void handleAccountSelection() { // calls this before launching vWii titles to signal GamePad support. extern "C" int32_t CMPTAcctSetDrcCtrlEnabled(int32_t enabled); -// With the GamePad off, nn_cmpt refuses vWii launches (-512): its switch of the +// With no GamePad connected, nn_cmpt refuses vWii launches (-512): its switch of the // TV to Wii mode (AVMSetDCWiiCompat) also reprograms the GamePad's display pipe // from avm.rpl's GamePad settings, and with no GamePad those say "off" (what // GX2SetDRCBuffer with GX2_DRC_RENDER_MODE_DISABLE stores), which dc.rpl rejects From 15513a108c46da2def471409d051c379cf8ae13d Mon Sep 17 00:00:00 2001 From: Grant <27168728+grantendo@users.noreply.github.com> Date: Sat, 31 Oct 2026 10:51:21 -0500 Subject: [PATCH 09/22] Ask the GamePad over its radio link whether it is connected VPADRead can report a GamePad that isn't there: the DRC Read Result Spoofer plugin makes every read succeed, so a vWii launch with no GamePad took the GamePad path and went black. CCRCDCDevicePing answers 0 only when a GamePad replies (2 to 4 ms either way on a Wii U, with and without the spoofer). --- source/BootUtils.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/source/BootUtils.cpp b/source/BootUtils.cpp index aeaf17e..2dcbb8c 100644 --- a/source/BootUtils.cpp +++ b/source/BootUtils.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -112,15 +113,13 @@ static void setDrcModeForWiiMode() { DEBUG_FUNCTION_LINE("AVMSetDRCBufferAttr(2, 1, 896) = %d", result); } -// Whether a GamePad is connected: VPADRead reports VPAD_READ_INVALID_CONTROLLER while none is. +// Whether a GamePad is connected: it answers a ping over its radio link. Not VPADRead, which +// a plugin can make succeed with no GamePad there (the DRC Read Result Spoofer does). // Asked for up to half a second, as a GamePad switched on with the console may still be // connecting when autoboot gets here. static bool isGamePadConnected() { for (int i = 0; i < 10; i++) { - VPADStatus status{}; - VPADReadError error = VPAD_READ_UNINITIALIZED; - VPADRead(VPAD_CHAN_0, &status, 1, &error); - if (error == VPAD_READ_SUCCESS || error == VPAD_READ_NO_SAMPLES) { + if (CCRCDCDevicePing(CCR_CDC_DESTINATION_DRC0) == 0) { return true; } OSSleepTicks(OSMillisecondsToTicks(50)); From 5dd32698d9008433b43b43fec8569fd9941ad25e Mon Sep 17 00:00:00 2001 From: Grant <27168728+grantendo@users.noreply.github.com> Date: Mon, 16 Nov 2026 14:26:10 -0600 Subject: [PATCH 10/22] Let X clear a saved custom entry whose title isn't installed The menu gets -1 for such an entry, so pressing X left the choice unchanged and nothing was written: the old title came back as the autoboot title once it was reinstalled. X and Y now always save. Also skip mbstowcs's result when it reports a byte it can't convert ((size_t) -1), now that entry names come from a file. --- source/DrawUtils.cpp | 4 ++-- source/MenuUtils.cpp | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) 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 61f2a16..b541107 100644 --- a/source/MenuUtils.cpp +++ b/source/MenuUtils.cpp @@ -220,6 +220,9 @@ int32_t handleMenuScreen(std::string &configPath, int32_t autobootOptionInput, c int32_t selectedIndex = autobootOptionInput > 0 ? autobootOptionInput : 0; int autobootIndex = autobootOptionInput; + // 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; // "Convert" id to index int32_t offset = 0; @@ -271,9 +274,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) { @@ -312,7 +317,7 @@ int32_t handleMenuScreen(std::string &configPath, int32_t autobootOptionInput, c autoboot = std::next(menu.begin(), autobootIndex)->first; } - if (autoboot != autobootOptionInput) { + if (autobootChanged || autoboot != autobootOptionInput) { writeAutobootOption(configPath, autoboot, customOptions); } From 6bb19fba09a90b52866fb87b181c73c7af8af492 Mon Sep 17 00:00:00 2001 From: Grant <27168728+grantendo@users.noreply.github.com> Date: Mon, 16 Nov 2026 15:21:28 -0600 Subject: [PATCH 11/22] Keep the menu to 7 rows and leave out system applets The menu doesn't scroll: with all four built-in entries and four custom ones, the eighth row covered the update status line. Custom entries that don't fit are left out with a log message. System applets (title ids 00050030..., like the Internet Browser) need their own launch calls, so bootOptions.cfg skips them. --- README.md | 2 +- source/MenuUtils.cpp | 6 ++++++ source/MenuUtils.h | 4 +++- source/main.cpp | 8 +++++--- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 027f967..9f46186 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ 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. A custom entry can be set as the autoboot title like any other. +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. ## Buildflags diff --git a/source/MenuUtils.cpp b/source/MenuUtils.cpp index b541107..7b9bfef 100644 --- a/source/MenuUtils.cpp +++ b/source/MenuUtils.cpp @@ -80,6 +80,12 @@ std::vector readCustomBootOptions(const std::string &path) { 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); diff --git a/source/MenuUtils.h b/source/MenuUtils.h index ae47b1c..9c71dc9 100644 --- a/source/MenuUtils.h +++ b/source/MenuUtils.h @@ -30,8 +30,10 @@ enum { // Entries from bootOptions.cfg use BOOT_OPTION_CUSTOM_BASE + their index in the file. #define BOOT_OPTION_CUSTOM_BASE 0x100 -// The menu has no scrolling; with the built-in options this still fits on screen. +// 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 struct CustomBootOption { std::string name; diff --git a/source/main.cpp b/source/main.cpp index f59330a..b1f70db 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -114,10 +114,12 @@ int32_t main(int32_t argc, char **argv) { } for (uint32_t i = 0; i < customOptions.size(); i++) { // Only offer titles that are installed, so a stale entry can never be launched. - if (titleExists(customOptions[i].titleId)) { - menu[BOOT_OPTION_CUSTOM_BASE + i] = customOptions[i].name; - } else { + if (!titleExists(customOptions[i].titleId)) { DEBUG_FUNCTION_LINE_WARN("bootOptions.cfg: %016llx (%s) is not installed", customOptions[i].titleId, customOptions[i].name.c_str()); + } else if (menu.size() >= MAX_MENU_ROWS) { + DEBUG_FUNCTION_LINE_WARN("bootOptions.cfg: no room in the menu for %016llx (%s)", customOptions[i].titleId, customOptions[i].name.c_str()); + } else { + menu[BOOT_OPTION_CUSTOM_BASE + i] = customOptions[i].name; } } From 548c986cf783081e3e268fe52fe17c41e3683cb8 Mon Sep 17 00:00:00 2001 From: Grant <27168728+grantendo@users.noreply.github.com> Date: Mon, 16 Nov 2026 15:40:45 -0600 Subject: [PATCH 12/22] Keep any saved entry the menu doesn't show, not just custom ones A saved Homebrew Launcher or vWii Homebrew Channel that is missing was passed to the menu unchanged, which then read its id as a row number: with a custom entry in that row, A started the custom title and saved it as the autoboot entry. Every saved entry the menu doesn't show now opens the menu with nothing preselected and stays saved, as a custom entry whose title is gone already did. --- source/main.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/main.cpp b/source/main.cpp index b1f70db..e2c805a 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -131,9 +131,10 @@ int32_t main(int32_t argc, char **argv) { if (!AXIsInit()) { AXInit(); } - // A saved custom entry whose title is gone stays saved (it comes back once the title - // is reinstalled) instead of being preselected or overwritten by the menu. - int32_t menuInput = (bootSelection >= BOOT_OPTION_CUSTOM_BASE && menu.count(bootSelection) == 0) ? -1 : bootSelection; + // 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 && menu.count(bootSelection) == 0) ? -1 : bootSelection; bootSelection = handleMenuScreen(configPath, menuInput, menu, customOptions); hadMenu = true; } From ac671ed5dc02b9a42aed9dbb822264b4d462f263 Mon Sep 17 00:00:00 2001 From: Grant <27168728+grantendo@users.noreply.github.com> Date: Tue, 20 Oct 2026 10:20:32 -0500 Subject: [PATCH 13/22] Let bootOptions.cfg set the boot menu order An "@" line in bootOptions.cfg names a built-in entry by its autoboot.cfg name (@wiiu_menu, @homebrew_launcher, @vwii_system_menu, @vwii_homebrew_channel). When the file has any, entries appear in the order of its lines; built-in entries it doesn't list follow in the usual order, so none can disappear, and unavailable ones stay hidden. Without "@" lines the menu looks as before. Names match in any case, an unknown one is skipped with a log message, and a byte order mark that some editors write at the start of the file is ignored. The menu is now an ordered list instead of a map keyed by option id, which also fixes the autoboot highlight and the starting cursor: they were found by matching ids to positions, which skipped the Wii U Menu (id 0) as the autoboot option. With no autoboot option the cursor starts on the Wii U Menu, as before. --- README.md | 13 +++++++ source/MenuUtils.cpp | 90 +++++++++++++++++++++++++++++++------------- source/MenuUtils.h | 11 +++++- source/main.cpp | 80 +++++++++++++++++++++++++++++---------- 4 files changed, 145 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index 9f46186..b14df6d 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,19 @@ 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. + ## Buildflags ### Logging diff --git a/source/MenuUtils.cpp b/source/MenuUtils.cpp index 7b9bfef..45a318a 100644 --- a/source/MenuUtils.cpp +++ b/source/MenuUtils.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -49,21 +50,55 @@ static void trimInPlace(char *str) { memmove(str, start, end - start + 1); } -std::vector readCustomBootOptions(const std::string &path) { +// 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; } + if (line[0] == '@') { + 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); @@ -102,12 +137,20 @@ std::vector readCustomBootOptions(const std::string &path) { } if (result.size() >= MAX_CUSTOM_BOOT_OPTIONS) { - DEBUG_FUNCTION_LINE_WARN("bootOptions.cfg: only the first %d entries are used", MAX_CUSTOM_BOOT_OPTIONS); - break; + // 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; } @@ -160,7 +203,7 @@ void writeAutobootOption(std::string &configPath, int32_t autobootOption, const } } -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); @@ -209,7 +252,7 @@ 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) { auto screenBuffer = DrawUtils::InitOSScreen(); if (!screenBuffer) { @@ -224,31 +267,24 @@ 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; - // 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; - - // "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 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 : 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; diff --git a/source/MenuUtils.h b/source/MenuUtils.h index 9c71dc9..8832b8a 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" @@ -35,18 +36,24 @@ enum { // The menu doesn't scroll, and an eighth row would cover the update status line. #define MAX_MENU_ROWS 7 +// Boot menu entries (option id, name) in the order they are shown. +using BootMenu = std::vector>; + struct CustomBootOption { std::string name; uint64_t titleId; }; -std::vector readCustomBootOptions(const std::string &path); +// 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); -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); nn::act::SlotNo handleAccountSelectScreen(const std::vector> &data); diff --git a/source/main.cpp b/source/main.cpp index e2c805a..ac3bbe3 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 @@ -100,33 +101,72 @@ int32_t main(int32_t argc, char **argv) { } } - auto customOptions = readCustomBootOptions(bootOptionsPath); + std::vector menuOrder; + auto customOptions = readCustomBootOptions(bootOptionsPath, menuOrder); int32_t bootSelection = readAutobootOption(configPath, customOptions); - std::map menu; - menu[BOOT_OPTION_WII_U_MENU] = "Wii U Menu"; - if (showHBL) { - menu[BOOT_OPTION_HOMEBREW_LAUNCHER] = "Homebrew Launcher"; - } - menu[BOOT_OPTION_VWII_SYSTEM_MENU] = "vWii System Menu"; - if (showvHBL) { - menu[BOOT_OPTION_VWII_HOMEBREW_CHANNEL] = "vWii Homebrew Channel"; - } + // 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++) { - // Only offer titles that are installed, so a stale entry can never be launched. - if (!titleExists(customOptions[i].titleId)) { - DEBUG_FUNCTION_LINE_WARN("bootOptions.cfg: %016llx (%s) is not installed", customOptions[i].titleId, customOptions[i].name.c_str()); - } else if (menu.size() >= MAX_MENU_ROWS) { - DEBUG_FUNCTION_LINE_WARN("bootOptions.cfg: no room in the menu for %016llx (%s)", customOptions[i].titleId, customOptions[i].name.c_str()); - } else { - menu[BOOT_OPTION_CUSTOM_BASE + i] = customOptions[i].name; + menuOrder.push_back(BOOT_OPTION_CUSTOM_BASE + i); + } + + 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 && menu.count(bootSelection) == 0) || + (bootSelection >= BOOT_OPTION_CUSTOM_BASE && !inMenu(bootSelection)) || (buttons.hold & VPAD_BUTTON_PLUS)) { if (!AXIsInit()) { AXInit(); @@ -134,7 +174,7 @@ int32_t main(int32_t argc, char **argv) { // 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 && menu.count(bootSelection) == 0) ? -1 : bootSelection; + int32_t menuInput = (bootSelection >= 0 && !inMenu(bootSelection)) ? -1 : bootSelection; bootSelection = handleMenuScreen(configPath, menuInput, menu, customOptions); hadMenu = true; } @@ -162,7 +202,7 @@ int32_t main(int32_t argc, char **argv) { bootHomebrewChannel(); break; default: - if (bootSelection >= BOOT_OPTION_CUSTOM_BASE && menu.count(bootSelection) != 0) { + if (bootSelection >= BOOT_OPTION_CUSTOM_BASE && inMenu(bootSelection)) { bootCustomTitle(customOptions[bootSelection - BOOT_OPTION_CUSTOM_BASE].titleId); break; } From 35dfeddeb3b6edf700e26c0a0ac4f6ca806955aa Mon Sep 17 00:00:00 2001 From: Grant <27168728+grantendo@users.noreply.github.com> Date: Sat, 31 Oct 2026 10:51:03 -0500 Subject: [PATCH 14/22] Start the cursor on the first entry when bootOptions.cfg sets the order With "@" lines in bootOptions.cfg and no autoboot entry, the menu's cursor starts on the first entry instead of the Wii U Menu, so the entry put first is also the one A starts. Without "@" lines nothing changes. --- README.md | 2 +- source/MenuUtils.cpp | 7 ++++--- source/MenuUtils.h | 4 +++- source/main.cpp | 3 ++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b14df6d..76d7a01 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ My vWii Channel,0x0001000152494654 @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. +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/MenuUtils.cpp b/source/MenuUtils.cpp index 45a318a..d66f6b2 100644 --- a/source/MenuUtils.cpp +++ b/source/MenuUtils.cpp @@ -253,7 +253,7 @@ void drawMenuScreen(const BootMenu &menu, uint32_t selectedIndex, uint32_t autob } int32_t handleMenuScreen(std::string &configPath, int32_t autobootOptionInput, const BootMenu &menu, - const std::vector &customOptions) { + const std::vector &customOptions, bool ordered) { auto screenBuffer = DrawUtils::InitOSScreen(); if (!screenBuffer) { OSFatal("AutobootModule: Failed to alloc memory for screen"); @@ -268,7 +268,8 @@ int32_t handleMenuScreen(std::string &configPath, int32_t autobootOptionInput, c } // Convert option ids to positions in the menu (-1 if not shown). With no - // autoboot option, the cursor starts on the Wii U Menu. + // 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) { @@ -278,7 +279,7 @@ int32_t handleMenuScreen(std::string &configPath, int32_t autobootOptionInput, c return -1; }; int autobootIndex = autobootOptionInput >= 0 ? indexOf(autobootOptionInput) : -1; - int32_t selectedIndex = autobootIndex >= 0 ? autobootIndex : indexOf(BOOT_OPTION_WII_U_MENU); + int32_t selectedIndex = autobootIndex >= 0 ? autobootIndex : (ordered ? 0 : indexOf(BOOT_OPTION_WII_U_MENU)); if (selectedIndex < 0) { selectedIndex = 0; } diff --git a/source/MenuUtils.h b/source/MenuUtils.h index 8832b8a..0dc72db 100644 --- a/source/MenuUtils.h +++ b/source/MenuUtils.h @@ -53,8 +53,10 @@ int32_t readAutobootOption(std::string &configPath, 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); + 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 ac3bbe3..4ccb75e 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -103,6 +103,7 @@ int32_t main(int32_t argc, char **argv) { 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 @@ -175,7 +176,7 @@ int32_t main(int32_t argc, char **argv) { // 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); + bootSelection = handleMenuScreen(configPath, menuInput, menu, customOptions, ordered); hadMenu = true; } From 1c3487e18a718b0f94d3408af493e155382c0fd7 Mon Sep 17 00:00:00 2001 From: Grant <27168728+grantendo@users.noreply.github.com> Date: Mon, 16 Nov 2026 14:26:46 -0600 Subject: [PATCH 15/22] Read an @ line with a comma as a custom entry A custom entry's name may start with @ ("@Games,0x..."), which the parser took for a built-in entry and skipped. Only lines without a comma name built-in entries now. --- source/MenuUtils.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/MenuUtils.cpp b/source/MenuUtils.cpp index d66f6b2..48f7090 100644 --- a/source/MenuUtils.cpp +++ b/source/MenuUtils.cpp @@ -86,7 +86,8 @@ std::vector readCustomBootOptions(const std::string &path, std continue; } - if (line[0] == '@') { + // 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); From c33662810054c5722bbf10a1cacc75ba61bec7b2 Mon Sep 17 00:00:00 2001 From: Grant <27168728+grantendo@users.noreply.github.com> Date: Thu, 22 Oct 2026 16:23:04 -0500 Subject: [PATCH 16/22] Add a boot menu countdown to the autoboot entry A "countdown=N" line in bootOptions.cfg (1-30 seconds) shows the menu at every boot even with an autoboot entry set, counts down to that entry and starts it when the countdown ends. Any button press stops the countdown and leaves the menu as usual. Without the line nothing changes. --- README.md | 4 +++ source/MenuUtils.cpp | 58 +++++++++++++++++++++++++++++++++++++++----- source/MenuUtils.h | 14 ++++++++--- source/main.cpp | 13 ++++++---- 4 files changed, 75 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 76d7a01..3604c3d 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,10 @@ My vWii Channel,0x0001000152494654 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. +### Menu countdown + +A line `countdown=5` in `bootOptions.cfg` (1 to 30 seconds) shows the menu at every boot even when an autoboot entry is set, with "Starting in 5..." above the bottom bar. When the countdown ends, the autoboot entry starts; pressing any button first stops the countdown and leaves the menu open as usual. Without an autoboot entry there is nothing to count down to, and the menu waits as before. Useful when no GamePad or Wii Remote is in reach at boot. + ## Buildflags ### Logging diff --git a/source/MenuUtils.cpp b/source/MenuUtils.cpp index 48f7090..f6a41b0 100644 --- a/source/MenuUtils.cpp +++ b/source/MenuUtils.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -60,16 +61,19 @@ static int32_t builtInOptionNamed(const char *name) { return -1; } -std::vector readCustomBootOptions(const std::string &path, std::vector &menuOrder) { +std::vector readCustomBootOptions(const std::string &path, std::vector &menuOrder, + uint32_t &countdownSeconds) { std::vector result; menuOrder.clear(); - FILE *f = fopen(path.c_str(), "r"); + countdownSeconds = 0; + 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. + // A line "@name" places a built-in entry ("@wiiu_menu") between them, and a line + // "countdown=5" turns on the menu's countdown to the autoboot entry. std::vector order; bool namesBuiltIns = false; bool tooMany = false; @@ -86,6 +90,19 @@ std::vector readCustomBootOptions(const std::string &path, std continue; } + if (strncasecmp(line, "countdown=", 10) == 0) { + char *valueStr = line + 10; + trimInPlace(valueStr); + char *valueEnd = nullptr; + unsigned long seconds = strtoul(valueStr, &valueEnd, 10); + if (valueEnd == valueStr || *valueEnd != '\0' || seconds < 1 || seconds > MAX_MENU_COUNTDOWN_SECONDS) { + DEBUG_FUNCTION_LINE_WARN("bootOptions.cfg: \"%s\" is not a countdown of 1 to %d seconds", line, MAX_MENU_COUNTDOWN_SECONDS); + continue; + } + countdownSeconds = seconds; + 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; @@ -204,7 +221,8 @@ void writeAutobootOption(std::string &configPath, int32_t autobootOption, const } } -void drawMenuScreen(const BootMenu &menu, uint32_t selectedIndex, uint32_t autobootIndex, bool updatesBlocked) { +// `secondsLeft` > 0: the countdown to the autoboot entry is running, shown above the bottom bar. +void drawMenuScreen(const BootMenu &menu, uint32_t selectedIndex, uint32_t autobootIndex, bool updatesBlocked, uint32_t secondsLeft) { DrawUtils::beginDraw(); DrawUtils::clear(COLOR_BACKGROUND); @@ -227,6 +245,15 @@ void drawMenuScreen(const BootMenu &menu, uint32_t selectedIndex, uint32_t autob DrawUtils::setFontColor(COLOR_TEXT); + if (secondsLeft > 0 && autobootIndex < menu.size()) { + std::string countdown = string_format("Starting %s in %u... Press any button to stay in this menu.", + menu[autobootIndex].second.c_str(), (unsigned int) secondsLeft); + DrawUtils::setFontSize(20); + DrawUtils::setFontColor(COLOR_AUTOBOOT); + DrawUtils::print(16, SCREEN_HEIGHT - 24 - 8 - 4 - 24, countdown.c_str()); + DrawUtils::setFontColor(COLOR_TEXT); + } + // draw top bar DrawUtils::setFontSize(24); DrawUtils::print(16, 6 + 24, "Boot Selector"); @@ -254,7 +281,7 @@ void drawMenuScreen(const BootMenu &menu, uint32_t selectedIndex, uint32_t autob } int32_t handleMenuScreen(std::string &configPath, int32_t autobootOptionInput, const BootMenu &menu, - const std::vector &customOptions, bool ordered) { + const std::vector &customOptions, bool ordered, uint32_t countdownSeconds) { auto screenBuffer = DrawUtils::InitOSScreen(); if (!screenBuffer) { OSFatal("AutobootModule: Failed to alloc memory for screen"); @@ -288,18 +315,37 @@ int32_t handleMenuScreen(std::string &configPath, int32_t autobootOptionInput, c // a saved custom entry whose title isn't installed (the menu gets -1 for it). bool autobootChanged = false; + // The countdown runs only towards an autoboot entry the menu shows, and stops for good at the + // first button pressed (or when the pairing screen opens). + bool countingDown = countdownSeconds > 0 && autobootIndex >= 0; + OSTime countdownStarted = OSGetTime(); + { PairMenu pairMenu; int32_t holdUpdateBlockedForFrames = 0; while (true) { if (pairMenu.ProcessPairScreen()) { + countingDown = false; continue; } InputUtils::InputData input = InputUtils::getControllerInput(); + uint32_t secondsLeft = 0; + if (countingDown && input.trigger != 0) { + countingDown = false; + } + if (countingDown) { + uint32_t elapsed = (uint32_t) OSTicksToSeconds(OSGetTime() - countdownStarted); + if (elapsed >= countdownSeconds) { + selectedIndex = autobootIndex; + break; + } + secondsLeft = countdownSeconds - elapsed; + } + if (input.trigger & VPAD_BUTTON_UP) { selectedIndex--; @@ -336,7 +382,7 @@ int32_t handleMenuScreen(std::string &configPath, int32_t autobootOptionInput, c holdUpdateBlockedForFrames = 0; } - drawMenuScreen(menu, selectedIndex, autobootIndex, gUpdatesBlocked); + drawMenuScreen(menu, selectedIndex, autobootIndex, gUpdatesBlocked, secondsLeft); } } diff --git a/source/MenuUtils.h b/source/MenuUtils.h index 0dc72db..7777ffc 100644 --- a/source/MenuUtils.h +++ b/source/MenuUtils.h @@ -44,10 +44,16 @@ struct CustomBootOption { uint64_t titleId; }; +// The longest countdown a "countdown=" line may ask for, in seconds. +#define MAX_MENU_COUNTDOWN_SECONDS 30 + // 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); +// without them it stays empty and the menu keeps the usual order. A line "countdown=5" sets +// `countdownSeconds` (0 without one): the menu then shows at every boot even with an autoboot +// entry, and starts that entry when the countdown ends unless a button is pressed. +std::vector readCustomBootOptions(const std::string &path, std::vector &menuOrder, + uint32_t &countdownSeconds); int32_t readAutobootOption(std::string &configPath, const std::vector &customOptions); @@ -55,8 +61,10 @@ void writeAutobootOption(std::string &configPath, int32_t autobootOption, const // `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. +// `countdownSeconds` > 0 with an autoboot entry in the menu: that entry starts by itself +// when the countdown ends, unless a button was pressed first. int32_t handleMenuScreen(std::string &configPath, int32_t autobootOptionInput, const BootMenu &menu, - const std::vector &customOptions, bool ordered); + const std::vector &customOptions, bool ordered, uint32_t countdownSeconds); nn::act::SlotNo handleAccountSelectScreen(const std::vector> &data); diff --git a/source/main.cpp b/source/main.cpp index 4ccb75e..e03c074 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -102,9 +102,10 @@ int32_t main(int32_t argc, char **argv) { } std::vector menuOrder; - auto customOptions = readCustomBootOptions(bootOptionsPath, menuOrder); - const bool ordered = !menuOrder.empty(); - int32_t bootSelection = readAutobootOption(configPath, customOptions); + uint32_t countdownSeconds = 0; + auto customOptions = readCustomBootOptions(bootOptionsPath, menuOrder, countdownSeconds); + 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. @@ -164,7 +165,9 @@ int32_t main(int32_t argc, char **argv) { return false; }; - if ((bootSelection == -1) || + // With a countdown set, the menu shows at every boot and counts down to the autoboot entry, + // so a console with no controller in reach still starts that entry by itself. + if ((bootSelection == -1) || (countdownSeconds > 0) || (bootSelection == BOOT_OPTION_HOMEBREW_LAUNCHER && !showHBL) || (bootSelection == BOOT_OPTION_VWII_HOMEBREW_CHANNEL && !showvHBL) || (bootSelection >= BOOT_OPTION_CUSTOM_BASE && !inMenu(bootSelection)) || @@ -176,7 +179,7 @@ int32_t main(int32_t argc, char **argv) { // 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); + bootSelection = handleMenuScreen(configPath, menuInput, menu, customOptions, ordered, countdownSeconds); hadMenu = true; } From 863de1b26dea4c076ea6eed475f4745098a8cc15 Mon Sep 17 00:00:00 2001 From: Grant <27168728+grantendo@users.noreply.github.com> Date: Mon, 16 Nov 2026 21:56:57 -0600 Subject: [PATCH 17/22] Let the first button only stop the countdown The press that stopped the countdown also went on to the menu, so A started the highlighted entry and X cleared autoboot. Now it only stops the countdown, as the README says. A line with a comma is also always a custom entry, even if its name starts with "countdown=". --- source/MenuUtils.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/MenuUtils.cpp b/source/MenuUtils.cpp index f6a41b0..4b47525 100644 --- a/source/MenuUtils.cpp +++ b/source/MenuUtils.cpp @@ -90,7 +90,8 @@ std::vector readCustomBootOptions(const std::string &path, std continue; } - if (strncasecmp(line, "countdown=", 10) == 0) { + // A line with a comma is a custom entry, even if its name starts with "countdown=". + if (strncasecmp(line, "countdown=", 10) == 0 && !strchr(line, ',')) { char *valueStr = line + 10; trimInPlace(valueStr); char *valueEnd = nullptr; @@ -334,8 +335,10 @@ int32_t handleMenuScreen(std::string &configPath, int32_t autobootOptionInput, c InputUtils::InputData input = InputUtils::getControllerInput(); uint32_t secondsLeft = 0; + // The first button only stops the countdown; it isn't also a menu action. if (countingDown && input.trigger != 0) { - countingDown = false; + countingDown = false; + input.trigger = 0; } if (countingDown) { uint32_t elapsed = (uint32_t) OSTicksToSeconds(OSGetTime() - countdownStarted); From a6a09dc81709dccfd273d71694fe536e5c88b6c7 Mon Sep 17 00:00:00 2001 From: Grant <27168728+grantendo@users.noreply.github.com> Date: Mon, 16 Nov 2026 14:31:19 -0600 Subject: [PATCH 18/22] Mark this build as the grantendo fork The menu shows "v0.3.2 (grantendo fork)". The README says it's not an official Aroma build, what it adds and who wrote it, how to install it, and to press B when the Aroma Updater asks about 99_autoboot.rpx. --- README.md | 24 ++++++++++++++++++++++-- source/version.h | 2 +- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3604c3d..007bad4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,22 @@ -[![CI-Release](https://github.com/wiiu-env/AutobootModule/actions/workflows/ci.yml/badge.svg)](https://github.com/wiiu-env/AutobootModule/actions/workflows/ci.yml) -# AutobootModule +# AutobootModule (grantendo fork) + +> **This is not an official Aroma build.** It's a fork of [wiiu-env/AutobootModule](https://github.com/wiiu-env/AutobootModule) v0.3.2 with four changes that are offered upstream but not merged yet. The menu shows "v0.3.2 (grantendo fork)" in its top-right corner. Problems with this build belong here, not in wiiu-env's issues. + +What it adds: +- **vWii titles start with no GamePad connected** (wiiu-env/AutobootModule#67). Based on [@patapovich](https://github.com/patapovich)'s wiiu-env/AutobootModule#69 (his commits keep his name), plus a GamePad check over its radio link and a GamePad pipe fix that let the launch go through. +- **Custom boot entries** from `bootOptions.cfg`, following [@razor85](https://github.com/razor85)'s wiiu-env/AutobootModule#25. +- **Menu order** from `bootOptions.cfg`. +- **Menu countdown** to the autoboot entry. + +Details for each are below. + +**Install:** replace `wiiu/environments/aroma/modules/setup/99_autoboot.rpx` on the SD card with the one from the release. Keep that file name. + +**When you update Aroma:** the Aroma Updater sees an unknown `99_autoboot.rpx` and asks whether to overwrite it. Press **B** to keep this one. Pressing **A** puts the official module back (that's also how to undo this fork). + +--- + +## About the original This is a bootmenu targetted to be loaded with the [EnvironmentLoader](https://github.com/wiiu-env/EnvironmentLoader). It allows you to boot into the Wii U Menu, Homebrew Channel, vWii System Menu or vWii Homebrew Channel. ## Usage @@ -80,3 +97,6 @@ docker run -it --rm -v ${PWD}:/project autobootmodule-builder make clean - GaryOderNichts - Maschell - Crementif +- patapovich (no-GamePad vWii launch, wiiu-env/AutobootModule#69) +- razor85 (custom boot entries, wiiu-env/AutobootModule#25) +- grantendo (this fork) diff --git a/source/version.h b/source/version.h index 38eb1a1..ff61762 100644 --- a/source/version.h +++ b/source/version.h @@ -1,2 +1,2 @@ #pragma once -#define AUTOBOOT_MODULE_VERSION_EXTRA "" \ No newline at end of file +#define AUTOBOOT_MODULE_VERSION_EXTRA " (grantendo fork)" \ No newline at end of file From 057dca620986883ee7276977a5cb4d90dd5973d1 Mon Sep 17 00:00:00 2001 From: Grant <27168728+grantendo@users.noreply.github.com> Date: Mon, 16 Nov 2026 22:16:02 -0600 Subject: [PATCH 19/22] No countdown when START (+) forces the menu open Holding START (+) at boot asks for the menu, but with countdown=N the countdown still ran: the press came before the menu opened, so it didn't stop it, and the autoboot entry could start anyway. --- README.md | 2 +- source/main.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 007bad4..767f171 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ The names are the ones `autoboot.cfg` uses: `@wiiu_menu`, `@homebrew_launcher`, ### Menu countdown -A line `countdown=5` in `bootOptions.cfg` (1 to 30 seconds) shows the menu at every boot even when an autoboot entry is set, with "Starting in 5..." above the bottom bar. When the countdown ends, the autoboot entry starts; pressing any button first stops the countdown and leaves the menu open as usual. Without an autoboot entry there is nothing to count down to, and the menu waits as before. Useful when no GamePad or Wii Remote is in reach at boot. +A line `countdown=5` in `bootOptions.cfg` (1 to 30 seconds) shows the menu at every boot even when an autoboot entry is set, with "Starting in 5..." above the bottom bar. When the countdown ends, the autoboot entry starts; pressing any button first stops the countdown and leaves the menu open as usual. Holding START (+) at boot opens the menu without a countdown. Without an autoboot entry there is nothing to count down to, and the menu waits as before. Useful when no GamePad or Wii Remote is in reach at boot. ## Buildflags diff --git a/source/main.cpp b/source/main.cpp index e03c074..65d221d 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -179,8 +179,10 @@ int32_t main(int32_t argc, char **argv) { // 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, countdownSeconds); - hadMenu = true; + // Holding START (+) at boot asks for the menu, so there's no countdown then. + uint32_t countdown = (buttons.hold & VPAD_BUTTON_PLUS) ? 0 : countdownSeconds; + bootSelection = handleMenuScreen(configPath, menuInput, menu, customOptions, ordered, countdown); + hadMenu = true; } if (bootSelection >= 0) { From d77a93c966631bbf938160470f82a0d6d4fcb751 Mon Sep 17 00:00:00 2001 From: Grant <27168728+grantendo@users.noreply.github.com> Date: Mon, 16 Nov 2026 23:20:41 -0600 Subject: [PATCH 20/22] Also check START as the menu opens, after the update warning START held while the update warning was open didn't stop the countdown: the buttons were only read before the warning. Reading them again keeps the boot-time press working too. --- source/main.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/main.cpp b/source/main.cpp index 65d221d..2219160 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -179,8 +179,10 @@ int32_t main(int32_t argc, char **argv) { // 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; - // Holding START (+) at boot asks for the menu, so there's no countdown then. - uint32_t countdown = (buttons.hold & VPAD_BUTTON_PLUS) ? 0 : countdownSeconds; + // Holding START (+) at boot asks for the menu, so there's no countdown then. The buttons + // are read again too, as START may have been held while the update warning was open. + bool startHeld = ((buttons.hold | InputUtils::getControllerInput().hold) & VPAD_BUTTON_PLUS) != 0; + uint32_t countdown = startHeld ? 0 : countdownSeconds; bootSelection = handleMenuScreen(configPath, menuInput, menu, customOptions, ordered, countdown); hadMenu = true; } From c09f1acbe82c695501b24d384d425b33f38581e8 Mon Sep 17 00:00:00 2001 From: Grant <27168728+grantendo@users.noreply.github.com> Date: Tue, 17 Nov 2026 05:31:30 -0600 Subject: [PATCH 21/22] Let a press as the menu opens stop the countdown The second button read kept only what was held, so a button pressed right then was lost, and the countdown ran on although a button had been pressed. --- source/main.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/source/main.cpp b/source/main.cpp index 2219160..0be9b06 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -180,9 +180,11 @@ int32_t main(int32_t argc, char **argv) { // instead of being preselected or overwritten by the menu. int32_t menuInput = (bootSelection >= 0 && !inMenu(bootSelection)) ? -1 : bootSelection; // Holding START (+) at boot asks for the menu, so there's no countdown then. The buttons - // are read again too, as START may have been held while the update warning was open. - bool startHeld = ((buttons.hold | InputUtils::getControllerInput().hold) & VPAD_BUTTON_PLUS) != 0; - uint32_t countdown = startHeld ? 0 : countdownSeconds; + // are read again too, as START may have been held while the update warning was open, and a + // button pressed in that read stops the countdown, as any first press in the menu does. + auto input = InputUtils::getControllerInput(); + bool startHeld = ((buttons.hold | input.hold) & VPAD_BUTTON_PLUS) != 0; + uint32_t countdown = (startHeld || input.trigger) ? 0 : countdownSeconds; bootSelection = handleMenuScreen(configPath, menuInput, menu, customOptions, ordered, countdown); hadMenu = true; } From 036989ab5def58a9527a8147a1d0c18ceac68f7c Mon Sep 17 00:00:00 2001 From: Grant <27168728+grantendo@users.noreply.github.com> Date: Tue, 17 Nov 2026 09:58:56 -0600 Subject: [PATCH 22/22] Name the upstream PRs in the fork notice --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 767f171..5826440 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # AutobootModule (grantendo fork) -> **This is not an official Aroma build.** It's a fork of [wiiu-env/AutobootModule](https://github.com/wiiu-env/AutobootModule) v0.3.2 with four changes that are offered upstream but not merged yet. The menu shows "v0.3.2 (grantendo fork)" in its top-right corner. Problems with this build belong here, not in wiiu-env's issues. +> **This is not an official Aroma build.** It's a fork of [wiiu-env/AutobootModule](https://github.com/wiiu-env/AutobootModule) v0.3.2 with four changes that aren't in the official build yet. The menu shows "v0.3.2 (grantendo fork)" in its top-right corner. Problems with this build belong here, not in wiiu-env's issues. What it adds: -- **vWii titles start with no GamePad connected** (wiiu-env/AutobootModule#67). Based on [@patapovich](https://github.com/patapovich)'s wiiu-env/AutobootModule#69 (his commits keep his name), plus a GamePad check over its radio link and a GamePad pipe fix that let the launch go through. -- **Custom boot entries** from `bootOptions.cfg`, following [@razor85](https://github.com/razor85)'s wiiu-env/AutobootModule#25. -- **Menu order** from `bootOptions.cfg`. -- **Menu countdown** to the autoboot entry. +- **vWii titles start with no GamePad connected** (wiiu-env/AutobootModule#67), opened upstream as wiiu-env/AutobootModule#70. Based on [@patapovich](https://github.com/patapovich)'s wiiu-env/AutobootModule#69 (his commits keep his name), plus a GamePad check over its radio link and a GamePad pipe fix that let the launch go through. +- **Custom boot entries** from `bootOptions.cfg`, opened upstream as wiiu-env/AutobootModule#71, following [@razor85](https://github.com/razor85)'s wiiu-env/AutobootModule#25. +- **Menu order** from `bootOptions.cfg`, opened upstream as wiiu-env/AutobootModule#72. +- **Menu countdown** to the autoboot entry, to be offered upstream after the menu order. Details for each are below.