2019-10-04 15:00:32 +10:00
|
|
|
#include "settings.h"
|
2020-08-23 14:42:53 +10:00
|
|
|
#include "common/make_array.h"
|
2020-01-10 13:31:12 +10:00
|
|
|
#include "common/string_util.h"
|
2021-04-29 02:42:08 +10:00
|
|
|
#include "host_display.h"
|
2020-05-10 00:44:37 +10:00
|
|
|
#include "host_interface.h"
|
settings: devirtualize SettingsInterface
SettingsInterface was a base class with five pure-virtual config-getter
methods, defined in core/settings.h. There has only ever been one
concrete subclass: LibretroSettingsInterface (in libretro/), which
backs every GetXxxValue call with a single retro_environment_callback
to RETRO_ENVIRONMENT_GET_VARIABLE.
The single-impl shape means every si.GetBoolValue / si.GetIntValue /
si.GetStringValue call in Settings::Load and elsewhere goes through a
vtable indirection that resolves to exactly one place. Settings::Load
issues 61 such calls, and runs at boot plus on every libretro
core-options change. The cost per call is small (~2 ns per virtual
dispatch on modern CPUs), so the wall-clock saving is modest, but
the abstraction itself buys nothing - there is no second
implementation, no plan to add one (the core target is libretro-only),
and no use case where the indirection would help.
Drop the base class:
- Remove 'class SettingsInterface' from core/settings.h, along with
its virtual destructor and five pure virtuals.
- Remove the SettingsInterface destructor definition from
core/settings.cpp.
- Make LibretroSettingsInterface a plain class with non-virtual
methods (drop the 'override' keyword and the public-inheritance
base).
- Change Settings::Load's signature from (SettingsInterface&) to
(LibretroSettingsInterface&). The one caller already passes a
LibretroSettingsInterface, so no call site needs to change.
- Forward-declare LibretroSettingsInterface in core/settings.h
(the type only appears as a reference in Load's signature) and
include the libretro header from settings.cpp where the
member function calls actually have to see the definition.
The forward-declaration plus include-from-cpp pattern keeps
core/settings.h free of libretro headers - a header-level layering
nicety. The cpp-level dependency is an existing pattern (multiple
core/ TUs already include libretro/ headers - gpu_hw_d3d11.cpp,
gpu_hw_opengl.cpp, gpu_hw_vulkan.cpp, texture_replacements.cpp).
Linux x64 build still warning-clean. .so size drops from 8048432
to 8047800 bytes (-632) from removing the SettingsInterface vtable,
its typeinfo, the virtual destructor, and the indirect-call sites
in Settings::Load. 25 retro_* exports unchanged. Behaviour is
identical (same calls, same arguments, just direct now).
2026-05-08 12:13:15 +00:00
|
|
|
#include "libretro/libretro_settings_interface.h"
|
2020-06-04 02:15:27 +10:00
|
|
|
#include <algorithm>
|
2020-06-08 02:53:53 +10:00
|
|
|
#include <array>
|
2020-11-02 00:38:54 +10:00
|
|
|
#include <cctype>
|
2020-09-29 23:29:28 +10:00
|
|
|
#include <numeric>
|
2019-11-07 01:43:51 +10:00
|
|
|
|
2020-07-31 17:09:18 +10:00
|
|
|
Settings g_settings;
|
|
|
|
|
|
2020-07-01 00:33:45 +10:00
|
|
|
const char* SettingInfo::StringDefaultValue() const
|
|
|
|
|
{
|
|
|
|
|
return default_value ? default_value : "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SettingInfo::BooleanDefaultValue() const
|
|
|
|
|
{
|
|
|
|
|
return default_value ? StringUtil::FromChars<bool>(default_value).value_or(false) : false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
s32 SettingInfo::IntegerDefaultValue() const
|
|
|
|
|
{
|
|
|
|
|
return default_value ? StringUtil::FromChars<s32>(default_value).value_or(0) : 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
s32 SettingInfo::IntegerMinValue() const
|
|
|
|
|
{
|
|
|
|
|
static constexpr s32 fallback_value = std::numeric_limits<s32>::min();
|
|
|
|
|
return min_value ? StringUtil::FromChars<s32>(min_value).value_or(fallback_value) : fallback_value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
s32 SettingInfo::IntegerMaxValue() const
|
|
|
|
|
{
|
|
|
|
|
static constexpr s32 fallback_value = std::numeric_limits<s32>::max();
|
|
|
|
|
return max_value ? StringUtil::FromChars<s32>(max_value).value_or(fallback_value) : fallback_value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
s32 SettingInfo::IntegerStepValue() const
|
|
|
|
|
{
|
|
|
|
|
static constexpr s32 fallback_value = 1;
|
|
|
|
|
return step_value ? StringUtil::FromChars<s32>(step_value).value_or(fallback_value) : fallback_value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float SettingInfo::FloatDefaultValue() const
|
|
|
|
|
{
|
|
|
|
|
return default_value ? StringUtil::FromChars<float>(default_value).value_or(0.0f) : 0.0f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float SettingInfo::FloatMinValue() const
|
|
|
|
|
{
|
|
|
|
|
static constexpr float fallback_value = std::numeric_limits<float>::min();
|
|
|
|
|
return min_value ? StringUtil::FromChars<float>(min_value).value_or(fallback_value) : fallback_value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float SettingInfo::FloatMaxValue() const
|
|
|
|
|
{
|
|
|
|
|
static constexpr float fallback_value = std::numeric_limits<float>::max();
|
|
|
|
|
return max_value ? StringUtil::FromChars<float>(max_value).value_or(fallback_value) : fallback_value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float SettingInfo::FloatStepValue() const
|
|
|
|
|
{
|
|
|
|
|
static constexpr float fallback_value = 0.1f;
|
|
|
|
|
return step_value ? StringUtil::FromChars<float>(step_value).value_or(fallback_value) : fallback_value;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-07 01:43:51 +10:00
|
|
|
Settings::Settings() = default;
|
|
|
|
|
|
2020-06-04 02:15:27 +10:00
|
|
|
bool Settings::HasAnyPerGameMemoryCards() const
|
|
|
|
|
{
|
|
|
|
|
return std::any_of(memory_card_types.begin(), memory_card_types.end(), [](MemoryCardType t) {
|
|
|
|
|
return (t == MemoryCardType::PerGame || t == MemoryCardType::PerGameTitle);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-01 14:59:59 -08:00
|
|
|
std::array<TinyString, NUM_CONTROLLER_AND_CARD_PORTS> Settings::GeneratePortLabels() const
|
2021-01-20 23:59:40 -08:00
|
|
|
{
|
2021-03-01 14:59:59 -08:00
|
|
|
static constexpr std::array<std::array<bool, NUM_MULTITAPS>, static_cast<size_t>(MultitapMode::Count)>
|
|
|
|
|
multitap_enabled_on_port = {{{false, false}, {true, false}, {false, true}, {true, true}}};
|
2021-01-20 23:59:40 -08:00
|
|
|
|
2021-03-01 14:59:59 -08:00
|
|
|
std::array<TinyString, NUM_CONTROLLER_AND_CARD_PORTS> labels;
|
2021-01-20 23:59:40 -08:00
|
|
|
|
2021-03-01 14:59:59 -08:00
|
|
|
u32 logical_port = 0;
|
|
|
|
|
for (u32 physical_port = 0; physical_port < NUM_MULTITAPS; physical_port++)
|
|
|
|
|
{
|
|
|
|
|
if (multitap_enabled_on_port[static_cast<size_t>(multitap_mode)][physical_port])
|
|
|
|
|
{
|
|
|
|
|
for (u32 i = 0; i < 4; i++)
|
|
|
|
|
{
|
|
|
|
|
labels[logical_port] = TinyString::FromFormat("Port %u%c", physical_port + 1u, 'A' + i);
|
|
|
|
|
logical_port++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
labels[logical_port] = TinyString::FromFormat("Port %u", physical_port + 1u);
|
|
|
|
|
logical_port++;
|
2021-01-20 23:59:40 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-01 14:59:59 -08:00
|
|
|
return labels;
|
2021-01-20 23:59:40 -08:00
|
|
|
}
|
|
|
|
|
|
2020-09-29 23:29:28 +10:00
|
|
|
void Settings::CPUOverclockPercentToFraction(u32 percent, u32* numerator, u32* denominator)
|
|
|
|
|
{
|
|
|
|
|
const u32 percent_gcd = std::gcd(percent, 100);
|
|
|
|
|
*numerator = percent / percent_gcd;
|
|
|
|
|
*denominator = 100u / percent_gcd;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
u32 Settings::CPUOverclockFractionToPercent(u32 numerator, u32 denominator)
|
|
|
|
|
{
|
|
|
|
|
return (numerator * 100u) / denominator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Settings::SetCPUOverclockPercent(u32 percent)
|
|
|
|
|
{
|
|
|
|
|
CPUOverclockPercentToFraction(percent, &cpu_overclock_numerator, &cpu_overclock_denominator);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
u32 Settings::GetCPUOverclockPercent() const
|
|
|
|
|
{
|
|
|
|
|
return CPUOverclockFractionToPercent(cpu_overclock_numerator, cpu_overclock_denominator);
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-30 23:46:35 +10:00
|
|
|
void Settings::UpdateOverclockActive()
|
|
|
|
|
{
|
|
|
|
|
cpu_overclock_active = (cpu_overclock_enable && (cpu_overclock_numerator != 1 || cpu_overclock_denominator != 1));
|
|
|
|
|
}
|
|
|
|
|
|
settings: devirtualize SettingsInterface
SettingsInterface was a base class with five pure-virtual config-getter
methods, defined in core/settings.h. There has only ever been one
concrete subclass: LibretroSettingsInterface (in libretro/), which
backs every GetXxxValue call with a single retro_environment_callback
to RETRO_ENVIRONMENT_GET_VARIABLE.
The single-impl shape means every si.GetBoolValue / si.GetIntValue /
si.GetStringValue call in Settings::Load and elsewhere goes through a
vtable indirection that resolves to exactly one place. Settings::Load
issues 61 such calls, and runs at boot plus on every libretro
core-options change. The cost per call is small (~2 ns per virtual
dispatch on modern CPUs), so the wall-clock saving is modest, but
the abstraction itself buys nothing - there is no second
implementation, no plan to add one (the core target is libretro-only),
and no use case where the indirection would help.
Drop the base class:
- Remove 'class SettingsInterface' from core/settings.h, along with
its virtual destructor and five pure virtuals.
- Remove the SettingsInterface destructor definition from
core/settings.cpp.
- Make LibretroSettingsInterface a plain class with non-virtual
methods (drop the 'override' keyword and the public-inheritance
base).
- Change Settings::Load's signature from (SettingsInterface&) to
(LibretroSettingsInterface&). The one caller already passes a
LibretroSettingsInterface, so no call site needs to change.
- Forward-declare LibretroSettingsInterface in core/settings.h
(the type only appears as a reference in Load's signature) and
include the libretro header from settings.cpp where the
member function calls actually have to see the definition.
The forward-declaration plus include-from-cpp pattern keeps
core/settings.h free of libretro headers - a header-level layering
nicety. The cpp-level dependency is an existing pattern (multiple
core/ TUs already include libretro/ headers - gpu_hw_d3d11.cpp,
gpu_hw_opengl.cpp, gpu_hw_vulkan.cpp, texture_replacements.cpp).
Linux x64 build still warning-clean. .so size drops from 8048432
to 8047800 bytes (-632) from removing the SettingsInterface vtable,
its typeinfo, the virtual destructor, and the indirect-call sites
in Settings::Load. 25 retro_* exports unchanged. Behaviour is
identical (same calls, same arguments, just direct now).
2026-05-08 12:13:15 +00:00
|
|
|
void Settings::Load(LibretroSettingsInterface& si)
|
2019-11-07 01:43:51 +10:00
|
|
|
{
|
2019-12-30 21:22:22 +10:00
|
|
|
region =
|
2021-05-26 17:59:09 +10:00
|
|
|
ParseConsoleRegionName(
|
|
|
|
|
si.GetStringValue("Console", "Region", Settings::GetConsoleRegionName(Settings::DEFAULT_CONSOLE_REGION)).c_str())
|
|
|
|
|
.value_or(DEFAULT_CONSOLE_REGION);
|
2021-05-02 20:46:48 +10:00
|
|
|
enable_8mb_ram = si.GetBoolValue("Console", "Enable8MBRAM", false);
|
2019-11-07 01:43:51 +10:00
|
|
|
|
2020-08-21 00:08:40 +10:00
|
|
|
apply_game_settings = si.GetBoolValue("Main", "ApplyGameSettings", true);
|
2021-01-26 02:48:40 +10:00
|
|
|
runahead_frames = static_cast<u32>(si.GetIntValue("Main", "RunaheadFrameCount", 0));
|
2019-11-16 20:27:30 +10:00
|
|
|
|
2023-10-01 00:22:22 +02:00
|
|
|
audio_fast_hook = si.GetBoolValue("Audio", "FastHook", true);
|
|
|
|
|
|
2020-07-01 00:33:53 +10:00
|
|
|
cpu_execution_mode =
|
|
|
|
|
ParseCPUExecutionMode(
|
|
|
|
|
si.GetStringValue("CPU", "ExecutionMode", GetCPUExecutionModeName(DEFAULT_CPU_EXECUTION_MODE)).c_str())
|
|
|
|
|
.value_or(DEFAULT_CPU_EXECUTION_MODE);
|
2023-03-17 01:11:54 +01:00
|
|
|
|
2021-05-22 14:55:25 +10:00
|
|
|
cpu_recompiler_block_linking = si.GetBoolValue("CPU", "RecompilerBlockLinking", true);
|
2020-08-29 22:07:33 +10:00
|
|
|
cpu_recompiler_icache = si.GetBoolValue("CPU", "RecompilerICache", false);
|
2020-11-23 01:06:25 +10:00
|
|
|
cpu_fastmem_mode = ParseCPUFastmemMode(
|
|
|
|
|
si.GetStringValue("CPU", "FastmemMode", GetCPUFastmemModeName(DEFAULT_CPU_FASTMEM_MODE)).c_str())
|
|
|
|
|
.value_or(DEFAULT_CPU_FASTMEM_MODE);
|
2021-12-26 00:05:20 +01:00
|
|
|
cpu_fastmem_rewrite = si.GetBoolValue("CPU", "FastmemRewrite", false);
|
2019-11-16 20:50:11 +10:00
|
|
|
|
2020-02-15 10:21:57 +09:00
|
|
|
gpu_renderer = ParseRendererName(si.GetStringValue("GPU", "Renderer", GetRendererName(DEFAULT_GPU_RENDERER)).c_str())
|
|
|
|
|
.value_or(DEFAULT_GPU_RENDERER);
|
2019-12-30 21:22:22 +10:00
|
|
|
gpu_resolution_scale = static_cast<u32>(si.GetIntValue("GPU", "ResolutionScale", 1));
|
2020-11-21 13:32:58 +10:00
|
|
|
gpu_use_thread = si.GetBoolValue("GPU", "UseThread", true);
|
2021-05-19 13:43:49 +10:00
|
|
|
gpu_use_software_renderer_for_readbacks = si.GetBoolValue("GPU", "UseSoftwareRendererForReadbacks", false);
|
2021-05-26 17:59:09 +10:00
|
|
|
gpu_true_color = si.GetBoolValue("GPU", "TrueColor", false);
|
2020-03-01 00:05:31 +10:00
|
|
|
gpu_scaled_dithering = si.GetBoolValue("GPU", "ScaledDithering", false);
|
2020-09-11 22:20:19 +10:00
|
|
|
gpu_texture_filter =
|
|
|
|
|
ParseTextureFilterName(
|
|
|
|
|
si.GetStringValue("GPU", "TextureFilter", GetTextureFilterName(DEFAULT_GPU_TEXTURE_FILTER)).c_str())
|
|
|
|
|
.value_or(DEFAULT_GPU_TEXTURE_FILTER);
|
2020-12-30 16:26:20 +10:00
|
|
|
gpu_downsample_mode =
|
|
|
|
|
ParseDownsampleModeName(
|
|
|
|
|
si.GetStringValue("GPU", "DownsampleMode", GetDownsampleModeName(DEFAULT_GPU_DOWNSAMPLE_MODE)).c_str())
|
|
|
|
|
.value_or(DEFAULT_GPU_DOWNSAMPLE_MODE);
|
2021-01-28 23:52:23 +10:00
|
|
|
gpu_disable_interlacing = si.GetBoolValue("GPU", "DisableInterlacing", true);
|
2020-04-10 13:34:12 +10:00
|
|
|
gpu_force_ntsc_timings = si.GetBoolValue("GPU", "ForceNTSCTimings", false);
|
2020-07-18 00:25:08 +10:00
|
|
|
gpu_widescreen_hack = si.GetBoolValue("GPU", "WidescreenHack", false);
|
2020-11-03 14:17:51 +10:00
|
|
|
gpu_24bit_chroma_smoothing = si.GetBoolValue("GPU", "ChromaSmoothing24Bit", false);
|
2020-08-02 00:25:07 +10:00
|
|
|
gpu_pgxp_enable = si.GetBoolValue("GPU", "PGXPEnable", false);
|
|
|
|
|
gpu_pgxp_culling = si.GetBoolValue("GPU", "PGXPCulling", true);
|
|
|
|
|
gpu_pgxp_texture_correction = si.GetBoolValue("GPU", "PGXPTextureCorrection", true);
|
2023-02-09 14:04:28 +01:00
|
|
|
gpu_pgxp_color_correction = si.GetBoolValue("GPU", "PGXPColorCorrection", false);
|
2020-08-02 00:25:07 +10:00
|
|
|
gpu_pgxp_vertex_cache = si.GetBoolValue("GPU", "PGXPVertexCache", false);
|
2020-08-19 23:26:57 +10:00
|
|
|
gpu_pgxp_cpu = si.GetBoolValue("GPU", "PGXPCPU", false);
|
2020-10-10 00:07:07 +10:00
|
|
|
gpu_pgxp_preserve_proj_fp = si.GetBoolValue("GPU", "PGXPPreserveProjFP", false);
|
2020-11-27 00:02:13 +10:00
|
|
|
gpu_pgxp_tolerance = si.GetFloatValue("GPU", "PGXPTolerance", -1.0f);
|
2020-12-23 01:10:49 +10:00
|
|
|
gpu_pgxp_depth_buffer = si.GetBoolValue("GPU", "PGXPDepthBuffer", false);
|
|
|
|
|
SetPGXPDepthClearThreshold(si.GetFloatValue("GPU", "PGXPDepthClearThreshold", DEFAULT_GPU_PGXP_DEPTH_THRESHOLD));
|
2019-11-23 20:22:09 +10:00
|
|
|
|
2020-07-01 00:33:53 +10:00
|
|
|
display_crop_mode =
|
|
|
|
|
ParseDisplayCropMode(
|
|
|
|
|
si.GetStringValue("Display", "CropMode", GetDisplayCropModeName(DEFAULT_DISPLAY_CROP_MODE)).c_str())
|
|
|
|
|
.value_or(DEFAULT_DISPLAY_CROP_MODE);
|
2020-04-10 15:12:16 +10:00
|
|
|
display_aspect_ratio =
|
|
|
|
|
ParseDisplayAspectRatio(
|
2020-07-01 00:33:53 +10:00
|
|
|
si.GetStringValue("Display", "AspectRatio", GetDisplayAspectRatioName(DEFAULT_DISPLAY_ASPECT_RATIO)).c_str())
|
|
|
|
|
.value_or(DEFAULT_DISPLAY_ASPECT_RATIO);
|
2021-04-29 02:42:08 +10:00
|
|
|
display_aspect_ratio_custom_numerator = static_cast<u16>(
|
|
|
|
|
std::clamp<int>(si.GetIntValue("Display", "CustomAspectRatioNumerator", 4), 1, std::numeric_limits<u16>::max()));
|
|
|
|
|
display_aspect_ratio_custom_denominator = static_cast<u16>(
|
|
|
|
|
std::clamp<int>(si.GetIntValue("Display", "CustomAspectRatioDenominator", 3), 1, std::numeric_limits<u16>::max()));
|
2020-09-26 15:11:45 +10:00
|
|
|
display_force_4_3_for_24bit = si.GetBoolValue("Display", "Force4_3For24Bit", false);
|
2020-08-20 21:30:11 +10:00
|
|
|
display_active_start_offset = static_cast<s16>(si.GetIntValue("Display", "ActiveStartOffset", 0));
|
|
|
|
|
display_active_end_offset = static_cast<s16>(si.GetIntValue("Display", "ActiveEndOffset", 0));
|
2020-12-03 22:31:21 +10:00
|
|
|
display_line_start_offset = static_cast<s8>(si.GetIntValue("Display", "LineStartOffset", 0));
|
|
|
|
|
display_line_end_offset = static_cast<s8>(si.GetIntValue("Display", "LineEndOffset", 0));
|
2020-03-21 23:05:04 +10:00
|
|
|
display_show_osd_messages = si.GetBoolValue("Display", "ShowOSDMessages", true);
|
2019-11-07 01:43:51 +10:00
|
|
|
|
2021-07-12 21:08:04 +10:00
|
|
|
cdrom_readahead_sectors = static_cast<u8>(si.GetIntValue("CDROM", "ReadaheadSectors", DEFAULT_CDROM_READAHEAD_SECTORS));
|
2021-05-26 17:59:09 +10:00
|
|
|
cdrom_region_check = si.GetBoolValue("CDROM", "RegionCheck", false);
|
2020-07-22 00:03:22 +10:00
|
|
|
cdrom_load_image_to_ram = si.GetBoolValue("CDROM", "LoadImageToRAM", false);
|
2022-01-23 14:13:56 +02:00
|
|
|
cdrom_precache_chd = si.GetBoolValue("CDROM", "PreCacheCHD", false);
|
2020-10-03 12:24:03 +10:00
|
|
|
cdrom_mute_cd_audio = si.GetBoolValue("CDROM", "MuteCDAudio", false);
|
2020-10-05 00:05:14 +10:00
|
|
|
cdrom_read_speedup = si.GetIntValue("CDROM", "ReadSpeedup", 1);
|
2021-05-23 13:35:10 +10:00
|
|
|
cdrom_seek_speedup = si.GetIntValue("CDROM", "SeekSpeedup", 1);
|
2020-02-22 00:19:10 +09:00
|
|
|
|
2024-07-03 03:53:32 +02:00
|
|
|
use_old_mdec_routines = si.GetBoolValue("Hacks", "OldMDECRoutines", true);
|
2023-02-09 14:04:28 +01:00
|
|
|
|
2021-04-08 03:20:25 +10:00
|
|
|
bios_patch_fast_boot = si.GetBoolValue("BIOS", "PatchFastBoot", DEFAULT_FAST_BOOT_VALUE);
|
2019-11-07 01:43:51 +10:00
|
|
|
|
2022-10-09 22:27:47 +02:00
|
|
|
controller_analog_combo = si.GetIntValue("Controller", "AnalogCombo", 1);
|
2023-01-22 04:17:01 +01:00
|
|
|
controller_enable_rumble = si.GetBoolValue("Controller", "EnableRumble", true);
|
2023-08-13 01:48:54 +02:00
|
|
|
controller_show_crosshair = si.GetBoolValue("Controller", "ShowCrosshair", true);
|
2022-10-09 22:27:47 +02:00
|
|
|
|
2022-12-23 20:09:39 +01:00
|
|
|
memory_card_types[0] =
|
|
|
|
|
ParseMemoryCardTypeName(
|
|
|
|
|
si.GetStringValue("MemoryCards", "Card1Type", GetMemoryCardTypeName(DEFAULT_MEMORY_CARD_1_TYPE)).c_str())
|
|
|
|
|
.value_or(DEFAULT_MEMORY_CARD_1_TYPE);
|
2020-04-27 16:15:38 +10:00
|
|
|
memory_card_types[1] =
|
|
|
|
|
ParseMemoryCardTypeName(
|
2020-07-01 00:33:53 +10:00
|
|
|
si.GetStringValue("MemoryCards", "Card2Type", GetMemoryCardTypeName(DEFAULT_MEMORY_CARD_2_TYPE)).c_str())
|
|
|
|
|
.value_or(DEFAULT_MEMORY_CARD_2_TYPE);
|
2023-03-17 01:11:54 +01:00
|
|
|
|
2020-08-15 20:38:54 +10:00
|
|
|
memory_card_use_playlist_title = si.GetBoolValue("MemoryCards", "UsePlaylistTitle", true);
|
2020-02-04 15:22:48 +09:00
|
|
|
|
2021-01-20 23:59:40 -08:00
|
|
|
multitap_mode =
|
|
|
|
|
ParseMultitapModeName(
|
|
|
|
|
si.GetStringValue("ControllerPorts", "MultitapMode", GetMultitapModeName(DEFAULT_MULTITAP_MODE)).c_str())
|
|
|
|
|
.value_or(DEFAULT_MULTITAP_MODE);
|
|
|
|
|
|
2020-07-01 00:33:53 +10:00
|
|
|
log_level = ParseLogLevelName(si.GetStringValue("Logging", "LogLevel", GetLogLevelName(DEFAULT_LOG_LEVEL)).c_str())
|
|
|
|
|
.value_or(DEFAULT_LOG_LEVEL);
|
2020-05-01 00:58:32 +10:00
|
|
|
|
2020-12-25 18:02:38 +10:00
|
|
|
texture_replacements.enable_vram_write_replacements =
|
|
|
|
|
si.GetBoolValue("TextureReplacements", "EnableVRAMWriteReplacements", false);
|
|
|
|
|
texture_replacements.preload_textures = si.GetBoolValue("TextureReplacements", "PreloadTextures", false);
|
2019-11-07 01:43:51 +10:00
|
|
|
}
|
|
|
|
|
|
2023-05-08 02:24:13 -04:00
|
|
|
static std::array<const char*, static_cast<std::size_t>(LogLevel::Count)> s_log_level_names = {
|
2020-12-09 01:03:23 +10:00
|
|
|
{"None", "Error", "Warning", "Perf", "Info", "Verbose", "Dev", "Profile", "Debug", "Trace"}};
|
2020-05-01 00:58:32 +10:00
|
|
|
|
2023-05-08 02:24:13 -04:00
|
|
|
std::optional<LogLevel> Settings::ParseLogLevelName(const char* str)
|
2020-05-01 00:58:32 +10:00
|
|
|
{
|
|
|
|
|
int index = 0;
|
|
|
|
|
for (const char* name : s_log_level_names)
|
|
|
|
|
{
|
|
|
|
|
if (StringUtil::Strcasecmp(name, str) == 0)
|
2023-05-08 02:24:13 -04:00
|
|
|
return static_cast<LogLevel>(index);
|
2020-05-01 00:58:32 +10:00
|
|
|
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return std::nullopt;
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-08 02:24:13 -04:00
|
|
|
const char* Settings::GetLogLevelName(LogLevel level)
|
2020-05-01 00:58:32 +10:00
|
|
|
{
|
|
|
|
|
return s_log_level_names[static_cast<int>(level)];
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-16 15:27:57 +10:00
|
|
|
static std::array<const char*, 4> s_console_region_names = {{"Auto", "NTSC-J", "NTSC-U", "PAL"}};
|
|
|
|
|
static std::array<const char*, 4> s_console_region_display_names = {
|
2020-08-22 13:01:52 +10:00
|
|
|
{TRANSLATABLE("ConsoleRegion", "Auto-Detect"), TRANSLATABLE("ConsoleRegion", "NTSC-J (Japan)"),
|
2020-09-09 15:54:07 +09:00
|
|
|
TRANSLATABLE("ConsoleRegion", "NTSC-U/C (US, Canada)"), TRANSLATABLE("ConsoleRegion", "PAL (Europe, Australia)")}};
|
2019-11-16 15:27:57 +10:00
|
|
|
|
|
|
|
|
std::optional<ConsoleRegion> Settings::ParseConsoleRegionName(const char* str)
|
|
|
|
|
{
|
|
|
|
|
int index = 0;
|
|
|
|
|
for (const char* name : s_console_region_names)
|
|
|
|
|
{
|
2020-01-10 13:31:12 +10:00
|
|
|
if (StringUtil::Strcasecmp(name, str) == 0)
|
2019-11-16 15:27:57 +10:00
|
|
|
return static_cast<ConsoleRegion>(index);
|
|
|
|
|
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return std::nullopt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char* Settings::GetConsoleRegionName(ConsoleRegion region)
|
|
|
|
|
{
|
|
|
|
|
return s_console_region_names[static_cast<int>(region)];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char* Settings::GetConsoleRegionDisplayName(ConsoleRegion region)
|
|
|
|
|
{
|
|
|
|
|
return s_console_region_display_names[static_cast<int>(region)];
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-12 13:51:29 +10:00
|
|
|
static std::array<const char*, 4> s_disc_region_names = {{"NTSC-J", "NTSC-U", "PAL", "Other"}};
|
|
|
|
|
static std::array<const char*, 4> s_disc_region_display_names = {
|
2020-09-09 15:54:07 +09:00
|
|
|
{TRANSLATABLE("DiscRegion", "NTSC-J (Japan)"), TRANSLATABLE("DiscRegion", "NTSC-U/C (US, Canada)"),
|
2020-08-22 13:01:52 +10:00
|
|
|
TRANSLATABLE("DiscRegion", "PAL (Europe, Australia)"), TRANSLATABLE("DiscRegion", "Other")}};
|
2020-03-12 13:51:29 +10:00
|
|
|
|
|
|
|
|
std::optional<DiscRegion> Settings::ParseDiscRegionName(const char* str)
|
|
|
|
|
{
|
|
|
|
|
int index = 0;
|
2020-05-16 20:01:19 +10:00
|
|
|
for (const char* name : s_disc_region_names)
|
2020-03-12 13:51:29 +10:00
|
|
|
{
|
|
|
|
|
if (StringUtil::Strcasecmp(name, str) == 0)
|
|
|
|
|
return static_cast<DiscRegion>(index);
|
|
|
|
|
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return std::nullopt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char* Settings::GetDiscRegionName(DiscRegion region)
|
|
|
|
|
{
|
|
|
|
|
return s_disc_region_names[static_cast<int>(region)];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char* Settings::GetDiscRegionDisplayName(DiscRegion region)
|
|
|
|
|
{
|
|
|
|
|
return s_disc_region_display_names[static_cast<int>(region)];
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-23 20:22:09 +10:00
|
|
|
static std::array<const char*, 3> s_cpu_execution_mode_names = {{"Interpreter", "CachedInterpreter", "Recompiler"}};
|
|
|
|
|
static std::array<const char*, 3> s_cpu_execution_mode_display_names = {
|
2021-02-11 02:17:25 +10:00
|
|
|
{TRANSLATABLE("CPUExecutionMode", "Interpreter (Slowest)"),
|
2020-08-23 14:42:53 +10:00
|
|
|
TRANSLATABLE("CPUExecutionMode", "Cached Interpreter (Faster)"),
|
2020-08-22 13:01:52 +10:00
|
|
|
TRANSLATABLE("CPUExecutionMode", "Recompiler (Fastest)")}};
|
2019-11-23 20:22:09 +10:00
|
|
|
|
|
|
|
|
std::optional<CPUExecutionMode> Settings::ParseCPUExecutionMode(const char* str)
|
|
|
|
|
{
|
|
|
|
|
u8 index = 0;
|
|
|
|
|
for (const char* name : s_cpu_execution_mode_names)
|
|
|
|
|
{
|
2020-01-10 13:31:12 +10:00
|
|
|
if (StringUtil::Strcasecmp(name, str) == 0)
|
2019-11-23 20:22:09 +10:00
|
|
|
return static_cast<CPUExecutionMode>(index);
|
|
|
|
|
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return std::nullopt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char* Settings::GetCPUExecutionModeName(CPUExecutionMode mode)
|
|
|
|
|
{
|
|
|
|
|
return s_cpu_execution_mode_names[static_cast<u8>(mode)];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char* Settings::GetCPUExecutionModeDisplayName(CPUExecutionMode mode)
|
|
|
|
|
{
|
|
|
|
|
return s_cpu_execution_mode_display_names[static_cast<u8>(mode)];
|
|
|
|
|
}
|
2020-11-23 01:06:25 +10:00
|
|
|
|
|
|
|
|
static std::array<const char*, static_cast<u32>(CPUFastmemMode::Count)> s_cpu_fastmem_mode_names = {
|
|
|
|
|
{"Disabled", "MMap", "LUT"}};
|
|
|
|
|
static std::array<const char*, static_cast<u32>(CPUFastmemMode::Count)> s_cpu_fastmem_mode_display_names = {
|
|
|
|
|
{TRANSLATABLE("CPUFastmemMode", "Disabled (Slowest)"),
|
|
|
|
|
TRANSLATABLE("CPUFastmemMode", "MMap (Hardware, Fastest, 64-Bit Only)"),
|
|
|
|
|
TRANSLATABLE("CPUFastmemMode", "LUT (Faster)")}};
|
|
|
|
|
|
|
|
|
|
std::optional<CPUFastmemMode> Settings::ParseCPUFastmemMode(const char* str)
|
|
|
|
|
{
|
|
|
|
|
u8 index = 0;
|
|
|
|
|
for (const char* name : s_cpu_fastmem_mode_names)
|
|
|
|
|
{
|
|
|
|
|
if (StringUtil::Strcasecmp(name, str) == 0)
|
|
|
|
|
return static_cast<CPUFastmemMode>(index);
|
|
|
|
|
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return std::nullopt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char* Settings::GetCPUFastmemModeName(CPUFastmemMode mode)
|
|
|
|
|
{
|
|
|
|
|
return s_cpu_fastmem_mode_names[static_cast<u8>(mode)];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char* Settings::GetCPUFastmemModeDisplayName(CPUFastmemMode mode)
|
|
|
|
|
{
|
|
|
|
|
return s_cpu_fastmem_mode_display_names[static_cast<u8>(mode)];
|
|
|
|
|
}
|
2019-11-23 20:22:09 +10:00
|
|
|
|
2020-08-23 14:42:53 +10:00
|
|
|
static constexpr auto s_gpu_renderer_names = make_array(
|
2021-06-28 20:16:48 +10:00
|
|
|
#ifdef _WIN32
|
2020-01-07 18:54:39 +10:00
|
|
|
"D3D11",
|
2021-07-10 21:37:08 +10:00
|
|
|
"D3D12",
|
2020-01-07 18:54:39 +10:00
|
|
|
#endif
|
2020-08-23 14:42:53 +10:00
|
|
|
"Vulkan", "OpenGL", "Software");
|
|
|
|
|
static constexpr auto s_gpu_renderer_display_names = make_array(
|
2021-06-28 20:16:48 +10:00
|
|
|
#ifdef _WIN32
|
2020-08-22 13:01:52 +10:00
|
|
|
TRANSLATABLE("GPURenderer", "Hardware (D3D11)"),
|
2021-07-10 21:37:08 +10:00
|
|
|
TRANSLATABLE("GPURenderer", "Hardware (D3D12)"),
|
2020-01-07 18:54:39 +10:00
|
|
|
#endif
|
2020-08-22 13:01:52 +10:00
|
|
|
TRANSLATABLE("GPURenderer", "Hardware (Vulkan)"), TRANSLATABLE("GPURenderer", "Hardware (OpenGL)"),
|
2020-08-23 14:42:53 +10:00
|
|
|
TRANSLATABLE("GPURenderer", "Software"));
|
2019-11-07 01:43:51 +10:00
|
|
|
|
2019-11-16 15:27:57 +10:00
|
|
|
std::optional<GPURenderer> Settings::ParseRendererName(const char* str)
|
2019-11-07 01:43:51 +10:00
|
|
|
{
|
|
|
|
|
int index = 0;
|
|
|
|
|
for (const char* name : s_gpu_renderer_names)
|
|
|
|
|
{
|
2020-01-10 13:31:12 +10:00
|
|
|
if (StringUtil::Strcasecmp(name, str) == 0)
|
2019-11-07 01:43:51 +10:00
|
|
|
return static_cast<GPURenderer>(index);
|
|
|
|
|
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return std::nullopt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char* Settings::GetRendererName(GPURenderer renderer)
|
|
|
|
|
{
|
|
|
|
|
return s_gpu_renderer_names[static_cast<int>(renderer)];
|
|
|
|
|
}
|
2019-11-07 23:52:19 +10:00
|
|
|
|
|
|
|
|
const char* Settings::GetRendererDisplayName(GPURenderer renderer)
|
|
|
|
|
{
|
|
|
|
|
return s_gpu_renderer_display_names[static_cast<int>(renderer)];
|
|
|
|
|
}
|
2019-12-14 23:29:26 +10:00
|
|
|
|
2020-11-01 22:54:03 +10:00
|
|
|
static constexpr auto s_texture_filter_names =
|
|
|
|
|
make_array("Nearest", "Bilinear", "BilinearBinAlpha", "JINC2", "JINC2BinAlpha", "xBR", "xBRBinAlpha");
|
2020-09-11 22:20:19 +10:00
|
|
|
static constexpr auto s_texture_filter_display_names =
|
|
|
|
|
make_array(TRANSLATABLE("GPUTextureFilter", "Nearest-Neighbor"), TRANSLATABLE("GPUTextureFilter", "Bilinear"),
|
2020-11-01 22:54:03 +10:00
|
|
|
TRANSLATABLE("GPUTextureFilter", "Bilinear (No Edge Blending)"), TRANSLATABLE("GPUTextureFilter", "JINC2"),
|
|
|
|
|
TRANSLATABLE("GPUTextureFilter", "JINC2 (No Edge Blending)"), TRANSLATABLE("GPUTextureFilter", "xBR"),
|
|
|
|
|
TRANSLATABLE("GPUTextureFilter", "xBR (No Edge Blending)"));
|
2020-09-11 22:20:19 +10:00
|
|
|
|
|
|
|
|
std::optional<GPUTextureFilter> Settings::ParseTextureFilterName(const char* str)
|
|
|
|
|
{
|
|
|
|
|
int index = 0;
|
|
|
|
|
for (const char* name : s_texture_filter_names)
|
|
|
|
|
{
|
|
|
|
|
if (StringUtil::Strcasecmp(name, str) == 0)
|
|
|
|
|
return static_cast<GPUTextureFilter>(index);
|
|
|
|
|
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return std::nullopt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char* Settings::GetTextureFilterName(GPUTextureFilter filter)
|
|
|
|
|
{
|
|
|
|
|
return s_texture_filter_names[static_cast<int>(filter)];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char* Settings::GetTextureFilterDisplayName(GPUTextureFilter filter)
|
|
|
|
|
{
|
|
|
|
|
return s_texture_filter_display_names[static_cast<int>(filter)];
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-30 16:26:20 +10:00
|
|
|
static constexpr auto s_downsample_mode_names = make_array("Disabled", "Box", "Adaptive");
|
|
|
|
|
|
|
|
|
|
std::optional<GPUDownsampleMode> Settings::ParseDownsampleModeName(const char* str)
|
|
|
|
|
{
|
|
|
|
|
int index = 0;
|
|
|
|
|
for (const char* name : s_downsample_mode_names)
|
|
|
|
|
{
|
|
|
|
|
if (StringUtil::Strcasecmp(name, str) == 0)
|
|
|
|
|
return static_cast<GPUDownsampleMode>(index);
|
|
|
|
|
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return std::nullopt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char* Settings::GetDownsampleModeName(GPUDownsampleMode mode)
|
|
|
|
|
{
|
|
|
|
|
return s_downsample_mode_names[static_cast<int>(mode)];
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-28 17:01:01 +10:00
|
|
|
static std::array<const char*, 3> s_display_crop_mode_names = {{"None", "Overscan", "Borders"}};
|
2020-08-23 14:42:53 +10:00
|
|
|
static std::array<const char*, 3> s_display_crop_mode_display_names = {
|
|
|
|
|
{TRANSLATABLE("DisplayCropMode", "None"), TRANSLATABLE("DisplayCropMode", "Only Overscan Area"),
|
|
|
|
|
TRANSLATABLE("DisplayCropMode", "All Borders")}};
|
2020-02-28 17:01:01 +10:00
|
|
|
|
|
|
|
|
std::optional<DisplayCropMode> Settings::ParseDisplayCropMode(const char* str)
|
|
|
|
|
{
|
|
|
|
|
int index = 0;
|
|
|
|
|
for (const char* name : s_display_crop_mode_names)
|
|
|
|
|
{
|
|
|
|
|
if (StringUtil::Strcasecmp(name, str) == 0)
|
|
|
|
|
return static_cast<DisplayCropMode>(index);
|
|
|
|
|
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return std::nullopt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char* Settings::GetDisplayCropModeName(DisplayCropMode crop_mode)
|
|
|
|
|
{
|
|
|
|
|
return s_display_crop_mode_names[static_cast<int>(crop_mode)];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char* Settings::GetDisplayCropModeDisplayName(DisplayCropMode crop_mode)
|
|
|
|
|
{
|
|
|
|
|
return s_display_crop_mode_display_names[static_cast<int>(crop_mode)];
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-30 02:29:39 +10:00
|
|
|
static std::array<const char*, static_cast<size_t>(DisplayAspectRatio::Count)> s_display_aspect_ratio_names = {
|
2021-05-01 13:18:32 +10:00
|
|
|
{TRANSLATABLE("DisplayAspectRatio", "Auto (Game Native)"), TRANSLATABLE("DisplayAspectRatio", "Auto (Match Window)"),
|
2022-09-23 18:02:28 +02:00
|
|
|
TRANSLATABLE("DisplayAspectRatio", "Custom"), "4:3", "16:9", "19:9", "20:9", "PAR 1:1", "Native"}};
|
2021-04-30 02:29:39 +10:00
|
|
|
static constexpr std::array<float, static_cast<size_t>(DisplayAspectRatio::Count)> s_display_aspect_ratio_values = {
|
2022-09-23 18:02:28 +02:00
|
|
|
{-1.0f, -1.0f, -1.0f, 4.0f / 3.0f, 16.0f / 9.0f, 19.0f / 9.0f, 20.0f / 9.0f, -1.0f, -1.0f}};
|
2020-04-10 15:12:16 +10:00
|
|
|
|
|
|
|
|
std::optional<DisplayAspectRatio> Settings::ParseDisplayAspectRatio(const char* str)
|
|
|
|
|
{
|
|
|
|
|
int index = 0;
|
|
|
|
|
for (const char* name : s_display_aspect_ratio_names)
|
|
|
|
|
{
|
|
|
|
|
if (StringUtil::Strcasecmp(name, str) == 0)
|
|
|
|
|
return static_cast<DisplayAspectRatio>(index);
|
|
|
|
|
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return std::nullopt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char* Settings::GetDisplayAspectRatioName(DisplayAspectRatio ar)
|
|
|
|
|
{
|
|
|
|
|
return s_display_aspect_ratio_names[static_cast<int>(ar)];
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-29 02:42:08 +10:00
|
|
|
float Settings::GetDisplayAspectRatioValue() const
|
2020-04-10 15:12:16 +10:00
|
|
|
{
|
2021-04-29 02:42:08 +10:00
|
|
|
switch (display_aspect_ratio)
|
|
|
|
|
{
|
|
|
|
|
case DisplayAspectRatio::MatchWindow:
|
|
|
|
|
{
|
|
|
|
|
const HostDisplay* display = g_host_interface->GetDisplay();
|
|
|
|
|
if (!display)
|
|
|
|
|
return s_display_aspect_ratio_values[static_cast<int>(DEFAULT_DISPLAY_ASPECT_RATIO)];
|
|
|
|
|
|
|
|
|
|
const u32 width = display->GetWindowWidth();
|
2022-09-08 04:10:13 +02:00
|
|
|
const u32 height = display->GetWindowHeight();
|
2021-04-29 02:42:08 +10:00
|
|
|
return static_cast<float>(width) / static_cast<float>(height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case DisplayAspectRatio::Custom:
|
|
|
|
|
{
|
|
|
|
|
return static_cast<float>(display_aspect_ratio_custom_numerator) /
|
|
|
|
|
static_cast<float>(display_aspect_ratio_custom_denominator);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
{
|
|
|
|
|
return s_display_aspect_ratio_values[static_cast<int>(display_aspect_ratio)];
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-10 15:12:16 +10:00
|
|
|
}
|
|
|
|
|
|
2024-07-04 17:29:03 +02:00
|
|
|
static std::array<const char*, 8> s_controller_type_names = {
|
|
|
|
|
{"None", "DigitalController", "AnalogController", "AnalogJoystick", "NamcoGunCon", "PlayStationMouse", "NeGcon", "NeGconRumble"}};
|
2019-12-14 23:29:26 +10:00
|
|
|
|
|
|
|
|
std::optional<ControllerType> Settings::ParseControllerTypeName(const char* str)
|
|
|
|
|
{
|
|
|
|
|
int index = 0;
|
|
|
|
|
for (const char* name : s_controller_type_names)
|
|
|
|
|
{
|
2020-01-10 13:31:12 +10:00
|
|
|
if (StringUtil::Strcasecmp(name, str) == 0)
|
2019-12-14 23:29:26 +10:00
|
|
|
return static_cast<ControllerType>(index);
|
|
|
|
|
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return std::nullopt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char* Settings::GetControllerTypeName(ControllerType type)
|
|
|
|
|
{
|
|
|
|
|
return s_controller_type_names[static_cast<int>(type)];
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-27 23:30:11 +07:00
|
|
|
static std::array<const char*, 7> s_memory_card_type_names = {
|
|
|
|
|
{"None", "Shared", "PerGame", "PerGameTitle", "PerGameFileTitle", "NonPersistent", "Libretro"}};
|
|
|
|
|
|
2020-04-27 16:15:38 +10:00
|
|
|
std::optional<MemoryCardType> Settings::ParseMemoryCardTypeName(const char* str)
|
|
|
|
|
{
|
|
|
|
|
int index = 0;
|
|
|
|
|
for (const char* name : s_memory_card_type_names)
|
|
|
|
|
{
|
|
|
|
|
if (StringUtil::Strcasecmp(name, str) == 0)
|
|
|
|
|
return static_cast<MemoryCardType>(index);
|
|
|
|
|
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return std::nullopt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char* Settings::GetMemoryCardTypeName(MemoryCardType type)
|
|
|
|
|
{
|
|
|
|
|
return s_memory_card_type_names[static_cast<int>(type)];
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-01 14:59:59 -08:00
|
|
|
static std::array<const char*, 4> s_multitap_enable_mode_names = {{"Disabled", "Port1Only", "Port2Only", "BothPorts"}};
|
2021-01-20 23:59:40 -08:00
|
|
|
|
|
|
|
|
std::optional<MultitapMode> Settings::ParseMultitapModeName(const char* str)
|
|
|
|
|
{
|
|
|
|
|
u32 index = 0;
|
|
|
|
|
for (const char* name : s_multitap_enable_mode_names)
|
|
|
|
|
{
|
|
|
|
|
if (StringUtil::Strcasecmp(name, str) == 0)
|
|
|
|
|
return static_cast<MultitapMode>(index);
|
|
|
|
|
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return std::nullopt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char* Settings::GetMultitapModeName(MultitapMode mode)
|
|
|
|
|
{
|
|
|
|
|
return s_multitap_enable_mode_names[static_cast<size_t>(mode)];
|
|
|
|
|
}
|