From 094f47d5b57ca8279ba7fd6021f13ac8210f56bd Mon Sep 17 00:00:00 2001 From: Dario Date: Sat, 3 May 2025 19:20:27 -0300 Subject: [PATCH] Fix define on flatpak, add cwd behavior. --- flatpak/io.github.zelda64recomp.zelda64recomp.json | 2 +- src/main/main.cpp | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/flatpak/io.github.zelda64recomp.zelda64recomp.json b/flatpak/io.github.zelda64recomp.zelda64recomp.json index cf90551..179167a 100644 --- a/flatpak/io.github.zelda64recomp.zelda64recomp.json +++ b/flatpak/io.github.zelda64recomp.zelda64recomp.json @@ -28,7 +28,7 @@ "./N64Recomp us.rev1.toml", "./RSPRecomp aspMain.us.rev1.toml", "./RSPRecomp njpgdspMain.us.rev1.toml", - "cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_MAKE_PROGRAM=ninja -DPATCHES_C_COMPILER=clang -DPATCHES_LD=ld.lld -DRECOMP_FLATPAK -G Ninja -S . -B cmake-build", + "cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_MAKE_PROGRAM=ninja -DPATCHES_C_COMPILER=clang -DPATCHES_LD=ld.lld -DRECOMP_FLATPAK=ON -G Ninja -S . -B cmake-build", "cmake --build cmake-build --config Release --target Zelda64Recompiled --parallel", "rm -rf assets/scss", "mkdir -p /app/bin", diff --git a/src/main/main.cpp b/src/main/main.cpp index d26efe0..720c8aa 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -601,7 +601,14 @@ int main(int argc, char** argv) { // Force wasapi on Windows, as there seems to be some issue with sample queueing with directsound currently. SDL_setenv("SDL_AUDIODRIVER", "wasapi", true); #endif - //printf("Current dir: %ls\n", std::filesystem::current_path().c_str()); + +#if defined(__linux__) && defined(RECOMP_FLATPAK) + // When using Flatpak, applications tend to launch from the home directory by default. + // Mods might use the current working directory to store the data, so we switch it to a directory + // with persistent data storage and write permissions under Flatpak to ensure it works. + std::error_code ec; + std::filesystem::current_path("/var/data", ec); +#endif // Initialize SDL audio and set the output frequency. SDL_InitSubSystem(SDL_INIT_AUDIO);