Options.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. using CommandLine;
  2. using Gommon;
  3. using Ryujinx.Ava.Utilities.Configuration;
  4. using Ryujinx.Common.Configuration;
  5. using Ryujinx.Common.Configuration.Hid;
  6. using Ryujinx.HLE;
  7. using Ryujinx.HLE.HOS.Services.Account.Acc;
  8. using Ryujinx.HLE.HOS.SystemState;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Linq;
  12. using System.Reflection;
  13. namespace Ryujinx.Headless
  14. {
  15. public class Options
  16. {
  17. public void InheritMainConfig(string[] originalArgs, ConfigurationState configurationState, out bool needsProfileSet)
  18. {
  19. needsProfileSet = NeedsOverride(nameof(UserProfile));
  20. if (NeedsOverride(nameof(IsFullscreen)))
  21. IsFullscreen = configurationState.UI.StartFullscreen;
  22. if (NeedsOverride(nameof(EnableKeyboard)))
  23. EnableKeyboard = configurationState.Hid.EnableKeyboard;
  24. if (NeedsOverride(nameof(EnableMouse)))
  25. EnableMouse = configurationState.Hid.EnableMouse;
  26. if (NeedsOverride(nameof(HideCursorMode)))
  27. HideCursorMode = configurationState.HideCursor;
  28. if (NeedsOverride(nameof(DisablePTC)))
  29. DisablePTC = !configurationState.System.EnablePtc;
  30. if (NeedsOverride(nameof(EnableInternetAccess)))
  31. EnableInternetAccess = configurationState.System.EnableInternetAccess;
  32. if (NeedsOverride(nameof(DisableFsIntegrityChecks)))
  33. DisableFsIntegrityChecks = configurationState.System.EnableFsIntegrityChecks;
  34. if (NeedsOverride(nameof(FsGlobalAccessLogMode)))
  35. FsGlobalAccessLogMode = configurationState.System.FsGlobalAccessLogMode;
  36. if (NeedsOverride(nameof(VSyncMode)))
  37. VSyncMode = configurationState.Graphics.VSyncMode;
  38. if (NeedsOverride(nameof(CustomVSyncInterval)))
  39. CustomVSyncInterval = configurationState.Graphics.CustomVSyncInterval;
  40. if (NeedsOverride(nameof(DisableShaderCache)))
  41. DisableShaderCache = !configurationState.Graphics.EnableShaderCache;
  42. if (NeedsOverride(nameof(EnableTextureRecompression)))
  43. EnableTextureRecompression = configurationState.Graphics.EnableTextureRecompression;
  44. if (NeedsOverride(nameof(DisableDockedMode)))
  45. DisableDockedMode = !configurationState.System.EnableDockedMode;
  46. if (NeedsOverride(nameof(SystemLanguage)))
  47. SystemLanguage = (SystemLanguage)(int)configurationState.System.Language.Value;
  48. if (NeedsOverride(nameof(SystemRegion)))
  49. SystemRegion = (RegionCode)(int)configurationState.System.Region.Value;
  50. if (NeedsOverride(nameof(SystemTimeZone)))
  51. SystemTimeZone = configurationState.System.TimeZone;
  52. if (NeedsOverride(nameof(SystemTimeOffset)))
  53. SystemTimeOffset = configurationState.System.SystemTimeOffset;
  54. if (NeedsOverride(nameof(MemoryManagerMode)))
  55. MemoryManagerMode = configurationState.System.MemoryManagerMode;
  56. if (NeedsOverride(nameof(AudioVolume)))
  57. AudioVolume = configurationState.System.AudioVolume;
  58. if (NeedsOverride(nameof(UseHypervisor)) && OperatingSystem.IsMacOS())
  59. UseHypervisor = configurationState.System.UseHypervisor;
  60. if (NeedsOverride(nameof(MultiplayerLanInterfaceId)))
  61. MultiplayerLanInterfaceId = configurationState.Multiplayer.LanInterfaceId;
  62. if (NeedsOverride(nameof(DisableFileLog)))
  63. DisableFileLog = !configurationState.Logger.EnableFileLog;
  64. if (NeedsOverride(nameof(LoggingEnableDebug)))
  65. LoggingEnableDebug = configurationState.Logger.EnableDebug;
  66. if (NeedsOverride(nameof(LoggingDisableStub)))
  67. LoggingDisableStub = !configurationState.Logger.EnableStub;
  68. if (NeedsOverride(nameof(LoggingDisableInfo)))
  69. LoggingDisableInfo = !configurationState.Logger.EnableInfo;
  70. if (NeedsOverride(nameof(LoggingDisableWarning)))
  71. LoggingDisableWarning = !configurationState.Logger.EnableWarn;
  72. if (NeedsOverride(nameof(LoggingDisableError)))
  73. LoggingDisableError = !configurationState.Logger.EnableError;
  74. if (NeedsOverride(nameof(LoggingEnableTrace)))
  75. LoggingEnableTrace = configurationState.Logger.EnableTrace;
  76. if (NeedsOverride(nameof(LoggingDisableGuest)))
  77. LoggingDisableGuest = !configurationState.Logger.EnableGuest;
  78. if (NeedsOverride(nameof(LoggingEnableFsAccessLog)))
  79. LoggingEnableFsAccessLog = configurationState.Logger.EnableFsAccessLog;
  80. if (NeedsOverride(nameof(LoggingGraphicsDebugLevel)))
  81. LoggingGraphicsDebugLevel = configurationState.Logger.GraphicsDebugLevel;
  82. if (NeedsOverride(nameof(ResScale)))
  83. ResScale = configurationState.Graphics.ResScale;
  84. if (NeedsOverride(nameof(MaxAnisotropy)))
  85. MaxAnisotropy = configurationState.Graphics.MaxAnisotropy;
  86. if (NeedsOverride(nameof(AspectRatio)))
  87. AspectRatio = configurationState.Graphics.AspectRatio;
  88. if (NeedsOverride(nameof(BackendThreading)))
  89. BackendThreading = configurationState.Graphics.BackendThreading;
  90. if (NeedsOverride(nameof(DisableMacroHLE)))
  91. DisableMacroHLE = !configurationState.Graphics.EnableMacroHLE;
  92. if (NeedsOverride(nameof(GraphicsShadersDumpPath)))
  93. GraphicsShadersDumpPath = configurationState.Graphics.ShadersDumpPath;
  94. if (NeedsOverride(nameof(GraphicsBackend)))
  95. GraphicsBackend = configurationState.Graphics.GraphicsBackend;
  96. if (NeedsOverride(nameof(AntiAliasing)))
  97. AntiAliasing = configurationState.Graphics.AntiAliasing;
  98. if (NeedsOverride(nameof(ScalingFilter)))
  99. ScalingFilter = configurationState.Graphics.ScalingFilter;
  100. if (NeedsOverride(nameof(ScalingFilterLevel)))
  101. ScalingFilterLevel = configurationState.Graphics.ScalingFilterLevel;
  102. if (NeedsOverride(nameof(DramSize)))
  103. DramSize = configurationState.System.DramSize;
  104. if (NeedsOverride(nameof(IgnoreMissingServices)))
  105. IgnoreMissingServices = configurationState.System.IgnoreMissingServices;
  106. if (NeedsOverride(nameof(IgnoreControllerApplet)))
  107. IgnoreControllerApplet = configurationState.IgnoreApplet;
  108. return;
  109. bool NeedsOverride(string argKey) => originalArgs.None(arg => arg.TrimStart('-').EqualsIgnoreCase(OptionName(argKey)));
  110. string OptionName(string propertyName) =>
  111. typeof(Options)!.GetProperty(propertyName)!.GetCustomAttribute<OptionAttribute>()!.LongName;
  112. }
  113. // General
  114. [Option("use-main-config", Required = false, Default = false, HelpText = "Use the settings from what was configured via the UI.")]
  115. public bool InheritConfig { get; set; }
  116. [Option("root-data-dir", Required = false, HelpText = "Set the custom folder path for Ryujinx data.")]
  117. public string BaseDataDir { get; set; }
  118. [Option("profile", Required = false, HelpText = "Set the user profile to launch the game with.")]
  119. public string UserProfile { get; set; }
  120. [Option("display-id", Required = false, Default = 0, HelpText = "Set the display to use - especially helpful for fullscreen mode. [0-n]")]
  121. public int DisplayId { get; set; }
  122. [Option("fullscreen", Required = false, Default = false, HelpText = "Launch the game in fullscreen mode.")]
  123. public bool IsFullscreen { get; set; }
  124. [Option("exclusive-fullscreen", Required = false, Default = false, HelpText = "Launch the game in exclusive fullscreen mode.")]
  125. public bool IsExclusiveFullscreen { get; set; }
  126. [Option("exclusive-fullscreen-width", Required = false, Default = 1920, HelpText = "Set horizontal resolution for exclusive fullscreen mode.")]
  127. public int ExclusiveFullscreenWidth { get; set; }
  128. [Option("exclusive-fullscreen-height", Required = false, Default = 1080, HelpText = "Set vertical resolution for exclusive fullscreen mode.")]
  129. public int ExclusiveFullscreenHeight { get; set; }
  130. // Input
  131. [Option("input-profile-1", Required = false, HelpText = "Set the input profile in use for Player 1.")]
  132. public string InputProfile1Name { get; set; }
  133. [Option("input-profile-2", Required = false, HelpText = "Set the input profile in use for Player 2.")]
  134. public string InputProfile2Name { get; set; }
  135. [Option("input-profile-3", Required = false, HelpText = "Set the input profile in use for Player 3.")]
  136. public string InputProfile3Name { get; set; }
  137. [Option("input-profile-4", Required = false, HelpText = "Set the input profile in use for Player 4.")]
  138. public string InputProfile4Name { get; set; }
  139. [Option("input-profile-5", Required = false, HelpText = "Set the input profile in use for Player 5.")]
  140. public string InputProfile5Name { get; set; }
  141. [Option("input-profile-6", Required = false, HelpText = "Set the input profile in use for Player 6.")]
  142. public string InputProfile6Name { get; set; }
  143. [Option("input-profile-7", Required = false, HelpText = "Set the input profile in use for Player 7.")]
  144. public string InputProfile7Name { get; set; }
  145. [Option("input-profile-8", Required = false, HelpText = "Set the input profile in use for Player 8.")]
  146. public string InputProfile8Name { get; set; }
  147. [Option("input-profile-handheld", Required = false, HelpText = "Set the input profile in use for the Handheld Player.")]
  148. public string InputProfileHandheldName { get; set; }
  149. [Option("input-id-1", Required = false, HelpText = "Set the input id in use for Player 1.")]
  150. public string InputId1 { get; set; }
  151. [Option("input-id-2", Required = false, HelpText = "Set the input id in use for Player 2.")]
  152. public string InputId2 { get; set; }
  153. [Option("input-id-3", Required = false, HelpText = "Set the input id in use for Player 3.")]
  154. public string InputId3 { get; set; }
  155. [Option("input-id-4", Required = false, HelpText = "Set the input id in use for Player 4.")]
  156. public string InputId4 { get; set; }
  157. [Option("input-id-5", Required = false, HelpText = "Set the input id in use for Player 5.")]
  158. public string InputId5 { get; set; }
  159. [Option("input-id-6", Required = false, HelpText = "Set the input id in use for Player 6.")]
  160. public string InputId6 { get; set; }
  161. [Option("input-id-7", Required = false, HelpText = "Set the input id in use for Player 7.")]
  162. public string InputId7 { get; set; }
  163. [Option("input-id-8", Required = false, HelpText = "Set the input id in use for Player 8.")]
  164. public string InputId8 { get; set; }
  165. [Option("input-id-handheld", Required = false, HelpText = "Set the input id in use for the Handheld Player.")]
  166. public string InputIdHandheld { get; set; }
  167. [Option("enable-keyboard", Required = false, Default = false, HelpText = "Enable or disable keyboard support (Independent from controllers binding).")]
  168. public bool EnableKeyboard { get; set; }
  169. [Option("enable-mouse", Required = false, Default = false, HelpText = "Enable or disable mouse support.")]
  170. public bool EnableMouse { get; set; }
  171. [Option("hide-cursor", Required = false, Default = HideCursorMode.OnIdle, HelpText = "Change when the cursor gets hidden.")]
  172. public HideCursorMode HideCursorMode { get; set; }
  173. [Option("list-input-profiles", Required = false, HelpText = "List input profiles.")]
  174. public bool ListInputProfiles { get; set; }
  175. [Option("list-input-ids", Required = false, HelpText = "List input IDs.")]
  176. public bool ListInputIds { get; set; }
  177. // System
  178. [Option("disable-ptc", Required = false, HelpText = "Disables profiled persistent translation cache.")]
  179. public bool DisablePTC { get; set; }
  180. [Option("enable-internet-connection", Required = false, Default = false, HelpText = "Enables guest Internet connection.")]
  181. public bool EnableInternetAccess { get; set; }
  182. [Option("disable-fs-integrity-checks", Required = false, HelpText = "Disables integrity checks on Game content files.")]
  183. public bool DisableFsIntegrityChecks { get; set; }
  184. [Option("fs-global-access-log-mode", Required = false, Default = 0, HelpText = "Enables FS access log output to the console.")]
  185. public int FsGlobalAccessLogMode { get; set; }
  186. [Option("vsync-mode", Required = false, Default = VSyncMode.Switch, HelpText = "Sets the emulated VSync mode (Switch, Unbounded, or Custom).")]
  187. public VSyncMode VSyncMode { get; set; }
  188. [Option("custom-refresh-rate", Required = false, Default = 90, HelpText = "Sets the custom refresh rate target value (integer).")]
  189. public int CustomVSyncInterval { get; set; }
  190. [Option("disable-shader-cache", Required = false, HelpText = "Disables Shader cache.")]
  191. public bool DisableShaderCache { get; set; }
  192. [Option("enable-texture-recompression", Required = false, Default = false, HelpText = "Enables Texture recompression.")]
  193. public bool EnableTextureRecompression { get; set; }
  194. [Option("disable-docked-mode", Required = false, HelpText = "Disables Docked Mode.")]
  195. public bool DisableDockedMode { get; set; }
  196. [Option("system-language", Required = false, Default = SystemLanguage.AmericanEnglish, HelpText = "Change System Language.")]
  197. public SystemLanguage SystemLanguage { get; set; }
  198. [Option("system-region", Required = false, Default = RegionCode.USA, HelpText = "Change System Region.")]
  199. public RegionCode SystemRegion { get; set; }
  200. [Option("system-timezone", Required = false, Default = "UTC", HelpText = "Change System TimeZone.")]
  201. public string SystemTimeZone { get; set; }
  202. [Option("system-time-offset", Required = false, Default = 0, HelpText = "Change System Time Offset in seconds.")]
  203. public long SystemTimeOffset { get; set; }
  204. [Option("memory-manager-mode", Required = false, Default = MemoryManagerMode.HostMappedUnsafe, HelpText = "The selected memory manager mode.")]
  205. public MemoryManagerMode MemoryManagerMode { get; set; }
  206. [Option("audio-volume", Required = false, Default = 1.0f, HelpText = "The audio level (0 to 1).")]
  207. public float AudioVolume { get; set; }
  208. [Option("use-hypervisor", Required = false, Default = true, HelpText = "Uses Hypervisor over JIT if available.")]
  209. public bool? UseHypervisor { get; set; }
  210. [Option("lan-interface-id", Required = false, Default = "0", HelpText = "GUID for the network interface used by LAN.")]
  211. public string MultiplayerLanInterfaceId { get; set; }
  212. // Logging
  213. [Option("disable-file-logging", Required = false, Default = false, HelpText = "Disables logging to a file on disk.")]
  214. public bool DisableFileLog { get; set; }
  215. [Option("enable-debug-logs", Required = false, Default = false, HelpText = "Enables printing debug log messages.")]
  216. public bool LoggingEnableDebug { get; set; }
  217. [Option("disable-stub-logs", Required = false, HelpText = "Disables printing stub log messages.")]
  218. public bool LoggingDisableStub { get; set; }
  219. [Option("disable-info-logs", Required = false, HelpText = "Disables printing info log messages.")]
  220. public bool LoggingDisableInfo { get; set; }
  221. [Option("disable-warning-logs", Required = false, HelpText = "Disables printing warning log messages.")]
  222. public bool LoggingDisableWarning { get; set; }
  223. [Option("disable-error-logs", Required = false, HelpText = "Disables printing error log messages.")]
  224. public bool LoggingDisableError { get; set; }
  225. [Option("enable-trace-logs", Required = false, Default = false, HelpText = "Enables printing trace log messages.")]
  226. public bool LoggingEnableTrace { get; set; }
  227. [Option("disable-guest-logs", Required = false, HelpText = "Disables printing guest log messages.")]
  228. public bool LoggingDisableGuest { get; set; }
  229. [Option("enable-fs-access-logs", Required = false, Default = false, HelpText = "Enables printing FS access log messages.")]
  230. public bool LoggingEnableFsAccessLog { get; set; }
  231. [Option("graphics-debug-level", Required = false, Default = GraphicsDebugLevel.None, HelpText = "Change Graphics API debug log level.")]
  232. public GraphicsDebugLevel LoggingGraphicsDebugLevel { get; set; }
  233. // Graphics
  234. [Option("resolution-scale", Required = false, Default = 1, HelpText = "Resolution Scale. A floating point scale applied to applicable render targets.")]
  235. public float ResScale { get; set; }
  236. [Option("max-anisotropy", Required = false, Default = -1, HelpText = "Max Anisotropy. Values range from 0 - 16. Set to -1 to let the game decide.")]
  237. public float MaxAnisotropy { get; set; }
  238. [Option("aspect-ratio", Required = false, Default = AspectRatio.Fixed16x9, HelpText = "Aspect Ratio applied to the renderer window.")]
  239. public AspectRatio AspectRatio { get; set; }
  240. [Option("backend-threading", Required = false, Default = BackendThreading.Auto, HelpText = "Whether or not backend threading is enabled. The \"Auto\" setting will determine whether threading should be enabled at runtime.")]
  241. public BackendThreading BackendThreading { get; set; }
  242. [Option("disable-macro-hle", Required = false, HelpText = "Disables high-level emulation of Macro code. Leaving this enabled improves performance but may cause graphical glitches in some games.")]
  243. public bool DisableMacroHLE { get; set; }
  244. [Option("graphics-shaders-dump-path", Required = false, HelpText = "Dumps shaders in this local directory. (Developer only)")]
  245. public string GraphicsShadersDumpPath { get; set; }
  246. [Option("graphics-backend", Required = false, Default = GraphicsBackend.OpenGl, HelpText = "Change Graphics Backend to use.")]
  247. public GraphicsBackend GraphicsBackend { get; set; }
  248. [Option("preferred-gpu-vendor", Required = false, Default = "", HelpText = "When using the Vulkan backend, prefer using the GPU from the specified vendor.")]
  249. public string PreferredGPUVendor { get; set; }
  250. [Option("anti-aliasing", Required = false, Default = AntiAliasing.None, HelpText = "Set the type of anti aliasing being used. [None|Fxaa|SmaaLow|SmaaMedium|SmaaHigh|SmaaUltra]")]
  251. public AntiAliasing AntiAliasing { get; set; }
  252. [Option("scaling-filter", Required = false, Default = ScalingFilter.Bilinear, HelpText = "Set the scaling filter. [Bilinear|Nearest|Fsr|Area]")]
  253. public ScalingFilter ScalingFilter { get; set; }
  254. [Option("scaling-filter-level", Required = false, Default = 0, HelpText = "Set the scaling filter intensity (currently only applies to FSR). [0-100]")]
  255. public int ScalingFilterLevel { get; set; }
  256. // Hacks
  257. [Option("dram-size", Required = false, Default = MemoryConfiguration.MemoryConfiguration4GiB, HelpText = "Set the RAM amount on the emulated system.")]
  258. public MemoryConfiguration DramSize { get; set; }
  259. [Option("ignore-missing-services", Required = false, Default = false, HelpText = "Enable ignoring missing services.")]
  260. public bool IgnoreMissingServices { get; set; }
  261. [Option("ignore-controller-applet", Required = false, Default = false, HelpText = "Enable ignoring the controller applet when your game loses connection to your controller.")]
  262. public bool IgnoreControllerApplet { get; set; }
  263. // Values
  264. [Value(0, MetaName = "input", HelpText = "Input to load.", Required = true)]
  265. public string InputPath { get; set; }
  266. }
  267. }