ConfigurationState.cs 70 KB

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