Fix quick starting into applets

This commit is contained in:
Maschell 2022-01-01 12:09:31 +01:00
parent 2152acd7e1
commit 05cc2a99c7
2 changed files with 137 additions and 15 deletions

View File

@ -26,7 +26,7 @@ INCLUDES := source include
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# options for code generation # options for code generation
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
CFLAGS := -g -Wall -O3 -ffunction-sections -fno-exceptions \ CFLAGS := -g -Wall -O2 -ffunction-sections -fno-exceptions \
$(MACHDEP) $(MACHDEP)
CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__ CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__

View File

@ -2,6 +2,8 @@
#include <cstdio> #include <cstdio>
#include <cstring> #include <cstring>
#include <string> #include <string>
#include <coreinit/thread.h>
#include <coreinit/foreground.h>
#include <coreinit/screen.h> #include <coreinit/screen.h>
#include <coreinit/filesystem.h> #include <coreinit/filesystem.h>
#include <coreinit/memdefaultheap.h> #include <coreinit/memdefaultheap.h>
@ -10,6 +12,7 @@
#include <sysapp/launch.h> #include <sysapp/launch.h>
#include <sysapp/title.h> #include <sysapp/title.h>
#include <padscore/kpad.h> #include <padscore/kpad.h>
#include <proc_ui/procui.h>
#include <nn/acp.h> #include <nn/acp.h>
#include <nn/act.h> #include <nn/act.h>
#include <nn/cmpt.h> #include <nn/cmpt.h>
@ -34,6 +37,48 @@
#define COLOR_BORDER Color(204, 204, 204, 255) #define COLOR_BORDER Color(204, 204, 204, 255)
#define COLOR_BORDER_HIGHLIGHTED Color(0x3478e4ff) #define COLOR_BORDER_HIGHLIGHTED Color(0x3478e4ff)
void bootWiiUMenu();
void StartAppletAndExit() {
DEBUG_FUNCTION_LINE("Wait for applet");
ProcUIInit(OSSavesDone_ReadyToRelease);
bool doProcUi = true;
bool launchWiiUMenuOnNextForeground = false;
while (true) {
switch (ProcUIProcessMessages(true)) {
case PROCUI_STATUS_EXITING: {
doProcUi = false;
break;
}
case PROCUI_STATUS_RELEASE_FOREGROUND: {
ProcUIDrawDoneRelease();
launchWiiUMenuOnNextForeground = true;
break;
}
case PROCUI_STATUS_IN_FOREGROUND: {
if (launchWiiUMenuOnNextForeground) {
bootWiiUMenu();
launchWiiUMenuOnNextForeground = false;
}
break;
}
case PROCUI_STATUS_IN_BACKGROUND: {
break;
}
default:
break;
}
OSSleepTicks(OSMillisecondsToTicks(1));
if (!doProcUi) {
break;
}
}
ProcUIShutdown();
DEBUG_FUNCTION_LINE("Exit to Wii U Menu");
_Exit(0);
}
enum { enum {
BOOT_OPTION_WII_U_MENU, BOOT_OPTION_WII_U_MENU,
BOOT_OPTION_HOMEBREW_LAUNCHER, BOOT_OPTION_HOMEBREW_LAUNCHER,
@ -86,6 +131,26 @@ void writeAutobootOption(int32_t autobootOption) {
} }
} }
extern "C" int32_t SYSSwitchToBrowser(void *);
extern "C" int32_t SYSSwitchToEShop(void *);
extern "C" int32_t _SYSSwitchTo(uint32_t pfid);
void loadConsoleAccount(const char *data_uuid) {
nn::act::Initialize();
for (int32_t i = 0; i < 13; i++) {
char uuid[16];
auto result = nn::act::GetUuidEx(uuid, i);
if (result.IsSuccess()) {
if (memcmp(uuid, data_uuid, 8) == 0) {
DEBUG_FUNCTION_LINE("Load Console account %d", i);
nn::act::LoadConsoleAccount(i, 0, nullptr, false);
break;
}
}
}
nn::act::Finalize();
}
bool getQuickBoot() { bool getQuickBoot() {
auto bootCheck = CCRSysCaffeineBootCheck(); auto bootCheck = CCRSysCaffeineBootCheck();
if (bootCheck == 0) { if (bootCheck == 0) {
@ -125,12 +190,82 @@ bool getQuickBoot() {
return false; return false;
} }
DEBUG_FUNCTION_LINE("Trying to autoboot for titleId %016llX", info.titleId);
if (info.titleId == 0x0005001010040000L || if (info.titleId == 0x0005001010040000L ||
info.titleId == 0x0005001010040100L || info.titleId == 0x0005001010040100L ||
info.titleId == 0x0005001010040200L) { info.titleId == 0x0005001010040200L) {
DEBUG_FUNCTION_LINE("Skip quick booting into the Wii U Menu"); DEBUG_FUNCTION_LINE("Skip quick booting into the Wii U Menu");
return false; return false;
} }
if (info.titleId == 0x000500301001220AL ||
info.titleId == 0x000500301001210AL ||
info.titleId == 0x000500301001200AL) {
DEBUG_FUNCTION_LINE("Launching the browser");
loadConsoleAccount(data.uuid);
SYSSwitchToBrowser(nullptr);
StartAppletAndExit();
return true;
}
if (info.titleId == 0x000500301001400AL ||
info.titleId == 0x000500301001410AL ||
info.titleId == 0x000500301001420AL) {
DEBUG_FUNCTION_LINE("Launching the Eshop");
loadConsoleAccount(data.uuid);
SYSSwitchToEShop(nullptr);
StartAppletAndExit();
return true;
}
if (info.titleId == 0x000500301001800AL ||
info.titleId == 0x000500301001810AL ||
info.titleId == 0x000500301001820AL) {
DEBUG_FUNCTION_LINE("Launching the Download Management");
loadConsoleAccount(data.uuid);
_SYSSwitchTo(12);
StartAppletAndExit();
return true;
}
if (info.titleId == 0x000500301001600AL ||
info.titleId == 0x000500301001610AL ||
info.titleId == 0x000500301001620AL) {
DEBUG_FUNCTION_LINE("Launching Miiverse");
loadConsoleAccount(data.uuid);
_SYSSwitchTo(9);
StartAppletAndExit();
return true;
}
if (info.titleId == 0x000500301001500AL ||
info.titleId == 0x000500301001510AL ||
info.titleId == 0x000500301001520AL) {
DEBUG_FUNCTION_LINE("Launching Friendlist");
loadConsoleAccount(data.uuid);
_SYSSwitchTo(11);
StartAppletAndExit();
return true;
}
if (info.titleId == 0x000500301001300AL ||
info.titleId == 0x000500301001310AL ||
info.titleId == 0x000500301001320AL) {
DEBUG_FUNCTION_LINE("Launching TVii");
loadConsoleAccount(data.uuid);
_SYSSwitchTo(3);
StartAppletAndExit();
return true;
}
if (!SYSCheckTitleExists(info.titleId)) { if (!SYSCheckTitleExists(info.titleId)) {
DEBUG_FUNCTION_LINE("Title %016llX doesn't exist", info.titleId); DEBUG_FUNCTION_LINE("Title %016llX doesn't exist", info.titleId);
return false; return false;
@ -141,20 +276,7 @@ bool getQuickBoot() {
auto err = MCP_GetTitleInfo(handle, info.titleId, &titleInfo); auto err = MCP_GetTitleInfo(handle, info.titleId, &titleInfo);
MCP_Close(handle); MCP_Close(handle);
if (err == 0) { if (err == 0) {
nn::act::Initialize(); loadConsoleAccount(data.uuid);
for (int32_t i = 0; i < 13; i++) {
char uuid[16];
result = nn::act::GetUuidEx(uuid, i);
if (result.IsSuccess()) {
if (memcmp(uuid, data.uuid, 8) == 0) {
DEBUG_FUNCTION_LINE("Load Console account %d", i);
nn::act::LoadConsoleAccount(i, 0, 0, 0);
break;
}
}
}
nn::act::Finalize();
ACPAssignTitlePatch(&titleInfo); ACPAssignTitlePatch(&titleInfo);
_SYSLaunchTitleWithStdArgsInNoSplash(info.titleId, nullptr); _SYSLaunchTitleWithStdArgsInNoSplash(info.titleId, nullptr);
return true; return true;