Files
eden/src/core/settings.h
T

223 lines
5.0 KiB
C++
Raw Normal View History

2014-09-12 17:06:13 -07:00
// Copyright 2014 Citra Emulator Project
2014-12-16 21:38:14 -08:00
// Licensed under GPLv2 or any later version
2014-09-12 17:06:13 -07:00
// Refer to the license.txt file included.
#pragma once
2015-06-20 04:34:45 +01:00
#include <array>
2018-09-09 00:57:41 +02:00
#include <atomic>
#include <chrono>
#include <map>
2018-11-11 22:34:23 -05:00
#include <optional>
2016-09-18 09:38:01 +09:00
#include <string>
#include <vector>
#include "common/common_types.h"
2020-07-22 10:39:53 -04:00
#include "input_common/settings.h"
2014-12-06 20:00:08 -02:00
2014-09-12 17:06:13 -07:00
namespace Settings {
2020-01-21 16:37:41 -03:00
enum class RendererBackend {
OpenGL = 0,
Vulkan = 1,
};
enum class GPUAccuracy : u32 {
Normal = 0,
High = 1,
Extreme = 2,
};
2020-07-11 16:25:49 +01:00
enum class CPUAccuracy {
Accurate = 0,
2020-08-16 13:19:55 +01:00
Unsafe = 1,
DebugMode = 2,
2020-07-11 16:25:49 +01:00
};
template <typename Type>
class Setting final {
public:
Setting() = default;
explicit Setting(Type val) : global{val} {}
~Setting() = default;
void SetGlobal(bool to_global) {
use_global = to_global;
}
bool UsingGlobal() const {
return use_global;
}
Type GetValue(bool need_global = false) const {
if (use_global || need_global) {
return global;
}
return local;
}
void SetValue(const Type& value) {
if (use_global) {
global = value;
} else {
local = value;
}
}
private:
bool use_global = true;
Type global{};
Type local{};
};
2020-07-14 19:01:36 +02:00
struct TouchFromButtonMap {
std::string name;
std::vector<std::string> buttons;
};
2014-09-12 17:06:13 -07:00
struct Values {
// Audio
std::string audio_device_id;
std::string sink_id;
bool audio_muted;
Setting<bool> enable_audio_stretching;
Setting<float> volume;
// Core
Setting<bool> use_multi_core;
// Cpu
2020-07-11 16:25:49 +01:00
CPUAccuracy cpu_accuracy;
bool cpuopt_page_tables;
bool cpuopt_block_linking;
bool cpuopt_return_stack_buffer;
bool cpuopt_fast_dispatcher;
bool cpuopt_context_elimination;
bool cpuopt_const_prop;
bool cpuopt_misc_ir;
bool cpuopt_reduce_misalign_checks;
2020-08-16 13:19:55 +01:00
bool cpuopt_unsafe_unfuse_fma;
bool cpuopt_unsafe_reduce_fp_error;
// Renderer
Setting<RendererBackend> renderer_backend;
bool renderer_debug;
Setting<int> vulkan_device;
Setting<u16> resolution_factor = Setting(static_cast<u16>(1));
Setting<int> aspect_ratio;
Setting<int> max_anisotropy;
Setting<bool> use_frame_limit;
Setting<u16> frame_limit;
Setting<bool> use_disk_shader_cache;
Setting<GPUAccuracy> gpu_accuracy;
Setting<bool> use_asynchronous_gpu_emulation;
2020-10-26 23:07:36 -04:00
Setting<bool> use_nvdec_emulation;
Setting<bool> use_vsync;
Setting<bool> use_assembly_shaders;
2020-07-10 14:00:02 +10:00
Setting<bool> use_asynchronous_shaders;
Setting<bool> use_fast_gpu_time;
Setting<float> bg_red;
Setting<float> bg_green;
Setting<float> bg_blue;
// System
Setting<std::optional<u32>> rng_seed;
2019-01-07 19:40:23 -05:00
// Measured in seconds since epoch
Setting<std::optional<std::chrono::seconds>> custom_rtc;
2019-01-07 19:40:23 -05:00
// Set on game boot, reset on stop. Seconds difference between current time and `custom_rtc`
std::chrono::seconds custom_rtc_differential;
2018-11-06 16:38:10 +01:00
s32 current_user;
Setting<s32> language_index;
Setting<s32> region_index;
Setting<s32> time_zone_index;
Setting<s32> sound_index;
// Controls
std::array<PlayerInput, 10> players;
2020-07-22 10:39:53 -04:00
bool use_docked_mode;
2018-11-01 21:52:51 -04:00
bool mouse_enabled;
std::string mouse_device;
MouseButtonsRaw mouse_buttons;
2018-11-01 21:53:31 -04:00
bool keyboard_enabled;
KeyboardKeysRaw keyboard_keys;
KeyboardModsRaw keyboard_mods;
bool debug_pad_enabled;
ButtonsRaw debug_pad_buttons;
AnalogsRaw debug_pad_analogs;
2020-07-22 10:39:53 -04:00
bool vibration_enabled;
bool motion_enabled;
2020-07-14 19:01:36 +02:00
std::string motion_device;
std::string touch_device;
TouchscreenInput touchscreen;
2018-09-09 00:57:41 +02:00
std::atomic_bool is_device_reload_pending{true};
2020-07-14 19:01:36 +02:00
bool use_touch_from_button;
int touch_from_button_map_index;
std::string udp_input_address;
u16 udp_input_port;
u8 udp_pad_index;
2020-07-14 19:01:36 +02:00
std::vector<TouchFromButtonMap> touch_from_button_maps;
2017-01-20 22:46:39 +02:00
// Data Storage
bool use_virtual_sd;
bool gamecard_inserted;
bool gamecard_current_game;
std::string gamecard_path;
2014-10-27 17:18:28 -04:00
2015-09-02 08:56:38 -04:00
// Debugging
bool record_frame_times;
2015-09-02 08:56:38 -04:00
bool use_gdbstub;
u16 gdbstub_port;
2018-09-30 14:05:12 -04:00
std::string program_args;
bool dump_exefs;
bool dump_nso;
bool reporting_services;
bool quest_flag;
2020-05-29 14:53:27 +10:00
bool disable_macro_jit;
2018-09-16 20:05:51 +02:00
// Misceallaneous
std::string log_filter;
bool use_dev_keys;
// Services
2019-04-28 18:44:46 -04:00
std::string bcat_backend;
bool bcat_boxcat_local;
2018-09-16 20:05:51 +02:00
// WebService
bool enable_telemetry;
std::string web_api_url;
std::string yuzu_username;
std::string yuzu_token;
// Add-Ons
std::map<u64, std::vector<std::string>> disabled_addons;
};
2014-09-12 17:06:13 -07:00
extern Values values;
bool IsConfiguringGlobal();
void SetConfiguringGlobal(bool is_global);
2020-06-25 21:05:03 +02:00
2020-04-15 21:42:05 -04:00
bool IsGPULevelExtreme();
bool IsGPULevelHigh();
float Volume();
std::string GetTimeZoneString();
2016-04-11 14:38:42 +02:00
void Apply();
2018-07-10 18:02:14 +08:00
void LogSettings();
// Restore the global state of all applicable settings in the Values struct
void RestoreGlobalState();
// Fixes settings that are known to cause issues with the emulator
void Sanitize();
2017-08-25 23:53:07 +02:00
} // namespace Settings