Skip to content

Commit

Permalink
(WiiU) Support WFS-formatted USB drives
Browse files Browse the repository at this point in the history
Some users like to use native-format drives to store their data alongside Wii U games. Use libmocha to support this.

Note Mocha_MountFS claims success even if the mounted folder doesn't exist.
  • Loading branch information
ashquarky committed Jun 19, 2024
1 parent 4405bc4 commit 5f6d7a8
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions frontend/drivers/platform_wiiu.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
#define WIIU_VOL_CONTENT_PATH "fs:/vol/content/"
#define WIIU_SD_FAT_PATH "sd:/"
#define WIIU_USB_FAT_PATH "usb:/"
#define WIIU_USB_WFS_PATH "storage_usb:/"

/**
* The Wii U frontend driver, along with the main() method.
Expand All @@ -92,6 +93,7 @@
static enum frontend_fork wiiu_fork_mode = FRONTEND_FORK_NONE;
static bool have_libfat_usb = false;
static bool have_libfat_sdcard = false;
static bool have_wfs_usb = false;
#endif
static bool in_exec = false;

Expand Down Expand Up @@ -244,6 +246,12 @@ static int frontend_wiiu_parse_drive_list(void *data, bool load_content)
enum_idx,
FILE_TYPE_DIRECTORY, 0, 0, NULL);

if (have_wfs_usb)
menu_entries_append(list, WIIU_USB_WFS_PATH,
msg_hash_to_str(MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR),
enum_idx,
FILE_TYPE_DIRECTORY, 0, 0, NULL);

#endif
return 0;
}
Expand Down Expand Up @@ -672,27 +680,42 @@ static void main_loop(void)

static void init_filesystems(void)
{
#if defined(HAVE_LIBMOCHA) && defined(HAVE_LIBFAT)
#if defined(HAVE_LIBMOCHA)
if (Mocha_InitLibrary() == MOCHA_RESULT_SUCCESS)
{
if (Mocha_MountFS("storage_usb", NULL, "/vol/storage_usb01") == MOCHA_RESULT_SUCCESS) {
if (exists(WIIU_USB_WFS_PATH))
have_wfs_usb = true;
else /* Liar! */
Mocha_UnmountFS("storage_usb");
}


#if defined(HAVE_LIBFAT)
have_libfat_usb = fatMount("usb", &Mocha_usb_disc_interface, 0, 512, 128);
/* Mounting SD card with libfat is unsafe under Aroma */
if (!in_aroma)
have_libfat_sdcard = fatMount("sd", &Mocha_sdio_disc_interface, 0, 512, 128);
#endif /* HAVE_LIBFAT */
}
#endif
#endif /* HAVE_LIBMOCHA */
}

static void deinit_filesystems(void)
{
#if defined(HAVE_LIBMOCHA) && defined(HAVE_LIBFAT)
#if defined(HAVE_LIBMOCHA)
if (have_wfs_usb)
Mocha_UnmountFS("storage_usb");

#if defined(HAVE_LIBFAT)
if (have_libfat_usb)
fatUnmount("usb");
if (have_libfat_sdcard)
fatUnmount("sd");
#endif /* HAVE_LIBFAT */

Mocha_DeInitLibrary();
#endif
#endif /* HAVE_LIBMOCHA */
}

static devoptab_t dotab_stdout =
Expand Down

0 comments on commit 5f6d7a8

Please sign in to comment.