mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-12-23 02:11:55 +01:00
*Optimized the automatic usb port switching. It is now a lot faster on mounting if partitions are FAT/NTFS/EXT because no port switch is required on WBFS_Open() or WBFS_Close() on those partitions.
*Disabled use of custom paths on other than SD if automatic port switching is enabled. This could damage a partition and we don't want to take that risk. So if you want to enable automatic usb port switching than you have to set all paths on sd:/ first now. Also when in this mode, only sd:/ will be available for setting custom paths. *Changed setting of usb port switching to a more failsafer way. NOTE: To all that did already enable the automatic usb port switching and have custom paths on some usb partition. Change this please or else your usbs filesystems are in danger. You have been warned!
This commit is contained in:
parent
d625c5adfc
commit
8e962e6187
@ -2,8 +2,8 @@
|
||||
<app version="1">
|
||||
<name> USB Loader GX</name>
|
||||
<coder>USB Loader GX Team</coder>
|
||||
<version>2.0 r1066</version>
|
||||
<release_date>201102052106</release_date>
|
||||
<version>2.0 r1067</version>
|
||||
<release_date>201102052107</release_date>
|
||||
<no_ios_reload/>
|
||||
<short_description>Loads games from USB-devices</short_description>
|
||||
<long_description>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.
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -38,7 +38,7 @@ class LoaderSettings : public SettingsMenu
|
||||
|
||||
int OldSettingsPartition;
|
||||
int OldSettingsMultiplePartitions;
|
||||
int OldSettingsUSBPort;
|
||||
int NewSettingsUSBPort;
|
||||
|
||||
OptionList GuiOptions;
|
||||
};
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user