ConfigurationState.cs 75 KB

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