mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2024-11-22 11:29:24 +01:00
Improvements in the USB init management code
This commit is contained in:
parent
07b3a3c166
commit
41d0826a4a
@ -24,7 +24,7 @@ FileBrowser::~FileBrowser()
|
|||||||
void FileBrowser::pushDirectory(const char *in_path)
|
void FileBrowser::pushDirectory(const char *in_path)
|
||||||
{
|
{
|
||||||
const char *cur = this->cur_path_prefix ? xstrdup(this->cur_path_prefix) : NULL;
|
const char *cur = this->cur_path_prefix ? xstrdup(this->cur_path_prefix) : NULL;
|
||||||
size_t cur_len = this->cur_path_prefix ? strlen(this->cur_path_prefix) : NULL;
|
size_t cur_len = this->cur_path_prefix ? strlen(this->cur_path_prefix) : 0;
|
||||||
char *path_cpy = xstrdup(in_path);
|
char *path_cpy = xstrdup(in_path);
|
||||||
char *path = path_cpy;
|
char *path = path_cpy;
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "menu.hh"
|
#include "menu.hh"
|
||||||
#include "dialogue_box.hh"
|
#include "dialogue_box.hh"
|
||||||
|
|
||||||
extern int usbismount;
|
extern bool usbismount;
|
||||||
|
|
||||||
class KeyboardTypingListener : public KeyboardListener, TimeoutHandler
|
class KeyboardTypingListener : public KeyboardListener, TimeoutHandler
|
||||||
{
|
{
|
||||||
@ -70,7 +70,7 @@ public:
|
|||||||
switch (which)
|
switch (which)
|
||||||
{
|
{
|
||||||
case 0: /* Insert disc */
|
case 0: /* Insert disc */
|
||||||
if (Gui::gui->np->Usbport & usbismount) Gui::gui->dv->setDirectory(Gui::gui->game_base_path_usb);
|
if (Gui::gui->np->Usbport && usbismount) Gui::gui->dv->setDirectory(Gui::gui->game_base_path_usb);
|
||||||
else Gui::gui->dv->setDirectory(Gui::gui->game_base_path);
|
else Gui::gui->dv->setDirectory(Gui::gui->game_base_path);
|
||||||
|
|
||||||
Gui::gui->pushView(Gui::gui->dv);
|
Gui::gui->pushView(Gui::gui->dv);
|
||||||
|
@ -81,7 +81,7 @@ public:
|
|||||||
|
|
||||||
void updateSubmenus()
|
void updateSubmenus()
|
||||||
{
|
{
|
||||||
int submenu_defs[4];
|
int submenu_defs[5];
|
||||||
|
|
||||||
submenu_defs[0] = Gui::gui->np->JoystickSwap == true ? 0 : 1;
|
submenu_defs[0] = Gui::gui->np->JoystickSwap == true ? 0 : 1;
|
||||||
submenu_defs[1] = !Gui::gui->np->Emul1541Proc;
|
submenu_defs[1] = !Gui::gui->np->Emul1541Proc;
|
||||||
|
34
Src/main.cpp
34
Src/main.cpp
@ -45,7 +45,7 @@ extern int init_graphics(void);
|
|||||||
// Global variables
|
// Global variables
|
||||||
C64 *TheC64 = NULL; // Global C64 object
|
C64 *TheC64 = NULL; // Global C64 object
|
||||||
char AppDirPath[1024]; // Path of application directory
|
char AppDirPath[1024]; // Path of application directory
|
||||||
int usbismount = 0;
|
bool usbismount = false;
|
||||||
|
|
||||||
// ROM file names
|
// ROM file names
|
||||||
#ifndef DATADIR
|
#ifndef DATADIR
|
||||||
@ -83,32 +83,28 @@ int usbismount = 0;
|
|||||||
#if defined(GEKKO)
|
#if defined(GEKKO)
|
||||||
|
|
||||||
//init and deinit USB device functions
|
//init and deinit USB device functions
|
||||||
//code taken from Arikado
|
|
||||||
|
|
||||||
|
|
||||||
int InitUSB()
|
bool InitUSB()
|
||||||
{
|
{
|
||||||
printf("Initializing USB FAT subsytem ...\n\n");
|
printf("Initializing USB FAT subsytem ...\n\n");
|
||||||
fatUnmount("usb:");
|
fatUnmount("usb:");
|
||||||
|
|
||||||
|
// This should wake up the drive
|
||||||
bool isMounted = fatMountSimple("usb", &__io_usbstorage);
|
bool isMounted = fatMountSimple("usb", &__io_usbstorage);
|
||||||
|
|
||||||
if(!isMounted)
|
|
||||||
{
|
|
||||||
fatUnmount("usb:");
|
|
||||||
fatMountSimple("usb", &__io_usbstorage);
|
|
||||||
bool isInserted = __io_usbstorage.isInserted();
|
bool isInserted = __io_usbstorage.isInserted();
|
||||||
|
if (!isInserted) return false;
|
||||||
|
|
||||||
if(isInserted)
|
// USB Drive may be "sleeeeping"
|
||||||
{ int retry = 10;
|
// We need to try Mounting a few times to wake it up
|
||||||
while(retry)
|
int retry = 10;
|
||||||
|
while (retry && !isMounted)
|
||||||
{
|
{
|
||||||
isMounted = fatMountSimple("usb", &__io_usbstorage);
|
|
||||||
if (isMounted) break;
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
isMounted = fatMountSimple("usb", &__io_usbstorage);
|
||||||
retry--;
|
retry--;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
return isMounted;
|
return isMounted;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,17 +180,19 @@ extern "C" int main(int argc, char **argv)
|
|||||||
sleep(3);
|
sleep(3);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
printf("SD FAT subsytem initialized\n\n");
|
||||||
|
|
||||||
usbismount = InitUSB();
|
usbismount = InitUSB();
|
||||||
if (usbismount)
|
if (usbismount)
|
||||||
printf("USB FAT subsytem initialized\n");
|
printf("USB FAT subsytem initialized\n\n");
|
||||||
else
|
else
|
||||||
printf("Impossible to initialize USB FAT subsytem\n");
|
printf("Impossible to initialize USB FAT subsytem\n\n");
|
||||||
sleep(2);
|
sleep(3);
|
||||||
|
|
||||||
//create tmp directory if it does not exist
|
//create tmp directory if it does not exist
|
||||||
dir_tmp = diropen("/frodo/tmp");
|
dir_tmp = diropen("/frodo/tmp");
|
||||||
if (!dir_tmp) {mkdir("/frodo/tmp",0777);printf("Making tmp directory\n");sleep(3);} else dirclose(dir_tmp);
|
if (!dir_tmp) {mkdir("/frodo/tmp",0777);printf("Making tmp directory\n");sleep(2);} else dirclose(dir_tmp);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user