Now the lib tries to mount the SD Card on each start until it actually works.

This should fix the config reading problems some people have.
Also fixing some compiler warnings
This commit is contained in:
Maschell 2017-04-06 12:49:50 +02:00
parent 7292edb8ce
commit 5a3aa0d0aa
5 changed files with 18 additions and 16 deletions

View File

@ -29,12 +29,6 @@ ConfigReader *ConfigReader::instance = NULL;
ConfigReader::ConfigReader(){
InitOSFunctionPointers();
InitFSFunctionPointers();
int status = 0;
if((status = InitSDCard()) == 0){
if(HID_DEBUG) log_printf("ConfigReader::ConfigReader(): SD Card mounted for controller config!\n");
}else{
log_printf("ConfigReader::ConfigReader() error: SD mounting failed! %d\n",status);
}
}
void ConfigReader::ReadAllConfigs(){

View File

@ -66,7 +66,6 @@ class ConfigReader{
//!Destructor
~ConfigReader();
int InitSDCard();
void freeFSHandles();

View File

@ -419,16 +419,25 @@ bool ControllerPatcher::Init(){
if(HID_DEBUG) log_printf("First time calling the Init\n");
gConfig_done = HID_INIT_DONE;
ControllerPatcher::ResetConfig();
log_print("Reading config files from SD Card\n");
ConfigReader* reader = ConfigReader::getInstance();
reader->ReadAllConfigs();
log_print("Done with reading config files from SD Card\n");
ConfigReader::destroyInstance();
gConfig_done = HID_SDCARD_READ;
}else{
if(HID_DEBUG) log_print("Config already done!\n");
}
if(gConfig_done != HID_SDCARD_READ){
log_print("Reading config files from SD Card\n");
ConfigReader* reader = ConfigReader::getInstance();
int status = 0;
if((status = reader->InitSDCard()) == 0){
if(HID_DEBUG) log_printf("ConfigReader::ConfigReader(): SD Card mounted for controller config!\n");
reader->ReadAllConfigs();
log_print("Done with reading config files from SD Card\n");
gConfig_done = HID_SDCARD_READ;
}else{
log_printf("ConfigReader::ConfigReader() error: SD mounting failed! %d\n",status);
}
ConfigReader::destroyInstance();
}
log_print("Initializing the data for button remapping\n");
InitButtonMapping();

View File

@ -8,7 +8,7 @@ int ControllerPatcherNet::recvwait(int sock, void *buffer, int len) {
ret = recv(sock, buffer, len, 0);
if(ret < 0) return ret;
len -= ret;
buffer += ret;
buffer = (void *)(((char *) buffer) + ret);
}
return 0;
}
@ -38,7 +38,7 @@ int ControllerPatcherNet::sendwait(int sock, const void *buffer, int len) {
ret = send(sock, buffer, len, 0);
if(ret < 0) return ret;
len -= ret;
buffer += ret;
buffer = (void *)(((char *) buffer) + ret);
}
return 0;
}

View File

@ -88,7 +88,7 @@ void UDPServer::DoUDPThreadInternal(){
my_cb_user user;
while(1){
int usingVar = exitThread;
//int usingVar = exitThread;
if(exitThread)break;
memset(buffer,0,MAX_UDP_SIZE);
n = recv(sockfd,buffer,MAX_UDP_SIZE,0);