Add flatpak support.

This commit is contained in:
Dario
2025-04-26 23:21:27 -03:00
parent d766cf328f
commit 61643779a2
9 changed files with 184 additions and 7 deletions
+2 -1
View File
@@ -608,7 +608,8 @@ int main(int argc, char** argv) {
reset_audio(48000);
// Source controller mappings file
if (SDL_GameControllerAddMappingsFromFile("recompcontrollerdb.txt") < 0) {
std::u8string controller_db_path = (zelda64::get_program_path() / "recompcontrollerdb.txt").u8string();
if (SDL_GameControllerAddMappingsFromFile(reinterpret_cast<const char *>(controller_db_path.c_str())) < 0) {
fprintf(stderr, "Failed to load controller mappings: %s\n", SDL_GetError());
}
+11 -4
View File
@@ -45,13 +45,20 @@ namespace zelda64 {
// MARK: - Public API
std::filesystem::path get_asset_path(const char* asset) {
std::filesystem::path base_path = "";
std::filesystem::path get_program_path() {
#if defined(__APPLE__)
base_path = get_bundle_resource_directory();
return get_bundle_resource_directory();
#elif defined(__linux__)
std::error_code ec;
if (std::filesystem::exists("/.flatpak-info", ec)) {
return "/app/bin";
}
#endif
return "";
}
return base_path / "assets" / asset;
std::filesystem::path get_asset_path(const char* asset) {
return get_program_path() / "assets" / asset;
}
void open_file_dialog(std::function<void(bool success, const std::filesystem::path& path)> callback) {