Improvements in the USB init management code

This commit is contained in:
fabio.olimpieri 2011-06-10 21:44:13 +00:00
parent 07b3a3c166
commit 41d0826a4a
4 changed files with 30 additions and 32 deletions

View File

@ -24,7 +24,7 @@ FileBrowser::~FileBrowser()
void FileBrowser::pushDirectory(const char *in_path)
{
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 = path_cpy;

View File

@ -1,7 +1,7 @@
#include "menu.hh"
#include "dialogue_box.hh"
extern int usbismount;
extern bool usbismount;
class KeyboardTypingListener : public KeyboardListener, TimeoutHandler
{
@ -70,7 +70,7 @@ public:
switch (which)
{
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);
Gui::gui->pushView(Gui::gui->dv);

View File

@ -81,7 +81,7 @@ public:
void updateSubmenus()
{
int submenu_defs[4];
int submenu_defs[5];
submenu_defs[0] = Gui::gui->np->JoystickSwap == true ? 0 : 1;
submenu_defs[1] = !Gui::gui->np->Emul1541Proc;

View File

@ -45,7 +45,7 @@ extern int init_graphics(void);
// Global variables
C64 *TheC64 = NULL; // Global C64 object
char AppDirPath[1024]; // Path of application directory
int usbismount = 0;
bool usbismount = false;
// ROM file names
#ifndef DATADIR
@ -83,31 +83,27 @@ int usbismount = 0;
#if defined(GEKKO)
//init and deinit USB device functions
//code taken from Arikado
int InitUSB()
bool InitUSB()
{
printf("Initializing USB FAT subsytem ...\n\n");
fatUnmount("usb:");
// This should wake up the drive
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)
{ int retry = 10;
while(retry)
{
isMounted = fatMountSimple("usb", &__io_usbstorage);
if (isMounted) break;
sleep(1);
retry--;
}
}
// USB Drive may be "sleeeeping"
// We need to try Mounting a few times to wake it up
int retry = 10;
while (retry && !isMounted)
{
sleep(1);
isMounted = fatMountSimple("usb", &__io_usbstorage);
retry--;
}
return isMounted;
}
@ -180,21 +176,23 @@ extern "C" int main(int argc, char **argv)
//initialize libfat library
if (!fatInitDefault())
{
printf("Couldn't initialize SD fat subsytem\n\n");
sleep(3);
exit(0);
printf("Couldn't initialize SD fat subsytem\n\n");
sleep(3);
exit(0);
}
else
printf("SD FAT subsytem initialized\n\n");
usbismount = InitUSB();
if (usbismount)
printf("USB FAT subsytem initialized\n");
printf("USB FAT subsytem initialized\n\n");
else
printf("Impossible to initialize USB FAT subsytem\n");
sleep(2);
printf("Impossible to initialize USB FAT subsytem\n\n");
sleep(3);
//create tmp directory if it does not exist
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