ConfigurationState.cs 63 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312
  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. /// Preferred GPU
  374. /// </summary>
  375. public ReactiveObject<string> PreferredGpu { get; private set; }
  376. public GraphicsSection()
  377. {
  378. BackendThreading = new ReactiveObject<BackendThreading>();
  379. BackendThreading.Event += static (sender, e) => LogValueChange(sender, e, nameof(BackendThreading));
  380. ResScale = new ReactiveObject<int>();
  381. ResScale.Event += static (sender, e) => LogValueChange(sender, e, nameof(ResScale));
  382. ResScaleCustom = new ReactiveObject<float>();
  383. ResScaleCustom.Event += static (sender, e) => LogValueChange(sender, e, nameof(ResScaleCustom));
  384. MaxAnisotropy = new ReactiveObject<float>();
  385. MaxAnisotropy.Event += static (sender, e) => LogValueChange(sender, e, nameof(MaxAnisotropy));
  386. AspectRatio = new ReactiveObject<AspectRatio>();
  387. AspectRatio.Event += static (sender, e) => LogValueChange(sender, e, nameof(AspectRatio));
  388. ShadersDumpPath = new ReactiveObject<string>();
  389. EnableVsync = new ReactiveObject<bool>();
  390. EnableVsync.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableVsync));
  391. EnableShaderCache = new ReactiveObject<bool>();
  392. EnableShaderCache.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableShaderCache));
  393. EnableTextureRecompression = new ReactiveObject<bool>();
  394. EnableTextureRecompression.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableTextureRecompression));
  395. GraphicsBackend = new ReactiveObject<GraphicsBackend>();
  396. GraphicsBackend.Event += static (sender, e) => LogValueChange(sender, e, nameof(GraphicsBackend));
  397. PreferredGpu = new ReactiveObject<string>();
  398. PreferredGpu.Event += static (sender, e) => LogValueChange(sender, e, nameof(PreferredGpu));
  399. EnableMacroHLE = new ReactiveObject<bool>();
  400. EnableMacroHLE.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableMacroHLE));
  401. }
  402. }
  403. /// <summary>
  404. /// The default configuration instance
  405. /// </summary>
  406. public static ConfigurationState Instance { get; private set; }
  407. /// <summary>
  408. /// The Ui section
  409. /// </summary>
  410. public UiSection Ui { get; private set; }
  411. /// <summary>
  412. /// The Logger section
  413. /// </summary>
  414. public LoggerSection Logger { get; private set; }
  415. /// <summary>
  416. /// The System section
  417. /// </summary>
  418. public SystemSection System { get; private set; }
  419. /// <summary>
  420. /// The Graphics section
  421. /// </summary>
  422. public GraphicsSection Graphics { get; private set; }
  423. /// <summary>
  424. /// The Hid section
  425. /// </summary>
  426. public HidSection Hid { get; private set; }
  427. /// <summary>
  428. /// Enables or disables Discord Rich Presence
  429. /// </summary>
  430. public ReactiveObject<bool> EnableDiscordIntegration { get; private set; }
  431. /// <summary>
  432. /// Checks for updates when Ryujinx starts when enabled
  433. /// </summary>
  434. public ReactiveObject<bool> CheckUpdatesOnStart { get; private set; }
  435. /// <summary>
  436. /// Show "Confirm Exit" Dialog
  437. /// </summary>
  438. public ReactiveObject<bool> ShowConfirmExit { get; private set; }
  439. /// <summary>
  440. /// Hide Cursor on Idle
  441. /// </summary>
  442. public ReactiveObject<bool> HideCursorOnIdle { get; private set; }
  443. private ConfigurationState()
  444. {
  445. Ui = new UiSection();
  446. Logger = new LoggerSection();
  447. System = new SystemSection();
  448. Graphics = new GraphicsSection();
  449. Hid = new HidSection();
  450. EnableDiscordIntegration = new ReactiveObject<bool>();
  451. CheckUpdatesOnStart = new ReactiveObject<bool>();
  452. ShowConfirmExit = new ReactiveObject<bool>();
  453. HideCursorOnIdle = new ReactiveObject<bool>();
  454. }
  455. public ConfigurationFileFormat ToFileFormat()
  456. {
  457. ConfigurationFileFormat configurationFile = new ConfigurationFileFormat
  458. {
  459. Version = ConfigurationFileFormat.CurrentVersion,
  460. BackendThreading = Graphics.BackendThreading,
  461. EnableFileLog = Logger.EnableFileLog,
  462. ResScale = Graphics.ResScale,
  463. ResScaleCustom = Graphics.ResScaleCustom,
  464. MaxAnisotropy = Graphics.MaxAnisotropy,
  465. AspectRatio = Graphics.AspectRatio,
  466. GraphicsShadersDumpPath = Graphics.ShadersDumpPath,
  467. LoggingEnableDebug = Logger.EnableDebug,
  468. LoggingEnableStub = Logger.EnableStub,
  469. LoggingEnableInfo = Logger.EnableInfo,
  470. LoggingEnableWarn = Logger.EnableWarn,
  471. LoggingEnableError = Logger.EnableError,
  472. LoggingEnableTrace = Logger.EnableTrace,
  473. LoggingEnableGuest = Logger.EnableGuest,
  474. LoggingEnableFsAccessLog = Logger.EnableFsAccessLog,
  475. LoggingFilteredClasses = Logger.FilteredClasses,
  476. LoggingGraphicsDebugLevel = Logger.GraphicsDebugLevel,
  477. SystemLanguage = System.Language,
  478. SystemRegion = System.Region,
  479. SystemTimeZone = System.TimeZone,
  480. SystemTimeOffset = System.SystemTimeOffset,
  481. DockedMode = System.EnableDockedMode,
  482. EnableDiscordIntegration = EnableDiscordIntegration,
  483. CheckUpdatesOnStart = CheckUpdatesOnStart,
  484. ShowConfirmExit = ShowConfirmExit,
  485. HideCursorOnIdle = HideCursorOnIdle,
  486. EnableVsync = Graphics.EnableVsync,
  487. EnableShaderCache = Graphics.EnableShaderCache,
  488. EnableTextureRecompression = Graphics.EnableTextureRecompression,
  489. EnableMacroHLE = Graphics.EnableMacroHLE,
  490. EnablePtc = System.EnablePtc,
  491. EnableInternetAccess = System.EnableInternetAccess,
  492. EnableFsIntegrityChecks = System.EnableFsIntegrityChecks,
  493. FsGlobalAccessLogMode = System.FsGlobalAccessLogMode,
  494. AudioBackend = System.AudioBackend,
  495. AudioVolume = System.AudioVolume,
  496. MemoryManagerMode = System.MemoryManagerMode,
  497. ExpandRam = System.ExpandRam,
  498. IgnoreMissingServices = System.IgnoreMissingServices,
  499. UseHypervisor = System.UseHypervisor,
  500. GuiColumns = new GuiColumns
  501. {
  502. FavColumn = Ui.GuiColumns.FavColumn,
  503. IconColumn = Ui.GuiColumns.IconColumn,
  504. AppColumn = Ui.GuiColumns.AppColumn,
  505. DevColumn = Ui.GuiColumns.DevColumn,
  506. VersionColumn = Ui.GuiColumns.VersionColumn,
  507. TimePlayedColumn = Ui.GuiColumns.TimePlayedColumn,
  508. LastPlayedColumn = Ui.GuiColumns.LastPlayedColumn,
  509. FileExtColumn = Ui.GuiColumns.FileExtColumn,
  510. FileSizeColumn = Ui.GuiColumns.FileSizeColumn,
  511. PathColumn = Ui.GuiColumns.PathColumn
  512. },
  513. ColumnSort = new ColumnSort
  514. {
  515. SortColumnId = Ui.ColumnSort.SortColumnId,
  516. SortAscending = Ui.ColumnSort.SortAscending
  517. },
  518. GameDirs = Ui.GameDirs,
  519. LanguageCode = Ui.LanguageCode,
  520. EnableCustomTheme = Ui.EnableCustomTheme,
  521. CustomThemePath = Ui.CustomThemePath,
  522. BaseStyle = Ui.BaseStyle,
  523. GameListViewMode = Ui.GameListViewMode,
  524. ShowNames = Ui.ShowNames,
  525. GridSize = Ui.GridSize,
  526. ApplicationSort = Ui.ApplicationSort,
  527. IsAscendingOrder = Ui.IsAscendingOrder,
  528. StartFullscreen = Ui.StartFullscreen,
  529. ShowConsole = Ui.ShowConsole,
  530. EnableKeyboard = Hid.EnableKeyboard,
  531. EnableMouse = Hid.EnableMouse,
  532. Hotkeys = Hid.Hotkeys,
  533. KeyboardConfig = new List<object>(),
  534. ControllerConfig = new List<object>(),
  535. InputConfig = Hid.InputConfig,
  536. GraphicsBackend = Graphics.GraphicsBackend,
  537. PreferredGpu = Graphics.PreferredGpu
  538. };
  539. return configurationFile;
  540. }
  541. public void LoadDefault()
  542. {
  543. Logger.EnableFileLog.Value = true;
  544. Graphics.BackendThreading.Value = BackendThreading.Auto;
  545. Graphics.ResScale.Value = 1;
  546. Graphics.ResScaleCustom.Value = 1.0f;
  547. Graphics.MaxAnisotropy.Value = -1.0f;
  548. Graphics.AspectRatio.Value = AspectRatio.Fixed16x9;
  549. Graphics.GraphicsBackend.Value = OperatingSystem.IsMacOS() ? GraphicsBackend.Vulkan : GraphicsBackend.OpenGl;
  550. Graphics.PreferredGpu.Value = "";
  551. Graphics.ShadersDumpPath.Value = "";
  552. Logger.EnableDebug.Value = false;
  553. Logger.EnableStub.Value = true;
  554. Logger.EnableInfo.Value = true;
  555. Logger.EnableWarn.Value = true;
  556. Logger.EnableError.Value = true;
  557. Logger.EnableTrace.Value = false;
  558. Logger.EnableGuest.Value = true;
  559. Logger.EnableFsAccessLog.Value = false;
  560. Logger.FilteredClasses.Value = Array.Empty<LogClass>();
  561. Logger.GraphicsDebugLevel.Value = GraphicsDebugLevel.None;
  562. System.Language.Value = Language.AmericanEnglish;
  563. System.Region.Value = Region.USA;
  564. System.TimeZone.Value = "UTC";
  565. System.SystemTimeOffset.Value = 0;
  566. System.EnableDockedMode.Value = true;
  567. EnableDiscordIntegration.Value = true;
  568. CheckUpdatesOnStart.Value = true;
  569. ShowConfirmExit.Value = true;
  570. HideCursorOnIdle.Value = false;
  571. Graphics.EnableVsync.Value = true;
  572. Graphics.EnableShaderCache.Value = true;
  573. Graphics.EnableTextureRecompression.Value = false;
  574. Graphics.EnableMacroHLE.Value = true;
  575. System.EnablePtc.Value = true;
  576. System.EnableInternetAccess.Value = false;
  577. System.EnableFsIntegrityChecks.Value = true;
  578. System.FsGlobalAccessLogMode.Value = 0;
  579. System.AudioBackend.Value = AudioBackend.SDL2;
  580. System.AudioVolume.Value = 1;
  581. System.MemoryManagerMode.Value = MemoryManagerMode.HostMappedUnsafe;
  582. System.ExpandRam.Value = false;
  583. System.IgnoreMissingServices.Value = false;
  584. System.UseHypervisor.Value = true;
  585. Ui.GuiColumns.FavColumn.Value = true;
  586. Ui.GuiColumns.IconColumn.Value = true;
  587. Ui.GuiColumns.AppColumn.Value = true;
  588. Ui.GuiColumns.DevColumn.Value = true;
  589. Ui.GuiColumns.VersionColumn.Value = true;
  590. Ui.GuiColumns.TimePlayedColumn.Value = true;
  591. Ui.GuiColumns.LastPlayedColumn.Value = true;
  592. Ui.GuiColumns.FileExtColumn.Value = true;
  593. Ui.GuiColumns.FileSizeColumn.Value = true;
  594. Ui.GuiColumns.PathColumn.Value = true;
  595. Ui.ColumnSort.SortColumnId.Value = 0;
  596. Ui.ColumnSort.SortAscending.Value = false;
  597. Ui.GameDirs.Value = new List<string>();
  598. Ui.EnableCustomTheme.Value = false;
  599. Ui.LanguageCode.Value = "en_US";
  600. Ui.CustomThemePath.Value = "";
  601. Ui.BaseStyle.Value = "Dark";
  602. Ui.GameListViewMode.Value = 0;
  603. Ui.ShowNames.Value = true;
  604. Ui.GridSize.Value = 2;
  605. Ui.ApplicationSort.Value = 0;
  606. Ui.IsAscendingOrder.Value = true;
  607. Ui.StartFullscreen.Value = false;
  608. Ui.ShowConsole.Value = true;
  609. Hid.EnableKeyboard.Value = false;
  610. Hid.EnableMouse.Value = false;
  611. Hid.Hotkeys.Value = new KeyboardHotkeys
  612. {
  613. ToggleVsync = Key.F1,
  614. ToggleMute = Key.F2,
  615. Screenshot = Key.F8,
  616. ShowUi = Key.F4,
  617. Pause = Key.F5,
  618. ResScaleUp = Key.Unbound,
  619. ResScaleDown = Key.Unbound,
  620. VolumeUp = Key.Unbound,
  621. VolumeDown = Key.Unbound
  622. };
  623. Hid.InputConfig.Value = new List<InputConfig>
  624. {
  625. new StandardKeyboardInputConfig
  626. {
  627. Version = InputConfig.CurrentVersion,
  628. Backend = InputBackendType.WindowKeyboard,
  629. Id = "0",
  630. PlayerIndex = PlayerIndex.Player1,
  631. ControllerType = ControllerType.JoyconPair,
  632. LeftJoycon = new LeftJoyconCommonConfig<Key>
  633. {
  634. DpadUp = Key.Up,
  635. DpadDown = Key.Down,
  636. DpadLeft = Key.Left,
  637. DpadRight = Key.Right,
  638. ButtonMinus = Key.Minus,
  639. ButtonL = Key.E,
  640. ButtonZl = Key.Q,
  641. ButtonSl = Key.Unbound,
  642. ButtonSr = Key.Unbound
  643. },
  644. LeftJoyconStick = new JoyconConfigKeyboardStick<Key>
  645. {
  646. StickUp = Key.W,
  647. StickDown = Key.S,
  648. StickLeft = Key.A,
  649. StickRight = Key.D,
  650. StickButton = Key.F,
  651. },
  652. RightJoycon = new RightJoyconCommonConfig<Key>
  653. {
  654. ButtonA = Key.Z,
  655. ButtonB = Key.X,
  656. ButtonX = Key.C,
  657. ButtonY = Key.V,
  658. ButtonPlus = Key.Plus,
  659. ButtonR = Key.U,
  660. ButtonZr = Key.O,
  661. ButtonSl = Key.Unbound,
  662. ButtonSr = Key.Unbound
  663. },
  664. RightJoyconStick = new JoyconConfigKeyboardStick<Key>
  665. {
  666. StickUp = Key.I,
  667. StickDown = Key.K,
  668. StickLeft = Key.J,
  669. StickRight = Key.L,
  670. StickButton = Key.H,
  671. }
  672. }
  673. };
  674. }
  675. public ConfigurationLoadResult Load(ConfigurationFileFormat configurationFileFormat, string configurationFilePath)
  676. {
  677. bool configurationFileUpdated = false;
  678. if (configurationFileFormat.Version < 0 || configurationFileFormat.Version > ConfigurationFileFormat.CurrentVersion)
  679. {
  680. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Unsupported configuration version {configurationFileFormat.Version}, loading default.");
  681. LoadDefault();
  682. return ConfigurationLoadResult.NotLoaded;
  683. }
  684. ConfigurationLoadResult result = ConfigurationLoadResult.Success;
  685. if (configurationFileFormat.Version < 2)
  686. {
  687. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 2.");
  688. configurationFileFormat.SystemRegion = Region.USA;
  689. configurationFileUpdated = true;
  690. }
  691. if (configurationFileFormat.Version < 3)
  692. {
  693. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 3.");
  694. configurationFileFormat.SystemTimeZone = "UTC";
  695. configurationFileUpdated = true;
  696. }
  697. if (configurationFileFormat.Version < 4)
  698. {
  699. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 4.");
  700. configurationFileFormat.MaxAnisotropy = -1;
  701. configurationFileUpdated = true;
  702. }
  703. if (configurationFileFormat.Version < 5)
  704. {
  705. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 5.");
  706. configurationFileFormat.SystemTimeOffset = 0;
  707. configurationFileUpdated = true;
  708. }
  709. if (configurationFileFormat.Version < 8)
  710. {
  711. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 8.");
  712. configurationFileFormat.EnablePtc = true;
  713. configurationFileUpdated = true;
  714. }
  715. if (configurationFileFormat.Version < 9)
  716. {
  717. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 9.");
  718. configurationFileFormat.ColumnSort = new ColumnSort
  719. {
  720. SortColumnId = 0,
  721. SortAscending = false
  722. };
  723. configurationFileFormat.Hotkeys = new KeyboardHotkeys
  724. {
  725. ToggleVsync = Key.F1
  726. };
  727. configurationFileUpdated = true;
  728. }
  729. if (configurationFileFormat.Version < 10)
  730. {
  731. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 10.");
  732. configurationFileFormat.AudioBackend = AudioBackend.OpenAl;
  733. configurationFileUpdated = true;
  734. }
  735. if (configurationFileFormat.Version < 11)
  736. {
  737. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 11.");
  738. configurationFileFormat.ResScale = 1;
  739. configurationFileFormat.ResScaleCustom = 1.0f;
  740. configurationFileUpdated = true;
  741. }
  742. if (configurationFileFormat.Version < 12)
  743. {
  744. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 12.");
  745. configurationFileFormat.LoggingGraphicsDebugLevel = GraphicsDebugLevel.None;
  746. configurationFileUpdated = true;
  747. }
  748. if (configurationFileFormat.Version < 14)
  749. {
  750. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 14.");
  751. configurationFileFormat.CheckUpdatesOnStart = true;
  752. configurationFileUpdated = true;
  753. }
  754. if (configurationFileFormat.Version < 16)
  755. {
  756. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 16.");
  757. configurationFileFormat.EnableShaderCache = true;
  758. configurationFileUpdated = true;
  759. }
  760. if (configurationFileFormat.Version < 17)
  761. {
  762. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 17.");
  763. configurationFileFormat.StartFullscreen = false;
  764. configurationFileUpdated = true;
  765. }
  766. if (configurationFileFormat.Version < 18)
  767. {
  768. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 18.");
  769. configurationFileFormat.AspectRatio = AspectRatio.Fixed16x9;
  770. configurationFileUpdated = true;
  771. }
  772. if (configurationFileFormat.Version < 20)
  773. {
  774. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 20.");
  775. configurationFileFormat.ShowConfirmExit = true;
  776. configurationFileUpdated = true;
  777. }
  778. if (configurationFileFormat.Version < 22)
  779. {
  780. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 22.");
  781. configurationFileFormat.HideCursorOnIdle = false;
  782. configurationFileUpdated = true;
  783. }
  784. if (configurationFileFormat.Version < 24)
  785. {
  786. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 24.");
  787. configurationFileFormat.InputConfig = new List<InputConfig>
  788. {
  789. new StandardKeyboardInputConfig
  790. {
  791. Version = InputConfig.CurrentVersion,
  792. Backend = InputBackendType.WindowKeyboard,
  793. Id = "0",
  794. PlayerIndex = PlayerIndex.Player1,
  795. ControllerType = ControllerType.JoyconPair,
  796. LeftJoycon = new LeftJoyconCommonConfig<Key>
  797. {
  798. DpadUp = Key.Up,
  799. DpadDown = Key.Down,
  800. DpadLeft = Key.Left,
  801. DpadRight = Key.Right,
  802. ButtonMinus = Key.Minus,
  803. ButtonL = Key.E,
  804. ButtonZl = Key.Q,
  805. ButtonSl = Key.Unbound,
  806. ButtonSr = Key.Unbound
  807. },
  808. LeftJoyconStick = new JoyconConfigKeyboardStick<Key>
  809. {
  810. StickUp = Key.W,
  811. StickDown = Key.S,
  812. StickLeft = Key.A,
  813. StickRight = Key.D,
  814. StickButton = Key.F,
  815. },
  816. RightJoycon = new RightJoyconCommonConfig<Key>
  817. {
  818. ButtonA = Key.Z,
  819. ButtonB = Key.X,
  820. ButtonX = Key.C,
  821. ButtonY = Key.V,
  822. ButtonPlus = Key.Plus,
  823. ButtonR = Key.U,
  824. ButtonZr = Key.O,
  825. ButtonSl = Key.Unbound,
  826. ButtonSr = Key.Unbound
  827. },
  828. RightJoyconStick = new JoyconConfigKeyboardStick<Key>
  829. {
  830. StickUp = Key.I,
  831. StickDown = Key.K,
  832. StickLeft = Key.J,
  833. StickRight = Key.L,
  834. StickButton = Key.H,
  835. }
  836. }
  837. };
  838. configurationFileUpdated = true;
  839. }
  840. if (configurationFileFormat.Version < 25)
  841. {
  842. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 25.");
  843. configurationFileUpdated = true;
  844. }
  845. if (configurationFileFormat.Version < 26)
  846. {
  847. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 26.");
  848. configurationFileFormat.MemoryManagerMode = MemoryManagerMode.HostMappedUnsafe;
  849. configurationFileUpdated = true;
  850. }
  851. if (configurationFileFormat.Version < 27)
  852. {
  853. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 27.");
  854. configurationFileFormat.EnableMouse = false;
  855. configurationFileUpdated = true;
  856. }
  857. if (configurationFileFormat.Version < 28)
  858. {
  859. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 28.");
  860. configurationFileFormat.Hotkeys = new KeyboardHotkeys
  861. {
  862. ToggleVsync = Key.F1,
  863. Screenshot = Key.F8
  864. };
  865. configurationFileUpdated = true;
  866. }
  867. if (configurationFileFormat.Version < 29)
  868. {
  869. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 29.");
  870. configurationFileFormat.Hotkeys = new KeyboardHotkeys
  871. {
  872. ToggleVsync = Key.F1,
  873. Screenshot = Key.F8,
  874. ShowUi = Key.F4
  875. };
  876. configurationFileUpdated = true;
  877. }
  878. if (configurationFileFormat.Version < 30)
  879. {
  880. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 30.");
  881. foreach(InputConfig config in configurationFileFormat.InputConfig)
  882. {
  883. if (config is StandardControllerInputConfig controllerConfig)
  884. {
  885. controllerConfig.Rumble = new RumbleConfigController
  886. {
  887. EnableRumble = false,
  888. StrongRumble = 1f,
  889. WeakRumble = 1f
  890. };
  891. }
  892. }
  893. configurationFileUpdated = true;
  894. }
  895. if (configurationFileFormat.Version < 31)
  896. {
  897. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 31.");
  898. configurationFileFormat.BackendThreading = BackendThreading.Auto;
  899. configurationFileUpdated = true;
  900. }
  901. if (configurationFileFormat.Version < 32)
  902. {
  903. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 32.");
  904. configurationFileFormat.Hotkeys = new KeyboardHotkeys
  905. {
  906. ToggleVsync = configurationFileFormat.Hotkeys.ToggleVsync,
  907. Screenshot = configurationFileFormat.Hotkeys.Screenshot,
  908. ShowUi = configurationFileFormat.Hotkeys.ShowUi,
  909. Pause = Key.F5
  910. };
  911. configurationFileUpdated = true;
  912. }
  913. if (configurationFileFormat.Version < 33)
  914. {
  915. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 33.");
  916. configurationFileFormat.Hotkeys = new KeyboardHotkeys
  917. {
  918. ToggleVsync = configurationFileFormat.Hotkeys.ToggleVsync,
  919. Screenshot = configurationFileFormat.Hotkeys.Screenshot,
  920. ShowUi = configurationFileFormat.Hotkeys.ShowUi,
  921. Pause = configurationFileFormat.Hotkeys.Pause,
  922. ToggleMute = Key.F2
  923. };
  924. configurationFileFormat.AudioVolume = 1;
  925. configurationFileUpdated = true;
  926. }
  927. if (configurationFileFormat.Version < 34)
  928. {
  929. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 34.");
  930. configurationFileFormat.EnableInternetAccess = false;
  931. configurationFileUpdated = true;
  932. }
  933. if (configurationFileFormat.Version < 35)
  934. {
  935. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 35.");
  936. foreach (InputConfig config in configurationFileFormat.InputConfig)
  937. {
  938. if (config is StandardControllerInputConfig controllerConfig)
  939. {
  940. controllerConfig.RangeLeft = 1.0f;
  941. controllerConfig.RangeRight = 1.0f;
  942. }
  943. }
  944. configurationFileUpdated = true;
  945. }
  946. if (configurationFileFormat.Version < 36)
  947. {
  948. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 36.");
  949. configurationFileFormat.LoggingEnableTrace = false;
  950. configurationFileUpdated = true;
  951. }
  952. if (configurationFileFormat.Version < 37)
  953. {
  954. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 37.");
  955. configurationFileFormat.ShowConsole = true;
  956. configurationFileUpdated = true;
  957. }
  958. if (configurationFileFormat.Version < 38)
  959. {
  960. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 38.");
  961. configurationFileFormat.BaseStyle = "Dark";
  962. configurationFileFormat.GameListViewMode = 0;
  963. configurationFileFormat.ShowNames = true;
  964. configurationFileFormat.GridSize = 2;
  965. configurationFileFormat.LanguageCode = "en_US";
  966. configurationFileUpdated = true;
  967. }
  968. if (configurationFileFormat.Version < 39)
  969. {
  970. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 39.");
  971. configurationFileFormat.Hotkeys = new KeyboardHotkeys
  972. {
  973. ToggleVsync = configurationFileFormat.Hotkeys.ToggleVsync,
  974. Screenshot = configurationFileFormat.Hotkeys.Screenshot,
  975. ShowUi = configurationFileFormat.Hotkeys.ShowUi,
  976. Pause = configurationFileFormat.Hotkeys.Pause,
  977. ToggleMute = configurationFileFormat.Hotkeys.ToggleMute,
  978. ResScaleUp = Key.Unbound,
  979. ResScaleDown = Key.Unbound
  980. };
  981. configurationFileUpdated = true;
  982. }
  983. if (configurationFileFormat.Version < 40)
  984. {
  985. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 40.");
  986. configurationFileFormat.GraphicsBackend = GraphicsBackend.OpenGl;
  987. result |= ConfigurationLoadResult.MigratedFromPreVulkan;
  988. configurationFileUpdated = true;
  989. }
  990. if (configurationFileFormat.Version < 41)
  991. {
  992. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 41.");
  993. configurationFileFormat.Hotkeys = new KeyboardHotkeys
  994. {
  995. ToggleVsync = configurationFileFormat.Hotkeys.ToggleVsync,
  996. Screenshot = configurationFileFormat.Hotkeys.Screenshot,
  997. ShowUi = configurationFileFormat.Hotkeys.ShowUi,
  998. Pause = configurationFileFormat.Hotkeys.Pause,
  999. ToggleMute = configurationFileFormat.Hotkeys.ToggleMute,
  1000. ResScaleUp = configurationFileFormat.Hotkeys.ResScaleUp,
  1001. ResScaleDown = configurationFileFormat.Hotkeys.ResScaleDown,
  1002. VolumeUp = Key.Unbound,
  1003. VolumeDown = Key.Unbound
  1004. };
  1005. }
  1006. if (configurationFileFormat.Version < 42)
  1007. {
  1008. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 42.");
  1009. configurationFileFormat.EnableMacroHLE = true;
  1010. }
  1011. if (configurationFileFormat.Version < 43)
  1012. {
  1013. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 43.");
  1014. configurationFileFormat.UseHypervisor = true;
  1015. }
  1016. Logger.EnableFileLog.Value = configurationFileFormat.EnableFileLog;
  1017. Graphics.ResScale.Value = configurationFileFormat.ResScale;
  1018. Graphics.ResScaleCustom.Value = configurationFileFormat.ResScaleCustom;
  1019. Graphics.MaxAnisotropy.Value = configurationFileFormat.MaxAnisotropy;
  1020. Graphics.AspectRatio.Value = configurationFileFormat.AspectRatio;
  1021. Graphics.ShadersDumpPath.Value = configurationFileFormat.GraphicsShadersDumpPath;
  1022. Graphics.BackendThreading.Value = configurationFileFormat.BackendThreading;
  1023. Graphics.GraphicsBackend.Value = configurationFileFormat.GraphicsBackend;
  1024. Graphics.PreferredGpu.Value = configurationFileFormat.PreferredGpu;
  1025. Logger.EnableDebug.Value = configurationFileFormat.LoggingEnableDebug;
  1026. Logger.EnableStub.Value = configurationFileFormat.LoggingEnableStub;
  1027. Logger.EnableInfo.Value = configurationFileFormat.LoggingEnableInfo;
  1028. Logger.EnableWarn.Value = configurationFileFormat.LoggingEnableWarn;
  1029. Logger.EnableError.Value = configurationFileFormat.LoggingEnableError;
  1030. Logger.EnableTrace.Value = configurationFileFormat.LoggingEnableTrace;
  1031. Logger.EnableGuest.Value = configurationFileFormat.LoggingEnableGuest;
  1032. Logger.EnableFsAccessLog.Value = configurationFileFormat.LoggingEnableFsAccessLog;
  1033. Logger.FilteredClasses.Value = configurationFileFormat.LoggingFilteredClasses;
  1034. Logger.GraphicsDebugLevel.Value = configurationFileFormat.LoggingGraphicsDebugLevel;
  1035. System.Language.Value = configurationFileFormat.SystemLanguage;
  1036. System.Region.Value = configurationFileFormat.SystemRegion;
  1037. System.TimeZone.Value = configurationFileFormat.SystemTimeZone;
  1038. System.SystemTimeOffset.Value = configurationFileFormat.SystemTimeOffset;
  1039. System.EnableDockedMode.Value = configurationFileFormat.DockedMode;
  1040. EnableDiscordIntegration.Value = configurationFileFormat.EnableDiscordIntegration;
  1041. CheckUpdatesOnStart.Value = configurationFileFormat.CheckUpdatesOnStart;
  1042. ShowConfirmExit.Value = configurationFileFormat.ShowConfirmExit;
  1043. HideCursorOnIdle.Value = configurationFileFormat.HideCursorOnIdle;
  1044. Graphics.EnableVsync.Value = configurationFileFormat.EnableVsync;
  1045. Graphics.EnableShaderCache.Value = configurationFileFormat.EnableShaderCache;
  1046. Graphics.EnableTextureRecompression.Value = configurationFileFormat.EnableTextureRecompression;
  1047. Graphics.EnableMacroHLE.Value = configurationFileFormat.EnableMacroHLE;
  1048. System.EnablePtc.Value = configurationFileFormat.EnablePtc;
  1049. System.EnableInternetAccess.Value = configurationFileFormat.EnableInternetAccess;
  1050. System.EnableFsIntegrityChecks.Value = configurationFileFormat.EnableFsIntegrityChecks;
  1051. System.FsGlobalAccessLogMode.Value = configurationFileFormat.FsGlobalAccessLogMode;
  1052. System.AudioBackend.Value = configurationFileFormat.AudioBackend;
  1053. System.AudioVolume.Value = configurationFileFormat.AudioVolume;
  1054. System.MemoryManagerMode.Value = configurationFileFormat.MemoryManagerMode;
  1055. System.ExpandRam.Value = configurationFileFormat.ExpandRam;
  1056. System.IgnoreMissingServices.Value = configurationFileFormat.IgnoreMissingServices;
  1057. System.UseHypervisor.Value = configurationFileFormat.UseHypervisor;
  1058. Ui.GuiColumns.FavColumn.Value = configurationFileFormat.GuiColumns.FavColumn;
  1059. Ui.GuiColumns.IconColumn.Value = configurationFileFormat.GuiColumns.IconColumn;
  1060. Ui.GuiColumns.AppColumn.Value = configurationFileFormat.GuiColumns.AppColumn;
  1061. Ui.GuiColumns.DevColumn.Value = configurationFileFormat.GuiColumns.DevColumn;
  1062. Ui.GuiColumns.VersionColumn.Value = configurationFileFormat.GuiColumns.VersionColumn;
  1063. Ui.GuiColumns.TimePlayedColumn.Value = configurationFileFormat.GuiColumns.TimePlayedColumn;
  1064. Ui.GuiColumns.LastPlayedColumn.Value = configurationFileFormat.GuiColumns.LastPlayedColumn;
  1065. Ui.GuiColumns.FileExtColumn.Value = configurationFileFormat.GuiColumns.FileExtColumn;
  1066. Ui.GuiColumns.FileSizeColumn.Value = configurationFileFormat.GuiColumns.FileSizeColumn;
  1067. Ui.GuiColumns.PathColumn.Value = configurationFileFormat.GuiColumns.PathColumn;
  1068. Ui.ColumnSort.SortColumnId.Value = configurationFileFormat.ColumnSort.SortColumnId;
  1069. Ui.ColumnSort.SortAscending.Value = configurationFileFormat.ColumnSort.SortAscending;
  1070. Ui.GameDirs.Value = configurationFileFormat.GameDirs;
  1071. Ui.EnableCustomTheme.Value = configurationFileFormat.EnableCustomTheme;
  1072. Ui.LanguageCode.Value = configurationFileFormat.LanguageCode;
  1073. Ui.CustomThemePath.Value = configurationFileFormat.CustomThemePath;
  1074. Ui.BaseStyle.Value = configurationFileFormat.BaseStyle;
  1075. Ui.GameListViewMode.Value = configurationFileFormat.GameListViewMode;
  1076. Ui.ShowNames.Value = configurationFileFormat.ShowNames;
  1077. Ui.IsAscendingOrder.Value = configurationFileFormat.IsAscendingOrder;
  1078. Ui.GridSize.Value = configurationFileFormat.GridSize;
  1079. Ui.ApplicationSort.Value = configurationFileFormat.ApplicationSort;
  1080. Ui.StartFullscreen.Value = configurationFileFormat.StartFullscreen;
  1081. Ui.ShowConsole.Value = configurationFileFormat.ShowConsole;
  1082. Hid.EnableKeyboard.Value = configurationFileFormat.EnableKeyboard;
  1083. Hid.EnableMouse.Value = configurationFileFormat.EnableMouse;
  1084. Hid.Hotkeys.Value = configurationFileFormat.Hotkeys;
  1085. Hid.InputConfig.Value = configurationFileFormat.InputConfig;
  1086. if (Hid.InputConfig.Value == null)
  1087. {
  1088. Hid.InputConfig.Value = new List<InputConfig>();
  1089. }
  1090. if (configurationFileUpdated)
  1091. {
  1092. ToFileFormat().SaveConfig(configurationFilePath);
  1093. Ryujinx.Common.Logging.Logger.Notice.Print(LogClass.Application, $"Configuration file updated to version {ConfigurationFileFormat.CurrentVersion}");
  1094. }
  1095. return result;
  1096. }
  1097. private static void LogValueChange<T>(object sender, ReactiveEventArgs<T> eventArgs, string valueName)
  1098. {
  1099. Ryujinx.Common.Logging.Logger.Info?.Print(LogClass.Configuration, $"{valueName} set to: {eventArgs.NewValue}");
  1100. }
  1101. public static void Initialize()
  1102. {
  1103. if (Instance != null)
  1104. {
  1105. throw new InvalidOperationException("Configuration is already initialized");
  1106. }
  1107. Instance = new ConfigurationState();
  1108. }
  1109. }
  1110. }