From 5a3aa0d0aab1d1729f46f01c5b53f72a4a2dbd92 Mon Sep 17 00:00:00 2001 From: Maschell Date: Thu, 6 Apr 2017 12:49:50 +0200 Subject: [PATCH] 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 --- ConfigReader.cpp | 6 ------ ConfigReader.hpp | 1 - ControllerPatcher.cpp | 21 +++++++++++++++------ network/ControllerPatcherNet.cpp | 4 ++-- network/UDPServer.cpp | 2 +- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/ConfigReader.cpp b/ConfigReader.cpp index a9ada37..3b519c1 100644 --- a/ConfigReader.cpp +++ b/ConfigReader.cpp @@ -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(){ diff --git a/ConfigReader.hpp b/ConfigReader.hpp index a94f60e..feecca4 100644 --- a/ConfigReader.hpp +++ b/ConfigReader.hpp @@ -66,7 +66,6 @@ class ConfigReader{ //!Destructor ~ConfigReader(); - int InitSDCard(); void freeFSHandles(); diff --git a/ControllerPatcher.cpp b/ControllerPatcher.cpp index f22b114..001500f 100644 --- a/ControllerPatcher.cpp +++ b/ControllerPatcher.cpp @@ -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(); diff --git a/network/ControllerPatcherNet.cpp b/network/ControllerPatcherNet.cpp index 663c497..9fa01bd 100644 --- a/network/ControllerPatcherNet.cpp +++ b/network/ControllerPatcherNet.cpp @@ -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; } diff --git a/network/UDPServer.cpp b/network/UDPServer.cpp index eeb1315..527f48e 100644 --- a/network/UDPServer.cpp +++ b/network/UDPServer.cpp @@ -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);