From 88d3de4e85751b32faa577345a828994575d2eb1 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 6 Jun 2023 01:31:43 -0400 Subject: settings: Split enums to new file --- src/common/settings_enums.h | 237 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 237 insertions(+) create mode 100644 src/common/settings_enums.h (limited to 'src/common/settings_enums.h') diff --git a/src/common/settings_enums.h b/src/common/settings_enums.h new file mode 100644 index 000000000..f48fb7bd4 --- /dev/null +++ b/src/common/settings_enums.h @@ -0,0 +1,237 @@ +// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include +#include +#include +#include +#include "common/common_types.h" + +namespace Settings { + +enum class AudioEngine : u32 { + Auto, + Cubeb, + Sdl2, + Null, +}; + +enum class AudioMode : u32 { + Mono, + Stereo, + Surround, +}; + +enum class Language : u32 { + Japanese, + EnglishAmerican, + French, + German, + Italian, + Spanish, + Chinese, + Korean, + Dutch, + Portuguese, + Russian, + Taiwanese, + EnglishBritish, + FrenchCanadian, + SpanishLatin, + ChineseSimplified, + ChineseTraditional, + PortugueseBrazilian, +}; + +enum class Region : u32 { + Japan, + USA, + Europe, + Australia, + China, + Korea, + Taiwan, +}; + +enum class TimeZone : u32 { + Auto, + Default, + CET, + CST6CDT, + Cuba, + EET, + Egypt, + Eire, + EST, + EST5EDT, + GB, + GBEire, + GMT, + GMTPlusZero, + GMTMinusZero, + GMTZero, + Greenwich, + Hongkong, + HST, + Iceland, + Iran, + Israel, + Jamaica, + Japan, + Kwajalein, + Libya, + MET, + MST, + MST7MDT, + Navajo, + NZ, + NZCHAT, + Poland, + Portugal, + PRC, + PST8PDT, + ROC, + ROK, + Singapore, + Turkey, + UCT, + Universal, + UTC, + W_SU, + WET, + Zulu, +}; + +enum class AnisotropyMode : u32 { + Automatic = 0, + Default = 1, + X2 = 2, + X4 = 3, + X8 = 4, + X16 = 5, +}; + +enum class AstcDecodeMode : u32 { + CPU = 0, + GPU = 1, + CPUAsynchronous = 2, +}; + +enum class AstcRecompression : u32 { + Uncompressed = 0, + Bc1 = 1, + Bc3 = 2, +}; + +enum class VSyncMode : u32 { + Immediate = 0, + Mailbox = 1, + FIFO = 2, + FIFORelaxed = 3, +}; + +enum class RendererBackend : u32 { + OpenGL = 0, + Vulkan = 1, + Null = 2, +}; + +enum class ShaderBackend : u32 { + GLSL = 0, + GLASM = 1, + SPIRV = 2, +}; + +enum class GPUAccuracy : u32 { + Normal = 0, + High = 1, + Extreme = 2, + MaxEnum = 3, +}; + +enum class CPUAccuracy : u32 { + Auto = 0, + Accurate = 1, + Unsafe = 2, + Paranoid = 3, +}; + +enum class FullscreenMode : u32 { + Borderless = 0, + Exclusive = 1, +}; + +enum class NvdecEmulation : u32 { + Off = 0, + CPU = 1, + GPU = 2, +}; + +enum class ResolutionSetup : u32 { + Res1_2X = 0, + Res3_4X = 1, + Res1X = 2, + Res3_2X = 3, + Res2X = 4, + Res3X = 5, + Res4X = 6, + Res5X = 7, + Res6X = 8, + Res7X = 9, + Res8X = 10, +}; + +enum class ScalingFilter : u32 { + NearestNeighbor = 0, + Bilinear = 1, + Bicubic = 2, + Gaussian = 3, + ScaleForce = 4, + Fsr = 5, + LastFilter = Fsr, +}; + +enum class AntiAliasing : u32 { + None = 0, + Fxaa = 1, + Smaa = 2, + LastAA = Smaa, +}; + +enum class AspectRatio : u32 { + R16_9, + R4_3, + R21_9, + R16_10, + Stretch, +}; + +static std::map> translations = { + {typeid(AudioEngine), + { + {"auto", static_cast(AudioEngine::Auto)}, + {"cubeb", static_cast(AudioEngine::Cubeb)}, + {"sdl2", static_cast(AudioEngine::Sdl2)}, + {"null", static_cast(AudioEngine::Null)}, + }}}; + +static std::string empty_string{}; + +template +const std::string& TranslateEnum(Type id) { + auto& group = translations.at(typeid(Type)); + for (auto& [name, value] : group) { + if (static_cast(value) == id) { + return name; + } + } + return empty_string; +} + +template +static Type ToEnum(const std::string& text) { + return static_cast(translations.at(typeid(Type)).at(text)); +} +} // namespace Settings -- cgit v1.2.3 From d146dd9d123a999e40307a93403239b81b04bffc Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Wed, 7 Jun 2023 01:52:23 -0400 Subject: settings,general: Rename non-confirming enums --- src/common/settings_enums.h | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) (limited to 'src/common/settings_enums.h') diff --git a/src/common/settings_enums.h b/src/common/settings_enums.h index f48fb7bd4..6cd2ac28b 100644 --- a/src/common/settings_enums.h +++ b/src/common/settings_enums.h @@ -47,7 +47,7 @@ enum class Language : u32 { enum class Region : u32 { Japan, - USA, + Usa, Europe, Australia, China, @@ -114,9 +114,9 @@ enum class AnisotropyMode : u32 { }; enum class AstcDecodeMode : u32 { - CPU = 0, - GPU = 1, - CPUAsynchronous = 2, + Cpu = 0, + Gpu = 1, + CpuAsynchronous = 2, }; enum class AstcRecompression : u32 { @@ -128,8 +128,8 @@ enum class AstcRecompression : u32 { enum class VSyncMode : u32 { Immediate = 0, Mailbox = 1, - FIFO = 2, - FIFORelaxed = 3, + Fifo = 2, + FifoRelaxed = 3, }; enum class RendererBackend : u32 { @@ -139,19 +139,18 @@ enum class RendererBackend : u32 { }; enum class ShaderBackend : u32 { - GLSL = 0, - GLASM = 1, - SPIRV = 2, + Glsl = 0, + Glasm = 1, + SpirV = 2, }; -enum class GPUAccuracy : u32 { +enum class GpuAccuracy : u32 { Normal = 0, High = 1, Extreme = 2, - MaxEnum = 3, }; -enum class CPUAccuracy : u32 { +enum class CpuAccuracy : u32 { Auto = 0, Accurate = 1, Unsafe = 2, @@ -165,8 +164,8 @@ enum class FullscreenMode : u32 { enum class NvdecEmulation : u32 { Off = 0, - CPU = 1, - GPU = 2, + Cpu = 1, + Gpu = 2, }; enum class ResolutionSetup : u32 { @@ -220,18 +219,18 @@ static std::map> translations = { static std::string empty_string{}; template -const std::string& TranslateEnum(Type id) { - auto& group = translations.at(typeid(Type)); +const std::string& CanonicalizeEnum(Type id) { + auto& group = canonicalizations.at(typeid(Type)); for (auto& [name, value] : group) { if (static_cast(value) == id) { return name; } } - return empty_string; + return invalid_string; } template -static Type ToEnum(const std::string& text) { - return static_cast(translations.at(typeid(Type)).at(text)); +static Type ToEnum(const std::string& canonicalization) { + return static_cast(canonicalizations.at(typeid(Type)).at(canonicalization)); } } // namespace Settings -- cgit v1.2.3 From 8c17a945f71b8532b0a4c3903b00a09d99ff0d6c Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Wed, 7 Jun 2023 01:53:05 -0400 Subject: settings_enums: Cannonicalize settings names Gives every option of the enums a string literal via a macro. --- src/common/settings_enums.h | 165 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 163 insertions(+), 2 deletions(-) (limited to 'src/common/settings_enums.h') diff --git a/src/common/settings_enums.h b/src/common/settings_enums.h index 6cd2ac28b..d820bc48e 100644 --- a/src/common/settings_enums.h +++ b/src/common/settings_enums.h @@ -207,16 +207,177 @@ enum class AspectRatio : u32 { Stretch, }; -static std::map> translations = { +#define X(ENUM, NAME) \ + { (#NAME), static_cast(ENUM::NAME) } + +static std::map> canonicalizations = { {typeid(AudioEngine), { {"auto", static_cast(AudioEngine::Auto)}, {"cubeb", static_cast(AudioEngine::Cubeb)}, {"sdl2", static_cast(AudioEngine::Sdl2)}, {"null", static_cast(AudioEngine::Null)}, + }}, + {typeid(AudioMode), + { + X(AudioMode, Mono), + X(AudioMode, Stereo), + X(AudioMode, Surround), + }}, + {typeid(Language), + { + X(Language, Japanese), + X(Language, EnglishAmerican), + X(Language, French), + X(Language, German), + X(Language, Italian), + X(Language, Spanish), + X(Language, Chinese), + X(Language, Korean), + X(Language, Dutch), + X(Language, Portuguese), + X(Language, Russian), + X(Language, Taiwanese), + X(Language, EnglishBritish), + X(Language, FrenchCanadian), + X(Language, SpanishLatin), + X(Language, ChineseSimplified), + X(Language, ChineseTraditional), + X(Language, PortugueseBrazilian), + }}, + {typeid(Region), + { + X(Region, Japan), + X(Region, Usa), + X(Region, Europe), + X(Region, Australia), + X(Region, China), + X(Region, Korea), + X(Region, Taiwan), + }}, + {typeid(TimeZone), + { + X(TimeZone, Auto), X(TimeZone, Default), X(TimeZone, CET), + X(TimeZone, CST6CDT), X(TimeZone, Cuba), X(TimeZone, EET), + X(TimeZone, Egypt), X(TimeZone, Eire), X(TimeZone, EST5EDT), + X(TimeZone, GB), X(TimeZone, GBEire), X(TimeZone, GMT), + X(TimeZone, GMTPlusZero), X(TimeZone, GMTMinusZero), X(TimeZone, GMTZero), + X(TimeZone, Greenwich), X(TimeZone, Hongkong), X(TimeZone, HST), + X(TimeZone, Iceland), X(TimeZone, Iran), X(TimeZone, Israel), + X(TimeZone, Jamaica), X(TimeZone, Japan), X(TimeZone, Kwajalein), + X(TimeZone, Libya), X(TimeZone, MET), X(TimeZone, MST), + X(TimeZone, MST7MDT), X(TimeZone, Navajo), X(TimeZone, NZ), + X(TimeZone, NZCHAT), X(TimeZone, Poland), X(TimeZone, Portugal), + X(TimeZone, PRC), X(TimeZone, ROC), X(TimeZone, ROK), + X(TimeZone, Singapore), X(TimeZone, Turkey), X(TimeZone, UCT), + X(TimeZone, Universal), X(TimeZone, UTC), X(TimeZone, W_SU), + X(TimeZone, WET), X(TimeZone, Zulu), + }}, + {typeid(AnisotropyMode), + { + X(AnisotropyMode, Automatic), + X(AnisotropyMode, Default), + X(AnisotropyMode, X2), + X(AnisotropyMode, X4), + X(AnisotropyMode, X8), + X(AnisotropyMode, X16), + }}, + {typeid(AstcDecodeMode), + { + X(AstcDecodeMode, Cpu), + X(AstcDecodeMode, Gpu), + X(AstcDecodeMode, CpuAsynchronous), + }}, + {typeid(AstcRecompression), + { + X(AstcRecompression, Uncompressed), + X(AstcRecompression, Bc1), + X(AstcRecompression, Bc3), + }}, + {typeid(VSyncMode), + { + X(VSyncMode, Immediate), + X(VSyncMode, Mailbox), + X(VSyncMode, Fifo), + X(VSyncMode, FifoRelaxed), + }}, + {typeid(RendererBackend), + { + X(RendererBackend, OpenGL), + X(RendererBackend, Vulkan), + X(RendererBackend, Null), + }}, + {typeid(ShaderBackend), + { + X(ShaderBackend, Glsl), + X(ShaderBackend, Glasm), + X(ShaderBackend, SpirV), + }}, + {typeid(GpuAccuracy), + { + X(GpuAccuracy, Normal), + X(GpuAccuracy, High), + X(GpuAccuracy, Extreme), + }}, + {typeid(CpuAccuracy), + { + X(CpuAccuracy, Auto), + X(CpuAccuracy, Accurate), + X(CpuAccuracy, Unsafe), + X(CpuAccuracy, Paranoid), + }}, + {typeid(FullscreenMode), + { + X(FullscreenMode, Borderless), + X(FullscreenMode, Exclusive), + }}, + {typeid(NvdecEmulation), + { + X(NvdecEmulation, Off), + X(NvdecEmulation, Cpu), + X(NvdecEmulation, Gpu), + }}, + {typeid(ResolutionSetup), + { + X(ResolutionSetup, Res1_2X), + X(ResolutionSetup, Res3_4X), + X(ResolutionSetup, Res1X), + X(ResolutionSetup, Res3_2X), + X(ResolutionSetup, Res2X), + X(ResolutionSetup, Res3X), + X(ResolutionSetup, Res4X), + X(ResolutionSetup, Res5X), + X(ResolutionSetup, Res6X), + X(ResolutionSetup, Res7X), + X(ResolutionSetup, Res8X), + }}, + {typeid(ScalingFilter), + { + X(ScalingFilter, NearestNeighbor), + X(ScalingFilter, Bilinear), + X(ScalingFilter, Bicubic), + X(ScalingFilter, Gaussian), + X(ScalingFilter, ScaleForce), + X(ScalingFilter, Fsr), + }}, + {typeid(AntiAliasing), + { + X(AntiAliasing, None), + X(AntiAliasing, Fxaa), + X(AntiAliasing, Smaa), + }}, + {typeid(AspectRatio), + { + X(AspectRatio, R16_9), + X(AspectRatio, R4_3), + X(AspectRatio, R21_9), + X(AspectRatio, R16_10), + X(AspectRatio, Stretch), }}}; -static std::string empty_string{}; +#undef X + +static std::string invalid_string{"(invalid setting)"}; template const std::string& CanonicalizeEnum(Type id) { -- cgit v1.2.3 From 2fba913d0bc022085a0de8848ced02f38e48cd54 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Sat, 10 Jun 2023 00:35:45 -0400 Subject: settings_enums: Add const type where needed --- src/common/settings_enums.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/common/settings_enums.h') diff --git a/src/common/settings_enums.h b/src/common/settings_enums.h index d820bc48e..2710f136d 100644 --- a/src/common/settings_enums.h +++ b/src/common/settings_enums.h @@ -210,7 +210,7 @@ enum class AspectRatio : u32 { #define X(ENUM, NAME) \ { (#NAME), static_cast(ENUM::NAME) } -static std::map> canonicalizations = { +static const std::map> canonicalizations = { {typeid(AudioEngine), { {"auto", static_cast(AudioEngine::Auto)}, @@ -377,7 +377,7 @@ static std::map> canonicalizations = #undef X -static std::string invalid_string{"(invalid setting)"}; +static const std::string invalid_string{"(invalid setting)"}; template const std::string& CanonicalizeEnum(Type id) { -- cgit v1.2.3 From 0193add060ecc591ca27d029916823911df5d503 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Sat, 10 Jun 2023 00:44:03 -0400 Subject: general: Add typeinfo where needed Using typeid without including typeinfo first produces an ill-formed program. --- src/common/settings_enums.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/common/settings_enums.h') diff --git a/src/common/settings_enums.h b/src/common/settings_enums.h index 2710f136d..f3d76b927 100644 --- a/src/common/settings_enums.h +++ b/src/common/settings_enums.h @@ -7,6 +7,7 @@ #include #include #include +#include #include "common/common_types.h" namespace Settings { -- cgit v1.2.3 From 7ffbffe170326eb8e21fa96e5374ba6b68370db6 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 20 Jun 2023 23:25:39 -0400 Subject: settings_enums: More aggressively use macros This lets us define an enum and all the textual representations of its values in one swing. All for the price of some ugly macros. --- src/common/settings_enums.h | 500 +++++++++++++------------------------------- 1 file changed, 149 insertions(+), 351 deletions(-) (limited to 'src/common/settings_enums.h') diff --git a/src/common/settings_enums.h b/src/common/settings_enums.h index f3d76b927..71515257a 100644 --- a/src/common/settings_enums.h +++ b/src/common/settings_enums.h @@ -3,15 +3,72 @@ #pragma once -#include #include -#include -#include -#include +#include +#include #include "common/common_types.h" namespace Settings { +template +struct Canonicalization { + static constexpr std::vector> Get(); +}; + +#define PAIR_45(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_46(N, __VA_ARGS__)) +#define PAIR_44(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_45(N, __VA_ARGS__)) +#define PAIR_43(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_44(N, __VA_ARGS__)) +#define PAIR_42(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_43(N, __VA_ARGS__)) +#define PAIR_41(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_42(N, __VA_ARGS__)) +#define PAIR_40(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_41(N, __VA_ARGS__)) +#define PAIR_39(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_40(N, __VA_ARGS__)) +#define PAIR_38(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_39(N, __VA_ARGS__)) +#define PAIR_37(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_38(N, __VA_ARGS__)) +#define PAIR_36(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_37(N, __VA_ARGS__)) +#define PAIR_35(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_36(N, __VA_ARGS__)) +#define PAIR_34(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_35(N, __VA_ARGS__)) +#define PAIR_33(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_34(N, __VA_ARGS__)) +#define PAIR_32(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_33(N, __VA_ARGS__)) +#define PAIR_31(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_32(N, __VA_ARGS__)) +#define PAIR_30(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_31(N, __VA_ARGS__)) +#define PAIR_29(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_30(N, __VA_ARGS__)) +#define PAIR_28(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_29(N, __VA_ARGS__)) +#define PAIR_27(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_28(N, __VA_ARGS__)) +#define PAIR_26(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_27(N, __VA_ARGS__)) +#define PAIR_25(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_26(N, __VA_ARGS__)) +#define PAIR_24(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_25(N, __VA_ARGS__)) +#define PAIR_23(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_24(N, __VA_ARGS__)) +#define PAIR_22(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_23(N, __VA_ARGS__)) +#define PAIR_21(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_22(N, __VA_ARGS__)) +#define PAIR_20(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_21(N, __VA_ARGS__)) +#define PAIR_19(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_20(N, __VA_ARGS__)) +#define PAIR_18(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_19(N, __VA_ARGS__)) +#define PAIR_17(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_18(N, __VA_ARGS__)) +#define PAIR_16(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_17(N, __VA_ARGS__)) +#define PAIR_15(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_16(N, __VA_ARGS__)) +#define PAIR_14(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_15(N, __VA_ARGS__)) +#define PAIR_13(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_14(N, __VA_ARGS__)) +#define PAIR_12(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_13(N, __VA_ARGS__)) +#define PAIR_11(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_12(N, __VA_ARGS__)) +#define PAIR_10(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_11(N, __VA_ARGS__)) +#define PAIR_9(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_10(N, __VA_ARGS__)) +#define PAIR_8(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_9(N, __VA_ARGS__)) +#define PAIR_7(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_8(N, __VA_ARGS__)) +#define PAIR_6(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_7(N, __VA_ARGS__)) +#define PAIR_5(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_6(N, __VA_ARGS__)) +#define PAIR_4(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_5(N, __VA_ARGS__)) +#define PAIR_3(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_4(N, __VA_ARGS__)) +#define PAIR_2(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_3(N, __VA_ARGS__)) +#define PAIR_1(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_2(N, __VA_ARGS__)) +#define PAIR(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_1(N, __VA_ARGS__)) + +#define ENUM(NAME, ...) \ + enum class NAME : u32 { __VA_ARGS__ }; \ + template <> \ + constexpr std::vector> Canonicalization::Get() { \ + return {PAIR(NAME, __VA_ARGS__)}; \ + } + enum class AudioEngine : u32 { Auto, Cubeb, @@ -19,380 +76,121 @@ enum class AudioEngine : u32 { Null, }; -enum class AudioMode : u32 { - Mono, - Stereo, - Surround, -}; +template <> +constexpr std::vector> Canonicalization::Get() { + return { + {"auto", static_cast(AudioEngine::Auto)}, + {"cubeb", static_cast(AudioEngine::Cubeb)}, + {"sdl2", static_cast(AudioEngine::Sdl2)}, + {"null", static_cast(AudioEngine::Null)}, + }; +} -enum class Language : u32 { - Japanese, - EnglishAmerican, - French, - German, - Italian, - Spanish, - Chinese, - Korean, - Dutch, - Portuguese, - Russian, - Taiwanese, - EnglishBritish, - FrenchCanadian, - SpanishLatin, - ChineseSimplified, - ChineseTraditional, - PortugueseBrazilian, -}; +ENUM(AudioMode, Mono, Stereo, Surround); -enum class Region : u32 { - Japan, - Usa, - Europe, - Australia, - China, - Korea, - Taiwan, -}; +ENUM(Language, Japanese, EnglishAmerican, French, German, Italian, Spanish, Chinese, Korean, Dutch, + Portuguese, Russian, Taiwanese, EnglishBritish, FrenchCanadian, SpanishLatin, + ChineseSimplified, ChineseTraditional, PortugueseBrazilian); -enum class TimeZone : u32 { - Auto, - Default, - CET, - CST6CDT, - Cuba, - EET, - Egypt, - Eire, - EST, - EST5EDT, - GB, - GBEire, - GMT, - GMTPlusZero, - GMTMinusZero, - GMTZero, - Greenwich, - Hongkong, - HST, - Iceland, - Iran, - Israel, - Jamaica, - Japan, - Kwajalein, - Libya, - MET, - MST, - MST7MDT, - Navajo, - NZ, - NZCHAT, - Poland, - Portugal, - PRC, - PST8PDT, - ROC, - ROK, - Singapore, - Turkey, - UCT, - Universal, - UTC, - W_SU, - WET, - Zulu, -}; +ENUM(Region, Japan, Usa, Europe, Australia, China, Korea, Taiwan); -enum class AnisotropyMode : u32 { - Automatic = 0, - Default = 1, - X2 = 2, - X4 = 3, - X8 = 4, - X16 = 5, -}; +ENUM(TimeZone, Auto, Default, CET, CST6CDT, Cuba, EET, Egypt, Eire, EST, EST5EDT, GB, GBEire, GMT, + GMTPlusZero, GMTMinusZero, GMTZero, Greenwich, Hongkong, HST, Iceland, Iran, Israel, Jamaica, + Japan, Kwajalein, Libya, MET, MST, MST7MDT, Navajo, NZ, NZCHAT, Poland, Portugal, PRC, PST8PDT, + ROC, ROK, Singapore, Turkey, UCT, Universal, UTC, W_SU, WET, Zulu); -enum class AstcDecodeMode : u32 { - Cpu = 0, - Gpu = 1, - CpuAsynchronous = 2, -}; +ENUM(AnisotropyMode, Automatic, Default, X2, X4, X8, X16); -enum class AstcRecompression : u32 { - Uncompressed = 0, - Bc1 = 1, - Bc3 = 2, -}; +ENUM(AstcDecodeMode, Cpu, Gpu, CpuAsynchronous); -enum class VSyncMode : u32 { - Immediate = 0, - Mailbox = 1, - Fifo = 2, - FifoRelaxed = 3, -}; +ENUM(AstcRecompression, Uncompressed, Bc1, Bc3); -enum class RendererBackend : u32 { - OpenGL = 0, - Vulkan = 1, - Null = 2, -}; +ENUM(VSyncMode, Immediate, Mailbox, Fifo, FifoRelaxed); -enum class ShaderBackend : u32 { - Glsl = 0, - Glasm = 1, - SpirV = 2, -}; +ENUM(RendererBackend, OpenGL, Vulkan, Null); -enum class GpuAccuracy : u32 { - Normal = 0, - High = 1, - Extreme = 2, -}; +ENUM(ShaderBackend, Glsl, Glasm, SpirV); -enum class CpuAccuracy : u32 { - Auto = 0, - Accurate = 1, - Unsafe = 2, - Paranoid = 3, -}; - -enum class FullscreenMode : u32 { - Borderless = 0, - Exclusive = 1, -}; - -enum class NvdecEmulation : u32 { - Off = 0, - Cpu = 1, - Gpu = 2, -}; - -enum class ResolutionSetup : u32 { - Res1_2X = 0, - Res3_4X = 1, - Res1X = 2, - Res3_2X = 3, - Res2X = 4, - Res3X = 5, - Res4X = 6, - Res5X = 7, - Res6X = 8, - Res7X = 9, - Res8X = 10, -}; +ENUM(GpuAccuracy, Normal, High, Extreme); -enum class ScalingFilter : u32 { - NearestNeighbor = 0, - Bilinear = 1, - Bicubic = 2, - Gaussian = 3, - ScaleForce = 4, - Fsr = 5, - LastFilter = Fsr, -}; +ENUM(CpuAccuracy, Auto, Accurate, Unsafe, Paranoid); -enum class AntiAliasing : u32 { - None = 0, - Fxaa = 1, - Smaa = 2, - LastAA = Smaa, -}; +ENUM(FullscreenMode, Borderless, Exclusive); -enum class AspectRatio : u32 { - R16_9, - R4_3, - R21_9, - R16_10, - Stretch, -}; +ENUM(NvdecEmulation, Off, Cpu, Gpu); -#define X(ENUM, NAME) \ - { (#NAME), static_cast(ENUM::NAME) } +ENUM(ResolutionSetup, Res1_2X, Res3_4X, Res1X, Res3_2X, Res2X, Res3X, Res4X, Res5X, Res6X, Res7X, + Res8X); -static const std::map> canonicalizations = { - {typeid(AudioEngine), - { - {"auto", static_cast(AudioEngine::Auto)}, - {"cubeb", static_cast(AudioEngine::Cubeb)}, - {"sdl2", static_cast(AudioEngine::Sdl2)}, - {"null", static_cast(AudioEngine::Null)}, - }}, - {typeid(AudioMode), - { - X(AudioMode, Mono), - X(AudioMode, Stereo), - X(AudioMode, Surround), - }}, - {typeid(Language), - { - X(Language, Japanese), - X(Language, EnglishAmerican), - X(Language, French), - X(Language, German), - X(Language, Italian), - X(Language, Spanish), - X(Language, Chinese), - X(Language, Korean), - X(Language, Dutch), - X(Language, Portuguese), - X(Language, Russian), - X(Language, Taiwanese), - X(Language, EnglishBritish), - X(Language, FrenchCanadian), - X(Language, SpanishLatin), - X(Language, ChineseSimplified), - X(Language, ChineseTraditional), - X(Language, PortugueseBrazilian), - }}, - {typeid(Region), - { - X(Region, Japan), - X(Region, Usa), - X(Region, Europe), - X(Region, Australia), - X(Region, China), - X(Region, Korea), - X(Region, Taiwan), - }}, - {typeid(TimeZone), - { - X(TimeZone, Auto), X(TimeZone, Default), X(TimeZone, CET), - X(TimeZone, CST6CDT), X(TimeZone, Cuba), X(TimeZone, EET), - X(TimeZone, Egypt), X(TimeZone, Eire), X(TimeZone, EST5EDT), - X(TimeZone, GB), X(TimeZone, GBEire), X(TimeZone, GMT), - X(TimeZone, GMTPlusZero), X(TimeZone, GMTMinusZero), X(TimeZone, GMTZero), - X(TimeZone, Greenwich), X(TimeZone, Hongkong), X(TimeZone, HST), - X(TimeZone, Iceland), X(TimeZone, Iran), X(TimeZone, Israel), - X(TimeZone, Jamaica), X(TimeZone, Japan), X(TimeZone, Kwajalein), - X(TimeZone, Libya), X(TimeZone, MET), X(TimeZone, MST), - X(TimeZone, MST7MDT), X(TimeZone, Navajo), X(TimeZone, NZ), - X(TimeZone, NZCHAT), X(TimeZone, Poland), X(TimeZone, Portugal), - X(TimeZone, PRC), X(TimeZone, ROC), X(TimeZone, ROK), - X(TimeZone, Singapore), X(TimeZone, Turkey), X(TimeZone, UCT), - X(TimeZone, Universal), X(TimeZone, UTC), X(TimeZone, W_SU), - X(TimeZone, WET), X(TimeZone, Zulu), - }}, - {typeid(AnisotropyMode), - { - X(AnisotropyMode, Automatic), - X(AnisotropyMode, Default), - X(AnisotropyMode, X2), - X(AnisotropyMode, X4), - X(AnisotropyMode, X8), - X(AnisotropyMode, X16), - }}, - {typeid(AstcDecodeMode), - { - X(AstcDecodeMode, Cpu), - X(AstcDecodeMode, Gpu), - X(AstcDecodeMode, CpuAsynchronous), - }}, - {typeid(AstcRecompression), - { - X(AstcRecompression, Uncompressed), - X(AstcRecompression, Bc1), - X(AstcRecompression, Bc3), - }}, - {typeid(VSyncMode), - { - X(VSyncMode, Immediate), - X(VSyncMode, Mailbox), - X(VSyncMode, Fifo), - X(VSyncMode, FifoRelaxed), - }}, - {typeid(RendererBackend), - { - X(RendererBackend, OpenGL), - X(RendererBackend, Vulkan), - X(RendererBackend, Null), - }}, - {typeid(ShaderBackend), - { - X(ShaderBackend, Glsl), - X(ShaderBackend, Glasm), - X(ShaderBackend, SpirV), - }}, - {typeid(GpuAccuracy), - { - X(GpuAccuracy, Normal), - X(GpuAccuracy, High), - X(GpuAccuracy, Extreme), - }}, - {typeid(CpuAccuracy), - { - X(CpuAccuracy, Auto), - X(CpuAccuracy, Accurate), - X(CpuAccuracy, Unsafe), - X(CpuAccuracy, Paranoid), - }}, - {typeid(FullscreenMode), - { - X(FullscreenMode, Borderless), - X(FullscreenMode, Exclusive), - }}, - {typeid(NvdecEmulation), - { - X(NvdecEmulation, Off), - X(NvdecEmulation, Cpu), - X(NvdecEmulation, Gpu), - }}, - {typeid(ResolutionSetup), - { - X(ResolutionSetup, Res1_2X), - X(ResolutionSetup, Res3_4X), - X(ResolutionSetup, Res1X), - X(ResolutionSetup, Res3_2X), - X(ResolutionSetup, Res2X), - X(ResolutionSetup, Res3X), - X(ResolutionSetup, Res4X), - X(ResolutionSetup, Res5X), - X(ResolutionSetup, Res6X), - X(ResolutionSetup, Res7X), - X(ResolutionSetup, Res8X), - }}, - {typeid(ScalingFilter), - { - X(ScalingFilter, NearestNeighbor), - X(ScalingFilter, Bilinear), - X(ScalingFilter, Bicubic), - X(ScalingFilter, Gaussian), - X(ScalingFilter, ScaleForce), - X(ScalingFilter, Fsr), - }}, - {typeid(AntiAliasing), - { - X(AntiAliasing, None), - X(AntiAliasing, Fxaa), - X(AntiAliasing, Smaa), - }}, - {typeid(AspectRatio), - { - X(AspectRatio, R16_9), - X(AspectRatio, R4_3), - X(AspectRatio, R21_9), - X(AspectRatio, R16_10), - X(AspectRatio, Stretch), - }}}; +ENUM(ScalingFilter, NearestNeighbor, Bilinear, Bicubic, Gaussian, ScaleForce, Fsr, LastFilter); -#undef X +ENUM(AntiAliasing, None, Fxaa, Smaa, LastAA); -static const std::string invalid_string{"(invalid setting)"}; +ENUM(AspectRatio, R16_9, R4_3, R21_9, R16_10, Stretch); template -const std::string& CanonicalizeEnum(Type id) { - auto& group = canonicalizations.at(typeid(Type)); +constexpr std::string CanonicalizeEnum(Type id) { + const auto group = Canonicalization::Get(); for (auto& [name, value] : group) { if (static_cast(value) == id) { return name; } } - return invalid_string; + return "unknown"; } template -static Type ToEnum(const std::string& canonicalization) { - return static_cast(canonicalizations.at(typeid(Type)).at(canonicalization)); +constexpr Type ToEnum(const std::string& canonicalization) { + const auto group = Canonicalization::Get(); + for (auto& [name, value] : group) { + if (name == canonicalization) { + return static_cast(value); + } + } + return {}; } } // namespace Settings + +#undef ENUM +#undef PAIR +#undef PAIR_1 +#undef PAIR_2 +#undef PAIR_3 +#undef PAIR_4 +#undef PAIR_5 +#undef PAIR_6 +#undef PAIR_7 +#undef PAIR_8 +#undef PAIR_9 +#undef PAIR_10 +#undef PAIR_12 +#undef PAIR_13 +#undef PAIR_14 +#undef PAIR_15 +#undef PAIR_16 +#undef PAIR_17 +#undef PAIR_18 +#undef PAIR_19 +#undef PAIR_20 +#undef PAIR_22 +#undef PAIR_23 +#undef PAIR_24 +#undef PAIR_25 +#undef PAIR_26 +#undef PAIR_27 +#undef PAIR_28 +#undef PAIR_29 +#undef PAIR_30 +#undef PAIR_32 +#undef PAIR_33 +#undef PAIR_34 +#undef PAIR_35 +#undef PAIR_36 +#undef PAIR_37 +#undef PAIR_38 +#undef PAIR_39 +#undef PAIR_40 +#undef PAIR_42 +#undef PAIR_43 +#undef PAIR_44 +#undef PAIR_45 -- cgit v1.2.3 From 8366736b67d6febe278b6599badf4e945599bc30 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 20 Jun 2023 23:29:07 -0400 Subject: settings,opengl,yuzu-qt: Fix AA, Filter maximums The new enum macros don't support setting values directly. For LastAA and LastFilter, this means we need a simpler approach to loop around the toggle in the frontend... --- src/common/settings_enums.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/common/settings_enums.h') diff --git a/src/common/settings_enums.h b/src/common/settings_enums.h index 71515257a..cc5c929cf 100644 --- a/src/common/settings_enums.h +++ b/src/common/settings_enums.h @@ -122,9 +122,9 @@ ENUM(NvdecEmulation, Off, Cpu, Gpu); ENUM(ResolutionSetup, Res1_2X, Res3_4X, Res1X, Res3_2X, Res2X, Res3X, Res4X, Res5X, Res6X, Res7X, Res8X); -ENUM(ScalingFilter, NearestNeighbor, Bilinear, Bicubic, Gaussian, ScaleForce, Fsr, LastFilter); +ENUM(ScalingFilter, NearestNeighbor, Bilinear, Bicubic, Gaussian, ScaleForce, Fsr, MaxEnum); -ENUM(AntiAliasing, None, Fxaa, Smaa, LastAA); +ENUM(AntiAliasing, None, Fxaa, Smaa, MaxEnum); ENUM(AspectRatio, R16_9, R4_3, R21_9, R16_10, Stretch); -- cgit v1.2.3 From 8b28aa45b99cc6f6c9399bbe421460de67088cff Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 20 Jun 2023 23:34:03 -0400 Subject: settings,translation: Fix time zone enum Renames enum values to conform to naming convention. --- src/common/settings_enums.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/common/settings_enums.h') diff --git a/src/common/settings_enums.h b/src/common/settings_enums.h index cc5c929cf..c380e409e 100644 --- a/src/common/settings_enums.h +++ b/src/common/settings_enums.h @@ -94,10 +94,10 @@ ENUM(Language, Japanese, EnglishAmerican, French, German, Italian, Spanish, Chin ENUM(Region, Japan, Usa, Europe, Australia, China, Korea, Taiwan); -ENUM(TimeZone, Auto, Default, CET, CST6CDT, Cuba, EET, Egypt, Eire, EST, EST5EDT, GB, GBEire, GMT, - GMTPlusZero, GMTMinusZero, GMTZero, Greenwich, Hongkong, HST, Iceland, Iran, Israel, Jamaica, - Japan, Kwajalein, Libya, MET, MST, MST7MDT, Navajo, NZ, NZCHAT, Poland, Portugal, PRC, PST8PDT, - ROC, ROK, Singapore, Turkey, UCT, Universal, UTC, W_SU, WET, Zulu); +ENUM(TimeZone, Auto, Default, Cet, Cst6Cdt, Cuba, Eet, Egypt, Eire, Est, Est5Edt, Gb, GbEire, Gmt, + GmtPlusZero, GmtMinusZero, GmtZero, Greenwich, Hongkong, Hst, Iceland, Iran, Israel, Jamaica, + Japan, Kwajalein, Libya, Met, Mst, Mst7Mdt, Navajo, Nz, NzChat, Poland, Portugal, Prc, Pst8Pdt, + Roc, Rok, Singapore, Turkey, Uct, Universal, Utc, WSu, Wet, Zulu); ENUM(AnisotropyMode, Automatic, Default, X2, X4, X8, X16); -- cgit v1.2.3 From 8497fb0a046a208b0abcda9ba31ec77866ec922d Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Wed, 21 Jun 2023 15:39:28 -0400 Subject: settings_enums: Remove casting Not sure how I missed this earlier, but these vectors can be constructed using the type of the enum. --- src/common/settings_enums.h | 110 ++++++++++++++++++++++---------------------- 1 file changed, 55 insertions(+), 55 deletions(-) (limited to 'src/common/settings_enums.h') diff --git a/src/common/settings_enums.h b/src/common/settings_enums.h index c380e409e..a5f87c956 100644 --- a/src/common/settings_enums.h +++ b/src/common/settings_enums.h @@ -12,60 +12,60 @@ namespace Settings { template struct Canonicalization { - static constexpr std::vector> Get(); + static constexpr std::vector> Get(); }; -#define PAIR_45(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_46(N, __VA_ARGS__)) -#define PAIR_44(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_45(N, __VA_ARGS__)) -#define PAIR_43(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_44(N, __VA_ARGS__)) -#define PAIR_42(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_43(N, __VA_ARGS__)) -#define PAIR_41(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_42(N, __VA_ARGS__)) -#define PAIR_40(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_41(N, __VA_ARGS__)) -#define PAIR_39(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_40(N, __VA_ARGS__)) -#define PAIR_38(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_39(N, __VA_ARGS__)) -#define PAIR_37(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_38(N, __VA_ARGS__)) -#define PAIR_36(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_37(N, __VA_ARGS__)) -#define PAIR_35(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_36(N, __VA_ARGS__)) -#define PAIR_34(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_35(N, __VA_ARGS__)) -#define PAIR_33(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_34(N, __VA_ARGS__)) -#define PAIR_32(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_33(N, __VA_ARGS__)) -#define PAIR_31(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_32(N, __VA_ARGS__)) -#define PAIR_30(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_31(N, __VA_ARGS__)) -#define PAIR_29(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_30(N, __VA_ARGS__)) -#define PAIR_28(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_29(N, __VA_ARGS__)) -#define PAIR_27(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_28(N, __VA_ARGS__)) -#define PAIR_26(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_27(N, __VA_ARGS__)) -#define PAIR_25(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_26(N, __VA_ARGS__)) -#define PAIR_24(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_25(N, __VA_ARGS__)) -#define PAIR_23(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_24(N, __VA_ARGS__)) -#define PAIR_22(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_23(N, __VA_ARGS__)) -#define PAIR_21(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_22(N, __VA_ARGS__)) -#define PAIR_20(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_21(N, __VA_ARGS__)) -#define PAIR_19(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_20(N, __VA_ARGS__)) -#define PAIR_18(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_19(N, __VA_ARGS__)) -#define PAIR_17(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_18(N, __VA_ARGS__)) -#define PAIR_16(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_17(N, __VA_ARGS__)) -#define PAIR_15(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_16(N, __VA_ARGS__)) -#define PAIR_14(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_15(N, __VA_ARGS__)) -#define PAIR_13(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_14(N, __VA_ARGS__)) -#define PAIR_12(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_13(N, __VA_ARGS__)) -#define PAIR_11(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_12(N, __VA_ARGS__)) -#define PAIR_10(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_11(N, __VA_ARGS__)) -#define PAIR_9(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_10(N, __VA_ARGS__)) -#define PAIR_8(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_9(N, __VA_ARGS__)) -#define PAIR_7(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_8(N, __VA_ARGS__)) -#define PAIR_6(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_7(N, __VA_ARGS__)) -#define PAIR_5(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_6(N, __VA_ARGS__)) -#define PAIR_4(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_5(N, __VA_ARGS__)) -#define PAIR_3(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_4(N, __VA_ARGS__)) -#define PAIR_2(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_3(N, __VA_ARGS__)) -#define PAIR_1(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_2(N, __VA_ARGS__)) -#define PAIR(N, X, ...) {#X, static_cast(N::X)} __VA_OPT__(, PAIR_1(N, __VA_ARGS__)) +#define PAIR_45(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_46(N, __VA_ARGS__)) +#define PAIR_44(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_45(N, __VA_ARGS__)) +#define PAIR_43(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_44(N, __VA_ARGS__)) +#define PAIR_42(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_43(N, __VA_ARGS__)) +#define PAIR_41(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_42(N, __VA_ARGS__)) +#define PAIR_40(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_41(N, __VA_ARGS__)) +#define PAIR_39(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_40(N, __VA_ARGS__)) +#define PAIR_38(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_39(N, __VA_ARGS__)) +#define PAIR_37(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_38(N, __VA_ARGS__)) +#define PAIR_36(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_37(N, __VA_ARGS__)) +#define PAIR_35(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_36(N, __VA_ARGS__)) +#define PAIR_34(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_35(N, __VA_ARGS__)) +#define PAIR_33(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_34(N, __VA_ARGS__)) +#define PAIR_32(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_33(N, __VA_ARGS__)) +#define PAIR_31(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_32(N, __VA_ARGS__)) +#define PAIR_30(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_31(N, __VA_ARGS__)) +#define PAIR_29(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_30(N, __VA_ARGS__)) +#define PAIR_28(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_29(N, __VA_ARGS__)) +#define PAIR_27(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_28(N, __VA_ARGS__)) +#define PAIR_26(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_27(N, __VA_ARGS__)) +#define PAIR_25(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_26(N, __VA_ARGS__)) +#define PAIR_24(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_25(N, __VA_ARGS__)) +#define PAIR_23(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_24(N, __VA_ARGS__)) +#define PAIR_22(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_23(N, __VA_ARGS__)) +#define PAIR_21(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_22(N, __VA_ARGS__)) +#define PAIR_20(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_21(N, __VA_ARGS__)) +#define PAIR_19(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_20(N, __VA_ARGS__)) +#define PAIR_18(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_19(N, __VA_ARGS__)) +#define PAIR_17(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_18(N, __VA_ARGS__)) +#define PAIR_16(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_17(N, __VA_ARGS__)) +#define PAIR_15(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_16(N, __VA_ARGS__)) +#define PAIR_14(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_15(N, __VA_ARGS__)) +#define PAIR_13(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_14(N, __VA_ARGS__)) +#define PAIR_12(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_13(N, __VA_ARGS__)) +#define PAIR_11(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_12(N, __VA_ARGS__)) +#define PAIR_10(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_11(N, __VA_ARGS__)) +#define PAIR_9(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_10(N, __VA_ARGS__)) +#define PAIR_8(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_9(N, __VA_ARGS__)) +#define PAIR_7(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_8(N, __VA_ARGS__)) +#define PAIR_6(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_7(N, __VA_ARGS__)) +#define PAIR_5(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_6(N, __VA_ARGS__)) +#define PAIR_4(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_5(N, __VA_ARGS__)) +#define PAIR_3(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_4(N, __VA_ARGS__)) +#define PAIR_2(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_3(N, __VA_ARGS__)) +#define PAIR_1(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_2(N, __VA_ARGS__)) +#define PAIR(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_1(N, __VA_ARGS__)) #define ENUM(NAME, ...) \ enum class NAME : u32 { __VA_ARGS__ }; \ template <> \ - constexpr std::vector> Canonicalization::Get() { \ + constexpr std::vector> Canonicalization::Get() { \ return {PAIR(NAME, __VA_ARGS__)}; \ } @@ -77,12 +77,12 @@ enum class AudioEngine : u32 { }; template <> -constexpr std::vector> Canonicalization::Get() { +constexpr std::vector> Canonicalization::Get() { return { - {"auto", static_cast(AudioEngine::Auto)}, - {"cubeb", static_cast(AudioEngine::Cubeb)}, - {"sdl2", static_cast(AudioEngine::Sdl2)}, - {"null", static_cast(AudioEngine::Null)}, + {"auto", AudioEngine::Auto}, + {"cubeb", AudioEngine::Cubeb}, + {"sdl2", AudioEngine::Sdl2}, + {"null", AudioEngine::Null}, }; } @@ -132,7 +132,7 @@ template constexpr std::string CanonicalizeEnum(Type id) { const auto group = Canonicalization::Get(); for (auto& [name, value] : group) { - if (static_cast(value) == id) { + if (value == id) { return name; } } @@ -144,7 +144,7 @@ constexpr Type ToEnum(const std::string& canonicalization) { const auto group = Canonicalization::Get(); for (auto& [name, value] : group) { if (name == canonicalization) { - return static_cast(value); + return value; } } return {}; -- cgit v1.2.3 From e7f01128f181a7b754f6d5f94122cde059c7ed1a Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Wed, 21 Jun 2023 21:41:06 -0400 Subject: settings: Give indices to enums --- src/common/settings_enums.h | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'src/common/settings_enums.h') diff --git a/src/common/settings_enums.h b/src/common/settings_enums.h index a5f87c956..f9bb75840 100644 --- a/src/common/settings_enums.h +++ b/src/common/settings_enums.h @@ -11,8 +11,9 @@ namespace Settings { template -struct Canonicalization { - static constexpr std::vector> Get(); +struct EnumMetadata { + static constexpr std::vector> Canonicalizations(); + static constexpr u32 Index(); }; #define PAIR_45(N, X, ...) {#X, N::X} __VA_OPT__(, PAIR_46(N, __VA_ARGS__)) @@ -65,10 +66,17 @@ struct Canonicalization { #define ENUM(NAME, ...) \ enum class NAME : u32 { __VA_ARGS__ }; \ template <> \ - constexpr std::vector> Canonicalization::Get() { \ + constexpr std::vector> EnumMetadata::Canonicalizations() { \ return {PAIR(NAME, __VA_ARGS__)}; \ + } \ + template <> \ + constexpr u32 EnumMetadata::Index() { \ + return __COUNTER__; \ } +// AudioEngine must be specified discretely due to having existing but slightly different +// canonicalizations +// TODO (lat9nq): Remove explicit definition of AudioEngine/sink_id enum class AudioEngine : u32 { Auto, Cubeb, @@ -77,7 +85,8 @@ enum class AudioEngine : u32 { }; template <> -constexpr std::vector> Canonicalization::Get() { +constexpr std::vector> +EnumMetadata::Canonicalizations() { return { {"auto", AudioEngine::Auto}, {"cubeb", AudioEngine::Cubeb}, @@ -86,6 +95,13 @@ constexpr std::vector> Canonicalization +constexpr u32 EnumMetadata::Index() { + // This is just a sufficiently large number that is more than the number of other enums declared + // here + return 100; +} + ENUM(AudioMode, Mono, Stereo, Surround); ENUM(Language, Japanese, EnglishAmerican, French, German, Italian, Spanish, Chinese, Korean, Dutch, @@ -130,7 +146,7 @@ ENUM(AspectRatio, R16_9, R4_3, R21_9, R16_10, Stretch); template constexpr std::string CanonicalizeEnum(Type id) { - const auto group = Canonicalization::Get(); + const auto group = EnumMetadata::Canonicalizations(); for (auto& [name, value] : group) { if (value == id) { return name; @@ -141,7 +157,7 @@ constexpr std::string CanonicalizeEnum(Type id) { template constexpr Type ToEnum(const std::string& canonicalization) { - const auto group = Canonicalization::Get(); + const auto group = EnumMetadata::Canonicalizations(); for (auto& [name, value] : group) { if (name == canonicalization) { return value; -- cgit v1.2.3 From 127b3da0f13ea0850c10115d45488dfe32a0a3f4 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Mon, 17 Jul 2023 19:59:22 -0400 Subject: core,common: Give memory layout setting an enum Allows for 6GB and 8GB layouts to be selected. --- src/common/settings_enums.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/common/settings_enums.h') diff --git a/src/common/settings_enums.h b/src/common/settings_enums.h index f9bb75840..a1a29ebf6 100644 --- a/src/common/settings_enums.h +++ b/src/common/settings_enums.h @@ -131,6 +131,8 @@ ENUM(GpuAccuracy, Normal, High, Extreme); ENUM(CpuAccuracy, Auto, Accurate, Unsafe, Paranoid); +ENUM(MemoryLayout, Memory_4Gb, Memory_6Gb, Memory_8Gb); + ENUM(FullscreenMode, Borderless, Exclusive); ENUM(NvdecEmulation, Off, Cpu, Gpu); -- cgit v1.2.3