|
|
@ -238,28 +238,22 @@ void Config::ReadControlValues() { |
|
|
void Config::ReadMotionTouchValues() { |
|
|
void Config::ReadMotionTouchValues() { |
|
|
Settings::values.touch_from_button_maps.clear(); |
|
|
Settings::values.touch_from_button_maps.clear(); |
|
|
int num_touch_from_button_maps = BeginArray(std::string("touch_from_button_maps")); |
|
|
int num_touch_from_button_maps = BeginArray(std::string("touch_from_button_maps")); |
|
|
|
|
|
|
|
|
if (num_touch_from_button_maps > 0) { |
|
|
if (num_touch_from_button_maps > 0) { |
|
|
for (int i = 0; i < num_touch_from_button_maps; ++i) { |
|
|
for (int i = 0; i < num_touch_from_button_maps; ++i) { |
|
|
SetArrayIndex(i); |
|
|
SetArrayIndex(i); |
|
|
|
|
|
|
|
|
Settings::TouchFromButtonMap map; |
|
|
Settings::TouchFromButtonMap map; |
|
|
map.name = ReadStringSetting(std::string("name"), std::string("default")); |
|
|
map.name = ReadStringSetting(std::string("name"), std::string("default")); |
|
|
int const num_touch_maps = BeginArray(std::string("entries")); |
|
|
int const num_touch_maps = BeginArray(std::string("entries")); |
|
|
if (num_touch_maps > 0) { |
|
|
|
|
|
map.buttons.reserve(num_touch_maps); |
|
|
|
|
|
for (int j = 0; j < num_touch_maps; j++) { |
|
|
|
|
|
SetArrayIndex(j); |
|
|
|
|
|
std::string touch_mapping = ReadStringSetting(std::string("bind")); |
|
|
|
|
|
map.buttons.emplace_back(std::move(touch_mapping)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
map.buttons.resize(num_touch_maps); |
|
|
|
|
|
for (int j = 0; j < num_touch_maps; j++) { |
|
|
|
|
|
SetArrayIndex(j); |
|
|
|
|
|
map.buttons[j] = ReadStringSetting(std::string("bind")); |
|
|
} |
|
|
} |
|
|
EndArray(); // entries
|
|
|
EndArray(); // entries
|
|
|
Settings::values.touch_from_button_maps.emplace_back(std::move(map)); |
|
|
Settings::values.touch_from_button_maps.emplace_back(std::move(map)); |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
Settings::values.touch_from_button_maps.emplace_back( |
|
|
|
|
|
Settings::TouchFromButtonMap{"default", {}}); |
|
|
|
|
|
|
|
|
Settings::values.touch_from_button_maps.emplace_back(Settings::TouchFromButtonMap{"default", {}}); |
|
|
num_touch_from_button_maps = 1; |
|
|
num_touch_from_button_maps = 1; |
|
|
} |
|
|
} |
|
|
EndArray(); // touch_from_button_maps
|
|
|
EndArray(); // touch_from_button_maps
|
|
|
@ -501,15 +495,12 @@ void Config::SaveMotionTouchValues() { |
|
|
BeginArray(std::string("touch_from_button_maps")); |
|
|
BeginArray(std::string("touch_from_button_maps")); |
|
|
for (std::size_t p = 0; p < Settings::values.touch_from_button_maps.size(); ++p) { |
|
|
for (std::size_t p = 0; p < Settings::values.touch_from_button_maps.size(); ++p) { |
|
|
SetArrayIndex(int(p)); |
|
|
SetArrayIndex(int(p)); |
|
|
WriteStringSetting(std::string("name"), Settings::values.touch_from_button_maps[p].name, |
|
|
|
|
|
std::make_optional(std::string("default"))); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WriteStringSetting(std::string("name"), Settings::values.touch_from_button_maps[p].name, std::make_optional(std::string("default"))); |
|
|
BeginArray(std::string("entries")); |
|
|
BeginArray(std::string("entries")); |
|
|
for (std::size_t q = 0; q < Settings::values.touch_from_button_maps[p].buttons.size(); |
|
|
for (std::size_t q = 0; q < Settings::values.touch_from_button_maps[p].buttons.size(); |
|
|
++q) { |
|
|
++q) { |
|
|
SetArrayIndex(int(q)); |
|
|
SetArrayIndex(int(q)); |
|
|
WriteStringSetting(std::string("bind"), |
|
|
|
|
|
Settings::values.touch_from_button_maps[p].buttons[q]); |
|
|
|
|
|
|
|
|
WriteStringSetting(std::string("bind"), Settings::values.touch_from_button_maps[p].buttons[q]); |
|
|
} |
|
|
} |
|
|
EndArray(); // entries
|
|
|
EndArray(); // entries
|
|
|
} |
|
|
} |
|
|
@ -638,8 +629,7 @@ void Config::SaveDisabledAddOnValues() { |
|
|
BeginArray(std::string("disabled")); |
|
|
BeginArray(std::string("disabled")); |
|
|
for (std::size_t j = 0; j < elem.second.size(); ++j) { |
|
|
for (std::size_t j = 0; j < elem.second.size(); ++j) { |
|
|
SetArrayIndex(int(j)); |
|
|
SetArrayIndex(int(j)); |
|
|
WriteStringSetting(std::string("d"), elem.second[j], |
|
|
|
|
|
std::make_optional(std::string(""))); |
|
|
|
|
|
|
|
|
WriteStringSetting(std::string("d"), elem.second[j], std::make_optional(std::string(""))); |
|
|
} |
|
|
} |
|
|
EndArray(); // disabled
|
|
|
EndArray(); // disabled
|
|
|
++i; |
|
|
++i; |
|
|
@ -733,21 +723,18 @@ s64 Config::ReadIntegerSetting(const std::string& key, const std::optional<s64> |
|
|
std::string full_key = GetFullKey(key, false); |
|
|
std::string full_key = GetFullKey(key, false); |
|
|
if (!default_value.has_value()) { |
|
|
if (!default_value.has_value()) { |
|
|
try { |
|
|
try { |
|
|
return std::stoll( |
|
|
|
|
|
std::string(config->GetValue(GetSection().c_str(), full_key.c_str(), "0"))); |
|
|
|
|
|
|
|
|
return std::stoll(std::string(config->GetValue(GetSection().c_str(), full_key.c_str(), "0"))); |
|
|
} catch (...) { |
|
|
} catch (...) { |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
s64 result = 0; |
|
|
s64 result = 0; |
|
|
if (config->GetBoolValue(GetSection().c_str(), |
|
|
|
|
|
std::string(full_key).append("\\default").c_str(), true)) { |
|
|
|
|
|
|
|
|
if (config->GetBoolValue(GetSection().c_str(), std::string(full_key).append("\\default").c_str(), true)) { |
|
|
result = default_value.value(); |
|
|
result = default_value.value(); |
|
|
} else { |
|
|
} else { |
|
|
try { |
|
|
try { |
|
|
result = std::stoll(std::string(config->GetValue( |
|
|
|
|
|
GetSection().c_str(), full_key.c_str(), ToString(default_value.value()).c_str()))); |
|
|
|
|
|
|
|
|
result = std::stoll(std::string(config->GetValue(GetSection().c_str(), full_key.c_str(), ToString(default_value.value()).c_str()))); |
|
|
} catch (...) { |
|
|
} catch (...) { |
|
|
result = default_value.value(); |
|
|
result = default_value.value(); |
|
|
} |
|
|
} |
|
|
@ -919,14 +906,12 @@ void Config::ReadSettingGeneric(Settings::BasicSetting* const setting) { |
|
|
|
|
|
|
|
|
bool use_global = true; |
|
|
bool use_global = true; |
|
|
if (setting->Switchable() && !global) { |
|
|
if (setting->Switchable() && !global) { |
|
|
use_global = |
|
|
|
|
|
ReadBooleanSetting(std::string(key).append("\\use_global"), std::make_optional(true)); |
|
|
|
|
|
|
|
|
use_global = ReadBooleanSetting(std::string(key).append("\\use_global"), std::make_optional(true)); |
|
|
setting->SetGlobal(use_global); |
|
|
setting->SetGlobal(use_global); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (global || !use_global) { |
|
|
if (global || !use_global) { |
|
|
const bool is_default = |
|
|
|
|
|
ReadBooleanSetting(std::string(key).append("\\default"), std::make_optional(true)); |
|
|
|
|
|
|
|
|
const bool is_default = ReadBooleanSetting(std::string(key).append("\\default"), std::make_optional(true)); |
|
|
if (!is_default) { |
|
|
if (!is_default) { |
|
|
setting->LoadString(ReadStringSetting(key, default_value)); |
|
|
setting->LoadString(ReadStringSetting(key, default_value)); |
|
|
} else { |
|
|
} else { |
|
|
@ -1051,8 +1036,8 @@ std::string Config::GetFullKey(const std::string& key, bool skipArrayIndex) { |
|
|
int Config::BeginArray(const std::string& array) { |
|
|
int Config::BeginArray(const std::string& array) { |
|
|
array_stack.push_back(ConfigArray{AdjustKey(array), 0, 0}); |
|
|
array_stack.push_back(ConfigArray{AdjustKey(array), 0, 0}); |
|
|
const int size = config->GetLongValue(GetSection().c_str(), GetFullKey(std::string("size"), true).c_str(), 0); |
|
|
const int size = config->GetLongValue(GetSection().c_str(), GetFullKey(std::string("size"), true).c_str(), 0); |
|
|
array_stack.back().size = size; |
|
|
|
|
|
return size; |
|
|
|
|
|
|
|
|
array_stack.back().size = (std::max)(0, size); |
|
|
|
|
|
return array_stack.back().size; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void Config::EndArray() { |
|
|
void Config::EndArray() { |
|
|
@ -1070,7 +1055,7 @@ void Config::EndArray() { |
|
|
// Edge-case where the first array created doesn't have a name
|
|
|
// Edge-case where the first array created doesn't have a name
|
|
|
config->SetValue(GetSection().c_str(), std::string("size").c_str(), ToString(size).c_str()); |
|
|
config->SetValue(GetSection().c_str(), std::string("size").c_str(), ToString(size).c_str()); |
|
|
} else { |
|
|
} else { |
|
|
const auto key = GetFullKey(std::string("size"), true); |
|
|
|
|
|
|
|
|
auto const key = GetFullKey(std::string("size"), true); |
|
|
config->SetValue(GetSection().c_str(), key.c_str(), ToString(size).c_str()); |
|
|
config->SetValue(GetSection().c_str(), key.c_str(), ToString(size).c_str()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|