Reload the Wii U Menu when a sd card was inserted or ejected

This commit is contained in:
Maschell 2022-03-04 01:07:01 +01:00
parent 509bcc2060
commit 614729f9e6
5 changed files with 38 additions and 5 deletions

View File

@ -2,5 +2,6 @@ FROM wiiuenv/devkitppc:20220303
COPY --from=wiiuenv/wiiupluginsystem:20220123 /artifacts $DEVKITPRO
COPY --from=wiiuenv/librpxloader:20220212 /artifacts $DEVKITPRO
COPY --from=wiiuenv/libsdutils:20220303 /artifacts $DEVKITPRO
WORKDIR project

View File

@ -36,7 +36,7 @@ CFLAGS := -Wall -O2 -ffunction-sections \
CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__ -D__WUPS__
CXXFLAGS := $(CFLAGS)
CXXFLAGS := $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS := -g $(ARCH)
LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map) -T$(WUMS_ROOT)/share/librpxloader.ld $(WUPSSPECS)
@ -46,7 +46,7 @@ CXXFLAGS += -DDEBUG -g
CFLAGS += -DDEBUG -g
endif
LIBS := -lwups -lwut -lrpxloader
LIBS := -lwups -lwut -lrpxloader -lsdutils
#-------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level

View File

@ -13,7 +13,7 @@
bool gInWiiUMenu __attribute__((section(".data")));
static FSStatus CallWithNewPath(const char *oldPath, const std::function<FSStatus(const char *)> &callFunctionWithPath) {
if (!gInWiiUMenu || strncmp(oldPath, "/vol/save/", 10) != 0) {
if (!sSDIsMounted || !gInWiiUMenu || strncmp(oldPath, "/vol/save/", 10) != 0) {
return callFunctionWithPath(oldPath);
}

View File

@ -2,6 +2,7 @@
#include <stdbool.h>
extern bool gInWiiUMenu;
extern bool sSDIsMounted;
#define SAVE_REPLACEMENT_PATH "/vol/external01/wiiu/homebrew_on_menu_plugin"

View File

@ -1,4 +1,5 @@
#include "FileWrapper.h"
#include "SaveRedirection.h"
#include "fileinfos.h"
#include "filelist.h"
#include "fs/FSUtils.h"
@ -16,6 +17,7 @@
#include <malloc.h>
#include <nn/acp.h>
#include <rpxloader.h>
#include <sdutils/sdutils.h>
#include <sysapp/title.h>
#include <utils/logger.h>
#include <wups.h>
@ -58,14 +60,35 @@ INITIALIZE_PLUGIN() {
OSInitMutex(&fileinfoMutex);
}
bool sSDUtilsInitDone = false;
bool sSDIsMounted = false;
bool sTitleRebooting = false;
void SDAttachedHandler(SDUtilsAttachStatus status) {
if (!sTitleRebooting) {
_SYSLaunchTitleWithStdArgsInNoSplash(OSGetTitleID(), 0);
sTitleRebooting = true;
}
}
ON_APPLICATION_START() {
initLogging();
if (OSGetTitleID() == 0x0005001010040000L || // Wii U Menu JPN
OSGetTitleID() == 0x0005001010040100L || // Wii U Menu USA
OSGetTitleID() == 0x0005001010040200L) { // Wii U Menu ERU
OSGetTitleID() == 0x0005001010040200L) { // Wii U Menu EUR
if (SDUtils_Init() >= 0) {
sSDUtilsInitDone = true;
sTitleRebooting = false;
SDUtils_AddAttachHandler(SDAttachedHandler);
}
if (SDUtils_IsSdCardMounted(&sSDIsMounted) >= 0 && sSDIsMounted) {
readCustomTitlesFromSD();
}
} else {
gInWiiUMenu = false;
}
if (_SYSGetSystemApplicationTitleId(SYSTEM_APP_ID_HEALTH_AND_SAFETY) != OSGetTitleID()) {
DEBUG_FUNCTION_LINE("gHomebrewLaunched to FALSE");
@ -75,8 +98,16 @@ ON_APPLICATION_START() {
ON_APPLICATION_ENDS() {
unmountAllRomfs();
memset((void *) &gFileInfos, 0, sizeof(gFileInfos));
FileHandleWrapper_FreeAll();
deinitLogging();
gInWiiUMenu = false;
if (sSDUtilsInitDone) {
SDUtils_RemoveAttachHandler(SDAttachedHandler);
SDUtils_DeInit();
sSDUtilsInitDone = false;
}
sSDIsMounted = false;
}
void fillXmlForTitleID(uint32_t titleid_upper, uint32_t titleid_lower, ACPMetaXml *out_buf) {