*Fixed settings loading on boot up

*Added better wait loop for HDD spin up
*Changed almost all default config paths which are set when no config exists to be set to where the actual config file is saved (either /apps/usbloader_gx/ or /config/)
*Changed to startup and load a cios right away before loading settings. You need to have at least one non stub cios 249, 222 or 250 to start the loader now
*Fixed 30 secs timer on HDD spin wait
*Updated libfat to new libogc version
This commit is contained in:
dimok321 2010-11-28 15:31:08 +00:00
parent 2c1228fa37
commit 9da497419c
21 changed files with 244 additions and 252 deletions

View File

@ -47,10 +47,13 @@ bool SetupDefaultFont(const char *path)
{ {
bool result = false; bool result = false;
FILE *pfile = NULL; FILE *pfile = NULL;
char FontPath[300];
ClearFontData(); ClearFontData();
if (path) pfile = fopen(path, "rb"); snprintf(FontPath, sizeof(FontPath), "%sfont.ttf", path);
pfile = fopen(FontPath, "rb");
if (pfile) if (pfile)
{ {

View File

@ -51,10 +51,20 @@ int USBDevice_Init()
USBDevice_deInit(); USBDevice_deInit();
//right now mounts first FAT-partition //right now mounts first FAT-partition
//usbstorage.startup is actually not needed since it's done in libfat bool started = false;
//let's still do it before mount and wait a bit for slow ass hdds before reading from them int retries = 10;
__io_usbstorage2.startup();
usleep(200000); // wait 0.5 sec for the USB to spin up...stupid slow ass HDD
do
{
started = (!__io_usbstorage2.startup() || !__io_usbstorage2.isInserted());
usleep(50000);
--retries;
}
while(!started && retries > 0);
if(!started)
return -1;
if (fatMount("USB", &__io_usbstorage2, 0, CACHE, SECTORS)) if (fatMount("USB", &__io_usbstorage2, 0, CACHE, SECTORS))
{ {
@ -62,18 +72,32 @@ int USBDevice_Init()
return (fat_usb_mount = 1); return (fat_usb_mount = 1);
} }
__io_usbstorage.startup(); return -1;
usleep(200000); }
if(fatMount("USB", &__io_usbstorage, 0, CACHE, SECTORS)) int USBDevice_Init_Loop()
{
time_t starttime = time(0);
time_t timenow = starttime;
int ret = -1;
bool printStart = true;
while(timenow-starttime < 30 && ret < 0)
{ {
fat_usb_sec = _FAT_startSector; ret = USBDevice_Init();
return (fat_usb_mount = 1); if(ret < 0)
{
if(printStart)
{
printf("failed\n");
printf("\tWaiting for slow HDD...\n");
printStart = false;
}
printf("%i ", (int) (timenow-starttime+1));
}
} }
__io_usbstorage.shutdown(); return ret;
return -1;
} }
void USBDevice_deInit() void USBDevice_deInit()
@ -81,7 +105,6 @@ void USBDevice_deInit()
//closing all open Files write back the cache and then shutdown em! //closing all open Files write back the cache and then shutdown em!
fatUnmount("USB:/"); fatUnmount("USB:/");
//only shutdown libogc usb and not the cios one //only shutdown libogc usb and not the cios one
__io_usbstorage.shutdown();
__io_usbstorage2.shutdown(); __io_usbstorage2.shutdown();
fat_usb_mount = 0; fat_usb_mount = 0;
@ -100,11 +123,7 @@ int WBFSDevice_Init(u32 sector)
fat_wbfs_mount = 1; fat_wbfs_mount = 1;
fat_wbfs_sec = _FAT_startSector; fat_wbfs_sec = _FAT_startSector;
if (sector && fat_wbfs_sec != sector)
{
// This is an error situation...actually, but is ignored in Config loader also
// Should ask Oggzee about it...
}
return 0; return 0;
} }
@ -169,12 +188,8 @@ s32 MountNTFS(u32 sector)
{ {
ret = ntfsMount("NTFS", &__io_usbstorage2, sector, CACHE, SECTORS, NTFS_SHOW_HIDDEN_FILES | NTFS_RECOVER); ret = ntfsMount("NTFS", &__io_usbstorage2, sector, CACHE, SECTORS, NTFS_SHOW_HIDDEN_FILES | NTFS_RECOVER);
if (!ret) if (!ret)
{
ret = ntfsMount("NTFS", &__io_usbstorage, sector, CACHE, SECTORS, NTFS_SHOW_HIDDEN_FILES | NTFS_RECOVER);
if(!ret)
return -2; return -2;
} }
}
else if (wbfsDev == WBFS_DEVICE_SDHC) else if (wbfsDev == WBFS_DEVICE_SDHC)
{ {
if (sdhc_mode_sd == 0) if (sdhc_mode_sd == 0)

View File

@ -16,6 +16,7 @@ extern int fat_wbfs_mount;
extern sec_t fat_wbfs_sec; extern sec_t fat_wbfs_sec;
int USBDevice_Init(); int USBDevice_Init();
int USBDevice_Init_Loop(); //! Wait's for the drive before mounting it, only used on bootup
void USBDevice_deInit(); void USBDevice_deInit();
int WBFSDevice_Init(u32 sector); int WBFSDevice_Init(u32 sector);
void WBFSDevice_deInit(); void WBFSDevice_deInit();

View File

@ -4,8 +4,7 @@
#include <malloc.h> #include <malloc.h>
/* init-globals */ /* init-globals */
bool geckoinit = false; static bool geckoinit = false;
bool textVideoInit = false;
#ifndef NO_DEBUG #ifndef NO_DEBUG
#include <stdarg.h> #include <stdarg.h>
@ -37,6 +36,7 @@ bool InitGecko()
{ {
usb_flush(EXI_CHANNEL_1); usb_flush(EXI_CHANNEL_1);
CON_EnableGecko(1, true); CON_EnableGecko(1, true);
geckoinit = true;
return true; return true;
} }
else return false; else return false;

View File

@ -30,9 +30,9 @@
#define _COMMON_H #define _COMMON_H
#define BYTES_PER_READ 512 #define BYTES_PER_READ 512
#include <fat.h>
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include <fat.h>
// When compiling for NDS, make sure NDS is defined // When compiling for NDS, make sure NDS is defined
#ifndef NDS #ifndef NDS

View File

@ -439,16 +439,13 @@ bool _FAT_directory_getVolumeLabel (PARTITION* partition, char *label) {
end = false; end = false;
//this entry should be among the first 3 entries in the root directory table, if not, then system can have trouble displaying the right volume label //this entry should be among the first 3 entries in the root directory table, if not, then system can have trouble displaying the right volume label
while(!end) { while(!end) {
if (_FAT_directory_incrementDirEntryPosition (partition, &entryEnd, false) == false) {
end = true;
}
if(!_FAT_cache_readPartialSector (partition->cache, entryData, if(!_FAT_cache_readPartialSector (partition->cache, entryData,
_FAT_fat_clusterToSector(partition, entryEnd.cluster) + entryEnd.sector, _FAT_fat_clusterToSector(partition, entryEnd.cluster) + entryEnd.sector,
entryEnd.offset * DIR_ENTRY_DATA_SIZE, DIR_ENTRY_DATA_SIZE)) entryEnd.offset * DIR_ENTRY_DATA_SIZE, DIR_ENTRY_DATA_SIZE))
{ //error reading { //error reading
return false; return false;
} }
if (entryData[DIR_ENTRY_attributes] == ATTRIB_VOL && entryData[0] != DIR_ENTRY_FREE) { if (entryData[DIR_ENTRY_attributes] == ATTRIB_VOL && entryData[0] != DIR_ENTRY_FREE) {
for (i = 0; i < 11; i++) { for (i = 0; i < 11; i++) {
label[i] = entryData[DIR_ENTRY_name + i]; label[i] = entryData[DIR_ENTRY_name + i];
@ -457,6 +454,10 @@ bool _FAT_directory_getVolumeLabel (PARTITION* partition, char *label) {
} else if (entryData[0] == DIR_ENTRY_LAST) { } else if (entryData[0] == DIR_ENTRY_LAST) {
end = true; end = true;
} }
if (_FAT_directory_incrementDirEntryPosition (partition, &entryEnd, false) == false) {
end = true;
}
} }
return false; return false;
} }

View File

@ -158,7 +158,7 @@ bool _FAT_cache_readSectors(CACHE *cache,sec_t sector,sec_t numSectors,void *buf
sec_t sec; sec_t sec;
sec_t secs_to_read; sec_t secs_to_read;
CACHE_ENTRY *entry; CACHE_ENTRY *entry;
uint8_t *dest = buffer; uint8_t *dest = (uint8_t *)buffer;
while(numSectors>0) { while(numSectors>0) {
entry = _FAT_cache_getPage(cache,sector); entry = _FAT_cache_getPage(cache,sector);
@ -264,7 +264,7 @@ bool _FAT_cache_eraseWritePartialSector (CACHE* cache, const void* buffer, sec_t
return true; return true;
} }
#ifndef GEKKO
static CACHE_ENTRY* _FAT_cache_findPage(CACHE *cache, sec_t sector, sec_t count) { static CACHE_ENTRY* _FAT_cache_findPage(CACHE *cache, sec_t sector, sec_t count) {
unsigned int i; unsigned int i;
@ -291,22 +291,27 @@ static CACHE_ENTRY* _FAT_cache_findPage(CACHE *cache, sec_t sector, sec_t count)
return entry; return entry;
} }
#endif
bool _FAT_cache_writeSectors (CACHE* cache, sec_t sector, sec_t numSectors, const void* buffer) bool _FAT_cache_writeSectors (CACHE* cache, sec_t sector, sec_t numSectors, const void* buffer)
{ {
sec_t sec; sec_t sec;
sec_t secs_to_write; sec_t secs_to_write;
CACHE_ENTRY* entry; CACHE_ENTRY* entry;
const uint8_t *src = buffer; const uint8_t *src = (const uint8_t *)buffer;
while(numSectors>0) while(numSectors>0)
{ {
#ifdef GEKKO
entry = _FAT_cache_getPage(cache,sector);
if(entry==NULL) return false;
#else
entry = _FAT_cache_findPage(cache,sector,numSectors); entry = _FAT_cache_findPage(cache,sector,numSectors);
if(entry!=NULL) { if(entry==NULL)
return _FAT_disc_writeSectors(cache->disc,sector,numSectors,src);
if ( entry->sector > sector) { if ( entry->sector > sector) {
secs_to_write = entry->sector - sector; secs_to_write = entry->sector - sector;
_FAT_disc_writeSectors(cache->disc,sector,secs_to_write,src); _FAT_disc_writeSectors(cache->disc,sector,secs_to_write,src);
@ -314,10 +319,9 @@ bool _FAT_cache_writeSectors (CACHE* cache, sec_t sector, sec_t numSectors, cons
sector += secs_to_write; sector += secs_to_write;
numSectors -= secs_to_write; numSectors -= secs_to_write;
} }
#endif
sec = sector - entry->sector; sec = sector - entry->sector;
secs_to_write = entry->count - sec; secs_to_write = entry->count - sec;
if(secs_to_write>numSectors) secs_to_write = numSectors; if(secs_to_write>numSectors) secs_to_write = numSectors;
memcpy(entry->cache + (sec*BYTES_PER_READ),src,(secs_to_write*BYTES_PER_READ)); memcpy(entry->cache + (sec*BYTES_PER_READ),src,(secs_to_write*BYTES_PER_READ));
@ -327,11 +331,6 @@ bool _FAT_cache_writeSectors (CACHE* cache, sec_t sector, sec_t numSectors, cons
numSectors -= secs_to_write; numSectors -= secs_to_write;
entry->dirty = true; entry->dirty = true;
} else {
_FAT_disc_writeSectors(cache->disc,sector,numSectors,src);
numSectors=0;
}
} }
return true; return true;
} }

View File

@ -654,10 +654,9 @@ ssize_t _FAT_write_r (struct _reent *r, int fd, const char *ptr, size_t len) {
_FAT_lock(&partition->lock); _FAT_lock(&partition->lock);
// Only write up to the maximum file size, taking into account wrap-around of ints // Only write up to the maximum file size, taking into account wrap-around of ints
if (remain + file->filesize > FILE_MAX_SIZE || len + file->filesize < file->filesize) { if (len + file->filesize > FILE_MAX_SIZE || len + file->filesize < file->filesize) {
len = FILE_MAX_SIZE - file->filesize; len = FILE_MAX_SIZE - file->filesize;
} }
remain = len;
// Short circuit cases where len is 0 (or less) // Short circuit cases where len is 0 (or less)
if (len <= 0) { if (len <= 0) {
@ -665,6 +664,8 @@ ssize_t _FAT_write_r (struct _reent *r, int fd, const char *ptr, size_t len) {
return 0; return 0;
} }
remain = len;
// Get a new cluster for the start of the file if required // Get a new cluster for the start of the file if required
if (file->startCluster == CLUSTER_FREE) { if (file->startCluster == CLUSTER_FREE) {
tempNextCluster = _FAT_fat_linkFreeCluster (partition, CLUSTER_FREE); tempNextCluster = _FAT_fat_linkFreeCluster (partition, CLUSTER_FREE);
@ -1130,6 +1131,7 @@ int _FAT_fsync_r (struct _reent *r, int fd) {
return ret; return ret;
} }
typedef int (*_frag_append_t)(void *ff, u32 offset, u32 sector, u32 count); typedef int (*_frag_append_t)(void *ff, u32 offset, u32 sector, u32 count);
int _FAT_get_fragments (const char *path, _frag_append_t append_fragment, void *callback_data) int _FAT_get_fragments (const char *path, _frag_append_t append_fragment, void *callback_data)

View File

@ -69,31 +69,31 @@ struct _FILE_STRUCT {
typedef struct _FILE_STRUCT FILE_STRUCT; typedef struct _FILE_STRUCT FILE_STRUCT;
extern int _FAT_open_r (struct _reent *r, void *fileStruct, const char *path, int flags, int mode); int _FAT_open_r (struct _reent *r, void *fileStruct, const char *path, int flags, int mode);
extern int _FAT_close_r (struct _reent *r, int fd); int _FAT_close_r (struct _reent *r, int fd);
extern ssize_t _FAT_write_r (struct _reent *r,int fd, const char *ptr, size_t len); ssize_t _FAT_write_r (struct _reent *r,int fd, const char *ptr, size_t len);
extern ssize_t _FAT_read_r (struct _reent *r, int fd, char *ptr, size_t len); ssize_t _FAT_read_r (struct _reent *r, int fd, char *ptr, size_t len);
extern off_t _FAT_seek_r (struct _reent *r, int fd, off_t pos, int dir); off_t _FAT_seek_r (struct _reent *r, int fd, off_t pos, int dir);
extern int _FAT_fstat_r (struct _reent *r, int fd, struct stat *st); int _FAT_fstat_r (struct _reent *r, int fd, struct stat *st);
extern int _FAT_stat_r (struct _reent *r, const char *path, struct stat *st); int _FAT_stat_r (struct _reent *r, const char *path, struct stat *st);
extern int _FAT_link_r (struct _reent *r, const char *existing, const char *newLink); int _FAT_link_r (struct _reent *r, const char *existing, const char *newLink);
extern int _FAT_unlink_r (struct _reent *r, const char *name); int _FAT_unlink_r (struct _reent *r, const char *name);
extern int _FAT_chdir_r (struct _reent *r, const char *name); int _FAT_chdir_r (struct _reent *r, const char *name);
extern int _FAT_rename_r (struct _reent *r, const char *oldName, const char *newName); int _FAT_rename_r (struct _reent *r, const char *oldName, const char *newName);
extern int _FAT_ftruncate_r (struct _reent *r, int fd, off_t len); int _FAT_ftruncate_r (struct _reent *r, int fd, off_t len);
extern int _FAT_fsync_r (struct _reent *r, int fd); int _FAT_fsync_r (struct _reent *r, int fd);
/* /*
Synchronizes the file data to disc. Synchronizes the file data to disc.

View File

@ -246,7 +246,7 @@ uint32_t _FAT_fat_linkFreeCluster(PARTITION* partition, uint32_t cluster) {
} }
partition->fat.firstFree = firstFree; partition->fat.firstFree = firstFree;
if ((cluster >= CLUSTER_FIRST) && (cluster < lastCluster)) if ((cluster >= CLUSTER_FIRST) && (cluster <= lastCluster))
{ {
// Update the linked from FAT entry // Update the linked from FAT entry
_FAT_fat_writeFatEntry (partition, cluster, firstFree); _FAT_fat_writeFatEntry (partition, cluster, firstFree);

View File

@ -29,6 +29,7 @@
#include <sys/iosupport.h> #include <sys/iosupport.h>
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
#include <stdio.h>
#include "common.h" #include "common.h"
#include "partition.h" #include "partition.h"
@ -61,7 +62,9 @@ static const devoptab_t dotab_fat = {
_FAT_statvfs_r, _FAT_statvfs_r,
_FAT_ftruncate_r, _FAT_ftruncate_r,
_FAT_fsync_r, _FAT_fsync_r,
NULL /* Device data */ NULL, /* Device data */
NULL,
NULL
}; };
bool fatMount (const char* name, const DISC_INTERFACE* interface, sec_t startSector, uint32_t cacheSize, uint32_t SectorsPerPage) { bool fatMount (const char* name, const DISC_INTERFACE* interface, sec_t startSector, uint32_t cacheSize, uint32_t SectorsPerPage) {
@ -69,7 +72,7 @@ bool fatMount (const char* name, const DISC_INTERFACE* interface, sec_t startSec
devoptab_t* devops; devoptab_t* devops;
char* nameCopy; char* nameCopy;
if(!name || !interface) if(!name || strlen(name) > 8 || !interface)
return false; return false;
if(!interface->startup()) if(!interface->startup())
@ -78,6 +81,11 @@ bool fatMount (const char* name, const DISC_INTERFACE* interface, sec_t startSec
if(!interface->isInserted()) if(!interface->isInserted())
return false; return false;
char devname[10];
sprintf(devname, "%s:", name);
if(FindDevice(devname) >= 0)
return true;
devops = _FAT_mem_allocate (sizeof(devoptab_t) + strlen(name) + 1); devops = _FAT_mem_allocate (sizeof(devoptab_t) + strlen(name) + 1);
if (!devops) { if (!devops) {
return false; return false;
@ -220,11 +228,11 @@ void fatGetVolumeLabel (const char* name, char *label) {
for(i=0;buf[i]!='\0' && buf[i]!=':';i++); for(i=0;buf[i]!='\0' && buf[i]!=':';i++);
if (!devops || strncasecmp(buf,devops->name,i)) { if (!devops || strncasecmp(buf,devops->name,i)) {
free(buf); _FAT_mem_free(buf);
return; return;
} }
free(buf); _FAT_mem_free(buf);
// Perform a quick check to make sure we're dealing with a libfat controlled device // Perform a quick check to make sure we're dealing with a libfat controlled device
if (devops->open_r != dotab_fat.open_r) { if (devops->open_r != dotab_fat.open_r) {

View File

@ -31,8 +31,6 @@
#include "common.h" #include "common.h"
#ifdef USE_LWP_LOCK
static inline void _FAT_lock_init(mutex_t *mutex) static inline void _FAT_lock_init(mutex_t *mutex)
{ {
LWP_MutexInit(mutex, false); LWP_MutexInit(mutex, false);
@ -53,35 +51,6 @@ static inline void _FAT_unlock(mutex_t *mutex)
LWP_MutexUnlock(*mutex); LWP_MutexUnlock(*mutex);
} }
#else
// We still need a blank lock type
#ifndef mutex_t
typedef int mutex_t;
#endif
static inline void _FAT_lock_init(mutex_t *mutex)
{
return;
}
static inline void _FAT_lock_deinit(mutex_t *mutex)
{
return;
}
static inline void _FAT_lock(mutex_t *mutex)
{
return;
}
static inline void _FAT_unlock(mutex_t *mutex)
{
return;
}
#endif // USE_LWP_LOCK
#endif // _LOCK_H #endif // _LOCK_H

View File

@ -935,8 +935,6 @@ class GuiKeyboard: public GuiWindow
GuiImageData * keyMediumOver; GuiImageData * keyMediumOver;
GuiImageData * keyLarge; GuiImageData * keyLarge;
GuiImageData * keyLargeOver; GuiImageData * keyLargeOver;
GuiSound * keySoundOver;
GuiSound * keySoundClick;
GuiTrigger * trigA; GuiTrigger * trigA;
GuiTrigger * trigB; GuiTrigger * trigB;
}; };

View File

@ -166,8 +166,8 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max, int min, int lang)
//keyBack->SetImage(keyBackImg); //keyBack->SetImage(keyBackImg);
//keyBack->SetImageOver(keyBackOverImg); //keyBack->SetImageOver(keyBackOverImg);
keyBack->SetLabel(keyBackText); keyBack->SetLabel(keyBackText);
//keyBack->SetSoundOver(keySoundOver); //keyBack->SetSoundOver(btnSoundOver);
//keyBack->SetSoundClick(keySoundClick); //keyBack->SetSoundClick(btnSoundClick);
//keyBack->SetTrigger(trigA); //keyBack->SetTrigger(trigA);
keyBack->SetTrigger(trigB); keyBack->SetTrigger(trigB);
if (mode > 1) if (mode > 1)
@ -194,13 +194,13 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max, int min, int lang)
{ 0, 0, 0, 0xff}); { 0, 0, 0, 0xff});
} }
keyClear = new GuiButton(keyClearImg, keyClearOverImg, 0, 3, (10 * 42 + 40) + eurocheck, 4 * 42 + 120, trigA, keyClear = new GuiButton(keyClearImg, keyClearOverImg, 0, 3, (10 * 42 + 40) + eurocheck, 4 * 42 + 120, trigA,
keySoundOver, keySoundClick, 1); btnSoundOver, btnSoundClick, 1);
//keyClear = new GuiButton(keyMedium->GetWidth(), keyMedium->GetHeight()); //keyClear = new GuiButton(keyMedium->GetWidth(), keyMedium->GetHeight());
//keyClear->SetImage(keyClearImg); //keyClear->SetImage(keyClearImg);
//keyClear->SetImageOver(keyClearOverImg); //keyClear->SetImageOver(keyClearOverImg);
keyClear->SetLabel(keyClearText); keyClear->SetLabel(keyClearText);
//keyClear->SetSoundOver(keySoundOver); //keyClear->SetSoundOver(btnSoundOver);
//keyClear->SetSoundClick(keySoundClick); //keyClear->SetSoundClick(btnSoundClick);
//keyClear->SetTrigger(trigA); //keyClear->SetTrigger(trigA);
//keyClear->SetPosition((10*42+40)+eurocheck, 4*42+120);//(10*42+40, 0*42+80); //keyClear->SetPosition((10*42+40)+eurocheck, 4*42+120);//(10*42+40, 0*42+80);
//keyClear->SetEffectGrow(); //keyClear->SetEffectGrow();
@ -210,14 +210,14 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max, int min, int lang)
keyAltOverImg = new GuiImage(keyMediumOver); keyAltOverImg = new GuiImage(keyMediumOver);
keyAltText = new GuiText("Alt Gr", 20, ( GXColor ) keyAltText = new GuiText("Alt Gr", 20, ( GXColor )
{ 0, 0, 0, 0xff}); { 0, 0, 0, 0xff});
keyAlt = new GuiButton(keyAltImg, keyAltOverImg, 0, 3, 84 + eurocheck, 4 * 42 + 120, trigA, keySoundOver, keyAlt = new GuiButton(keyAltImg, keyAltOverImg, 0, 3, 84 + eurocheck, 4 * 42 + 120, trigA, btnSoundOver,
keySoundClick, 1); btnSoundClick, 1);
//keyAlt = new GuiButton(keyMedium->GetWidth(), keyMedium->GetHeight()); //keyAlt = new GuiButton(keyMedium->GetWidth(), keyMedium->GetHeight());
//keyAlt->SetImage(keyAltImg); //keyAlt->SetImage(keyAltImg);
//keyAlt->SetImageOver(keyAltOverImg); //keyAlt->SetImageOver(keyAltOverImg);
keyAlt->SetLabel(keyAltText); keyAlt->SetLabel(keyAltText);
//keyAlt->SetSoundOver(keySoundOver); //keyAlt->SetSoundOver(btnSoundOver);
//keyAlt->SetSoundClick(keySoundClick); //keyAlt->SetSoundClick(btnSoundClick);
//keyAlt->SetTrigger(trigA); //keyAlt->SetTrigger(trigA);
//keyAlt->SetPosition(84+eurocheck, 4*42+120);//(10*42+40, 4*42+120); //keyAlt->SetPosition(84+eurocheck, 4*42+120);//(10*42+40, 4*42+120);
//keyAlt->SetEffectGrow(); //keyAlt->SetEffectGrow();
@ -231,13 +231,13 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max, int min, int lang)
keyAlt2Text = new GuiText("Accent", 20, ( GXColor ) keyAlt2Text = new GuiText("Accent", 20, ( GXColor )
{ 0, 0, 0, 0xff}); { 0, 0, 0, 0xff});
keyAlt2 = new GuiButton(keyAlt2Img, keyAlt2OverImg, 0, 3, (8 * 42 + 40) + eurocheck, 4 * 42 + 120, trigA, keyAlt2 = new GuiButton(keyAlt2Img, keyAlt2OverImg, 0, 3, (8 * 42 + 40) + eurocheck, 4 * 42 + 120, trigA,
keySoundOver, keySoundClick, 1); btnSoundOver, btnSoundClick, 1);
//keyAlt2 = new GuiButton(keyMedium->GetWidth(), keyMedium->GetHeight()); //keyAlt2 = new GuiButton(keyMedium->GetWidth(), keyMedium->GetHeight());
//keyAlt2->SetImage(keyAlt2Img); //keyAlt2->SetImage(keyAlt2Img);
//keyAlt2->SetImageOver(keyAlt2OverImg); //keyAlt2->SetImageOver(keyAlt2OverImg);
keyAlt2->SetLabel(keyAlt2Text); keyAlt2->SetLabel(keyAlt2Text);
//keyAlt2->SetSoundOver(keySoundOver); //keyAlt2->SetSoundOver(btnSoundOver);
//keyAlt2->SetSoundClick(keySoundClick); //keyAlt2->SetSoundClick(btnSoundClick);
//keyAlt2->SetTrigger(trigA); //keyAlt2->SetTrigger(trigA);
//keyAlt2->SetPosition((8*42+40)+eurocheck, 4*42+120);//(10*42+40, 4*42+120); //keyAlt2->SetPosition((8*42+40)+eurocheck, 4*42+120);//(10*42+40, 4*42+120);
//keyAlt2->SetEffectGrow(); //keyAlt2->SetEffectGrow();
@ -250,14 +250,14 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max, int min, int lang)
keyCapsOverImg = new GuiImage(keyMediumOver); keyCapsOverImg = new GuiImage(keyMediumOver);
keyCapsText = new GuiText("Caps", 20, ( GXColor ) keyCapsText = new GuiText("Caps", 20, ( GXColor )
{ 0, 0, 0, 0xff}); { 0, 0, 0, 0xff});
keyCaps = new GuiButton(keyCapsImg, keyCapsOverImg, 0, 3, 0 + eurocheck, 2 * 42 + 120, trigA, keySoundOver, keyCaps = new GuiButton(keyCapsImg, keyCapsOverImg, 0, 3, 0 + eurocheck, 2 * 42 + 120, trigA, btnSoundOver,
keySoundClick, 1); btnSoundClick, 1);
//keyCaps = new GuiButton(keyMedium->GetWidth(), keyMedium->GetHeight()); //keyCaps = new GuiButton(keyMedium->GetWidth(), keyMedium->GetHeight());
//keyCaps->SetImage(keyCapsImg); //keyCaps->SetImage(keyCapsImg);
//keyCaps->SetImageOver(keyCapsOverImg); //keyCaps->SetImageOver(keyCapsOverImg);
keyCaps->SetLabel(keyCapsText); keyCaps->SetLabel(keyCapsText);
//keyCaps->SetSoundOver(keySoundOver); //keyCaps->SetSoundOver(btnSoundOver);
//keyCaps->SetSoundClick(keySoundClick); //keyCaps->SetSoundClick(btnSoundClick);
//keyCaps->SetTrigger(trigA); //keyCaps->SetTrigger(trigA);
//keyCaps->SetPosition(0+eurocheck, 2*42+120);//(0, 2*42+80); //keyCaps->SetPosition(0+eurocheck, 2*42+120);//(0, 2*42+80);
//keyCaps->SetEffectGrow(); //keyCaps->SetEffectGrow();
@ -267,14 +267,14 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max, int min, int lang)
keyShiftOverImg = new GuiImage(keyMediumOver); keyShiftOverImg = new GuiImage(keyMediumOver);
keyShiftText = new GuiText("Shift", 20, ( GXColor ) keyShiftText = new GuiText("Shift", 20, ( GXColor )
{ 0, 0, 0, 0xff}); { 0, 0, 0, 0xff});
keyShift = new GuiButton(keyShiftImg, keyShiftOverImg, 0, 3, 21 + eurocheck, 3 * 42 + 120, trigA, keySoundOver, keyShift = new GuiButton(keyShiftImg, keyShiftOverImg, 0, 3, 21 + eurocheck, 3 * 42 + 120, trigA, btnSoundOver,
keySoundClick, 1); btnSoundClick, 1);
//keyShift = new GuiButton(keyMedium->GetWidth(), keyMedium->GetHeight()); //keyShift = new GuiButton(keyMedium->GetWidth(), keyMedium->GetHeight());
//keyShift->SetImage(keyShiftImg); //keyShift->SetImage(keyShiftImg);
//keyShift->SetImageOver(keyShiftOverImg); //keyShift->SetImageOver(keyShiftOverImg);
keyShift->SetLabel(keyShiftText); keyShift->SetLabel(keyShiftText);
//keyShift->SetSoundOver(keySoundOver); //keyShift->SetSoundOver(btnSoundOver);
//keyShift->SetSoundClick(keySoundClick); //keyShift->SetSoundClick(btnSoundClick);
//keyShift->SetTrigger(trigA); //keyShift->SetTrigger(trigA);
//keyShift->SetPosition(21+eurocheck, 3*42+120);//(21, 3*42+80); //keyShift->SetPosition(21+eurocheck, 3*42+120);//(21, 3*42+80);
//keyShift->SetEffectGrow(); //keyShift->SetEffectGrow();
@ -282,13 +282,13 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max, int min, int lang)
keySpaceImg = new GuiImage(keyLarge); keySpaceImg = new GuiImage(keyLarge);
keySpaceOverImg = new GuiImage(keyLargeOver); keySpaceOverImg = new GuiImage(keyLargeOver);
keySpace = new GuiButton(keySpaceImg, keySpaceOverImg, 2, 3, 0 + eurocheck, 4 * 42 + 120, trigA, keySoundOver, keySpace = new GuiButton(keySpaceImg, keySpaceOverImg, 2, 3, 0 + eurocheck, 4 * 42 + 120, trigA, btnSoundOver,
keySoundClick, 1); btnSoundClick, 1);
//keySpace = new GuiButton(keyLarge->GetWidth(), keyLarge->GetHeight()); //keySpace = new GuiButton(keyLarge->GetWidth(), keyLarge->GetHeight());
//keySpace->SetImage(keySpaceImg); //keySpace->SetImage(keySpaceImg);
//keySpace->SetImageOver(keySpaceOverImg); //keySpace->SetImageOver(keySpaceOverImg);
//keySpace->SetSoundOver(keySoundOver); //keySpace->SetSoundOver(btnSoundOver);
//keySpace->SetSoundClick(keySoundClick); //keySpace->SetSoundClick(btnSoundClick);
//keySpace->SetTrigger(trigA); //keySpace->SetTrigger(trigA);
//keySpace->SetPosition(0+eurocheck, 4*42+120);//(0, 4*42+80); //keySpace->SetPosition(0+eurocheck, 4*42+120);//(0, 4*42+80);
//keySpace->SetAlignment(ALIGN_CENTRE, ALIGN_TOP); //keySpace->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
@ -310,12 +310,12 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max, int min, int lang)
keyTxt[i][j]->SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM); keyTxt[i][j]->SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM);
keyTxt[i][j]->SetPosition(0, -10); keyTxt[i][j]->SetPosition(0, -10);
keyBtn[i][j] = new GuiButton(keyImg[i][j], keyImgOver[i][j], 0, 3, (j * 42 + 21 * i + 40) + eurocheck, keyBtn[i][j] = new GuiButton(keyImg[i][j], keyImgOver[i][j], 0, 3, (j * 42 + 21 * i + 40) + eurocheck,
i * 42 + 120, trigA, keySoundOver, keySoundClick, 1); i * 42 + 120, trigA, btnSoundOver, btnSoundClick, 1);
//keyBtn[i][j] = new GuiButton(key->GetWidth(), key->GetHeight()); //keyBtn[i][j] = new GuiButton(key->GetWidth(), key->GetHeight());
//keyBtn[i][j]->SetImage(keyImg[i][j]); //keyBtn[i][j]->SetImage(keyImg[i][j]);
//keyBtn[i][j]->SetImageOver(keyImgOver[i][j]); //keyBtn[i][j]->SetImageOver(keyImgOver[i][j]);
//keyBtn[i][j]->SetSoundOver(keySoundOver); //keyBtn[i][j]->SetSoundOver(btnSoundOver);
//keyBtn[i][j]->SetSoundClick(keySoundClick); //keyBtn[i][j]->SetSoundClick(btnSoundClick);
//keyBtn[i][j]->SetTrigger(trigA); //keyBtn[i][j]->SetTrigger(trigA);
keyBtn[i][j]->SetLabel(keyTxt[i][j]); keyBtn[i][j]->SetLabel(keyTxt[i][j]);
//keyBtn[i][j]->SetPosition((j*42+21*i+40)+eurocheck, i*42+120);//SetPosition(j*42+21*i+40, i*42+80); //keyBtn[i][j]->SetPosition((j*42+21*i+40)+eurocheck, i*42+120);//SetPosition(j*42+21*i+40, i*42+80);

View File

@ -6,7 +6,6 @@
* libwiigui * libwiigui
* Tantric 2009 * Tantric 2009
***************************************************************************/ ***************************************************************************/
#include <gccore.h> #include <gccore.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -33,6 +32,9 @@
#include "input.h" #include "input.h"
#include "filelist.h" #include "filelist.h"
#include "FileOperations/fileops.h" #include "FileOperations/fileops.h"
#include "settings/CGameSettings.h"
#include "settings/CGameStatistics.h"
#include "themes/CTheme.h"
#include "main.h" #include "main.h"
#include "fatmounter.h" #include "fatmounter.h"
#include "sys.h" #include "sys.h"
@ -48,44 +50,29 @@
extern "C" extern "C"
{ {
extern void __exception_setreload(int t); void __exception_setreload(int t);
} }
extern bool geckoinit;
PartList partitions; PartList partitions;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
MEM2_init(48); MEM2_init(48);
setlocale(LC_ALL, "en.UTF-8"); setlocale(LC_ALL, "en.UTF-8");
geckoinit = InitGecko();
InitVideo(); InitVideo();
InitGecko();
__exception_setreload(20); __exception_setreload(20);
printf("\tStarting up\n"); printf("\tStarting up\n");
NandTitles.Get(); NandTitles.Get();
//Let's use libogc sd/usb for config loading // Let's try loading some cIOS
printf("\tInitialize sd card\n");
SDCard_Init();
printf("\tInitialize usb device\n");
USBDevice_Init();
gettextCleanUp();
printf("\tLoading configuration...");
Settings.Load();
VIDEO_SetWidescreen(Settings.widescreen);
printf("done\n");
// Let's load the cIOS now
if (IosLoader::LoadAppCios() < 0) if (IosLoader::LoadAppCios() < 0)
{ {
printf("\n\tWARNING!\n"); printf("\n\tWARNING!\n");
printf("\tUSB Loader GX needs unstubbed cIOS 222 v4+ or 249 v9+\n\n"); printf("\tUSB Loader GX needs unstubbed cIOS 222 v4+ or 249 v9+\n\n");
printf( printf("\tWe cannot determine the versions on your system,\n\tsince you have no patched ios 36 or 236 installed.\n");
"\tWe cannot determine the versions on your system,\n\tsince you have no patched ios 36 or 236 installed.\n");
printf("\tTherefor, if loading of USB Loader GX fails, you\n\tprobably have installed the 4.2 update,\n"); printf("\tTherefor, if loading of USB Loader GX fails, you\n\tprobably have installed the 4.2 update,\n");
printf("\tand you should go figure out how to get some cios action going on\n\tin your Wii.\n"); printf("\tand you should go figure out how to get some cios action going on\n\tin your Wii.\n");
@ -93,8 +80,36 @@ int main(int argc, char *argv[])
sleep(10); sleep(10);
Sys_BackToLoader(); Sys_BackToLoader();
} }
//Let's use libogc sd/usb for config loading
printf("\tInitialize sd card...%s\n", SDCard_Init() < 0 ? "failed" : "done");
printf("\tInitialize usb device...%s\n", USBDevice_Init_Loop() < 0 ? "failed" : "done");
//Load configurations
printf("\tLoading config...%s\n", Settings.Load() ? "done" : "failed");
printf("\tLoading language...%s\n", Settings.LoadLanguage(Settings.language_path, CONSOLE_DEFAULT) ? "done" : "failed");
printf("\tLoading game settings...%s\n", GameSettings.Load(Settings.ConfigPath) ? "done" : "failed");
printf("\tLoading game statistics...%s\n", GameStatistics.Load(Settings.ConfigPath) ? "done" : "failed");
printf("\tLoading theme...%s\n", Theme.Load(Settings.theme_path) ? "done" : "failed (using default)");
printf("\tLoading font system...%s\n", SetupDefaultFont(Settings.theme_path) ? "done" : "failed (using default)");
VIDEO_SetWidescreen(Settings.widescreen);
if(Settings.cios != IOS_GetVersion())
{
// Unmount fat before reloading IOS.
SDCard_deInit();
USBDevice_deInit();
// Loading now the cios setup in the settings
IosLoader::LoadAppCios();
printf("\tLoaded cIOS = %u (Rev %u)\n", IOS_GetVersion(), IOS_GetRevision()); printf("\tLoaded cIOS = %u (Rev %u)\n", IOS_GetVersion(), IOS_GetRevision());
// Remount devices after reloading IOS.
SDCard_Init();
USBDevice_Init_Loop();
}
//if a ID was passed via args copy it and try to boot it after the partition is mounted //if a ID was passed via args copy it and try to boot it after the partition is mounted
//its not really a headless mode. more like hairless. //its not really a headless mode. more like hairless.
if (argc > 1 && argv[1]) if (argc > 1 && argv[1])
@ -108,11 +123,6 @@ int main(int argc, char *argv[])
SetupPads(); SetupPads();
InitAudio(); InitAudio();
char *fontPath = NULL;
asprintf(&fontPath, "%sfont.ttf", Settings.theme_path);
SetupDefaultFont(fontPath);
free(fontPath);
MainMenu(MENU_DISCLIST); MainMenu(MENU_DISCLIST);
return 0; return 0;
} }

View File

@ -285,22 +285,16 @@ int MainMenu(int menu)
ResumeGui(); ResumeGui();
gprintf("Vor bgm\n");
bgMusic = new GuiBGM(bg_music_ogg, bg_music_ogg_size, Settings.volume); bgMusic = new GuiBGM(bg_music_ogg, bg_music_ogg_size, Settings.volume);
gprintf("new bgm\n");
bgMusic->SetLoop(Settings.musicloopmode); //loop music bgMusic->SetLoop(Settings.musicloopmode); //loop music
gprintf("SetLoop\n");
bgMusic->Load(Settings.ogg_path); bgMusic->Load(Settings.ogg_path);
gprintf("Load\n");
bgMusic->Play(); bgMusic->Play();
gprintf("Nach bgm\n");
MountGamePartition(); MountGamePartition();
while (currentMenu != MENU_EXIT) while (currentMenu != MENU_EXIT)
{ {
bgMusic->SetVolume(Settings.volume); bgMusic->SetVolume(Settings.volume);
// gprintf("Current menu: %d\n", currentMenu);
switch (currentMenu) switch (currentMenu)
{ {

View File

@ -1724,7 +1724,7 @@ int GameWindowPrompt()
***************************************************************************/ ***************************************************************************/
int DiscWait(const char *title, const char *msg, const char *btn1Label, const char *btn2Label, int IsDeviceWait) int DiscWait(const char *title, const char *msg, const char *btn1Label, const char *btn2Label, int IsDeviceWait)
{ {
int i = 30, ret = 0; int ret = 0;
u32 cover = 0; u32 cover = 0;
GuiWindow promptWindow(472, 320); GuiWindow promptWindow(472, 320);
@ -1823,18 +1823,20 @@ int DiscWait(const char *title, const char *msg, const char *btn1Label, const ch
if (IsDeviceWait) if (IsDeviceWait)
{ {
while (i >= 0) time_t starttime = time(0);
time_t timenow = starttime;
do
{ {
VIDEO_WaitVSync(); gprintf("%i\n", (int) (timenow-starttime));
timerTxt.SetTextf("%u %s", i, tr( "seconds left" ));
USBDevice_deInit();
USBDevice_Init();
ret = WBFS_Init(WBFS_DEVICE_USB); ret = WBFS_Init(WBFS_DEVICE_USB);
if (ret >= 0) break; if (ret >= 0) break;
i--; timerTxt.SetTextf("%i %s", (int) (30-(timenow-starttime)), tr( "seconds left" ));
sleep(1); USBDevice_deInit();
USBDevice_Init();
timenow = time(0);
} }
while (timenow-starttime < 30);
} }
else else
{ {

View File

@ -39,6 +39,7 @@ CSettings::CSettings()
{ {
CONF_Init(); CONF_Init();
strcpy(BootDevice, "SD:"); strcpy(BootDevice, "SD:");
snprintf(ConfigPath, sizeof(ConfigPath), "%s/config/", BootDevice);
this->SetDefault(); this->SetDefault();
} }
@ -48,20 +49,19 @@ CSettings::~CSettings()
void CSettings::SetDefault() void CSettings::SetDefault()
{ {
snprintf(ConfigPath, sizeof(ConfigPath), "%s/config/GXGlobal.cfg", BootDevice); snprintf(covers_path, sizeof(covers_path), "%simages/", ConfigPath);
snprintf(covers_path, sizeof(covers_path), "%s/images/", BootDevice); snprintf(covers2d_path, sizeof(covers2d_path), "%simages/2D/", ConfigPath);
snprintf(covers2d_path, sizeof(covers2d_path), "%s/images/2D/", BootDevice); snprintf(disc_path, sizeof(disc_path), "%simages/disc/", ConfigPath);
snprintf(disc_path, sizeof(disc_path), "%s/images/disc/", BootDevice); snprintf(titlestxt_path, sizeof(titlestxt_path), "%s", ConfigPath);
snprintf(titlestxt_path, sizeof(titlestxt_path), "%s/config/", BootDevice); snprintf(languagefiles_path, sizeof(languagefiles_path), "%slanguage/", ConfigPath);
snprintf(languagefiles_path, sizeof(languagefiles_path), "%s/config/language/", BootDevice);
snprintf(update_path, sizeof(update_path), "%s/apps/usbloader_gx/", BootDevice); snprintf(update_path, sizeof(update_path), "%s/apps/usbloader_gx/", BootDevice);
snprintf(theme_downloadpath, sizeof(theme_downloadpath), "%s/config/themes/", BootDevice); snprintf(theme_downloadpath, sizeof(theme_downloadpath), "%sthemes/", ConfigPath);
snprintf(homebrewapps_path, sizeof(homebrewapps_path), "%s/apps/", BootDevice); snprintf(homebrewapps_path, sizeof(homebrewapps_path), "%s/apps/", BootDevice);
snprintf(Cheatcodespath, sizeof(Cheatcodespath), "%s/codes/", BootDevice); snprintf(Cheatcodespath, sizeof(Cheatcodespath), "%scodes/", ConfigPath);
snprintf(TxtCheatcodespath, sizeof(TxtCheatcodespath), "%s/txtcodes/", BootDevice); snprintf(TxtCheatcodespath, sizeof(TxtCheatcodespath), "%stxtcodes/", ConfigPath);
snprintf(BcaCodepath, sizeof(BcaCodepath), "%s/bca/", BootDevice); snprintf(BcaCodepath, sizeof(BcaCodepath), "%sbca/", ConfigPath);
snprintf(WipCodepath, sizeof(WipCodepath), "%s/wip/", BootDevice); snprintf(WipCodepath, sizeof(WipCodepath), "%swip/", ConfigPath);
snprintf(theme_path, sizeof(theme_path), "%s/theme/", BootDevice); snprintf(theme_path, sizeof(theme_path), "%stheme/", ConfigPath);
snprintf(dolpath, sizeof(dolpath), "%s/", BootDevice); snprintf(dolpath, sizeof(dolpath), "%s/", BootDevice);
strcpy(language_path, ""); strcpy(language_path, "");
strcpy(ogg_path, ""); strcpy(ogg_path, "");
@ -132,16 +132,10 @@ bool CSettings::Load()
FindConfig(); FindConfig();
//! Reset default path variables to the right device //! Reset default path variables to the right device
SetDefault(); SetDefault();
//! Set up the default path in the classes
//! in case the config file does not exist yet
char tempPath[100];
snprintf(tempPath, sizeof(tempPath), "%s/config/", BootDevice);
GameStatistics.Load(tempPath);
GameSettings.Load(tempPath);
char line[1024]; char line[1024];
char filepath[300]; char filepath[300];
snprintf(filepath, sizeof(filepath), "%s", ConfigPath); snprintf(filepath, sizeof(filepath), "%sGXGlobal.cfg", ConfigPath);
file = fopen(filepath, "r"); file = fopen(filepath, "r");
if (!file) return false; if (!file) return false;
@ -154,17 +148,6 @@ bool CSettings::Load()
} }
fclose(file); fclose(file);
//!The following needs to be moved later
char GameSetPath[200];
snprintf(GameSetPath, sizeof(GameSetPath), ConfigPath);
char * ptr = strrchr(GameSetPath, '/');
if(ptr) ptr[1] = 0;
GameStatistics.Load(GameSetPath);
GameSettings.Load(GameSetPath);
Theme.Load(theme_path);
this->LoadLanguage(this->language_path);
return true; return true;
} }
@ -182,19 +165,12 @@ bool CSettings::Save()
{ {
if (!FindConfig()) return false; if (!FindConfig()) return false;
char filedest[100]; char filedest[300];
snprintf(filedest, sizeof(filedest), "%s", ConfigPath); snprintf(filedest, sizeof(filedest), "%sGXGlobal.cfg", ConfigPath);
char * tmppath = strrchr(filedest, '/'); if(!CreateSubfolder(ConfigPath)) return false;
if (tmppath)
{
tmppath++;
tmppath[0] = '\0';
}
if(!CreateSubfolder(filedest)) return false; file = fopen(filedest, "w");
file = fopen(ConfigPath, "w");
if (!file) return false; if (!file) return false;
fprintf(file, "# USB Loader global settings file\n"); fprintf(file, "# USB Loader global settings file\n");
@ -572,17 +548,20 @@ bool CSettings::SetSetting(char *name, char *value)
bool CSettings::FindConfig() bool CSettings::FindConfig()
{ {
bool found = false; bool found = false;
char CheckPath[300];
strcpy(BootDevice, "SD:"); strcpy(BootDevice, "SD:");
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)
{ {
if (i == 1) strcpy(BootDevice, "USB:"); if (i == 1) strcpy(BootDevice, "USB:");
snprintf(ConfigPath, sizeof(ConfigPath), "%s/config/GXGlobal.cfg", BootDevice); snprintf(ConfigPath, sizeof(ConfigPath), "%s/apps/usbloader_gx/", BootDevice);
if ((found = CheckFile(ConfigPath))) break; snprintf(CheckPath, sizeof(CheckPath), "%sGXGlobal.cfg", ConfigPath);
if ((found = CheckFile(CheckPath))) break;
snprintf(ConfigPath, sizeof(ConfigPath), "%s/apps/usbloader_gx/GXGlobal.cfg", BootDevice); snprintf(ConfigPath, sizeof(ConfigPath), "%s/config/", BootDevice);
if ((found = CheckFile(ConfigPath))) break; snprintf(CheckPath, sizeof(CheckPath), "%sGXGlobal.cfg", ConfigPath);
if ((found = CheckFile(CheckPath))) break;
} }
if (!found) if (!found)
@ -596,9 +575,8 @@ bool CSettings::FindConfig()
if (!found) if (!found)
{ {
snprintf(ConfigPath, sizeof(ConfigPath), "%s/apps/usbloader_gx/", BootDevice); snprintf(ConfigPath, sizeof(ConfigPath), "%s/apps/usbloader_gx/", BootDevice);
CreateSubfolder(ConfigPath); snprintf(CheckPath, sizeof(CheckPath), "%sGXGlobal.cfg", ConfigPath);
strcat(ConfigPath, "GXGlobal.cfg"); testFp = fopen(CheckPath, "wb");
testFp = fopen(ConfigPath, "wb");
found = (testFp != NULL); found = (testFp != NULL);
fclose(testFp); fclose(testFp);
} }
@ -606,8 +584,8 @@ bool CSettings::FindConfig()
{ {
snprintf(ConfigPath, sizeof(ConfigPath), "%s/config/", BootDevice); snprintf(ConfigPath, sizeof(ConfigPath), "%s/config/", BootDevice);
CreateSubfolder(ConfigPath); CreateSubfolder(ConfigPath);
strcat(ConfigPath, "GXGlobal.cfg"); snprintf(CheckPath, sizeof(CheckPath), "%sGXGlobal.cfg", ConfigPath);
testFp = fopen(ConfigPath, "wb"); testFp = fopen(CheckPath, "wb");
found = (testFp != NULL); found = (testFp != NULL);
fclose(testFp); fclose(testFp);
} }
@ -716,7 +694,7 @@ bool CSettings::LoadLanguage(const char *path, int language)
{ {
bool ret = false; bool ret = false;
if (language >= 0 || !path) if (language >= 0 || !path || strlen(path) == 0)
{ {
if (language < 0) return false; if (language < 0) return false;
@ -785,7 +763,11 @@ bool CSettings::LoadLanguage(const char *path, int language)
} }
ret = gettextLoadLanguage(filepath); ret = gettextLoadLanguage(filepath);
if (ret) strncpy(language_path, filepath, sizeof(language_path)); if (ret)
{
strncpy(language_path, filepath, sizeof(language_path));
strcpy(db_language, GetLangCode(language_path));
}
} }
else if (strlen(path) < 3) else if (strlen(path) < 3)
{ {
@ -799,7 +781,6 @@ bool CSettings::LoadLanguage(const char *path, int language)
strncpy(language_path, path, sizeof(language_path)); strncpy(language_path, path, sizeof(language_path));
strcpy(db_language, GetLangCode(language_path)); strcpy(db_language, GetLangCode(language_path));
} }
} }
return ret; return ret;

View File

@ -46,6 +46,7 @@ CustomPathsSM::CustomPathsSM()
Options->SetName(Idx++, tr("Theme Download Path")); Options->SetName(Idx++, tr("Theme Download Path"));
Options->SetName(Idx++, tr("BCA Codes Path")); Options->SetName(Idx++, tr("BCA Codes Path"));
Options->SetName(Idx++, tr("WIP Patches Path")); Options->SetName(Idx++, tr("WIP Patches Path"));
Options->SetName(Idx++, tr("Languagefiles Path"));
SetOptionValues(); SetOptionValues();
} }
@ -92,6 +93,9 @@ void CustomPathsSM::SetOptionValues()
//! Settings: WIP Patches Path //! Settings: WIP Patches Path
Options->SetValue(Idx++, Settings.WipCodepath); Options->SetValue(Idx++, Settings.WipCodepath);
//! Settings: Languagefiles Path
Options->SetValue(Idx++, Settings.languagefiles_path);
} }
int CustomPathsSM::GetMenuInternal() int CustomPathsSM::GetMenuInternal()
@ -215,6 +219,13 @@ int CustomPathsSM::GetMenuInternal()
ChangePath(Settings.WipCodepath, sizeof(Settings.WipCodepath)); ChangePath(Settings.WipCodepath, sizeof(Settings.WipCodepath));
} }
//! Settings: Languagefiles Path
else if (ret == ++Idx)
{
titleTxt->SetText(tr( "Languagefiles Path" ));
ChangePath(Settings.languagefiles_path, sizeof(Settings.languagefiles_path));
}
//! Global set back of the titleTxt after a change //! Global set back of the titleTxt after a change
titleTxt->SetText(tr( "Custom Paths" )); titleTxt->SetText(tr( "Custom Paths" ));
SetOptionValues(); SetOptionValues();

View File

@ -44,17 +44,20 @@ bool IosLoader::IsWaninkokoIOS(s32 ios)
*/ */
s32 IosLoader::LoadAppCios() s32 IosLoader::LoadAppCios()
{ {
u32 activeCios = IOS_GetVersion();
s32 ret = -1; s32 ret = -1;
// We have what we need
if((int) activeCios == Settings.cios)
return 0;
// Unmount fat before reloading IOS. // Unmount fat before reloading IOS.
SDCard_deInit(); SDCard_deInit();
USBDevice_deInit(); USBDevice_deInit();
__io_usbstorage.shutdown(); // libogc usb __io_usbstorage.shutdown();
__io_usbstorage2.shutdown(); // cios usb USB_Deinitialize();
USB_Deinitialize(); // main usb handle
u32 ciosLoadPriority[] = { 250, 249, 222, Settings.cios }; // Descending. u32 ciosLoadPriority[] = { 250, 222, 249, Settings.cios }; // Descending.
u32 activeCios = IOS_GetVersion();
for (u8 i = (sizeof(ciosLoadPriority)/sizeof(ciosLoadPriority[0]))-1; i >= 0; i--) for (u8 i = (sizeof(ciosLoadPriority)/sizeof(ciosLoadPriority[0]))-1; i >= 0; i--)
@ -75,11 +78,6 @@ s32 IosLoader::LoadAppCios()
} }
} }
// Remount devices after reloading IOS.
SDCard_Init();
USBDevice_Init();
Disc_Init();
return ret; return ret;
} }