ConfigurationState.cs 65 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353
  1. using Ryujinx.Common;
  2. using Ryujinx.Common.Configuration;
  3. using Ryujinx.Common.Configuration.Hid;
  4. using Ryujinx.Common.Configuration.Hid.Controller;
  5. using Ryujinx.Common.Configuration.Hid.Keyboard;
  6. using Ryujinx.Common.Logging;
  7. using Ryujinx.Ui.Common.Configuration.System;
  8. using Ryujinx.Ui.Common.Configuration.Ui;
  9. using Ryujinx.Ui.Common.Helper;
  10. using System;
  11. using System.Collections.Generic;
  12. namespace Ryujinx.Ui.Common.Configuration
  13. {
  14. public class ConfigurationState
  15. {
  16. /// <summary>
  17. /// UI configuration section
  18. /// </summary>
  19. public class UiSection
  20. {
  21. public class Columns
  22. {
  23. public ReactiveObject<bool> FavColumn { get; private set; }
  24. public ReactiveObject<bool> IconColumn { get; private set; }
  25. public ReactiveObject<bool> AppColumn { get; private set; }
  26. public ReactiveObject<bool> DevColumn { get; private set; }
  27. public ReactiveObject<bool> VersionColumn { get; private set; }
  28. public ReactiveObject<bool> TimePlayedColumn { get; private set; }
  29. public ReactiveObject<bool> LastPlayedColumn { get; private set; }
  30. public ReactiveObject<bool> FileExtColumn { get; private set; }
  31. public ReactiveObject<bool> FileSizeColumn { get; private set; }
  32. public ReactiveObject<bool> PathColumn { get; private set; }
  33. public Columns()
  34. {
  35. FavColumn = new ReactiveObject<bool>();
  36. IconColumn = new ReactiveObject<bool>();
  37. AppColumn = new ReactiveObject<bool>();
  38. DevColumn = new ReactiveObject<bool>();
  39. VersionColumn = new ReactiveObject<bool>();
  40. TimePlayedColumn = new ReactiveObject<bool>();
  41. LastPlayedColumn = new ReactiveObject<bool>();
  42. FileExtColumn = new ReactiveObject<bool>();
  43. FileSizeColumn = new ReactiveObject<bool>();
  44. PathColumn = new ReactiveObject<bool>();
  45. }
  46. }
  47. public class ColumnSortSettings
  48. {
  49. public ReactiveObject<int> SortColumnId { get; private set; }
  50. public ReactiveObject<bool> SortAscending { get; private set; }
  51. public ColumnSortSettings()
  52. {
  53. SortColumnId = new ReactiveObject<int>();
  54. SortAscending = new ReactiveObject<bool>();
  55. }
  56. }
  57. /// <summary>
  58. /// Used to toggle columns in the GUI
  59. /// </summary>
  60. public Columns GuiColumns { get; private set; }
  61. /// <summary>
  62. /// Used to configure column sort settings in the GUI
  63. /// </summary>
  64. public ColumnSortSettings ColumnSort { get; private set; }
  65. /// <summary>
  66. /// A list of directories containing games to be used to load games into the games list
  67. /// </summary>
  68. public ReactiveObject<List<string>> GameDirs { get; private set; }
  69. /// <summary>
  70. /// Language Code for the UI
  71. /// </summary>
  72. public ReactiveObject<string> LanguageCode { get; private set; }
  73. /// <summary>
  74. /// Enable or disable custom themes in the GUI
  75. /// </summary>
  76. public ReactiveObject<bool> EnableCustomTheme { get; private set; }
  77. /// <summary>
  78. /// Path to custom GUI theme
  79. /// </summary>
  80. public ReactiveObject<string> CustomThemePath { get; private set; }
  81. /// <summary>
  82. /// Selects the base style
  83. /// </summary>
  84. public ReactiveObject<string> BaseStyle { get; private set; }
  85. /// <summary>
  86. /// Start games in fullscreen mode
  87. /// </summary>
  88. public ReactiveObject<bool> StartFullscreen { get; private set; }
  89. /// <summary>
  90. /// Hide / Show Console Window
  91. /// </summary>
  92. public ReactiveObject<bool> ShowConsole { get; private set; }
  93. /// <summary>
  94. /// View Mode of the Game list
  95. /// </summary>
  96. public ReactiveObject<int> GameListViewMode { get; private set; }
  97. /// <summary>
  98. /// Show application name in Grid Mode
  99. /// </summary>
  100. public ReactiveObject<bool> ShowNames { get; private set; }
  101. /// <summary>
  102. /// Sets App Icon Size in Grid Mode
  103. /// </summary>
  104. public ReactiveObject<int> GridSize { get; private set; }
  105. /// <summary>
  106. /// Sorts Apps in Grid Mode
  107. /// </summary>
  108. public ReactiveObject<int> ApplicationSort { get; private set; }
  109. /// <summary>
  110. /// Sets if Grid is ordered in Ascending Order
  111. /// </summary>
  112. public ReactiveObject<bool> IsAscendingOrder { get; private set; }
  113. public UiSection()
  114. {
  115. GuiColumns = new Columns();
  116. ColumnSort = new ColumnSortSettings();
  117. GameDirs = new ReactiveObject<List<string>>();
  118. EnableCustomTheme = new ReactiveObject<bool>();
  119. CustomThemePath = new ReactiveObject<string>();
  120. BaseStyle = new ReactiveObject<string>();
  121. StartFullscreen = new ReactiveObject<bool>();
  122. GameListViewMode = new ReactiveObject<int>();
  123. ShowNames = new ReactiveObject<bool>();
  124. GridSize = new ReactiveObject<int>();
  125. ApplicationSort = new ReactiveObject<int>();
  126. IsAscendingOrder = new ReactiveObject<bool>();
  127. LanguageCode = new ReactiveObject<string>();
  128. ShowConsole = new ReactiveObject<bool>();
  129. ShowConsole.Event += static (s, e) => { ConsoleHelper.SetConsoleWindowState(e.NewValue); };
  130. }
  131. }
  132. /// <summary>
  133. /// Logger configuration section
  134. /// </summary>
  135. public class LoggerSection
  136. {
  137. /// <summary>
  138. /// Enables printing debug log messages
  139. /// </summary>
  140. public ReactiveObject<bool> EnableDebug { get; private set; }
  141. /// <summary>
  142. /// Enables printing stub log messages
  143. /// </summary>
  144. public ReactiveObject<bool> EnableStub { get; private set; }
  145. /// <summary>
  146. /// Enables printing info log messages
  147. /// </summary>
  148. public ReactiveObject<bool> EnableInfo { get; private set; }
  149. /// <summary>
  150. /// Enables printing warning log messages
  151. /// </summary>
  152. public ReactiveObject<bool> EnableWarn { get; private set; }
  153. /// <summary>
  154. /// Enables printing error log messages
  155. /// </summary>
  156. public ReactiveObject<bool> EnableError { get; private set; }
  157. /// <summary>
  158. /// Enables printing trace log messages
  159. /// </summary>
  160. public ReactiveObject<bool> EnableTrace { get; private set; }
  161. /// <summary>
  162. /// Enables printing guest log messages
  163. /// </summary>
  164. public ReactiveObject<bool> EnableGuest { get; private set; }
  165. /// <summary>
  166. /// Enables printing FS access log messages
  167. /// </summary>
  168. public ReactiveObject<bool> EnableFsAccessLog { get; private set; }
  169. /// <summary>
  170. /// Controls which log messages are written to the log targets
  171. /// </summary>
  172. public ReactiveObject<LogClass[]> FilteredClasses { get; private set; }
  173. /// <summary>
  174. /// Enables or disables logging to a file on disk
  175. /// </summary>
  176. public ReactiveObject<bool> EnableFileLog { get; private set; }
  177. /// <summary>
  178. /// Controls which OpenGL log messages are recorded in the log
  179. /// </summary>
  180. public ReactiveObject<GraphicsDebugLevel> GraphicsDebugLevel { get; private set; }
  181. public LoggerSection()
  182. {
  183. EnableDebug = new ReactiveObject<bool>();
  184. EnableStub = new ReactiveObject<bool>();
  185. EnableInfo = new ReactiveObject<bool>();
  186. EnableWarn = new ReactiveObject<bool>();
  187. EnableError = new ReactiveObject<bool>();
  188. EnableTrace = new ReactiveObject<bool>();
  189. EnableGuest = new ReactiveObject<bool>();
  190. EnableFsAccessLog = new ReactiveObject<bool>();
  191. FilteredClasses = new ReactiveObject<LogClass[]>();
  192. EnableFileLog = new ReactiveObject<bool>();
  193. EnableFileLog.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableFileLog));
  194. GraphicsDebugLevel = new ReactiveObject<GraphicsDebugLevel>();
  195. }
  196. }
  197. /// <summary>
  198. /// System configuration section
  199. /// </summary>
  200. public class SystemSection
  201. {
  202. /// <summary>
  203. /// Change System Language
  204. /// </summary>
  205. public ReactiveObject<Language> Language { get; private set; }
  206. /// <summary>
  207. /// Change System Region
  208. /// </summary>
  209. public ReactiveObject<Region> Region { get; private set; }
  210. /// <summary>
  211. /// Change System TimeZone
  212. /// </summary>
  213. public ReactiveObject<string> TimeZone { get; private set; }
  214. /// <summary>
  215. /// System Time Offset in Seconds
  216. /// </summary>
  217. public ReactiveObject<long> SystemTimeOffset { get; private set; }
  218. /// <summary>
  219. /// Enables or disables Docked Mode
  220. /// </summary>
  221. public ReactiveObject<bool> EnableDockedMode { get; private set; }
  222. /// <summary>
  223. /// Enables or disables profiled translation cache persistency
  224. /// </summary>
  225. public ReactiveObject<bool> EnablePtc { get; private set; }
  226. /// <summary>
  227. /// Enables or disables guest Internet access
  228. /// </summary>
  229. public ReactiveObject<bool> EnableInternetAccess { get; private set; }
  230. /// <summary>
  231. /// Enables integrity checks on Game content files
  232. /// </summary>
  233. public ReactiveObject<bool> EnableFsIntegrityChecks { get; private set; }
  234. /// <summary>
  235. /// Enables FS access log output to the console. Possible modes are 0-3
  236. /// </summary>
  237. public ReactiveObject<int> FsGlobalAccessLogMode { get; private set; }
  238. /// <summary>
  239. /// The selected audio backend
  240. /// </summary>
  241. public ReactiveObject<AudioBackend> AudioBackend { get; private set; }
  242. /// <summary>
  243. /// The audio backend volume
  244. /// </summary>
  245. public ReactiveObject<float> AudioVolume { get; private set; }
  246. /// <summary>
  247. /// The selected memory manager mode
  248. /// </summary>
  249. public ReactiveObject<MemoryManagerMode> MemoryManagerMode { get; private set; }
  250. /// <summary>
  251. /// Defines the amount of RAM available on the emulated system, and how it is distributed
  252. /// </summary>
  253. public ReactiveObject<bool> ExpandRam { get; private set; }
  254. /// <summary>
  255. /// Enable or disable ignoring missing services
  256. /// </summary>
  257. public ReactiveObject<bool> IgnoreMissingServices { get; private set; }
  258. /// <summary>
  259. /// Uses Hypervisor over JIT if available
  260. /// </summary>
  261. public ReactiveObject<bool> UseHypervisor { get; private set; }
  262. public SystemSection()
  263. {
  264. Language = new ReactiveObject<Language>();
  265. Region = new ReactiveObject<Region>();
  266. TimeZone = new ReactiveObject<string>();
  267. SystemTimeOffset = new ReactiveObject<long>();
  268. EnableDockedMode = new ReactiveObject<bool>();
  269. EnableDockedMode.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableDockedMode));
  270. EnablePtc = new ReactiveObject<bool>();
  271. EnablePtc.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnablePtc));
  272. EnableInternetAccess = new ReactiveObject<bool>();
  273. EnableInternetAccess.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableInternetAccess));
  274. EnableFsIntegrityChecks = new ReactiveObject<bool>();
  275. EnableFsIntegrityChecks.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableFsIntegrityChecks));
  276. FsGlobalAccessLogMode = new ReactiveObject<int>();
  277. FsGlobalAccessLogMode.Event += static (sender, e) => LogValueChange(sender, e, nameof(FsGlobalAccessLogMode));
  278. AudioBackend = new ReactiveObject<AudioBackend>();
  279. AudioBackend.Event += static (sender, e) => LogValueChange(sender, e, nameof(AudioBackend));
  280. MemoryManagerMode = new ReactiveObject<MemoryManagerMode>();
  281. MemoryManagerMode.Event += static (sender, e) => LogValueChange(sender, e, nameof(MemoryManagerMode));
  282. ExpandRam = new ReactiveObject<bool>();
  283. ExpandRam.Event += static (sender, e) => LogValueChange(sender, e, nameof(ExpandRam));
  284. IgnoreMissingServices = new ReactiveObject<bool>();
  285. IgnoreMissingServices.Event += static (sender, e) => LogValueChange(sender, e, nameof(IgnoreMissingServices));
  286. AudioVolume = new ReactiveObject<float>();
  287. AudioVolume.Event += static (sender, e) => LogValueChange(sender, e, nameof(AudioVolume));
  288. UseHypervisor = new ReactiveObject<bool>();
  289. UseHypervisor.Event += static (sender, e) => LogValueChange(sender, e, nameof(UseHypervisor));
  290. }
  291. }
  292. /// <summary>
  293. /// Hid configuration section
  294. /// </summary>
  295. public class HidSection
  296. {
  297. /// <summary>
  298. /// Enable or disable keyboard support (Independent from controllers binding)
  299. /// </summary>
  300. public ReactiveObject<bool> EnableKeyboard { get; private set; }
  301. /// <summary>
  302. /// Enable or disable mouse support (Independent from controllers binding)
  303. /// </summary>
  304. public ReactiveObject<bool> EnableMouse { get; private set; }
  305. /// <summary>
  306. /// Hotkey Keyboard Bindings
  307. /// </summary>
  308. public ReactiveObject<KeyboardHotkeys> Hotkeys { get; private set; }
  309. /// <summary>
  310. /// Input device configuration.
  311. /// NOTE: This ReactiveObject won't issue an event when the List has elements added or removed.
  312. /// TODO: Implement a ReactiveList class.
  313. /// </summary>
  314. public ReactiveObject<List<InputConfig>> InputConfig { get; private set; }
  315. public HidSection()
  316. {
  317. EnableKeyboard = new ReactiveObject<bool>();
  318. EnableMouse = new ReactiveObject<bool>();
  319. Hotkeys = new ReactiveObject<KeyboardHotkeys>();
  320. InputConfig = new ReactiveObject<List<InputConfig>>();
  321. }
  322. }
  323. /// <summary>
  324. /// Graphics configuration section
  325. /// </summary>
  326. public class GraphicsSection
  327. {
  328. /// <summary>
  329. /// Whether or not backend threading is enabled. The "Auto" setting will determine whether threading should be enabled at runtime.
  330. /// </summary>
  331. public ReactiveObject<BackendThreading> BackendThreading { get; private set; }
  332. /// <summary>
  333. /// Max Anisotropy. Values range from 0 - 16. Set to -1 to let the game decide.
  334. /// </summary>
  335. public ReactiveObject<float> MaxAnisotropy { get; private set; }
  336. /// <summary>
  337. /// Aspect Ratio applied to the renderer window.
  338. /// </summary>
  339. public ReactiveObject<AspectRatio> AspectRatio { get; private set; }
  340. /// <summary>
  341. /// Resolution Scale. An integer scale applied to applicable render targets. Values 1-4, or -1 to use a custom floating point scale instead.
  342. /// </summary>
  343. public ReactiveObject<int> ResScale { get; private set; }
  344. /// <summary>
  345. /// Custom Resolution Scale. A custom floating point scale applied to applicable render targets. Only active when Resolution Scale is -1.
  346. /// </summary>
  347. public ReactiveObject<float> ResScaleCustom { get; private set; }
  348. /// <summary>
  349. /// Dumps shaders in this local directory
  350. /// </summary>
  351. public ReactiveObject<string> ShadersDumpPath { get; private set; }
  352. /// <summary>
  353. /// Enables or disables Vertical Sync
  354. /// </summary>
  355. public ReactiveObject<bool> EnableVsync { get; private set; }
  356. /// <summary>
  357. /// Enables or disables Shader cache
  358. /// </summary>
  359. public ReactiveObject<bool> EnableShaderCache { get; private set; }
  360. /// <summary>
  361. /// Enables or disables texture recompression
  362. /// </summary>
  363. public ReactiveObject<bool> EnableTextureRecompression { get; private set; }
  364. /// <summary>
  365. /// Enables or disables Macro high-level emulation
  366. /// </summary>
  367. public ReactiveObject<bool> EnableMacroHLE { get; private set; }
  368. /// <summary>
  369. /// Graphics backend
  370. /// </summary>
  371. public ReactiveObject<GraphicsBackend> GraphicsBackend { get; private set; }
  372. /// <summary>
  373. /// Applies anti-aliasing to the renderer.
  374. /// </summary>
  375. public ReactiveObject<AntiAliasing> AntiAliasing { get; private set; }
  376. /// <summary>
  377. /// Sets the framebuffer upscaling type.
  378. /// </summary>
  379. public ReactiveObject<ScalingFilter> ScalingFilter { get; private set; }
  380. /// <summary>
  381. /// Sets the framebuffer upscaling level.
  382. /// </summary>
  383. public ReactiveObject<int> ScalingFilterLevel { get; private set; }
  384. /// <summary>
  385. /// Preferred GPU
  386. /// </summary>
  387. public ReactiveObject<string> PreferredGpu { get; private set; }
  388. public GraphicsSection()
  389. {
  390. BackendThreading = new ReactiveObject<BackendThreading>();
  391. BackendThreading.Event += static (sender, e) => LogValueChange(sender, e, nameof(BackendThreading));
  392. ResScale = new ReactiveObject<int>();
  393. ResScale.Event += static (sender, e) => LogValueChange(sender, e, nameof(ResScale));
  394. ResScaleCustom = new ReactiveObject<float>();
  395. ResScaleCustom.Event += static (sender, e) => LogValueChange(sender, e, nameof(ResScaleCustom));
  396. MaxAnisotropy = new ReactiveObject<float>();
  397. MaxAnisotropy.Event += static (sender, e) => LogValueChange(sender, e, nameof(MaxAnisotropy));
  398. AspectRatio = new ReactiveObject<AspectRatio>();
  399. AspectRatio.Event += static (sender, e) => LogValueChange(sender, e, nameof(AspectRatio));
  400. ShadersDumpPath = new ReactiveObject<string>();
  401. EnableVsync = new ReactiveObject<bool>();
  402. EnableVsync.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableVsync));
  403. EnableShaderCache = new ReactiveObject<bool>();
  404. EnableShaderCache.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableShaderCache));
  405. EnableTextureRecompression = new ReactiveObject<bool>();
  406. EnableTextureRecompression.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableTextureRecompression));
  407. GraphicsBackend = new ReactiveObject<GraphicsBackend>();
  408. GraphicsBackend.Event += static (sender, e) => LogValueChange(sender, e, nameof(GraphicsBackend));
  409. PreferredGpu = new ReactiveObject<string>();
  410. PreferredGpu.Event += static (sender, e) => LogValueChange(sender, e, nameof(PreferredGpu));
  411. EnableMacroHLE = new ReactiveObject<bool>();
  412. EnableMacroHLE.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableMacroHLE));
  413. AntiAliasing = new ReactiveObject<AntiAliasing>();
  414. AntiAliasing.Event += static (sender, e) => LogValueChange(sender, e, nameof(AntiAliasing));
  415. ScalingFilter = new ReactiveObject<ScalingFilter>();
  416. ScalingFilter.Event += static (sender, e) => LogValueChange(sender, e, nameof(ScalingFilter));
  417. ScalingFilterLevel = new ReactiveObject<int>();
  418. ScalingFilterLevel.Event += static (sender, e) => LogValueChange(sender, e, nameof(ScalingFilterLevel));
  419. }
  420. }
  421. /// <summary>
  422. /// The default configuration instance
  423. /// </summary>
  424. public static ConfigurationState Instance { get; private set; }
  425. /// <summary>
  426. /// The Ui section
  427. /// </summary>
  428. public UiSection Ui { get; private set; }
  429. /// <summary>
  430. /// The Logger section
  431. /// </summary>
  432. public LoggerSection Logger { get; private set; }
  433. /// <summary>
  434. /// The System section
  435. /// </summary>
  436. public SystemSection System { get; private set; }
  437. /// <summary>
  438. /// The Graphics section
  439. /// </summary>
  440. public GraphicsSection Graphics { get; private set; }
  441. /// <summary>
  442. /// The Hid section
  443. /// </summary>
  444. public HidSection Hid { get; private set; }
  445. /// <summary>
  446. /// Enables or disables Discord Rich Presence
  447. /// </summary>
  448. public ReactiveObject<bool> EnableDiscordIntegration { get; private set; }
  449. /// <summary>
  450. /// Checks for updates when Ryujinx starts when enabled
  451. /// </summary>
  452. public ReactiveObject<bool> CheckUpdatesOnStart { get; private set; }
  453. /// <summary>
  454. /// Show "Confirm Exit" Dialog
  455. /// </summary>
  456. public ReactiveObject<bool> ShowConfirmExit { get; private set; }
  457. /// <summary>
  458. /// Hide Cursor on Idle
  459. /// </summary>
  460. public ReactiveObject<bool> HideCursorOnIdle { get; private set; }
  461. private ConfigurationState()
  462. {
  463. Ui = new UiSection();
  464. Logger = new LoggerSection();
  465. System = new SystemSection();
  466. Graphics = new GraphicsSection();
  467. Hid = new HidSection();
  468. EnableDiscordIntegration = new ReactiveObject<bool>();
  469. CheckUpdatesOnStart = new ReactiveObject<bool>();
  470. ShowConfirmExit = new ReactiveObject<bool>();
  471. HideCursorOnIdle = new ReactiveObject<bool>();
  472. }
  473. public ConfigurationFileFormat ToFileFormat()
  474. {
  475. ConfigurationFileFormat configurationFile = new ConfigurationFileFormat
  476. {
  477. Version = ConfigurationFileFormat.CurrentVersion,
  478. BackendThreading = Graphics.BackendThreading,
  479. EnableFileLog = Logger.EnableFileLog,
  480. ResScale = Graphics.ResScale,
  481. ResScaleCustom = Graphics.ResScaleCustom,
  482. MaxAnisotropy = Graphics.MaxAnisotropy,
  483. AspectRatio = Graphics.AspectRatio,
  484. AntiAliasing = Graphics.AntiAliasing,
  485. ScalingFilter = Graphics.ScalingFilter,
  486. ScalingFilterLevel = Graphics.ScalingFilterLevel,
  487. GraphicsShadersDumpPath = Graphics.ShadersDumpPath,
  488. LoggingEnableDebug = Logger.EnableDebug,
  489. LoggingEnableStub = Logger.EnableStub,
  490. LoggingEnableInfo = Logger.EnableInfo,
  491. LoggingEnableWarn = Logger.EnableWarn,
  492. LoggingEnableError = Logger.EnableError,
  493. LoggingEnableTrace = Logger.EnableTrace,
  494. LoggingEnableGuest = Logger.EnableGuest,
  495. LoggingEnableFsAccessLog = Logger.EnableFsAccessLog,
  496. LoggingFilteredClasses = Logger.FilteredClasses,
  497. LoggingGraphicsDebugLevel = Logger.GraphicsDebugLevel,
  498. SystemLanguage = System.Language,
  499. SystemRegion = System.Region,
  500. SystemTimeZone = System.TimeZone,
  501. SystemTimeOffset = System.SystemTimeOffset,
  502. DockedMode = System.EnableDockedMode,
  503. EnableDiscordIntegration = EnableDiscordIntegration,
  504. CheckUpdatesOnStart = CheckUpdatesOnStart,
  505. ShowConfirmExit = ShowConfirmExit,
  506. HideCursorOnIdle = HideCursorOnIdle,
  507. EnableVsync = Graphics.EnableVsync,
  508. EnableShaderCache = Graphics.EnableShaderCache,
  509. EnableTextureRecompression = Graphics.EnableTextureRecompression,
  510. EnableMacroHLE = Graphics.EnableMacroHLE,
  511. EnablePtc = System.EnablePtc,
  512. EnableInternetAccess = System.EnableInternetAccess,
  513. EnableFsIntegrityChecks = System.EnableFsIntegrityChecks,
  514. FsGlobalAccessLogMode = System.FsGlobalAccessLogMode,
  515. AudioBackend = System.AudioBackend,
  516. AudioVolume = System.AudioVolume,
  517. MemoryManagerMode = System.MemoryManagerMode,
  518. ExpandRam = System.ExpandRam,
  519. IgnoreMissingServices = System.IgnoreMissingServices,
  520. UseHypervisor = System.UseHypervisor,
  521. GuiColumns = new GuiColumns
  522. {
  523. FavColumn = Ui.GuiColumns.FavColumn,
  524. IconColumn = Ui.GuiColumns.IconColumn,
  525. AppColumn = Ui.GuiColumns.AppColumn,
  526. DevColumn = Ui.GuiColumns.DevColumn,
  527. VersionColumn = Ui.GuiColumns.VersionColumn,
  528. TimePlayedColumn = Ui.GuiColumns.TimePlayedColumn,
  529. LastPlayedColumn = Ui.GuiColumns.LastPlayedColumn,
  530. FileExtColumn = Ui.GuiColumns.FileExtColumn,
  531. FileSizeColumn = Ui.GuiColumns.FileSizeColumn,
  532. PathColumn = Ui.GuiColumns.PathColumn
  533. },
  534. ColumnSort = new ColumnSort
  535. {
  536. SortColumnId = Ui.ColumnSort.SortColumnId,
  537. SortAscending = Ui.ColumnSort.SortAscending
  538. },
  539. GameDirs = Ui.GameDirs,
  540. LanguageCode = Ui.LanguageCode,
  541. EnableCustomTheme = Ui.EnableCustomTheme,
  542. CustomThemePath = Ui.CustomThemePath,
  543. BaseStyle = Ui.BaseStyle,
  544. GameListViewMode = Ui.GameListViewMode,
  545. ShowNames = Ui.ShowNames,
  546. GridSize = Ui.GridSize,
  547. ApplicationSort = Ui.ApplicationSort,
  548. IsAscendingOrder = Ui.IsAscendingOrder,
  549. StartFullscreen = Ui.StartFullscreen,
  550. ShowConsole = Ui.ShowConsole,
  551. EnableKeyboard = Hid.EnableKeyboard,
  552. EnableMouse = Hid.EnableMouse,
  553. Hotkeys = Hid.Hotkeys,
  554. KeyboardConfig = new List<object>(),
  555. ControllerConfig = new List<object>(),
  556. InputConfig = Hid.InputConfig,
  557. GraphicsBackend = Graphics.GraphicsBackend,
  558. PreferredGpu = Graphics.PreferredGpu
  559. };
  560. return configurationFile;
  561. }
  562. public void LoadDefault()
  563. {
  564. Logger.EnableFileLog.Value = true;
  565. Graphics.BackendThreading.Value = BackendThreading.Auto;
  566. Graphics.ResScale.Value = 1;
  567. Graphics.ResScaleCustom.Value = 1.0f;
  568. Graphics.MaxAnisotropy.Value = -1.0f;
  569. Graphics.AspectRatio.Value = AspectRatio.Fixed16x9;
  570. Graphics.GraphicsBackend.Value = OperatingSystem.IsMacOS() ? GraphicsBackend.Vulkan : GraphicsBackend.OpenGl;
  571. Graphics.PreferredGpu.Value = "";
  572. Graphics.ShadersDumpPath.Value = "";
  573. Logger.EnableDebug.Value = false;
  574. Logger.EnableStub.Value = true;
  575. Logger.EnableInfo.Value = true;
  576. Logger.EnableWarn.Value = true;
  577. Logger.EnableError.Value = true;
  578. Logger.EnableTrace.Value = false;
  579. Logger.EnableGuest.Value = true;
  580. Logger.EnableFsAccessLog.Value = false;
  581. Logger.FilteredClasses.Value = Array.Empty<LogClass>();
  582. Logger.GraphicsDebugLevel.Value = GraphicsDebugLevel.None;
  583. System.Language.Value = Language.AmericanEnglish;
  584. System.Region.Value = Region.USA;
  585. System.TimeZone.Value = "UTC";
  586. System.SystemTimeOffset.Value = 0;
  587. System.EnableDockedMode.Value = true;
  588. EnableDiscordIntegration.Value = true;
  589. CheckUpdatesOnStart.Value = true;
  590. ShowConfirmExit.Value = true;
  591. HideCursorOnIdle.Value = false;
  592. Graphics.EnableVsync.Value = true;
  593. Graphics.EnableShaderCache.Value = true;
  594. Graphics.EnableTextureRecompression.Value = false;
  595. Graphics.EnableMacroHLE.Value = true;
  596. Graphics.AntiAliasing.Value = AntiAliasing.None;
  597. Graphics.ScalingFilter.Value = ScalingFilter.Bilinear;
  598. Graphics.ScalingFilterLevel.Value = 80;
  599. System.EnablePtc.Value = true;
  600. System.EnableInternetAccess.Value = false;
  601. System.EnableFsIntegrityChecks.Value = true;
  602. System.FsGlobalAccessLogMode.Value = 0;
  603. System.AudioBackend.Value = AudioBackend.SDL2;
  604. System.AudioVolume.Value = 1;
  605. System.MemoryManagerMode.Value = MemoryManagerMode.HostMappedUnsafe;
  606. System.ExpandRam.Value = false;
  607. System.IgnoreMissingServices.Value = false;
  608. System.UseHypervisor.Value = true;
  609. Ui.GuiColumns.FavColumn.Value = true;
  610. Ui.GuiColumns.IconColumn.Value = true;
  611. Ui.GuiColumns.AppColumn.Value = true;
  612. Ui.GuiColumns.DevColumn.Value = true;
  613. Ui.GuiColumns.VersionColumn.Value = true;
  614. Ui.GuiColumns.TimePlayedColumn.Value = true;
  615. Ui.GuiColumns.LastPlayedColumn.Value = true;
  616. Ui.GuiColumns.FileExtColumn.Value = true;
  617. Ui.GuiColumns.FileSizeColumn.Value = true;
  618. Ui.GuiColumns.PathColumn.Value = true;
  619. Ui.ColumnSort.SortColumnId.Value = 0;
  620. Ui.ColumnSort.SortAscending.Value = false;
  621. Ui.GameDirs.Value = new List<string>();
  622. Ui.EnableCustomTheme.Value = false;
  623. Ui.LanguageCode.Value = "en_US";
  624. Ui.CustomThemePath.Value = "";
  625. Ui.BaseStyle.Value = "Dark";
  626. Ui.GameListViewMode.Value = 0;
  627. Ui.ShowNames.Value = true;
  628. Ui.GridSize.Value = 2;
  629. Ui.ApplicationSort.Value = 0;
  630. Ui.IsAscendingOrder.Value = true;
  631. Ui.StartFullscreen.Value = false;
  632. Ui.ShowConsole.Value = true;
  633. Hid.EnableKeyboard.Value = false;
  634. Hid.EnableMouse.Value = false;
  635. Hid.Hotkeys.Value = new KeyboardHotkeys
  636. {
  637. ToggleVsync = Key.F1,
  638. ToggleMute = Key.F2,
  639. Screenshot = Key.F8,
  640. ShowUi = Key.F4,
  641. Pause = Key.F5,
  642. ResScaleUp = Key.Unbound,
  643. ResScaleDown = Key.Unbound,
  644. VolumeUp = Key.Unbound,
  645. VolumeDown = Key.Unbound
  646. };
  647. Hid.InputConfig.Value = new List<InputConfig>
  648. {
  649. new StandardKeyboardInputConfig
  650. {
  651. Version = InputConfig.CurrentVersion,
  652. Backend = InputBackendType.WindowKeyboard,
  653. Id = "0",
  654. PlayerIndex = PlayerIndex.Player1,
  655. ControllerType = ControllerType.JoyconPair,
  656. LeftJoycon = new LeftJoyconCommonConfig<Key>
  657. {
  658. DpadUp = Key.Up,
  659. DpadDown = Key.Down,
  660. DpadLeft = Key.Left,
  661. DpadRight = Key.Right,
  662. ButtonMinus = Key.Minus,
  663. ButtonL = Key.E,
  664. ButtonZl = Key.Q,
  665. ButtonSl = Key.Unbound,
  666. ButtonSr = Key.Unbound
  667. },
  668. LeftJoyconStick = new JoyconConfigKeyboardStick<Key>
  669. {
  670. StickUp = Key.W,
  671. StickDown = Key.S,
  672. StickLeft = Key.A,
  673. StickRight = Key.D,
  674. StickButton = Key.F,
  675. },
  676. RightJoycon = new RightJoyconCommonConfig<Key>
  677. {
  678. ButtonA = Key.Z,
  679. ButtonB = Key.X,
  680. ButtonX = Key.C,
  681. ButtonY = Key.V,
  682. ButtonPlus = Key.Plus,
  683. ButtonR = Key.U,
  684. ButtonZr = Key.O,
  685. ButtonSl = Key.Unbound,
  686. ButtonSr = Key.Unbound
  687. },
  688. RightJoyconStick = new JoyconConfigKeyboardStick<Key>
  689. {
  690. StickUp = Key.I,
  691. StickDown = Key.K,
  692. StickLeft = Key.J,
  693. StickRight = Key.L,
  694. StickButton = Key.H,
  695. }
  696. }
  697. };
  698. }
  699. public ConfigurationLoadResult Load(ConfigurationFileFormat configurationFileFormat, string configurationFilePath)
  700. {
  701. bool configurationFileUpdated = false;
  702. if (configurationFileFormat.Version < 0 || configurationFileFormat.Version > ConfigurationFileFormat.CurrentVersion)
  703. {
  704. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Unsupported configuration version {configurationFileFormat.Version}, loading default.");
  705. LoadDefault();
  706. return ConfigurationLoadResult.NotLoaded;
  707. }
  708. ConfigurationLoadResult result = ConfigurationLoadResult.Success;
  709. if (configurationFileFormat.Version < 2)
  710. {
  711. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 2.");
  712. configurationFileFormat.SystemRegion = Region.USA;
  713. configurationFileUpdated = true;
  714. }
  715. if (configurationFileFormat.Version < 3)
  716. {
  717. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 3.");
  718. configurationFileFormat.SystemTimeZone = "UTC";
  719. configurationFileUpdated = true;
  720. }
  721. if (configurationFileFormat.Version < 4)
  722. {
  723. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 4.");
  724. configurationFileFormat.MaxAnisotropy = -1;
  725. configurationFileUpdated = true;
  726. }
  727. if (configurationFileFormat.Version < 5)
  728. {
  729. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 5.");
  730. configurationFileFormat.SystemTimeOffset = 0;
  731. configurationFileUpdated = true;
  732. }
  733. if (configurationFileFormat.Version < 8)
  734. {
  735. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 8.");
  736. configurationFileFormat.EnablePtc = true;
  737. configurationFileUpdated = true;
  738. }
  739. if (configurationFileFormat.Version < 9)
  740. {
  741. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 9.");
  742. configurationFileFormat.ColumnSort = new ColumnSort
  743. {
  744. SortColumnId = 0,
  745. SortAscending = false
  746. };
  747. configurationFileFormat.Hotkeys = new KeyboardHotkeys
  748. {
  749. ToggleVsync = Key.F1
  750. };
  751. configurationFileUpdated = true;
  752. }
  753. if (configurationFileFormat.Version < 10)
  754. {
  755. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 10.");
  756. configurationFileFormat.AudioBackend = AudioBackend.OpenAl;
  757. configurationFileUpdated = true;
  758. }
  759. if (configurationFileFormat.Version < 11)
  760. {
  761. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 11.");
  762. configurationFileFormat.ResScale = 1;
  763. configurationFileFormat.ResScaleCustom = 1.0f;
  764. configurationFileUpdated = true;
  765. }
  766. if (configurationFileFormat.Version < 12)
  767. {
  768. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 12.");
  769. configurationFileFormat.LoggingGraphicsDebugLevel = GraphicsDebugLevel.None;
  770. configurationFileUpdated = true;
  771. }
  772. if (configurationFileFormat.Version < 14)
  773. {
  774. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 14.");
  775. configurationFileFormat.CheckUpdatesOnStart = true;
  776. configurationFileUpdated = true;
  777. }
  778. if (configurationFileFormat.Version < 16)
  779. {
  780. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 16.");
  781. configurationFileFormat.EnableShaderCache = true;
  782. configurationFileUpdated = true;
  783. }
  784. if (configurationFileFormat.Version < 17)
  785. {
  786. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 17.");
  787. configurationFileFormat.StartFullscreen = false;
  788. configurationFileUpdated = true;
  789. }
  790. if (configurationFileFormat.Version < 18)
  791. {
  792. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 18.");
  793. configurationFileFormat.AspectRatio = AspectRatio.Fixed16x9;
  794. configurationFileUpdated = true;
  795. }
  796. if (configurationFileFormat.Version < 20)
  797. {
  798. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 20.");
  799. configurationFileFormat.ShowConfirmExit = true;
  800. configurationFileUpdated = true;
  801. }
  802. if (configurationFileFormat.Version < 22)
  803. {
  804. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 22.");
  805. configurationFileFormat.HideCursorOnIdle = false;
  806. configurationFileUpdated = true;
  807. }
  808. if (configurationFileFormat.Version < 24)
  809. {
  810. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 24.");
  811. configurationFileFormat.InputConfig = new List<InputConfig>
  812. {
  813. new StandardKeyboardInputConfig
  814. {
  815. Version = InputConfig.CurrentVersion,
  816. Backend = InputBackendType.WindowKeyboard,
  817. Id = "0",
  818. PlayerIndex = PlayerIndex.Player1,
  819. ControllerType = ControllerType.JoyconPair,
  820. LeftJoycon = new LeftJoyconCommonConfig<Key>
  821. {
  822. DpadUp = Key.Up,
  823. DpadDown = Key.Down,
  824. DpadLeft = Key.Left,
  825. DpadRight = Key.Right,
  826. ButtonMinus = Key.Minus,
  827. ButtonL = Key.E,
  828. ButtonZl = Key.Q,
  829. ButtonSl = Key.Unbound,
  830. ButtonSr = Key.Unbound
  831. },
  832. LeftJoyconStick = new JoyconConfigKeyboardStick<Key>
  833. {
  834. StickUp = Key.W,
  835. StickDown = Key.S,
  836. StickLeft = Key.A,
  837. StickRight = Key.D,
  838. StickButton = Key.F,
  839. },
  840. RightJoycon = new RightJoyconCommonConfig<Key>
  841. {
  842. ButtonA = Key.Z,
  843. ButtonB = Key.X,
  844. ButtonX = Key.C,
  845. ButtonY = Key.V,
  846. ButtonPlus = Key.Plus,
  847. ButtonR = Key.U,
  848. ButtonZr = Key.O,
  849. ButtonSl = Key.Unbound,
  850. ButtonSr = Key.Unbound
  851. },
  852. RightJoyconStick = new JoyconConfigKeyboardStick<Key>
  853. {
  854. StickUp = Key.I,
  855. StickDown = Key.K,
  856. StickLeft = Key.J,
  857. StickRight = Key.L,
  858. StickButton = Key.H,
  859. }
  860. }
  861. };
  862. configurationFileUpdated = true;
  863. }
  864. if (configurationFileFormat.Version < 25)
  865. {
  866. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 25.");
  867. configurationFileUpdated = true;
  868. }
  869. if (configurationFileFormat.Version < 26)
  870. {
  871. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 26.");
  872. configurationFileFormat.MemoryManagerMode = MemoryManagerMode.HostMappedUnsafe;
  873. configurationFileUpdated = true;
  874. }
  875. if (configurationFileFormat.Version < 27)
  876. {
  877. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 27.");
  878. configurationFileFormat.EnableMouse = false;
  879. configurationFileUpdated = true;
  880. }
  881. if (configurationFileFormat.Version < 28)
  882. {
  883. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 28.");
  884. configurationFileFormat.Hotkeys = new KeyboardHotkeys
  885. {
  886. ToggleVsync = Key.F1,
  887. Screenshot = Key.F8
  888. };
  889. configurationFileUpdated = true;
  890. }
  891. if (configurationFileFormat.Version < 29)
  892. {
  893. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 29.");
  894. configurationFileFormat.Hotkeys = new KeyboardHotkeys
  895. {
  896. ToggleVsync = Key.F1,
  897. Screenshot = Key.F8,
  898. ShowUi = Key.F4
  899. };
  900. configurationFileUpdated = true;
  901. }
  902. if (configurationFileFormat.Version < 30)
  903. {
  904. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 30.");
  905. foreach(InputConfig config in configurationFileFormat.InputConfig)
  906. {
  907. if (config is StandardControllerInputConfig controllerConfig)
  908. {
  909. controllerConfig.Rumble = new RumbleConfigController
  910. {
  911. EnableRumble = false,
  912. StrongRumble = 1f,
  913. WeakRumble = 1f
  914. };
  915. }
  916. }
  917. configurationFileUpdated = true;
  918. }
  919. if (configurationFileFormat.Version < 31)
  920. {
  921. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 31.");
  922. configurationFileFormat.BackendThreading = BackendThreading.Auto;
  923. configurationFileUpdated = true;
  924. }
  925. if (configurationFileFormat.Version < 32)
  926. {
  927. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 32.");
  928. configurationFileFormat.Hotkeys = new KeyboardHotkeys
  929. {
  930. ToggleVsync = configurationFileFormat.Hotkeys.ToggleVsync,
  931. Screenshot = configurationFileFormat.Hotkeys.Screenshot,
  932. ShowUi = configurationFileFormat.Hotkeys.ShowUi,
  933. Pause = Key.F5
  934. };
  935. configurationFileUpdated = true;
  936. }
  937. if (configurationFileFormat.Version < 33)
  938. {
  939. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 33.");
  940. configurationFileFormat.Hotkeys = new KeyboardHotkeys
  941. {
  942. ToggleVsync = configurationFileFormat.Hotkeys.ToggleVsync,
  943. Screenshot = configurationFileFormat.Hotkeys.Screenshot,
  944. ShowUi = configurationFileFormat.Hotkeys.ShowUi,
  945. Pause = configurationFileFormat.Hotkeys.Pause,
  946. ToggleMute = Key.F2
  947. };
  948. configurationFileFormat.AudioVolume = 1;
  949. configurationFileUpdated = true;
  950. }
  951. if (configurationFileFormat.Version < 34)
  952. {
  953. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 34.");
  954. configurationFileFormat.EnableInternetAccess = false;
  955. configurationFileUpdated = true;
  956. }
  957. if (configurationFileFormat.Version < 35)
  958. {
  959. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 35.");
  960. foreach (InputConfig config in configurationFileFormat.InputConfig)
  961. {
  962. if (config is StandardControllerInputConfig controllerConfig)
  963. {
  964. controllerConfig.RangeLeft = 1.0f;
  965. controllerConfig.RangeRight = 1.0f;
  966. }
  967. }
  968. configurationFileUpdated = true;
  969. }
  970. if (configurationFileFormat.Version < 36)
  971. {
  972. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 36.");
  973. configurationFileFormat.LoggingEnableTrace = false;
  974. configurationFileUpdated = true;
  975. }
  976. if (configurationFileFormat.Version < 37)
  977. {
  978. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 37.");
  979. configurationFileFormat.ShowConsole = true;
  980. configurationFileUpdated = true;
  981. }
  982. if (configurationFileFormat.Version < 38)
  983. {
  984. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 38.");
  985. configurationFileFormat.BaseStyle = "Dark";
  986. configurationFileFormat.GameListViewMode = 0;
  987. configurationFileFormat.ShowNames = true;
  988. configurationFileFormat.GridSize = 2;
  989. configurationFileFormat.LanguageCode = "en_US";
  990. configurationFileUpdated = true;
  991. }
  992. if (configurationFileFormat.Version < 39)
  993. {
  994. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 39.");
  995. configurationFileFormat.Hotkeys = new KeyboardHotkeys
  996. {
  997. ToggleVsync = configurationFileFormat.Hotkeys.ToggleVsync,
  998. Screenshot = configurationFileFormat.Hotkeys.Screenshot,
  999. ShowUi = configurationFileFormat.Hotkeys.ShowUi,
  1000. Pause = configurationFileFormat.Hotkeys.Pause,
  1001. ToggleMute = configurationFileFormat.Hotkeys.ToggleMute,
  1002. ResScaleUp = Key.Unbound,
  1003. ResScaleDown = Key.Unbound
  1004. };
  1005. configurationFileUpdated = true;
  1006. }
  1007. if (configurationFileFormat.Version < 40)
  1008. {
  1009. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 40.");
  1010. configurationFileFormat.GraphicsBackend = GraphicsBackend.OpenGl;
  1011. result |= ConfigurationLoadResult.MigratedFromPreVulkan;
  1012. configurationFileUpdated = true;
  1013. }
  1014. if (configurationFileFormat.Version < 41)
  1015. {
  1016. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 41.");
  1017. configurationFileFormat.Hotkeys = new KeyboardHotkeys
  1018. {
  1019. ToggleVsync = configurationFileFormat.Hotkeys.ToggleVsync,
  1020. Screenshot = configurationFileFormat.Hotkeys.Screenshot,
  1021. ShowUi = configurationFileFormat.Hotkeys.ShowUi,
  1022. Pause = configurationFileFormat.Hotkeys.Pause,
  1023. ToggleMute = configurationFileFormat.Hotkeys.ToggleMute,
  1024. ResScaleUp = configurationFileFormat.Hotkeys.ResScaleUp,
  1025. ResScaleDown = configurationFileFormat.Hotkeys.ResScaleDown,
  1026. VolumeUp = Key.Unbound,
  1027. VolumeDown = Key.Unbound
  1028. };
  1029. }
  1030. if (configurationFileFormat.Version < 42)
  1031. {
  1032. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 42.");
  1033. configurationFileFormat.EnableMacroHLE = true;
  1034. }
  1035. if (configurationFileFormat.Version < 43)
  1036. {
  1037. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 43.");
  1038. configurationFileFormat.UseHypervisor = true;
  1039. }
  1040. if (configurationFileFormat.Version < 44)
  1041. {
  1042. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 42.");
  1043. configurationFileFormat.AntiAliasing = AntiAliasing.None;
  1044. configurationFileFormat.ScalingFilter = ScalingFilter.Bilinear;
  1045. configurationFileFormat.ScalingFilterLevel = 80;
  1046. configurationFileUpdated = true;
  1047. }
  1048. Logger.EnableFileLog.Value = configurationFileFormat.EnableFileLog;
  1049. Graphics.ResScale.Value = configurationFileFormat.ResScale;
  1050. Graphics.ResScaleCustom.Value = configurationFileFormat.ResScaleCustom;
  1051. Graphics.MaxAnisotropy.Value = configurationFileFormat.MaxAnisotropy;
  1052. Graphics.AspectRatio.Value = configurationFileFormat.AspectRatio;
  1053. Graphics.ShadersDumpPath.Value = configurationFileFormat.GraphicsShadersDumpPath;
  1054. Graphics.BackendThreading.Value = configurationFileFormat.BackendThreading;
  1055. Graphics.GraphicsBackend.Value = configurationFileFormat.GraphicsBackend;
  1056. Graphics.PreferredGpu.Value = configurationFileFormat.PreferredGpu;
  1057. Graphics.AntiAliasing.Value = configurationFileFormat.AntiAliasing;
  1058. Graphics.ScalingFilter.Value = configurationFileFormat.ScalingFilter;
  1059. Graphics.ScalingFilterLevel.Value = configurationFileFormat.ScalingFilterLevel;
  1060. Logger.EnableDebug.Value = configurationFileFormat.LoggingEnableDebug;
  1061. Logger.EnableStub.Value = configurationFileFormat.LoggingEnableStub;
  1062. Logger.EnableInfo.Value = configurationFileFormat.LoggingEnableInfo;
  1063. Logger.EnableWarn.Value = configurationFileFormat.LoggingEnableWarn;
  1064. Logger.EnableError.Value = configurationFileFormat.LoggingEnableError;
  1065. Logger.EnableTrace.Value = configurationFileFormat.LoggingEnableTrace;
  1066. Logger.EnableGuest.Value = configurationFileFormat.LoggingEnableGuest;
  1067. Logger.EnableFsAccessLog.Value = configurationFileFormat.LoggingEnableFsAccessLog;
  1068. Logger.FilteredClasses.Value = configurationFileFormat.LoggingFilteredClasses;
  1069. Logger.GraphicsDebugLevel.Value = configurationFileFormat.LoggingGraphicsDebugLevel;
  1070. System.Language.Value = configurationFileFormat.SystemLanguage;
  1071. System.Region.Value = configurationFileFormat.SystemRegion;
  1072. System.TimeZone.Value = configurationFileFormat.SystemTimeZone;
  1073. System.SystemTimeOffset.Value = configurationFileFormat.SystemTimeOffset;
  1074. System.EnableDockedMode.Value = configurationFileFormat.DockedMode;
  1075. EnableDiscordIntegration.Value = configurationFileFormat.EnableDiscordIntegration;
  1076. CheckUpdatesOnStart.Value = configurationFileFormat.CheckUpdatesOnStart;
  1077. ShowConfirmExit.Value = configurationFileFormat.ShowConfirmExit;
  1078. HideCursorOnIdle.Value = configurationFileFormat.HideCursorOnIdle;
  1079. Graphics.EnableVsync.Value = configurationFileFormat.EnableVsync;
  1080. Graphics.EnableShaderCache.Value = configurationFileFormat.EnableShaderCache;
  1081. Graphics.EnableTextureRecompression.Value = configurationFileFormat.EnableTextureRecompression;
  1082. Graphics.EnableMacroHLE.Value = configurationFileFormat.EnableMacroHLE;
  1083. System.EnablePtc.Value = configurationFileFormat.EnablePtc;
  1084. System.EnableInternetAccess.Value = configurationFileFormat.EnableInternetAccess;
  1085. System.EnableFsIntegrityChecks.Value = configurationFileFormat.EnableFsIntegrityChecks;
  1086. System.FsGlobalAccessLogMode.Value = configurationFileFormat.FsGlobalAccessLogMode;
  1087. System.AudioBackend.Value = configurationFileFormat.AudioBackend;
  1088. System.AudioVolume.Value = configurationFileFormat.AudioVolume;
  1089. System.MemoryManagerMode.Value = configurationFileFormat.MemoryManagerMode;
  1090. System.ExpandRam.Value = configurationFileFormat.ExpandRam;
  1091. System.IgnoreMissingServices.Value = configurationFileFormat.IgnoreMissingServices;
  1092. System.UseHypervisor.Value = configurationFileFormat.UseHypervisor;
  1093. Ui.GuiColumns.FavColumn.Value = configurationFileFormat.GuiColumns.FavColumn;
  1094. Ui.GuiColumns.IconColumn.Value = configurationFileFormat.GuiColumns.IconColumn;
  1095. Ui.GuiColumns.AppColumn.Value = configurationFileFormat.GuiColumns.AppColumn;
  1096. Ui.GuiColumns.DevColumn.Value = configurationFileFormat.GuiColumns.DevColumn;
  1097. Ui.GuiColumns.VersionColumn.Value = configurationFileFormat.GuiColumns.VersionColumn;
  1098. Ui.GuiColumns.TimePlayedColumn.Value = configurationFileFormat.GuiColumns.TimePlayedColumn;
  1099. Ui.GuiColumns.LastPlayedColumn.Value = configurationFileFormat.GuiColumns.LastPlayedColumn;
  1100. Ui.GuiColumns.FileExtColumn.Value = configurationFileFormat.GuiColumns.FileExtColumn;
  1101. Ui.GuiColumns.FileSizeColumn.Value = configurationFileFormat.GuiColumns.FileSizeColumn;
  1102. Ui.GuiColumns.PathColumn.Value = configurationFileFormat.GuiColumns.PathColumn;
  1103. Ui.ColumnSort.SortColumnId.Value = configurationFileFormat.ColumnSort.SortColumnId;
  1104. Ui.ColumnSort.SortAscending.Value = configurationFileFormat.ColumnSort.SortAscending;
  1105. Ui.GameDirs.Value = configurationFileFormat.GameDirs;
  1106. Ui.EnableCustomTheme.Value = configurationFileFormat.EnableCustomTheme;
  1107. Ui.LanguageCode.Value = configurationFileFormat.LanguageCode;
  1108. Ui.CustomThemePath.Value = configurationFileFormat.CustomThemePath;
  1109. Ui.BaseStyle.Value = configurationFileFormat.BaseStyle;
  1110. Ui.GameListViewMode.Value = configurationFileFormat.GameListViewMode;
  1111. Ui.ShowNames.Value = configurationFileFormat.ShowNames;
  1112. Ui.IsAscendingOrder.Value = configurationFileFormat.IsAscendingOrder;
  1113. Ui.GridSize.Value = configurationFileFormat.GridSize;
  1114. Ui.ApplicationSort.Value = configurationFileFormat.ApplicationSort;
  1115. Ui.StartFullscreen.Value = configurationFileFormat.StartFullscreen;
  1116. Ui.ShowConsole.Value = configurationFileFormat.ShowConsole;
  1117. Hid.EnableKeyboard.Value = configurationFileFormat.EnableKeyboard;
  1118. Hid.EnableMouse.Value = configurationFileFormat.EnableMouse;
  1119. Hid.Hotkeys.Value = configurationFileFormat.Hotkeys;
  1120. Hid.InputConfig.Value = configurationFileFormat.InputConfig;
  1121. if (Hid.InputConfig.Value == null)
  1122. {
  1123. Hid.InputConfig.Value = new List<InputConfig>();
  1124. }
  1125. if (configurationFileUpdated)
  1126. {
  1127. ToFileFormat().SaveConfig(configurationFilePath);
  1128. Ryujinx.Common.Logging.Logger.Notice.Print(LogClass.Application, $"Configuration file updated to version {ConfigurationFileFormat.CurrentVersion}");
  1129. }
  1130. return result;
  1131. }
  1132. private static void LogValueChange<T>(object sender, ReactiveEventArgs<T> eventArgs, string valueName)
  1133. {
  1134. Ryujinx.Common.Logging.Logger.Info?.Print(LogClass.Configuration, $"{valueName} set to: {eventArgs.NewValue}");
  1135. }
  1136. public static void Initialize()
  1137. {
  1138. if (Instance != null)
  1139. {
  1140. throw new InvalidOperationException("Configuration is already initialized");
  1141. }
  1142. Instance = new ConfigurationState();
  1143. }
  1144. }
  1145. }