mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-05 19:15:07 +01:00
d625c5adfc
*Added support for using both USB ports at once (ONLY ON HERMES CIOS) Big thanks to rodries for writing the necessary ehcmodules! NOTE: You can change port of USB device in the Loader Settings. The loader currently does not support loading configs off port 1 (only from port 0) If you select to use both usb ports the loader will switch between ports automatically, on demand. It is not possible to use both ports at once currently. Right now the wiilight blinks each time it switches the port. I will talk to rodries and see if we can disable it. Using the "both ports" option only makes sense in combination with "Multiple Partitions" option. In that case all games on all partitions from BOTH HDDs will be loaded. I think I don't have to say that switching between ports and loading all games is slower than normal mode with one port only in use. You might wanna just set one port and switch yourself when you need to. Well the option for both ports (automatic switching) is there for the lazy ones who don't like to hit the settings button ;).
106 lines
1.9 KiB
C++
106 lines
1.9 KiB
C++
#include <stdio.h>
|
|
#include <unistd.h>
|
|
#include <malloc.h>
|
|
#include <ogcsys.h>
|
|
#include <errno.h>
|
|
|
|
#include "Controls/DeviceHandler.hpp"
|
|
#include "usbloader/sdhc.h"
|
|
#include "usbloader/usbstorage2.h"
|
|
#include "usbloader/wbfs.h"
|
|
#include "wbfs_rw.h"
|
|
|
|
#include "wbfs_base.h"
|
|
|
|
Wbfs::Wbfs(u32 l, u32 s, u32 part)
|
|
: hdd(NULL), lba(l), size(s), partition(part)
|
|
{
|
|
}
|
|
|
|
s32 Wbfs::Init(u32 device)
|
|
{
|
|
s32 ret;
|
|
const DISC_INTERFACE * handle = DeviceHandler::GetUSBInterface();
|
|
|
|
switch (WBFS_DEVICE_USB)
|
|
{
|
|
case WBFS_DEVICE_USB:
|
|
/* Initialize USB storage */
|
|
ret = handle->startup();
|
|
if (ret)
|
|
{
|
|
currentHandle = handle;
|
|
/* Setup callbacks */
|
|
readCallback = __ReadUSB;
|
|
writeCallback = __WriteUSB;
|
|
}
|
|
else
|
|
return -1;
|
|
break;
|
|
case WBFS_DEVICE_SDHC:
|
|
/* Initialize SDHC */
|
|
ret = SDHC_Init();
|
|
|
|
if (ret)
|
|
{
|
|
/* Setup callbacks */
|
|
readCallback = __ReadSDHC;
|
|
writeCallback = __WriteSDHC;
|
|
}
|
|
else return -1;
|
|
break;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
// Default behavior: can't format
|
|
s32 Wbfs::Format()
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
s32 Wbfs::CheckGame(u8 *discid)
|
|
{
|
|
wbfs_disc_t *disc = NULL;
|
|
|
|
/* Try to open game disc */
|
|
disc = OpenDisc(discid);
|
|
if (disc)
|
|
{
|
|
/* Close disc */
|
|
CloseDisc(disc);
|
|
|
|
return 1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
s32 Wbfs::GameSize(u8 *discid, f32 *size)
|
|
{
|
|
wbfs_disc_t *disc = NULL;
|
|
|
|
u32 sectors;
|
|
|
|
/* Open disc */
|
|
disc = OpenDisc(discid);
|
|
if (!disc) return -2;
|
|
|
|
/* Get game size in sectors */
|
|
sectors = wbfs_sector_used(disc->p, disc->header);
|
|
|
|
/* Copy value */
|
|
*size = (disc->p->wbfs_sec_sz / GB_SIZE) * sectors;
|
|
|
|
/* Close disc */
|
|
CloseDisc(disc);
|
|
|
|
return 0;
|
|
}
|
|
|
|
bool Wbfs::ShowFreeSpace(void)
|
|
{
|
|
return true;
|
|
}
|