Skip to content

Commit

Permalink
- just minor clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Fledge68 committed Dec 29, 2021
1 parent 6b37a3c commit 8b2bacf
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 49 deletions.
101 changes: 53 additions & 48 deletions source/devicemounter/DeviceHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,21 @@ void DeviceHandler::SetMountUSB(bool using_usb)
mount_usb = using_usb;
}

void DeviceHandler::MountAll()
void DeviceHandler::SetModes()
{
MountSD();
MountAllUSB();
sdhc_mode_sd = 1;// use libogc and ios 58 (wiisd_libogc.c)
usb_libogc_mode = 1;// use libogc and ios 58 (usbstorage_libogc.c)
if(CustomIOS(CurrentIOS.Type))// if wiiflow is using a cios (force cios is on)
{
usb_libogc_mode = 0;// use cios for USB (usbstorage.c)
sdhc_mode_sd = 0;// use cios for SD (sdhc.c)
}
}

void DeviceHandler::UnMountAll()
void DeviceHandler::MountAll()
{
/* Kill possible USB thread */
//KillUSBKeepAliveThread();

for(u32 i = SD; i < MAXDEVICES; i++)
UnMount(i);
USBStorage2_Deinit();
USB_Deinitialize();
SDHC_Close();

sd.Cleanup();
usb.Cleanup();
MountSD();
MountAllUSB();
}

bool DeviceHandler::Mount(int dev)
Expand All @@ -84,35 +80,6 @@ bool DeviceHandler::Mount(int dev)
return false;
}

bool DeviceHandler::IsInserted(int dev)
{
if(dev == SD)
return SD_Inserted() && sd.IsMounted(0);
else if(dev >= USB1 && dev <= USB8)
return usb.IsMounted(dev-USB1);

return false;
}

void DeviceHandler::UnMount(int dev)
{
if(dev == SD)
UnMountSD();
else if(dev >= USB1 && dev <= USB8)
UnMountUSB(dev-USB1);
}

void DeviceHandler::SetModes()
{
sdhc_mode_sd = 1;// use libogc and ios 58 (wiisd_libogc.c)
usb_libogc_mode = 1;// use libogc and ios 58 (usbstorage_libogc.c)
if(CustomIOS(CurrentIOS.Type))// if wiiflow is using a cios (force cios is on)
{
usb_libogc_mode = 0;// use cios for USB (usbstorage.c)
sdhc_mode_sd = 0;// use cios for SD (sdhc.c)
}
}

bool DeviceHandler::MountSD()
{
if(!sd.IsInserted() || !sd.IsMounted(0))
Expand All @@ -128,7 +95,7 @@ bool DeviceHandler::MountSD()
}
sd.SetDevice(&__io_sdhc);
//! Mount only one SD Partition
return sd.Mount(0, DeviceName[SD], true); /* Force FAT */
return sd.Mount(0, DeviceName[SD], true); /* Force FAT, SD cards should always be FAT */
}
return true;
}
Expand All @@ -147,27 +114,65 @@ bool DeviceHandler::MountAllUSB()

/* Kill possible USB thread */
//KillUSBKeepAliveThread();

/* usb spinup - Wait for our slowass HDD */
if(WaitForDevice(GetUSBInterface()) == false)
return false;
/* Get Partitions and Mount them */
return false;// failed to spin up in time or no USB HDD connected

if(!usb.IsInserted() || !usb.IsMounted(0))
usb.SetDevice(GetUSBInterface());

/* Get Partitions and Mount them */
bool result = false;
int partCount = GetUSBPartitionCount();
for(int i = 0; i < partCount; i++)
{
if(MountUSB(i))
result = true;
}
// why force FAT? why not just return result?
// in case no partition is mounted for some strange reason, we force mount the first partition to FAT
if(!result)
result = usb.Mount(0, DeviceName[USB1], true); /* Force FAT */

//if(result && usb_libogc_mode)
// CreateUSBKeepAliveThread();

return result;
}

bool DeviceHandler::IsInserted(int dev)
{
if(dev == SD)
return sd.IsInserted() && sd.IsMounted(0);
else if(dev >= USB1 && dev <= USB8)
return usb.IsMounted(dev-USB1);

return false;
}

void DeviceHandler::UnMount(int dev)
{
if(dev == SD)
UnMountSD();
else if(dev >= USB1 && dev <= USB8)
UnMountUSB(dev-USB1);
}

void DeviceHandler::UnMountAll()
{
/* Kill possible USB thread */
//KillUSBKeepAliveThread();

for(u32 i = SD; i < MAXDEVICES; i++)
UnMount(i);
USBStorage2_Deinit();
USB_Deinitialize();
SDHC_Close();

sd.Cleanup();
usb.Cleanup();
}

void DeviceHandler::UnMountUSB(int pos)
{
if(pos >= GetUSBPartitionCount())
Expand Down
2 changes: 1 addition & 1 deletion source/menu/menu_game_boot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,7 @@ void CMenu::_launchWii(dir_discHdr *hdr, bool dvd, bool disc_cfg)
}
}
else
emulate_mode = 0;//sets to off if we are using neek2o or launching a DVD game
emulate_mode = 0;//sets to off if we are launching a DVD game

// this is a temporary region change of real nand(rn) if 'tempregionrn' is set true.
// added by overjoy but he never added a gamesettings option. must be set by editing wiiflow_lite.ini.
Expand Down

0 comments on commit 8b2bacf

Please sign in to comment.