diff options
Diffstat (limited to 'src/Config.cpp')
-rw-r--r-- | src/Config.cpp | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/Config.cpp b/src/Config.cpp index d9e2b50..be9e53f 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -1,5 +1,5 @@ /* - Copyright 2016-2017 StapleButter + Copyright 2016-2019 StapleButter This file is part of melonDS. @@ -53,6 +53,8 @@ int Threaded3D; int SocketBindAnyAddr; +int SavestateRelocSRAM; + typedef struct { char Name[16]; @@ -75,7 +77,7 @@ ConfigEntry ConfigFile[] = {"Key_Up", 0, &KeyMapping[6], 328, NULL, 0}, {"Key_Down", 0, &KeyMapping[7], 336, NULL, 0}, {"Key_R", 0, &KeyMapping[8], 54, NULL, 0}, - {"Key_L", 0, &KeyMapping[9], 42, NULL, 0}, + {"Key_L", 0, &KeyMapping[9], 86, NULL, 0}, {"Key_X", 0, &KeyMapping[10], 17, NULL, 0}, {"Key_Y", 0, &KeyMapping[11], 30, NULL, 0}, @@ -107,6 +109,8 @@ ConfigEntry ConfigFile[] = {"SockBindAnyAddr", 0, &SocketBindAnyAddr, 0, NULL, 0}, + {"SavStaRelocSRAM", 0, &SavestateRelocSRAM, 1, NULL, 0}, + {"", -1, NULL, 0, NULL, 0} }; @@ -125,7 +129,20 @@ FILE* GetConfigFile(const char* fileName, const char* permissions) SHGetKnownFolderPath(FOLDERID_RoamingAppData, 0, NULL, &appDataPath); if (!appDataPath) return NULL; - CoTaskMemRealloc(appDataPath, (wcslen(appDataPath)+9+strlen(fileName)+1)*sizeof(WCHAR)); + + const WCHAR* appdir = L"\\melonDS\\"; + + int fnlen = MultiByteToWideChar(CP_UTF8, 0, fileName, -1, NULL, 0); + if (fnlen < 1) return NULL; + WCHAR* wfileName = new WCHAR[fnlen]; + int res = MultiByteToWideChar(CP_UTF8, 0, fileName, -1, wfileName, fnlen); + if (res != fnlen) { delete[] wfileName; return NULL; } // checkme? + + int pos = wcslen(appDataPath); + CoTaskMemRealloc(appDataPath, (pos+wcslen(appdir)+fnlen+1)*sizeof(WCHAR)); + + wcscpy(&appDataPath[pos], appdir); pos += wcslen(appdir); + wcscpy(&appDataPath[pos], wfileName); // this will be more than enough WCHAR fatperm[4]; @@ -136,6 +153,7 @@ FILE* GetConfigFile(const char* fileName, const char* permissions) f = _wfopen(appDataPath, fatperm); CoTaskMemFree(appDataPath); + delete[] wfileName; if (f) return f; #else // Now check XDG_CONFIG_HOME |