From 48b19b2588634ffb882bd496c1799bd27e240bdb Mon Sep 17 00:00:00 2001 From: wheremyfoodat <44909372+wheremyfoodat@users.noreply.github.com> Date: Sat, 19 Aug 2023 19:31:40 +0300 Subject: [PATCH] Add SD card configs --- include/config.hpp | 3 +++ src/config.cpp | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/config.hpp b/include/config.hpp index 9c2c9517..8398bb22 100644 --- a/include/config.hpp +++ b/include/config.hpp @@ -9,6 +9,9 @@ struct EmulatorConfig { bool discordRpcEnabled = false; RendererType rendererType = RendererType::OpenGL; + bool sdCardInserted = true; + bool sdWriteProtected = false; + bool chargerPlugged = true; // Default to 3% battery to make users suffer int batteryPercentage = 3; diff --git a/src/config.cpp b/src/config.cpp index 680ce6a8..b262a8a5 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -71,6 +71,16 @@ void EmulatorConfig::load(const std::filesystem::path& path) { batteryPercentage = std::clamp(batteryPercentage, 0, 100); } } + + if (data.contains("SD")) { + auto sdResult = toml::expect(data.at("SD")); + if (sdResult.is_ok()) { + auto sd = sdResult.unwrap(); + + sdCardInserted = toml::find_or(sd, "UseVirtualSD", true); + sdWriteProtected = toml::find_or(sd, "WriteProtectVirtualSD", false); + } + } } void EmulatorConfig::save(const std::filesystem::path& path) { @@ -98,6 +108,9 @@ void EmulatorConfig::save(const std::filesystem::path& path) { data["Battery"]["ChargerPlugged"] = chargerPlugged; data["Battery"]["BatteryPercentage"] = batteryPercentage; + data["SD"]["UseVirtualSD"] = sdCardInserted; + data["SD"]["WriteProtectVirtualSD"] = sdWriteProtected; + std::ofstream file(path, std::ios::out); file << data; file.close();