Try to mount WFS drives once even if now USBStorageDevice is connected

This commit is contained in:
Maschell 2024-05-03 22:30:30 +02:00
parent 67dfdd1fc8
commit b2ae87ae1f

View File

@ -90,23 +90,21 @@ void initExternalStorage() {
// the lib before actually using it. // the lib before actually using it.
return; return;
} }
int connectedStorage = 0; int numConnectedStorage;
if ((connectedStorage = numberUSBStorageDevicesConnected()) <= 0) { int maxTries = 1200; // Wait up to 20 seconds, like the Wii U Menu
nn::spm::Initialize(); if ((numConnectedStorage = numberUSBStorageDevicesConnected()) <= 0) {
InitEmptyExternalStorage(); maxTries = 1; // Only try once if no USBStorageDrive is connected
nn::spm::Finalize(); } else {
return; DEBUG_FUNCTION_LINE("Connected StorageDevices = %d", numConnectedStorage);
} }
DEBUG_FUNCTION_LINE("Connected StorageDevices = %d", connectedStorage);
nn::spm::Initialize(); nn::spm::Initialize();
nn::spm::StorageListItem items[0x20]; nn::spm::StorageListItem items[0x20];
int tries = 0; int tries = 0;
bool found = false; bool found = false;
while (tries < 1200) { // Wait up to 20 seconds, like the Wii U Menu while (tries < maxTries) {
int32_t numItems = nn::spm::GetStorageList(items, 0x20); int32_t numItems = nn::spm::GetStorageList(items, 0x20);
DEBUG_FUNCTION_LINE("Number of items: %d", numItems); DEBUG_FUNCTION_LINE("Number of items: %d", numItems);
@ -127,7 +125,7 @@ void initExternalStorage() {
} }
} }
} }
if (found || (connectedStorage == numItems)) { if (found || (numConnectedStorage == numItems)) {
DEBUG_FUNCTION_LINE("Found all expected items, breaking."); DEBUG_FUNCTION_LINE("Found all expected items, breaking.");
break; break;
} }
@ -135,7 +133,9 @@ void initExternalStorage() {
tries++; tries++;
} }
if (!found) { if (!found) {
DEBUG_FUNCTION_LINE("USB Storage is connected but either it doesn't have a WFS partition or we ran into a timeout."); if (numConnectedStorage > 0) {
DEBUG_FUNCTION_LINE("USB Storage is connected but either it doesn't have a WFS partition or we ran into a timeout.");
}
InitEmptyExternalStorage(); InitEmptyExternalStorage();
} }