From 7a7ac625cd35c3d59f1d109aa791f2964073c2b0 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sun, 16 Feb 2020 21:27:58 +0100 Subject: [PATCH] move enum formatters from system to config files --- rpcs3/Emu/CMakeLists.txt | 1 + rpcs3/Emu/Io/pad_config.cpp | 24 ++++ rpcs3/Emu/System.cpp | 229 ------------------------------ rpcs3/Emu/system_config_types.cpp | 207 +++++++++++++++++++++++++++ rpcs3/emucore.vcxproj | 1 + rpcs3/emucore.vcxproj.filters | 3 + 6 files changed, 236 insertions(+), 229 deletions(-) create mode 100644 rpcs3/Emu/system_config_types.cpp diff --git a/rpcs3/Emu/CMakeLists.txt b/rpcs3/Emu/CMakeLists.txt index 47668d7254..b70834c141 100644 --- a/rpcs3/Emu/CMakeLists.txt +++ b/rpcs3/Emu/CMakeLists.txt @@ -2,6 +2,7 @@ IdManager.cpp System.cpp system_config.cpp + system_config_types.cpp VFS.cpp GDB.cpp title.cpp diff --git a/rpcs3/Emu/Io/pad_config.cpp b/rpcs3/Emu/Io/pad_config.cpp index 5c356dedac..bbc7788ca6 100644 --- a/rpcs3/Emu/Io/pad_config.cpp +++ b/rpcs3/Emu/Io/pad_config.cpp @@ -2,6 +2,30 @@ #include "pad_config.h" #include "Emu/System.h" +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](pad_handler value) + { + switch (value) + { + case pad_handler::null: return "Null"; + case pad_handler::keyboard: return "Keyboard"; + case pad_handler::ds3: return "DualShock 3"; + case pad_handler::ds4: return "DualShock 4"; +#ifdef _WIN32 + case pad_handler::xinput: return "XInput"; + case pad_handler::mm: return "MMJoystick"; +#endif +#ifdef HAVE_LIBEVDEV + case pad_handler::evdev: return "Evdev"; +#endif + } + + return unknown; + }); +} + bool cfg_input::load(const std::string& title_id) { cfg_name = Emulator::GetCustomInputConfigPath(title_id); diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 338d24a4a0..0e84f7dd23 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -76,235 +76,6 @@ atomic_t g_progr_fdone{0}; atomic_t g_progr_ptotal{0}; atomic_t g_progr_pdone{0}; -template <> -void fmt_class_string::format(std::string& out, u64 arg) -{ - format_enum(out, arg, [](mouse_handler value) - { - switch (value) - { - case mouse_handler::null: return "Null"; - case mouse_handler::basic: return "Basic"; - } - - return unknown; - }); -} - -template <> -void fmt_class_string::format(std::string& out, u64 arg) -{ - format_enum(out, arg, [](pad_handler value) - { - switch (value) - { - case pad_handler::null: return "Null"; - case pad_handler::keyboard: return "Keyboard"; - case pad_handler::ds3: return "DualShock 3"; - case pad_handler::ds4: return "DualShock 4"; -#ifdef _WIN32 - case pad_handler::xinput: return "XInput"; - case pad_handler::mm: return "MMJoystick"; -#endif -#ifdef HAVE_LIBEVDEV - case pad_handler::evdev: return "Evdev"; -#endif - } - - return unknown; - }); -} - -template <> -void fmt_class_string::format(std::string& out, u64 arg) -{ - format_enum(out, arg, [](video_renderer value) - { - switch (value) - { - case video_renderer::null: return "Null"; - case video_renderer::opengl: return "OpenGL"; - case video_renderer::vulkan: return "Vulkan"; - } - - return unknown; - }); -} - -template <> -void fmt_class_string::format(std::string& out, u64 arg) -{ - format_enum(out, arg, [](video_resolution value) - { - switch (value) - { - case video_resolution::_1080: return "1920x1080"; - case video_resolution::_720: return "1280x720"; - case video_resolution::_480: return "720x480"; - case video_resolution::_576: return "720x576"; - case video_resolution::_1600x1080: return "1600x1080"; - case video_resolution::_1440x1080: return "1440x1080"; - case video_resolution::_1280x1080: return "1280x1080"; - case video_resolution::_960x1080: return "960x1080"; - } - - return unknown; - }); -} - -template <> -void fmt_class_string::format(std::string& out, u64 arg) -{ - format_enum(out, arg, [](video_aspect value) - { - switch (value) - { - case video_aspect::_4_3: return "4:3"; - case video_aspect::_16_9: return "16:9"; - } - - return unknown; - }); -} - -template <> -void fmt_class_string::format(std::string& out, u64 arg) -{ - format_enum(out, arg, [](msaa_level value) - { - switch (value) - { - case msaa_level::none: return "Disabled"; - case msaa_level::_auto: return "Auto"; - } - - return unknown; - }); -} - -template <> -void fmt_class_string::format(std::string& out, u64 arg) -{ - format_enum(out, arg, [](keyboard_handler value) - { - switch (value) - { - case keyboard_handler::null: return "Null"; - case keyboard_handler::basic: return "Basic"; - } - - return unknown; - }); -} - -template <> -void fmt_class_string::format(std::string& out, u64 arg) -{ - format_enum(out, arg, [](audio_renderer value) - { - switch (value) - { - case audio_renderer::null: return "Null"; -#ifdef _WIN32 - case audio_renderer::xaudio: return "XAudio2"; -#endif -#ifdef HAVE_ALSA - case audio_renderer::alsa: return "ALSA"; -#endif -#ifdef HAVE_PULSE - case audio_renderer::pulse: return "PulseAudio"; -#endif - case audio_renderer::openal: return "OpenAL"; -#ifdef HAVE_FAUDIO - case audio_renderer::faudio: return "FAudio"; -#endif - } - - return unknown; - }); -} - -template <> -void fmt_class_string::format(std::string& out, u64 arg) -{ - format_enum(out, arg, [](detail_level value) - { - switch (value) - { - case detail_level::minimal: return "Minimal"; - case detail_level::low: return "Low"; - case detail_level::medium: return "Medium"; - case detail_level::high: return "High"; - } - - return unknown; - }); -} - -template <> -void fmt_class_string::format(std::string& out, u64 arg) -{ - format_enum(out, arg, [](screen_quadrant value) - { - switch (value) - { - case screen_quadrant::top_left: return "Top Left"; - case screen_quadrant::top_right: return "Top Right"; - case screen_quadrant::bottom_left: return "Bottom Left"; - case screen_quadrant::bottom_right: return "Bottom Right"; - } - - return unknown; - }); -} - -template <> -void fmt_class_string::format(std::string& out, u64 arg) -{ - format_enum(out, arg, [](tsx_usage value) - { - switch (value) - { - case tsx_usage::disabled: return "Disabled"; - case tsx_usage::enabled: return "Enabled"; - case tsx_usage::forced: return "Forced"; - } - - return unknown; - }); -} - -template <> -void fmt_class_string::format(std::string& out, u64 arg) -{ - format_enum(out, arg, [](sleep_timers_accuracy_level value) - { - switch (value) - { - case sleep_timers_accuracy_level::_as_host: return "As Host"; - case sleep_timers_accuracy_level::_usleep: return "Usleep Only"; - case sleep_timers_accuracy_level::_all_timers: return "All Timers"; - } - - return unknown; - }); -} - -template <> -void fmt_class_string::format(std::string& out, u64 arg) -{ - format_enum(out, arg, [](enter_button_assign value) - { - switch (value) - { - case enter_button_assign::circle: return "Enter with circle"; - case enter_button_assign::cross: return "Enter with cross"; - } - - return unknown; - }); -} - void Emulator::Init() { jit_runtime::initialize(); diff --git a/rpcs3/Emu/system_config_types.cpp b/rpcs3/Emu/system_config_types.cpp new file mode 100644 index 0000000000..8c418e6cf3 --- /dev/null +++ b/rpcs3/Emu/system_config_types.cpp @@ -0,0 +1,207 @@ +#include "stdafx.h" +#include "system_config_types.h" + +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](mouse_handler value) + { + switch (value) + { + case mouse_handler::null: return "Null"; + case mouse_handler::basic: return "Basic"; + } + + return unknown; + }); +} + +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](video_renderer value) + { + switch (value) + { + case video_renderer::null: return "Null"; + case video_renderer::opengl: return "OpenGL"; + case video_renderer::vulkan: return "Vulkan"; + } + + return unknown; + }); +} + +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](video_resolution value) + { + switch (value) + { + case video_resolution::_1080: return "1920x1080"; + case video_resolution::_720: return "1280x720"; + case video_resolution::_480: return "720x480"; + case video_resolution::_576: return "720x576"; + case video_resolution::_1600x1080: return "1600x1080"; + case video_resolution::_1440x1080: return "1440x1080"; + case video_resolution::_1280x1080: return "1280x1080"; + case video_resolution::_960x1080: return "960x1080"; + } + + return unknown; + }); +} + +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](video_aspect value) + { + switch (value) + { + case video_aspect::_4_3: return "4:3"; + case video_aspect::_16_9: return "16:9"; + } + + return unknown; + }); +} + +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](msaa_level value) + { + switch (value) + { + case msaa_level::none: return "Disabled"; + case msaa_level::_auto: return "Auto"; + } + + return unknown; + }); +} + +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](keyboard_handler value) + { + switch (value) + { + case keyboard_handler::null: return "Null"; + case keyboard_handler::basic: return "Basic"; + } + + return unknown; + }); +} + +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](audio_renderer value) + { + switch (value) + { + case audio_renderer::null: return "Null"; +#ifdef _WIN32 + case audio_renderer::xaudio: return "XAudio2"; +#endif +#ifdef HAVE_ALSA + case audio_renderer::alsa: return "ALSA"; +#endif +#ifdef HAVE_PULSE + case audio_renderer::pulse: return "PulseAudio"; +#endif + case audio_renderer::openal: return "OpenAL"; +#ifdef HAVE_FAUDIO + case audio_renderer::faudio: return "FAudio"; +#endif + } + + return unknown; + }); +} + +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](detail_level value) + { + switch (value) + { + case detail_level::minimal: return "Minimal"; + case detail_level::low: return "Low"; + case detail_level::medium: return "Medium"; + case detail_level::high: return "High"; + } + + return unknown; + }); +} + +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](screen_quadrant value) + { + switch (value) + { + case screen_quadrant::top_left: return "Top Left"; + case screen_quadrant::top_right: return "Top Right"; + case screen_quadrant::bottom_left: return "Bottom Left"; + case screen_quadrant::bottom_right: return "Bottom Right"; + } + + return unknown; + }); +} + +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](tsx_usage value) + { + switch (value) + { + case tsx_usage::disabled: return "Disabled"; + case tsx_usage::enabled: return "Enabled"; + case tsx_usage::forced: return "Forced"; + } + + return unknown; + }); +} + +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](sleep_timers_accuracy_level value) + { + switch (value) + { + case sleep_timers_accuracy_level::_as_host: return "As Host"; + case sleep_timers_accuracy_level::_usleep: return "Usleep Only"; + case sleep_timers_accuracy_level::_all_timers: return "All Timers"; + } + + return unknown; + }); +} + +template <> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](enter_button_assign value) + { + switch (value) + { + case enter_button_assign::circle: return "Enter with circle"; + case enter_button_assign::cross: return "Enter with cross"; + } + + return unknown; + }); +} diff --git a/rpcs3/emucore.vcxproj b/rpcs3/emucore.vcxproj index 5188ea935f..4d0d32bdc8 100644 --- a/rpcs3/emucore.vcxproj +++ b/rpcs3/emucore.vcxproj @@ -74,6 +74,7 @@ + diff --git a/rpcs3/emucore.vcxproj.filters b/rpcs3/emucore.vcxproj.filters index 3f32d9a18c..bca5a1c828 100644 --- a/rpcs3/emucore.vcxproj.filters +++ b/rpcs3/emucore.vcxproj.filters @@ -893,6 +893,9 @@ Emu\Io + + Emu +