settings.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  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. struct Values {
  301. // System
  302. bool use_docked_mode;
  303. bool enable_nfc;
  304. std::optional<u32> rng_seed;
  305. // Measured in seconds since epoch
  306. std::optional<std::chrono::seconds> custom_rtc;
  307. // Set on game boot, reset on stop. Seconds difference between current time and `custom_rtc`
  308. std::chrono::seconds custom_rtc_differential;
  309. s32 current_user;
  310. s32 language_index;
  311. // Controls
  312. std::array<PlayerInput, 10> players;
  313. bool mouse_enabled;
  314. std::string mouse_device;
  315. MouseButtonsRaw mouse_buttons;
  316. bool keyboard_enabled;
  317. KeyboardKeysRaw keyboard_keys;
  318. KeyboardModsRaw keyboard_mods;
  319. bool debug_pad_enabled;
  320. ButtonsRaw debug_pad_buttons;
  321. AnalogsRaw debug_pad_analogs;
  322. std::string motion_device;
  323. TouchscreenInput touchscreen;
  324. std::atomic_bool is_device_reload_pending{true};
  325. // Core
  326. bool use_cpu_jit;
  327. bool use_multi_core;
  328. // Data Storage
  329. bool use_virtual_sd;
  330. std::string nand_dir;
  331. std::string sdmc_dir;
  332. // Renderer
  333. float resolution_factor;
  334. bool use_frame_limit;
  335. u16 frame_limit;
  336. bool use_disk_shader_cache;
  337. bool use_accurate_gpu_emulation;
  338. bool use_asynchronous_gpu_emulation;
  339. float bg_red;
  340. float bg_green;
  341. float bg_blue;
  342. std::string log_filter;
  343. bool use_dev_keys;
  344. // Audio
  345. std::string sink_id;
  346. bool enable_audio_stretching;
  347. std::string audio_device_id;
  348. float volume;
  349. // Debugging
  350. bool use_gdbstub;
  351. u16 gdbstub_port;
  352. std::string program_args;
  353. bool dump_exefs;
  354. bool dump_nso;
  355. // WebService
  356. bool enable_telemetry;
  357. std::string web_api_url;
  358. std::string yuzu_username;
  359. std::string yuzu_token;
  360. // Add-Ons
  361. std::map<u64, std::vector<std::string>> disabled_addons;
  362. } extern values;
  363. void Apply();
  364. void LogSettings();
  365. } // namespace Settings