diff --git a/HBC/META.XML b/HBC/META.XML index c3c46911..da47d666 100644 --- a/HBC/META.XML +++ b/HBC/META.XML @@ -2,8 +2,8 @@ USB Loader GX USB Loader GX Team - 2.0 r1066 - 201102052106 + 2.0 r1067 + 201102052107 Loads games from USB-devices USB Loader GX is a libwiigui based USB iso loader with a wii-like GUI. You can install games to your HDDs and boot them with shorter loading times. diff --git a/source/prompts/filebrowser.cpp b/source/prompts/filebrowser.cpp index ae1757c5..b55342c6 100644 --- a/source/prompts/filebrowser.cpp +++ b/source/prompts/filebrowser.cpp @@ -79,6 +79,9 @@ int InitBrowsers() { if (strcmp(devoptab_list[i]->name, "stdnull") && devoptab_list[i]->write_r != NULL) { + if(Settings.USBPort == 2 && strcmp(devoptab_list[i]->name, "sd") != 0) + continue; + snprintf(rootdir, sizeof(rootdir), "%s:/", devoptab_list[i]->name); if ( DIR *dir = opendir( rootdir ) ) { @@ -243,7 +246,7 @@ int ParseDirectory(const char* Path, int Flags, FILTERCASCADE *Filter) } else return -1; } - + struct dirent *dirent = NULL; while ((dirent = readdir(dir)) != 0) @@ -251,9 +254,9 @@ int ParseDirectory(const char* Path, int Flags, FILTERCASCADE *Filter) snprintf(filename, sizeof(filename), "%s/%s", fulldir, dirent->d_name); if(stat(filename, &filestat) != 0) continue; - + snprintf(filename, sizeof(filename), dirent->d_name); - + if (strcmp(filename, ".") != 0) { BROWSERENTRY newEntry; diff --git a/source/settings/menus/LoaderSettings.cpp b/source/settings/menus/LoaderSettings.cpp index 0dbf0f3e..03c485d6 100644 --- a/source/settings/menus/LoaderSettings.cpp +++ b/source/settings/menus/LoaderSettings.cpp @@ -127,11 +127,11 @@ LoaderSettings::LoaderSettings() Options->SetName(Idx++, "%s", tr( "Messageboard Update" )); Options->SetName(Idx++, "%s", tr( "Sync FAT32 FS Info" )); - SetOptionValues(); - OldSettingsPartition = Settings.partition; OldSettingsMultiplePartitions = Settings.MultiplePartitions; - OldSettingsUSBPort = Settings.USBPort; + NewSettingsUSBPort = Settings.USBPort; + + SetOptionValues(); } LoaderSettings::~LoaderSettings() @@ -139,15 +139,17 @@ LoaderSettings::~LoaderSettings() //! if partition has changed, Reinitialize it if (Settings.partition != OldSettingsPartition || Settings.MultiplePartitions != OldSettingsMultiplePartitions || - Settings.USBPort != OldSettingsUSBPort) + Settings.USBPort != NewSettingsUSBPort) { - int tempPort = Settings.USBPort; - Settings.USBPort = OldSettingsUSBPort; WBFS_CloseAll(); - DeviceHandler::Instance()->UnMountAllUSB(); - Settings.USBPort = tempPort; - DeviceHandler::SetUSBPort(Settings.USBPort); - if(Settings.USBPort == 2) DeviceHandler::Instance()->MountAllUSB(); + + if(Settings.USBPort != NewSettingsUSBPort) + { + DeviceHandler::Instance()->UnMountAllUSB(); + Settings.USBPort = NewSettingsUSBPort; + DeviceHandler::SetUSBPort(Settings.USBPort); + if(Settings.USBPort == 2) DeviceHandler::Instance()->MountAllUSB(); + } if(Settings.MultiplePartitions) WBFS_OpenAll(); @@ -194,10 +196,10 @@ void LoaderSettings::SetOptionValues() Options->SetValue(Idx++, "%s", tr( OnOffText[Settings.MultiplePartitions] )); //! Settings: USB Port - if(Settings.USBPort == 2) + if(NewSettingsUSBPort == 2) Options->SetValue(Idx++, tr("Both Ports")); else - Options->SetValue(Idx++, "%i", Settings.USBPort); + Options->SetValue(Idx++, "%i", NewSettingsUSBPort); //! Settings: Install directories Options->SetValue(Idx++, "%s", tr( InstallToText[Settings.InstallToDir] )); @@ -328,11 +330,51 @@ int LoaderSettings::GetMenuInternal() if(!IosLoader::IsHermesIOS()) { WindowPrompt(tr("ERROR:"), tr("USB Port changing is only supported on Hermes cIOS."), tr("OK")); + NewSettingsUSBPort = 0; Settings.USBPort = 0; } - else if (++Settings.USBPort >= 3) // 2 = both ports - Settings.USBPort = 0; + else if (++NewSettingsUSBPort >= 3) // 2 = both ports + NewSettingsUSBPort = 0; + + if(NewSettingsUSBPort == 2) + { + bool allSDPaths = true; + if(strncmp(Settings.covers_path, "usb", 3) == 0) + allSDPaths = false; + else if(strncmp(Settings.coversFull_path, "usb", 3) == 0) + allSDPaths = false; + else if(strncmp(Settings.disc_path, "usb", 3) == 0) + allSDPaths = false; + else if(strncmp(Settings.theme_path, "usb", 3) == 0) + allSDPaths = false; + else if(strncmp(Settings.titlestxt_path, "usb", 3) == 0) + allSDPaths = false; + else if(strncmp(Settings.update_path, "usb", 3) == 0) + allSDPaths = false; + else if(strncmp(Settings.Cheatcodespath, "usb", 3) == 0) + allSDPaths = false; + else if(strncmp(Settings.TxtCheatcodespath, "usb", 3) == 0) + allSDPaths = false; + else if(strncmp(Settings.dolpath, "usb", 3) == 0) + allSDPaths = false; + else if(strncmp(Settings.homebrewapps_path, "usb", 3) == 0) + allSDPaths = false; + else if(strncmp(Settings.BcaCodepath, "usb", 3) == 0) + allSDPaths = false; + else if(strncmp(Settings.WipCodepath, "usb", 3) == 0) + allSDPaths = false; + else if(strncmp(Settings.languagefiles_path, "usb", 3) == 0) + allSDPaths = false; + else if(strncmp(Settings.WDMpath, "usb", 3) == 0) + allSDPaths = false; + + if(!allSDPaths) + { + WindowPrompt(tr("ERROR:"), tr("Automatic port switching is done on the fly. You should change all custom paths to sd:/ for this option or else it could damage a filesystem."), tr("OK")); + NewSettingsUSBPort = 0; + } + } } //! Settings: Install directories diff --git a/source/settings/menus/LoaderSettings.hpp b/source/settings/menus/LoaderSettings.hpp index 70b572f0..9ff3eb61 100644 --- a/source/settings/menus/LoaderSettings.hpp +++ b/source/settings/menus/LoaderSettings.hpp @@ -38,7 +38,7 @@ class LoaderSettings : public SettingsMenu int OldSettingsPartition; int OldSettingsMultiplePartitions; - int OldSettingsUSBPort; + int NewSettingsUSBPort; OptionList GuiOptions; }; diff --git a/source/usbloader/usbstorage2.c b/source/usbloader/usbstorage2.c index 3ce0d440..20b8b07f 100644 --- a/source/usbloader/usbstorage2.c +++ b/source/usbloader/usbstorage2.c @@ -132,6 +132,7 @@ void USBStorage2_Deinit(void) s32 USBStorage2_SetPort(u32 port) { + //! Port = 2 is handle in the loader, no need to handle it in cIOS if(port < 0 || port > 1) return -1; diff --git a/source/usbloader/wbfs.cpp b/source/usbloader/wbfs.cpp index b01605e7..d47e6c99 100644 --- a/source/usbloader/wbfs.cpp +++ b/source/usbloader/wbfs.cpp @@ -73,7 +73,10 @@ s32 WBFS_OpenPart(int part_num) if(part_num < 0 || part_num >= usbHandle->GetPartitionTotalCount()) return -1; - DeviceHandler::SetUSBPortFromPartition(part_num); + //! No need to switch ports on other partitions than WBFS + //! the open() function does not actually read from drive there. + if(strncmp(usbHandle->GetFSName(part_num), "WBFS", 4) == 0) + DeviceHandler::SetUSBPortFromPartition(part_num); // close WBFS_Close(part_num); @@ -119,7 +122,10 @@ bool WBFS_Close(int part_num) if(!VALID(part_num)) return false; - DeviceHandler::SetUSBPortFromPartition(part_num); + //! No need to switch ports on other partitions than WBFS + //! the close() function does not actually write to drive there. + if(WbfsList[part_num]->GetFSType() == PART_FS_WBFS) + DeviceHandler::SetUSBPortFromPartition(part_num); delete WbfsList[part_num]; WbfsList[part_num] = NULL; diff --git a/source/usbloader/wbfs/wbfs_base.h b/source/usbloader/wbfs/wbfs_base.h index 191710a4..b836f6a8 100644 --- a/source/usbloader/wbfs/wbfs_base.h +++ b/source/usbloader/wbfs/wbfs_base.h @@ -4,6 +4,7 @@ #include "libs/libwbfs/libwbfs.h" #include "usbloader/utils.h" #include "usbloader/frag.h" +#include "usbloader/wbfs.h" #define CACHE_SIZE 32 #define CACHED_SECTORS 64 @@ -33,7 +34,7 @@ class Wbfs virtual s32 RenameGame(u8 *, const void *) = 0; virtual s32 ReIDGame(u8 *discid, const void *newID) = 0; virtual u64 EstimateGameSize(void) = 0; - virtual const u8 GetFSType(void) const = 0; + virtual const u8 GetFSType(void) const { return PART_FS_WBFS; } const wbfs_t *GetHDDHandle(void) const { return hdd; } protected: wbfs_t *hdd; diff --git a/source/usbloader/wbfs/wbfs_fat.cpp b/source/usbloader/wbfs/wbfs_fat.cpp index 2383a542..898943c1 100644 --- a/source/usbloader/wbfs/wbfs_fat.cpp +++ b/source/usbloader/wbfs/wbfs_fat.cpp @@ -50,7 +50,7 @@ s32 Wbfs_Fat::Open() PartitionHandle * usbHandle = DeviceHandler::Instance()->GetUSBHandle(); - if(partition >= 0 && partition < usbHandle->GetPartitionTotalCount()) + if(partition >= 0 && (int) partition < usbHandle->GetPartitionTotalCount()) { if (lba == usbHandle->GetLBAStart(partition)) {