ConfigurationState.cs 68 KB

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