settings.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <array>
  6. #include <atomic>
  7. #include <chrono>
  8. #include <map>
  9. #include <optional>
  10. #include <string>
  11. #include <vector>
  12. #include "common/common_types.h"
  13. namespace Settings {
  14. namespace NativeButton {
  15. enum Values {
  16. A,
  17. B,
  18. X,
  19. Y,
  20. LStick,
  21. RStick,
  22. L,
  23. R,
  24. ZL,
  25. ZR,
  26. Plus,
  27. Minus,
  28. DLeft,
  29. DUp,
  30. DRight,
  31. DDown,
  32. LStick_Left,
  33. LStick_Up,
  34. LStick_Right,
  35. LStick_Down,
  36. RStick_Left,
  37. RStick_Up,
  38. RStick_Right,
  39. RStick_Down,
  40. SL,
  41. SR,
  42. Home,
  43. Screenshot,
  44. NumButtons,
  45. };
  46. constexpr int BUTTON_HID_BEGIN = A;
  47. constexpr int BUTTON_NS_BEGIN = Home;
  48. constexpr int BUTTON_HID_END = BUTTON_NS_BEGIN;
  49. constexpr int BUTTON_NS_END = NumButtons;
  50. constexpr int NUM_BUTTONS_HID = BUTTON_HID_END - BUTTON_HID_BEGIN;
  51. constexpr int NUM_BUTTONS_NS = BUTTON_NS_END - BUTTON_NS_BEGIN;
  52. extern const std::array<const char*, NumButtons> mapping;
  53. } // namespace NativeButton
  54. namespace NativeAnalog {
  55. enum Values {
  56. LStick,
  57. RStick,
  58. NumAnalogs,
  59. };
  60. constexpr int STICK_HID_BEGIN = LStick;
  61. constexpr int STICK_HID_END = NumAnalogs;
  62. constexpr int NUM_STICKS_HID = NumAnalogs;
  63. extern const std::array<const char*, NumAnalogs> mapping;
  64. } // namespace NativeAnalog
  65. namespace NativeMouseButton {
  66. enum Values {
  67. Left,
  68. Right,
  69. Middle,
  70. Forward,
  71. Back,
  72. NumMouseButtons,
  73. };
  74. constexpr int MOUSE_HID_BEGIN = Left;
  75. constexpr int MOUSE_HID_END = NumMouseButtons;
  76. constexpr int NUM_MOUSE_HID = NumMouseButtons;
  77. extern const std::array<const char*, NumMouseButtons> mapping;
  78. } // namespace NativeMouseButton
  79. namespace NativeKeyboard {
  80. enum Keys {
  81. None,
  82. Error,
  83. A = 4,
  84. B,
  85. C,
  86. D,
  87. E,
  88. F,
  89. G,
  90. H,
  91. I,
  92. J,
  93. K,
  94. L,
  95. M,
  96. N,
  97. O,
  98. P,
  99. Q,
  100. R,
  101. S,
  102. T,
  103. U,
  104. V,
  105. W,
  106. X,
  107. Y,
  108. Z,
  109. N1,
  110. N2,
  111. N3,
  112. N4,
  113. N5,
  114. N6,
  115. N7,
  116. N8,
  117. N9,
  118. N0,
  119. Enter,
  120. Escape,
  121. Backspace,
  122. Tab,
  123. Space,
  124. Minus,
  125. Equal,
  126. LeftBrace,
  127. RightBrace,
  128. Backslash,
  129. Tilde,
  130. Semicolon,
  131. Apostrophe,
  132. Grave,
  133. Comma,
  134. Dot,
  135. Slash,
  136. CapsLockKey,
  137. F1,
  138. F2,
  139. F3,
  140. F4,
  141. F5,
  142. F6,
  143. F7,
  144. F8,
  145. F9,
  146. F10,
  147. F11,
  148. F12,
  149. SystemRequest,
  150. ScrollLockKey,
  151. Pause,
  152. Insert,
  153. Home,
  154. PageUp,
  155. Delete,
  156. End,
  157. PageDown,
  158. Right,
  159. Left,
  160. Down,
  161. Up,
  162. NumLockKey,
  163. KPSlash,
  164. KPAsterisk,
  165. KPMinus,
  166. KPPlus,
  167. KPEnter,
  168. KP1,
  169. KP2,
  170. KP3,
  171. KP4,
  172. KP5,
  173. KP6,
  174. KP7,
  175. KP8,
  176. KP9,
  177. KP0,
  178. KPDot,
  179. Key102,
  180. Compose,
  181. Power,
  182. KPEqual,
  183. F13,
  184. F14,
  185. F15,
  186. F16,
  187. F17,
  188. F18,
  189. F19,
  190. F20,
  191. F21,
  192. F22,
  193. F23,
  194. F24,
  195. Open,
  196. Help,
  197. Properties,
  198. Front,
  199. Stop,
  200. Repeat,
  201. Undo,
  202. Cut,
  203. Copy,
  204. Paste,
  205. Find,
  206. Mute,
  207. VolumeUp,
  208. VolumeDown,
  209. CapsLockActive,
  210. NumLockActive,
  211. ScrollLockActive,
  212. KPComma,
  213. KPLeftParenthesis,
  214. KPRightParenthesis,
  215. LeftControlKey = 0xE0,
  216. LeftShiftKey,
  217. LeftAltKey,
  218. LeftMetaKey,
  219. RightControlKey,
  220. RightShiftKey,
  221. RightAltKey,
  222. RightMetaKey,
  223. MediaPlayPause,
  224. MediaStopCD,
  225. MediaPrevious,
  226. MediaNext,
  227. MediaEject,
  228. MediaVolumeUp,
  229. MediaVolumeDown,
  230. MediaMute,
  231. MediaWebsite,
  232. MediaBack,
  233. MediaForward,
  234. MediaStop,
  235. MediaFind,
  236. MediaScrollUp,
  237. MediaScrollDown,
  238. MediaEdit,
  239. MediaSleep,
  240. MediaCoffee,
  241. MediaRefresh,
  242. MediaCalculator,
  243. NumKeyboardKeys,
  244. };
  245. static_assert(NumKeyboardKeys == 0xFC, "Incorrect number of keyboard keys.");
  246. enum Modifiers {
  247. LeftControl,
  248. LeftShift,
  249. LeftAlt,
  250. LeftMeta,
  251. RightControl,
  252. RightShift,
  253. RightAlt,
  254. RightMeta,
  255. CapsLock,
  256. ScrollLock,
  257. NumLock,
  258. NumKeyboardMods,
  259. };
  260. constexpr int KEYBOARD_KEYS_HID_BEGIN = None;
  261. constexpr int KEYBOARD_KEYS_HID_END = NumKeyboardKeys;
  262. constexpr int NUM_KEYBOARD_KEYS_HID = NumKeyboardKeys;
  263. constexpr int KEYBOARD_MODS_HID_BEGIN = LeftControl;
  264. constexpr int KEYBOARD_MODS_HID_END = NumKeyboardMods;
  265. constexpr int NUM_KEYBOARD_MODS_HID = NumKeyboardMods;
  266. } // namespace NativeKeyboard
  267. using ButtonsRaw = std::array<std::string, NativeButton::NumButtons>;
  268. using AnalogsRaw = std::array<std::string, NativeAnalog::NumAnalogs>;
  269. using MouseButtonsRaw = std::array<std::string, NativeMouseButton::NumMouseButtons>;
  270. using KeyboardKeysRaw = std::array<std::string, NativeKeyboard::NumKeyboardKeys>;
  271. using KeyboardModsRaw = std::array<std::string, NativeKeyboard::NumKeyboardMods>;
  272. constexpr u32 JOYCON_BODY_NEON_RED = 0xFF3C28;
  273. constexpr u32 JOYCON_BUTTONS_NEON_RED = 0x1E0A0A;
  274. constexpr u32 JOYCON_BODY_NEON_BLUE = 0x0AB9E6;
  275. constexpr u32 JOYCON_BUTTONS_NEON_BLUE = 0x001E1E;
  276. enum class ControllerType {
  277. ProController,
  278. DualJoycon,
  279. RightJoycon,
  280. LeftJoycon,
  281. };
  282. struct PlayerInput {
  283. bool connected;
  284. ControllerType type;
  285. ButtonsRaw buttons;
  286. AnalogsRaw analogs;
  287. u32 body_color_right;
  288. u32 button_color_right;
  289. u32 body_color_left;
  290. u32 button_color_left;
  291. };
  292. struct TouchscreenInput {
  293. bool enabled;
  294. std::string device;
  295. u32 finger;
  296. u32 diameter_x;
  297. u32 diameter_y;
  298. u32 rotation_angle;
  299. };
  300. enum class NANDTotalSize : u64 {
  301. S29_1GB = 0x747C00000ULL,
  302. };
  303. enum class NANDUserSize : u64 {
  304. S26GB = 0x680000000ULL,
  305. };
  306. enum class NANDSystemSize : u64 {
  307. S2_5GB = 0xA0000000,
  308. };
  309. enum class SDMCSize : u64 {
  310. S1GB = 0x40000000,
  311. S2GB = 0x80000000,
  312. S4GB = 0x100000000ULL,
  313. S8GB = 0x200000000ULL,
  314. S16GB = 0x400000000ULL,
  315. S32GB = 0x800000000ULL,
  316. S64GB = 0x1000000000ULL,
  317. S128GB = 0x2000000000ULL,
  318. S256GB = 0x4000000000ULL,
  319. S1TB = 0x10000000000ULL,
  320. };
  321. struct Values {
  322. // System
  323. bool use_docked_mode;
  324. std::optional<u32> rng_seed;
  325. // Measured in seconds since epoch
  326. std::optional<std::chrono::seconds> custom_rtc;
  327. // Set on game boot, reset on stop. Seconds difference between current time and `custom_rtc`
  328. std::chrono::seconds custom_rtc_differential;
  329. s32 current_user;
  330. s32 language_index;
  331. // Controls
  332. std::array<PlayerInput, 10> players;
  333. bool mouse_enabled;
  334. std::string mouse_device;
  335. MouseButtonsRaw mouse_buttons;
  336. bool keyboard_enabled;
  337. KeyboardKeysRaw keyboard_keys;
  338. KeyboardModsRaw keyboard_mods;
  339. bool debug_pad_enabled;
  340. ButtonsRaw debug_pad_buttons;
  341. AnalogsRaw debug_pad_analogs;
  342. std::string motion_device;
  343. TouchscreenInput touchscreen;
  344. std::atomic_bool is_device_reload_pending{true};
  345. // Core
  346. bool use_multi_core;
  347. // Data Storage
  348. bool use_virtual_sd;
  349. bool gamecard_inserted;
  350. bool gamecard_current_game;
  351. std::string gamecard_path;
  352. NANDTotalSize nand_total_size;
  353. NANDSystemSize nand_system_size;
  354. NANDUserSize nand_user_size;
  355. SDMCSize sdmc_size;
  356. // Renderer
  357. float resolution_factor;
  358. bool use_frame_limit;
  359. u16 frame_limit;
  360. bool use_disk_shader_cache;
  361. bool use_accurate_gpu_emulation;
  362. bool use_asynchronous_gpu_emulation;
  363. bool force_30fps_mode;
  364. float bg_red;
  365. float bg_green;
  366. float bg_blue;
  367. std::string log_filter;
  368. bool use_dev_keys;
  369. // Audio
  370. std::string sink_id;
  371. bool enable_audio_stretching;
  372. std::string audio_device_id;
  373. float volume;
  374. // Debugging
  375. bool record_frame_times;
  376. bool use_gdbstub;
  377. u16 gdbstub_port;
  378. std::string program_args;
  379. bool dump_exefs;
  380. bool dump_nso;
  381. bool reporting_services;
  382. bool quest_flag;
  383. // BCAT
  384. std::string bcat_backend;
  385. bool bcat_boxcat_local;
  386. // WebService
  387. bool enable_telemetry;
  388. std::string web_api_url;
  389. std::string yuzu_username;
  390. std::string yuzu_token;
  391. // Add-Ons
  392. std::map<u64, std::vector<std::string>> disabled_addons;
  393. } extern values;
  394. void Apply();
  395. void LogSettings();
  396. } // namespace Settings