settings.h 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946
  1. // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <algorithm>
  5. #include <array>
  6. #include <forward_list>
  7. #include <functional>
  8. #include <map>
  9. #include <optional>
  10. #include <stdexcept>
  11. #include <string>
  12. #include <typeindex>
  13. #include <utility>
  14. #include <vector>
  15. #include "common/common_types.h"
  16. #include "common/settings_input.h"
  17. namespace Settings {
  18. enum class AnisotropyMode : u32 {
  19. Automatic = 0,
  20. Default = 1,
  21. X2 = 2,
  22. X4 = 3,
  23. X8 = 4,
  24. X16 = 5,
  25. };
  26. enum class AstcDecodeMode : u32 {
  27. CPU = 0,
  28. GPU = 1,
  29. CPUAsynchronous = 2,
  30. };
  31. enum class VSyncMode : u32 {
  32. Immediate = 0,
  33. Mailbox = 1,
  34. FIFO = 2,
  35. FIFORelaxed = 3,
  36. };
  37. enum class RendererBackend : u32 {
  38. OpenGL = 0,
  39. Vulkan = 1,
  40. Null = 2,
  41. };
  42. enum class ShaderBackend : u32 {
  43. GLSL = 0,
  44. GLASM = 1,
  45. SPIRV = 2,
  46. };
  47. enum class GPUAccuracy : u32 {
  48. Normal = 0,
  49. High = 1,
  50. Extreme = 2,
  51. MaxEnum = 3,
  52. };
  53. enum class CPUAccuracy : u32 {
  54. Auto = 0,
  55. Accurate = 1,
  56. Unsafe = 2,
  57. Paranoid = 3,
  58. };
  59. enum class FullscreenMode : u32 {
  60. Borderless = 0,
  61. Exclusive = 1,
  62. };
  63. enum class NvdecEmulation : u32 {
  64. Off = 0,
  65. CPU = 1,
  66. GPU = 2,
  67. };
  68. enum class ResolutionSetup : u32 {
  69. Res1_2X = 0,
  70. Res3_4X = 1,
  71. Res1X = 2,
  72. Res3_2X = 3,
  73. Res2X = 4,
  74. Res3X = 5,
  75. Res4X = 6,
  76. Res5X = 7,
  77. Res6X = 8,
  78. Res7X = 9,
  79. Res8X = 10,
  80. };
  81. enum class ScalingFilter : u32 {
  82. NearestNeighbor = 0,
  83. Bilinear = 1,
  84. Bicubic = 2,
  85. Gaussian = 3,
  86. ScaleForce = 4,
  87. Fsr = 5,
  88. LastFilter = Fsr,
  89. };
  90. enum class AntiAliasing : u32 {
  91. None = 0,
  92. Fxaa = 1,
  93. Smaa = 2,
  94. LastAA = Smaa,
  95. };
  96. enum class AstcRecompression : u32 {
  97. Uncompressed = 0,
  98. Bc1 = 1,
  99. Bc3 = 2,
  100. };
  101. enum class AspectRatio : u32 {
  102. R16_9,
  103. R4_3,
  104. R21_9,
  105. R16_10,
  106. Stretch,
  107. };
  108. enum class Category : u32 {
  109. Audio,
  110. Core,
  111. Cpu,
  112. CpuDebug,
  113. CpuUnsafe,
  114. Renderer,
  115. RendererAdvanced,
  116. RendererDebug,
  117. System,
  118. DataStorage,
  119. Debugging,
  120. DebuggingGraphics,
  121. Miscellaneous,
  122. Network,
  123. WebService,
  124. AddOns,
  125. Controls,
  126. Ui,
  127. UiLayout,
  128. UiGameList,
  129. Screenshots,
  130. Shortcuts,
  131. Multiplayer,
  132. Services,
  133. Paths,
  134. MaxEnum,
  135. };
  136. const char* TranslateCategory(Settings::Category category);
  137. struct ResolutionScalingInfo {
  138. u32 up_scale{1};
  139. u32 down_shift{0};
  140. f32 up_factor{1.0f};
  141. f32 down_factor{1.0f};
  142. bool active{};
  143. bool downscale{};
  144. s32 ScaleUp(s32 value) const {
  145. if (value == 0) {
  146. return 0;
  147. }
  148. return std::max((value * static_cast<s32>(up_scale)) >> static_cast<s32>(down_shift), 1);
  149. }
  150. u32 ScaleUp(u32 value) const {
  151. if (value == 0U) {
  152. return 0U;
  153. }
  154. return std::max((value * up_scale) >> down_shift, 1U);
  155. }
  156. };
  157. class BasicSetting {
  158. protected:
  159. explicit BasicSetting() = default;
  160. public:
  161. virtual ~BasicSetting() = default;
  162. virtual Category Category() const = 0;
  163. virtual constexpr bool Switchable() const = 0;
  164. virtual std::string ToString() const = 0;
  165. virtual std::string ToStringGlobal() const {
  166. return {};
  167. }
  168. virtual void LoadString(const std::string& load) = 0;
  169. virtual const std::string& GetLabel() const = 0;
  170. virtual std::string DefaultToString() const = 0;
  171. virtual bool Save() const = 0;
  172. virtual std::type_index TypeId() const = 0;
  173. virtual bool IsEnum() const = 0;
  174. virtual bool RuntimeModfiable() const = 0;
  175. virtual void SetGlobal(bool global) {}
  176. virtual constexpr u32 Id() const = 0;
  177. virtual bool UsingGlobal() const {
  178. return false;
  179. }
  180. };
  181. class Linkage {
  182. public:
  183. std::map<Category, std::forward_list<BasicSetting*>> by_category;
  184. std::vector<std::function<void()>> restore_functions;
  185. u32 count;
  186. };
  187. /** The Setting class is a simple resource manager. It defines a label and default value
  188. * alongside the actual value of the setting for simpler and less-error prone use with frontend
  189. * configurations. Specifying a default value and label is required. A minimum and maximum range
  190. * can be specified for sanitization.
  191. */
  192. template <typename Type, bool ranged = false, bool save = true, bool runtime_modifiable = false>
  193. class Setting : public BasicSetting {
  194. protected:
  195. Setting() = default;
  196. /**
  197. * Only sets the setting to the given initializer, leaving the other members to their default
  198. * initializers.
  199. *
  200. * @param global_val Initial value of the setting
  201. */
  202. explicit Setting(const Type& val) : value{val} {}
  203. public:
  204. /**
  205. * Sets a default value, label, and setting value.
  206. *
  207. * @param linkage Setting registry
  208. * @param default_val Initial value of the setting, and default value of the setting
  209. * @param name Label for the setting
  210. * @param category_ Category of the setting AKA INI group
  211. */
  212. explicit Setting(Linkage& linkage, const Type& default_val, const std::string& name,
  213. enum Category category_)
  214. requires(!ranged)
  215. : value{default_val},
  216. default_value{default_val}, label{name}, category{category_}, id{linkage.count} {
  217. linkage.by_category[category].push_front(this);
  218. linkage.count++;
  219. }
  220. virtual ~Setting() = default;
  221. /**
  222. * Sets a default value, minimum value, maximum value, and label.
  223. *
  224. * @param linkage Setting registry
  225. * @param default_val Initial value of the setting, and default value of the setting
  226. * @param min_val Sets the minimum allowed value of the setting
  227. * @param max_val Sets the maximum allowed value of the setting
  228. * @param name Label for the setting
  229. * @param category_ Category of the setting AKA INI group
  230. */
  231. explicit Setting(Linkage& linkage, const Type& default_val, const Type& min_val,
  232. const Type& max_val, const std::string& name, enum Category category_)
  233. requires(ranged)
  234. : value{default_val}, default_value{default_val}, maximum{max_val}, minimum{min_val},
  235. label{name}, category{category_}, id{linkage.count} {
  236. linkage.by_category[category].push_front(this);
  237. linkage.count++;
  238. }
  239. /**
  240. * Returns a reference to the setting's value.
  241. *
  242. * @returns A reference to the setting
  243. */
  244. [[nodiscard]] virtual const Type& GetValue() const {
  245. return value;
  246. }
  247. /**
  248. * Sets the setting to the given value.
  249. *
  250. * @param val The desired value
  251. */
  252. virtual void SetValue(const Type& val) {
  253. Type temp{ranged ? std::clamp(val, minimum, maximum) : val};
  254. std::swap(value, temp);
  255. }
  256. /**
  257. * Returns the value that this setting was created with.
  258. *
  259. * @returns A reference to the default value
  260. */
  261. [[nodiscard]] const Type& GetDefault() const {
  262. return default_value;
  263. }
  264. /**
  265. * Returns the label this setting was created with.
  266. *
  267. * @returns A reference to the label
  268. */
  269. [[nodiscard]] const std::string& GetLabel() const override {
  270. return label;
  271. }
  272. /**
  273. * Returns the setting's category AKA INI group.
  274. *
  275. * @returns The setting's category
  276. */
  277. [[nodiscard]] enum Category Category() const override {
  278. return category;
  279. }
  280. [[nodiscard]] bool RuntimeModfiable() const override {
  281. return runtime_modifiable;
  282. }
  283. [[nodiscard]] bool IsEnum() const override {
  284. return std::is_enum<Type>::value;
  285. }
  286. /**
  287. * Returns whether the current setting is Switchable.
  288. *
  289. * @returns If the setting is a SwitchableSetting
  290. */
  291. [[nodiscard]] virtual constexpr bool Switchable() const override {
  292. return false;
  293. }
  294. protected:
  295. std::string ToString(const Type& value_) const {
  296. if constexpr (std::is_same<Type, std::string>()) {
  297. return value_;
  298. } else if constexpr (std::is_same<Type, std::optional<u32>>()) {
  299. return value_.has_value() ? std::to_string(*value_) : "0";
  300. } else if constexpr (std::is_same<Type, bool>()) {
  301. return value_ ? "true" : "false";
  302. } else {
  303. return std::to_string(static_cast<u64>(value_));
  304. }
  305. }
  306. public:
  307. /**
  308. * Converts the value of the setting to a std::string. Respects the global state if the setting
  309. * has one.
  310. *
  311. * @returns The current setting as a std::string
  312. */
  313. std::string ToString() const override {
  314. return ToString(this->GetValue());
  315. }
  316. /**
  317. * Returns the default value of the setting as a std::string.
  318. *
  319. * @returns The default value as a string.
  320. */
  321. std::string DefaultToString() const override {
  322. return ToString(default_value);
  323. }
  324. /**
  325. * Assigns a value to the setting.
  326. *
  327. * @param val The desired setting value
  328. *
  329. * @returns A reference to the setting
  330. */
  331. virtual const Type& operator=(const Type& val) {
  332. Type temp{ranged ? std::clamp(val, minimum, maximum) : val};
  333. std::swap(value, temp);
  334. return value;
  335. }
  336. /**
  337. * Returns a reference to the setting.
  338. *
  339. * @returns A reference to the setting
  340. */
  341. explicit virtual operator const Type&() const {
  342. return value;
  343. }
  344. /**
  345. * Converts the given value to the Setting's type of value. Uses SetValue to enter the setting,
  346. * thus respecting its constraints.
  347. *
  348. * @param input The desired value
  349. */
  350. void LoadString(const std::string& input) override {
  351. if (input.empty()) {
  352. this->SetValue(this->GetDefault());
  353. return;
  354. }
  355. try {
  356. if constexpr (std::is_same<Type, std::string>()) {
  357. this->SetValue(input);
  358. } else if constexpr (std::is_same<Type, std::optional<u32>>()) {
  359. this->SetValue(static_cast<u32>(std::stoll(input)));
  360. } else if constexpr (std::is_same<Type, bool>()) {
  361. this->SetValue(input == "true");
  362. } else {
  363. this->SetValue(static_cast<Type>(std::stoll(input)));
  364. }
  365. } catch (std::invalid_argument) {
  366. this->SetValue(this->GetDefault());
  367. }
  368. }
  369. /**
  370. * Returns the save preference of the setting i.e. when saving or reading the setting from a
  371. * frontend, whether this setting should be skipped.
  372. *
  373. * @returns The save preference
  374. */
  375. virtual bool Save() const override {
  376. return save;
  377. }
  378. /**
  379. * Gives us another way to identify the setting without having to go through a string.
  380. *
  381. * @returns the type_index of the setting's type
  382. */
  383. virtual std::type_index TypeId() const override {
  384. return std::type_index(typeid(Type));
  385. }
  386. virtual constexpr u32 Id() const override {
  387. return id;
  388. }
  389. protected:
  390. Type value{}; ///< The setting
  391. const Type default_value{}; ///< The default value
  392. const Type maximum{}; ///< Maximum allowed value of the setting
  393. const Type minimum{}; ///< Minimum allowed value of the setting
  394. const std::string label{}; ///< The setting's label
  395. const enum Category category; ///< The setting's category AKA INI group
  396. const u32 id;
  397. };
  398. /**
  399. * The SwitchableSetting class is a slightly more complex version of the Setting class. This adds a
  400. * custom setting to switch to when a guest application specifically requires it. The effect is that
  401. * other components of the emulator can access the setting's intended value without any need for the
  402. * component to ask whether the custom or global setting is needed at the moment.
  403. *
  404. * By default, the global setting is used.
  405. */
  406. template <typename Type, bool ranged = false, bool save = true, bool runtime_modifiable = false>
  407. class SwitchableSetting : virtual public Setting<Type, ranged, save, runtime_modifiable> {
  408. public:
  409. /**
  410. * Sets a default value, label, and setting value.
  411. *
  412. * @param linkage Setting registry
  413. * @param default_val Initial value of the setting, and default value of the setting
  414. * @param name Label for the setting
  415. * @param category_ Category of the setting AKA INI group
  416. */
  417. explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const std::string& name,
  418. Category category)
  419. requires(!ranged)
  420. : Setting<Type, false, save, runtime_modifiable>{linkage, default_val, name, category} {
  421. linkage.restore_functions.emplace_back([this]() { this->SetGlobal(true); });
  422. }
  423. virtual ~SwitchableSetting() = default;
  424. /**
  425. * Sets a default value, minimum value, maximum value, and label.
  426. *
  427. * @param linkage Setting registry
  428. * @param default_val Initial value of the setting, and default value of the setting
  429. * @param min_val Sets the minimum allowed value of the setting
  430. * @param max_val Sets the maximum allowed value of the setting
  431. * @param name Label for the setting
  432. * @param category_ Category of the setting AKA INI group
  433. */
  434. explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const Type& min_val,
  435. const Type& max_val, const std::string& name, Category category)
  436. requires(ranged)
  437. : Setting<Type, true, save, runtime_modifiable>{linkage, default_val, min_val,
  438. max_val, name, category} {
  439. linkage.restore_functions.emplace_back([this]() { this->SetGlobal(true); });
  440. }
  441. /**
  442. * Tells this setting to represent either the global or custom setting when other member
  443. * functions are used.
  444. *
  445. * @param to_global Whether to use the global or custom setting.
  446. */
  447. void SetGlobal(bool to_global) override {
  448. use_global = to_global;
  449. }
  450. /**
  451. * Returns whether this setting is using the global setting or not.
  452. *
  453. * @returns The global state
  454. */
  455. [[nodiscard]] bool UsingGlobal() const override {
  456. return use_global;
  457. }
  458. /**
  459. * Returns either the global or custom setting depending on the values of this setting's global
  460. * state or if the global value was specifically requested.
  461. *
  462. * @param need_global Request global value regardless of setting's state; defaults to false
  463. *
  464. * @returns The required value of the setting
  465. */
  466. [[nodiscard]] virtual const Type& GetValue() const override {
  467. if (use_global) {
  468. return this->value;
  469. }
  470. return custom;
  471. }
  472. [[nodiscard]] virtual const Type& GetValue(bool need_global) const {
  473. if (use_global || need_global) {
  474. return this->value;
  475. }
  476. return custom;
  477. }
  478. /**
  479. * Sets the current setting value depending on the global state.
  480. *
  481. * @param val The new value
  482. */
  483. void SetValue(const Type& val) override {
  484. Type temp{ranged ? std::clamp(val, this->minimum, this->maximum) : val};
  485. if (use_global) {
  486. std::swap(this->value, temp);
  487. } else {
  488. std::swap(custom, temp);
  489. }
  490. }
  491. [[nodiscard]] virtual constexpr bool Switchable() const override {
  492. return true;
  493. }
  494. [[nodiscard]] virtual std::string ToStringGlobal() const override {
  495. return this->ToString(this->value);
  496. }
  497. /**
  498. * Assigns the current setting value depending on the global state.
  499. *
  500. * @param val The new value
  501. *
  502. * @returns A reference to the current setting value
  503. */
  504. const Type& operator=(const Type& val) override {
  505. Type temp{ranged ? std::clamp(val, this->minimum, this->maximum) : val};
  506. if (use_global) {
  507. std::swap(this->value, temp);
  508. return this->value;
  509. }
  510. std::swap(custom, temp);
  511. return custom;
  512. }
  513. /**
  514. * Returns the current setting value depending on the global state.
  515. *
  516. * @returns A reference to the current setting value
  517. */
  518. virtual explicit operator const Type&() const override {
  519. if (use_global) {
  520. return this->value;
  521. }
  522. return custom;
  523. }
  524. protected:
  525. bool use_global{true}; ///< The setting's global state
  526. Type custom{}; ///< The custom value of the setting
  527. };
  528. /**
  529. * The InputSetting class allows for getting a reference to either the global or custom members.
  530. * This is required as we cannot easily modify the values of user-defined types within containers
  531. * using the SetValue() member function found in the Setting class. The primary purpose of this
  532. * class is to store an array of 10 PlayerInput structs for both the global and custom setting and
  533. * allows for easily accessing and modifying both settings.
  534. */
  535. template <typename Type>
  536. class InputSetting final {
  537. public:
  538. InputSetting() = default;
  539. explicit InputSetting(Type val) : Setting<Type>(val) {}
  540. ~InputSetting() = default;
  541. void SetGlobal(bool to_global) {
  542. use_global = to_global;
  543. }
  544. [[nodiscard]] bool UsingGlobal() const {
  545. return use_global;
  546. }
  547. [[nodiscard]] Type& GetValue(bool need_global = false) {
  548. if (use_global || need_global) {
  549. return global;
  550. }
  551. return custom;
  552. }
  553. private:
  554. bool use_global{true}; ///< The setting's global state
  555. Type global{}; ///< The setting
  556. Type custom{}; ///< The custom setting value
  557. };
  558. struct TouchFromButtonMap {
  559. std::string name;
  560. std::vector<std::string> buttons;
  561. };
  562. struct Values {
  563. Linkage linkage{};
  564. // Audio
  565. Setting<std::string> sink_id{linkage, "auto", "output_engine", Category::Audio};
  566. Setting<std::string> audio_output_device_id{linkage, "auto", "output_device", Category::Audio};
  567. Setting<std::string> audio_input_device_id{linkage, "auto", "input_device", Category::Audio};
  568. Setting<bool, false, false> audio_muted{linkage, false, "audio_muted", Category::Audio};
  569. SwitchableSetting<u8, true> volume{linkage, 100, 0, 200, "volume", Category::Audio};
  570. Setting<bool, false, false> dump_audio_commands{linkage, false, "dump_audio_commands",
  571. Category::Audio};
  572. // Core
  573. SwitchableSetting<bool> use_multi_core{linkage, true, "use_multi_core", Category::Core};
  574. SwitchableSetting<bool> use_unsafe_extended_memory_layout{
  575. linkage, false, "use_unsafe_extended_memory_layout", Category::Core};
  576. // Cpu
  577. SwitchableSetting<CPUAccuracy, true> cpu_accuracy{linkage, CPUAccuracy::Auto,
  578. CPUAccuracy::Auto, CPUAccuracy::Paranoid,
  579. "cpu_accuracy", Category::Cpu};
  580. // TODO: remove cpu_accuracy_first_time, migration setting added 8 July 2021
  581. Setting<bool> cpu_accuracy_first_time{linkage, true, "cpu_accuracy_first_time", Category::Cpu};
  582. Setting<bool> cpu_debug_mode{linkage, false, "cpu_debug_mode", Category::CpuDebug};
  583. Setting<bool> cpuopt_page_tables{linkage, true, "cpuopt_page_tables", Category::CpuDebug};
  584. Setting<bool> cpuopt_block_linking{linkage, true, "cpuopt_block_linking", Category::CpuDebug};
  585. Setting<bool> cpuopt_return_stack_buffer{linkage, true, "cpuopt_return_stack_buffer",
  586. Category::CpuDebug};
  587. Setting<bool> cpuopt_fast_dispatcher{linkage, true, "cpuopt_fast_dispatcher",
  588. Category::CpuDebug};
  589. Setting<bool> cpuopt_context_elimination{linkage, true, "cpuopt_context_elimination",
  590. Category::CpuDebug};
  591. Setting<bool> cpuopt_const_prop{linkage, true, "cpuopt_const_prop", Category::CpuDebug};
  592. Setting<bool> cpuopt_misc_ir{linkage, true, "cpuopt_misc_ir", Category::CpuDebug};
  593. Setting<bool> cpuopt_reduce_misalign_checks{linkage, true, "cpuopt_reduce_misalign_checks",
  594. Category::CpuDebug};
  595. Setting<bool> cpuopt_fastmem{linkage, true, "cpuopt_fastmem", Category::CpuDebug};
  596. Setting<bool> cpuopt_fastmem_exclusives{linkage, true, "cpuopt_fastmem_exclusives",
  597. Category::CpuDebug};
  598. Setting<bool> cpuopt_recompile_exclusives{linkage, true, "cpuopt_recompile_exclusives",
  599. Category::CpuDebug};
  600. Setting<bool> cpuopt_ignore_memory_aborts{linkage, true, "cpuopt_ignore_memory_aborts",
  601. Category::CpuDebug};
  602. SwitchableSetting<bool> cpuopt_unsafe_unfuse_fma{linkage, true, "cpuopt_unsafe_unfuse_fma",
  603. Category::CpuUnsafe};
  604. SwitchableSetting<bool> cpuopt_unsafe_reduce_fp_error{
  605. linkage, true, "cpuopt_unsafe_reduce_fp_error", Category::CpuUnsafe};
  606. SwitchableSetting<bool> cpuopt_unsafe_ignore_standard_fpcr{
  607. linkage, true, "cpuopt_unsafe_ignore_standard_fpcr", Category::CpuUnsafe};
  608. SwitchableSetting<bool> cpuopt_unsafe_inaccurate_nan{
  609. linkage, true, "cpuopt_unsafe_inaccurate_nan", Category::CpuUnsafe};
  610. SwitchableSetting<bool> cpuopt_unsafe_fastmem_check{
  611. linkage, true, "cpuopt_unsafe_fastmem_check", Category::CpuUnsafe};
  612. SwitchableSetting<bool> cpuopt_unsafe_ignore_global_monitor{
  613. linkage, true, "cpuopt_unsafe_ignore_global_monitor", Category::CpuUnsafe};
  614. // Renderer
  615. SwitchableSetting<RendererBackend, true> renderer_backend{
  616. linkage, RendererBackend::Vulkan, RendererBackend::OpenGL, RendererBackend::Null,
  617. "backend", Category::Renderer};
  618. SwitchableSetting<bool> async_presentation{linkage, false, "async_presentation",
  619. Category::RendererAdvanced};
  620. SwitchableSetting<bool> renderer_force_max_clock{linkage, false, "force_max_clock",
  621. Category::RendererAdvanced};
  622. Setting<bool> renderer_debug{linkage, false, "debug", Category::RendererDebug};
  623. Setting<bool> renderer_shader_feedback{linkage, false, "shader_feedback",
  624. Category::RendererDebug};
  625. Setting<bool> enable_nsight_aftermath{linkage, false, "nsight_aftermath",
  626. Category::RendererDebug};
  627. Setting<bool> disable_shader_loop_safety_checks{
  628. linkage, false, "disable_shader_loop_safety_checks", Category::RendererDebug};
  629. SwitchableSetting<int> vulkan_device{linkage, 0, "vulkan_device", Category::Renderer};
  630. ResolutionScalingInfo resolution_info{};
  631. SwitchableSetting<ResolutionSetup> resolution_setup{linkage, ResolutionSetup::Res1X,
  632. "resolution_setup", Category::Renderer};
  633. SwitchableSetting<ScalingFilter, false, true, true> scaling_filter{
  634. linkage, ScalingFilter::Bilinear, "scaling_filter", Category::Renderer};
  635. SwitchableSetting<int, true, true, true> fsr_sharpening_slider{
  636. linkage, 25, 0, 200, "fsr_sharpening_slider", Category::Renderer};
  637. SwitchableSetting<AntiAliasing, false, true, true> anti_aliasing{
  638. linkage, AntiAliasing::None, "anti_aliasing", Category::Renderer};
  639. // *nix platforms may have issues with the borderless windowed fullscreen mode.
  640. // Default to exclusive fullscreen on these platforms for now.
  641. SwitchableSetting<FullscreenMode, true, true, true> fullscreen_mode{linkage,
  642. #ifdef _WIN32
  643. FullscreenMode::Borderless,
  644. #else
  645. FullscreenMode::Exclusive,
  646. #endif
  647. FullscreenMode::Borderless,
  648. FullscreenMode::Exclusive,
  649. "fullscreen_mode",
  650. Category::Renderer};
  651. SwitchableSetting<int, true, true, true> aspect_ratio{
  652. linkage, 0, 0, 4, "aspect_ratio", Category::Renderer};
  653. SwitchableSetting<AnisotropyMode, true> max_anisotropy{
  654. linkage, AnisotropyMode::Automatic, AnisotropyMode::Automatic, AnisotropyMode::X16,
  655. "max_anisotropy", Category::RendererAdvanced};
  656. SwitchableSetting<bool, false, false, true> use_speed_limit{linkage, true, "use_speed_limit",
  657. Category::Renderer};
  658. SwitchableSetting<u16, true, true, true> speed_limit{
  659. linkage, 100, 0, 9999, "speed_limit", Category::Renderer};
  660. SwitchableSetting<bool> use_disk_shader_cache{linkage, true, "use_disk_shader_cache",
  661. Category::Renderer};
  662. SwitchableSetting<GPUAccuracy, true, true, true> gpu_accuracy{
  663. linkage, GPUAccuracy::High, GPUAccuracy::Normal, GPUAccuracy::Extreme,
  664. "gpu_accuracy", Category::RendererAdvanced};
  665. SwitchableSetting<bool> use_asynchronous_gpu_emulation{
  666. linkage, true, "use_asynchronous_gpu_emulation", Category::Renderer};
  667. SwitchableSetting<NvdecEmulation> nvdec_emulation{linkage, NvdecEmulation::GPU,
  668. "nvdec_emulation", Category::Renderer};
  669. SwitchableSetting<AstcDecodeMode, true> accelerate_astc{linkage,
  670. AstcDecodeMode::CPU,
  671. AstcDecodeMode::CPU,
  672. AstcDecodeMode::CPUAsynchronous,
  673. "accelerate_astc",
  674. Category::Renderer};
  675. Setting<VSyncMode, true, true, true> vsync_mode{
  676. linkage, VSyncMode::FIFO, VSyncMode::Immediate, VSyncMode::FIFORelaxed,
  677. "use_vsync", Category::Renderer};
  678. SwitchableSetting<bool> use_reactive_flushing{linkage, true, "use_reactive_flushing",
  679. Category::RendererAdvanced};
  680. SwitchableSetting<ShaderBackend, true> shader_backend{
  681. linkage, ShaderBackend::GLSL, ShaderBackend::GLSL, ShaderBackend::SPIRV,
  682. "shader_backend", Category::Renderer};
  683. SwitchableSetting<bool> use_asynchronous_shaders{linkage, false, "use_asynchronous_shaders",
  684. Category::RendererAdvanced};
  685. SwitchableSetting<bool, false, true, true> use_fast_gpu_time{linkage, true, "use_fast_gpu_time",
  686. Category::RendererAdvanced};
  687. SwitchableSetting<bool, false, true, true> use_vulkan_driver_pipeline_cache{
  688. linkage, true, "use_vulkan_driver_pipeline_cache", Category::RendererAdvanced};
  689. SwitchableSetting<bool> enable_compute_pipelines{linkage, false, "enable_compute_pipelines",
  690. Category::RendererAdvanced};
  691. SwitchableSetting<AstcRecompression, true> astc_recompression{linkage,
  692. AstcRecompression::Uncompressed,
  693. AstcRecompression::Uncompressed,
  694. AstcRecompression::Bc3,
  695. "astc_recompression",
  696. Category::RendererAdvanced};
  697. SwitchableSetting<bool> use_video_framerate{linkage, false, "use_video_framerate",
  698. Category::RendererAdvanced};
  699. SwitchableSetting<bool> barrier_feedback_loops{linkage, true, "barrier_feedback_loops",
  700. Category::RendererAdvanced};
  701. SwitchableSetting<u8, false, true, true> bg_red{linkage, 0, "bg_red", Category::Renderer};
  702. SwitchableSetting<u8, false, true, true> bg_green{linkage, 0, "bg_green", Category::Renderer};
  703. SwitchableSetting<u8, false, true, true> bg_blue{linkage, 0, "bg_blue", Category::Renderer};
  704. // System
  705. SwitchableSetting<bool> rng_seed_enabled{linkage, false, "rng_seed_enabled", Category::System};
  706. SwitchableSetting<u32> rng_seed{linkage, 0, "rng_seed", Category::System};
  707. Setting<std::string> device_name{linkage, "Yuzu", "device_name", Category::System};
  708. // Measured in seconds since epoch
  709. Setting<bool> custom_rtc_enabled{linkage, false, "custom_rtc_enabled", Category::System};
  710. Setting<s64> custom_rtc{linkage, 0, "custom_rtc", Category::System};
  711. // Set on game boot, reset on stop. Seconds difference between current time and `custom_rtc`
  712. s64 custom_rtc_differential;
  713. Setting<s32> current_user{linkage, 0, "current_user", Category::System};
  714. SwitchableSetting<s32, true> language_index{linkage, 1, 0, 17, "language_index",
  715. Category::System};
  716. SwitchableSetting<s32, true> region_index{linkage, 1, 0, 6, "region_index", Category::System};
  717. SwitchableSetting<s32, true> time_zone_index{linkage, 0, 0, 45, "time_zone_index",
  718. Category::System};
  719. SwitchableSetting<s32, true> sound_index{linkage, 1, 0, 2, "sound_index", Category::System};
  720. SwitchableSetting<bool> use_docked_mode{linkage, true, "use_docked_mode", Category::System};
  721. // Controls
  722. InputSetting<std::array<PlayerInput, 10>> players;
  723. Setting<bool, false,
  724. // Only read/write enable_raw_input on Windows platforms
  725. #ifdef _WIN32
  726. true
  727. #else
  728. false
  729. #endif
  730. >
  731. enable_raw_input{linkage, false, "enable_raw_input", Category::Controls};
  732. Setting<bool> controller_navigation{linkage, true, "controller_navigation", Category::Controls};
  733. Setting<bool> enable_joycon_driver{linkage, true, "enable_joycon_driver", Category::Controls};
  734. Setting<bool> enable_procon_driver{linkage, false, "enable_procon_driver", Category::Controls};
  735. SwitchableSetting<bool> vibration_enabled{linkage, true, "vibration_enabled",
  736. Category::Controls};
  737. SwitchableSetting<bool> enable_accurate_vibrations{linkage, false, "enable_accurate_vibrations",
  738. Category::Controls};
  739. SwitchableSetting<bool> motion_enabled{linkage, true, "motion_enabled", Category::Controls};
  740. Setting<std::string> udp_input_servers{linkage, "127.0.0.1:26760", "udp_input_servers",
  741. Category::Controls};
  742. Setting<bool> enable_udp_controller{linkage, false, "enable_udp_controller",
  743. Category::Controls};
  744. Setting<bool> pause_tas_on_load{linkage, true, "pause_tas_on_load", Category::Controls};
  745. Setting<bool> tas_enable{linkage, false, "tas_enable", Category::Controls};
  746. Setting<bool> tas_loop{linkage, false, "tas_loop", Category::Controls};
  747. Setting<bool, false, false> mouse_panning{linkage, false, "mouse_panning", Category::Controls};
  748. Setting<u8, true> mouse_panning_sensitivity{
  749. linkage, 50, 1, 100, "mouse_panning_sensitivity", Category::Controls};
  750. Setting<bool> mouse_enabled{linkage, false, "mouse_enabled", Category::Controls};
  751. Setting<u8, true> mouse_panning_x_sensitivity{
  752. linkage, 50, 1, 100, "mouse_panning_x_sensitivity", Category::Controls};
  753. Setting<u8, true> mouse_panning_y_sensitivity{
  754. linkage, 50, 1, 100, "mouse_panning_y_sensitivity", Category::Controls};
  755. Setting<u8, true> mouse_panning_deadzone_counterweight{
  756. linkage, 20, 0, 100, "mouse_panning_deadzone_counterweight", Category::Controls};
  757. Setting<u8, true> mouse_panning_decay_strength{
  758. linkage, 18, 0, 100, "mouse_panning_decay_strength", Category::Controls};
  759. Setting<u8, true> mouse_panning_min_decay{
  760. linkage, 6, 0, 100, "mouse_panning_min_decay", Category::Controls};
  761. Setting<bool> emulate_analog_keyboard{linkage, false, "emulate_analog_keyboard",
  762. Category::Controls};
  763. Setting<bool> keyboard_enabled{linkage, false, "keyboard_enabled", Category::Controls};
  764. Setting<bool> debug_pad_enabled{linkage, false, "debug_pad_enabled", Category::Controls};
  765. ButtonsRaw debug_pad_buttons;
  766. AnalogsRaw debug_pad_analogs;
  767. TouchscreenInput touchscreen;
  768. Setting<std::string> touch_device{linkage, "min_x:100,min_y:50,max_x:1800,max_y:850",
  769. "touch_device", Category::Controls};
  770. Setting<int> touch_from_button_map_index{linkage, 0, "touch_from_button_map",
  771. Category::Controls};
  772. std::vector<TouchFromButtonMap> touch_from_button_maps;
  773. Setting<bool> enable_ring_controller{linkage, true, "enable_ring_controller",
  774. Category::Controls};
  775. RingconRaw ringcon_analogs;
  776. Setting<bool> enable_ir_sensor{linkage, false, "enable_ir_sensor", Category::Controls};
  777. Setting<std::string> ir_sensor_device{linkage, "auto", "ir_sensor_device", Category::Controls};
  778. Setting<bool> random_amiibo_id{linkage, false, "random_amiibo_id", Category::Controls};
  779. // Data Storage
  780. Setting<bool> use_virtual_sd{linkage, true, "use_virtual_sd", Category::DataStorage};
  781. Setting<bool> gamecard_inserted{linkage, false, "gamecard_inserted", Category::DataStorage};
  782. Setting<bool> gamecard_current_game{linkage, false, "gamecard_current_game",
  783. Category::DataStorage};
  784. Setting<std::string> gamecard_path{linkage, std::string(), "gamecard_path",
  785. Category::DataStorage};
  786. // Debugging
  787. bool record_frame_times;
  788. Setting<bool> use_gdbstub{linkage, false, "use_gdbstub", Category::Debugging};
  789. Setting<u16> gdbstub_port{linkage, 6543, "gdbstub_port", Category::Debugging};
  790. Setting<std::string> program_args{linkage, std::string(), "program_args", Category::Debugging};
  791. Setting<bool> dump_exefs{linkage, false, "dump_exefs", Category::Debugging};
  792. Setting<bool> dump_nso{linkage, false, "dump_nso", Category::Debugging};
  793. Setting<bool, false, false> dump_shaders{linkage, false, "dump_shaders",
  794. Category::DebuggingGraphics};
  795. Setting<bool, false, false> dump_macros{linkage, false, "dump_macros",
  796. Category::DebuggingGraphics};
  797. Setting<bool> enable_fs_access_log{linkage, false, "enable_fs_access_log", Category::Debugging};
  798. Setting<bool, false, false> reporting_services{linkage, false, "reporting_services",
  799. Category::Debugging};
  800. Setting<bool> quest_flag{linkage, false, "quest_flag", Category::Debugging};
  801. Setting<bool> disable_macro_jit{linkage, false, "disable_macro_jit",
  802. Category::DebuggingGraphics};
  803. Setting<bool> disable_macro_hle{linkage, false, "disable_macro_hle",
  804. Category::DebuggingGraphics};
  805. Setting<bool, false, false> extended_logging{linkage, false, "extended_logging",
  806. Category::Debugging};
  807. Setting<bool> use_debug_asserts{linkage, false, "use_debug_asserts", Category::Debugging};
  808. Setting<bool, false, false> use_auto_stub{linkage, false, "use_auto_stub", Category::Debugging};
  809. Setting<bool> enable_all_controllers{linkage, false, "enable_all_controllers",
  810. Category::Debugging};
  811. Setting<bool> create_crash_dumps{linkage, false, "create_crash_dumps", Category::Debugging};
  812. Setting<bool> perform_vulkan_check{linkage, true, "perform_vulkan_check", Category::Debugging};
  813. // Miscellaneous
  814. Setting<std::string> log_filter{linkage, "*:Info", "log_filter", Category::Miscellaneous};
  815. Setting<bool> use_dev_keys{linkage, false, "use_dev_keys", Category::Miscellaneous};
  816. // Network
  817. Setting<std::string> network_interface{linkage, std::string(), "network_interface",
  818. Category::Network};
  819. // WebService
  820. Setting<bool> enable_telemetry{linkage, true, "enable_telemetry", Category::WebService};
  821. Setting<std::string> web_api_url{linkage, "https://api.yuzu-emu.org", "web_api_url",
  822. Category::WebService};
  823. Setting<std::string> yuzu_username{linkage, std::string(), "yuzu_username",
  824. Category::WebService};
  825. Setting<std::string> yuzu_token{linkage, std::string(), "yuzu_token", Category::WebService};
  826. // Add-Ons
  827. std::map<u64, std::vector<std::string>> disabled_addons;
  828. };
  829. extern Values values;
  830. bool IsConfiguringGlobal();
  831. void SetConfiguringGlobal(bool is_global);
  832. bool IsGPULevelExtreme();
  833. bool IsGPULevelHigh();
  834. bool IsFastmemEnabled();
  835. float Volume();
  836. std::string GetTimeZoneString();
  837. void LogSettings();
  838. void UpdateRescalingInfo();
  839. // Restore the global state of all applicable settings in the Values struct
  840. void RestoreGlobalState(bool is_powered_on);
  841. } // namespace Settings