diff options
Diffstat (limited to 'Ryujinx.Common/Configuration')
| -rw-r--r-- | Ryujinx.Common/Configuration/ConfigurationFileFormat.cs | 211 | ||||
| -rw-r--r-- | Ryujinx.Common/Configuration/ConfigurationState.cs | 502 | ||||
| -rw-r--r-- | Ryujinx.Common/Configuration/Hid/ControllerInputId.cs | 45 | ||||
| -rw-r--r-- | Ryujinx.Common/Configuration/Hid/ControllerType.cs | 11 | ||||
| -rw-r--r-- | Ryujinx.Common/Configuration/Hid/Key.cs | 153 | ||||
| -rw-r--r-- | Ryujinx.Common/Configuration/Hid/KeyboardHotkeys.cs | 7 | ||||
| -rw-r--r-- | Ryujinx.Common/Configuration/Hid/NpadController.cs | 35 | ||||
| -rw-r--r-- | Ryujinx.Common/Configuration/Hid/NpadControllerLeft.cs | 15 | ||||
| -rw-r--r-- | Ryujinx.Common/Configuration/Hid/NpadControllerRight.cs | 15 | ||||
| -rw-r--r-- | Ryujinx.Common/Configuration/Hid/NpadKeyboard.cs | 20 | ||||
| -rw-r--r-- | Ryujinx.Common/Configuration/Hid/NpadKeyboardLeft.cs | 18 | ||||
| -rw-r--r-- | Ryujinx.Common/Configuration/Hid/NpadKeyboardRight.cs | 18 | ||||
| -rw-r--r-- | Ryujinx.Common/Configuration/LoggerModule.cs | 109 | ||||
| -rw-r--r-- | Ryujinx.Common/Configuration/System/Language.cs | 23 | ||||
| -rw-r--r-- | Ryujinx.Common/Configuration/Ui/GuiColumns.cs | 16 |
15 files changed, 1198 insertions, 0 deletions
diff --git a/Ryujinx.Common/Configuration/ConfigurationFileFormat.cs b/Ryujinx.Common/Configuration/ConfigurationFileFormat.cs new file mode 100644 index 00000000..1a9407cb --- /dev/null +++ b/Ryujinx.Common/Configuration/ConfigurationFileFormat.cs @@ -0,0 +1,211 @@ +using JsonPrettyPrinterPlus; +using Ryujinx.Common.Logging; +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using Utf8Json; +using Utf8Json.Resolvers; +using Ryujinx.Configuration.System; +using Ryujinx.Configuration.Hid; +using Ryujinx.Common.Configuration.Hid; +using Ryujinx.UI.Input; +using Ryujinx.Configuration.Ui; + +namespace Ryujinx.Configuration +{ + public class ConfigurationFileFormat + { + public int Version { get; set; } + + /// <summary> + /// Dumps shaders in this local directory + /// </summary> + public string GraphicsShadersDumpPath { get; set; } + + /// <summary> + /// Enables printing debug log messages + /// </summary> + public bool LoggingEnableDebug { get; set; } + + /// <summary> + /// Enables printing stub log messages + /// </summary> + public bool LoggingEnableStub { get; set; } + + /// <summary> + /// Enables printing info log messages + /// </summary> + public bool LoggingEnableInfo { get; set; } + + /// <summary> + /// Enables printing warning log messages + /// </summary> + public bool LoggingEnableWarn { get; set; } + + /// <summary> + /// Enables printing error log messages + /// </summary> + public bool LoggingEnableError { get; set; } + + /// <summary> + /// Enables printing guest log messages + /// </summary> + public bool LoggingEnableGuest { get; set; } + + /// <summary> + /// Enables printing FS access log messages + /// </summary> + public bool LoggingEnableFsAccessLog { get; set; } + + /// <summary> + /// Controls which log messages are written to the log targets + /// </summary> + public LogClass[] LoggingFilteredClasses { get; set; } + + /// <summary> + /// Enables or disables logging to a file on disk + /// </summary> + public bool EnableFileLog { get; set; } + + /// <summary> + /// Change System Language + /// </summary> + public Language SystemLanguage { get; set; } + + /// <summary> + /// Enables or disables Docked Mode + /// </summary> + public bool DockedMode { get; set; } + + /// <summary> + /// Enables or disables Discord Rich Presence + /// </summary> + public bool EnableDiscordIntegration { get; set; } + + /// <summary> + /// Enables or disables Vertical Sync + /// </summary> + public bool EnableVsync { get; set; } + + /// <summary> + /// Enables or disables multi-core scheduling of threads + /// </summary> + public bool EnableMulticoreScheduling { get; set; } + + /// <summary> + /// Enables integrity checks on Game content files + /// </summary> + public bool EnableFsIntegrityChecks { get; set; } + + /// <summary> + /// Enables FS access log output to the console. Possible modes are 0-3 + /// </summary> + public int FsGlobalAccessLogMode { get; set; } + + /// <summary> + /// Enable or disable ignoring missing services + /// </summary> + public bool IgnoreMissingServices { get; set; } + + /// <summary> + /// The primary controller's type + /// </summary> + public ControllerType ControllerType { get; set; } + + /// <summary> + /// Used to toggle columns in the GUI + /// </summary> + public GuiColumns GuiColumns { get; set; } + + /// <summary> + /// A list of directories containing games to be used to load games into the games list + /// </summary> + public List<string> GameDirs { get; set; } + + /// <summary> + /// Enable or disable custom themes in the GUI + /// </summary> + public bool EnableCustomTheme { get; set; } + + /// <summary> + /// Path to custom GUI theme + /// </summary> + public string CustomThemePath { get; set; } + + /// <summary> + /// Enable or disable keyboard support (Independent from controllers binding) + /// </summary> + public bool EnableKeyboard { get; set; } + + /// <summary> + /// Keyboard control bindings + /// </summary> + public NpadKeyboard KeyboardControls { get; set; } + + /// <summary> + /// Controller control bindings + /// </summary> + public NpadController JoystickControls { get; set; } + + /// <summary> + /// Loads a configuration file from disk + /// </summary> + /// <param name="path">The path to the JSON configuration file</param> + public static ConfigurationFileFormat Load(string path) + { + var resolver = CompositeResolver.Create( + new[] { new ConfigurationEnumFormatter<Key>() }, + new[] { StandardResolver.AllowPrivateSnakeCase } + ); + + using (Stream stream = File.OpenRead(path)) + { + return JsonSerializer.Deserialize<ConfigurationFileFormat>(stream, resolver); + } + } + + /// <summary> + /// Save a configuration file to disk + /// </summary> + /// <param name="path">The path to the JSON configuration file</param> + public void SaveConfig(string path) + { + IJsonFormatterResolver resolver = CompositeResolver.Create( + new[] { new ConfigurationEnumFormatter<Key>() }, + new[] { StandardResolver.AllowPrivateSnakeCase } + ); + + byte[] data = JsonSerializer.Serialize(this, resolver); + File.WriteAllText(path, Encoding.UTF8.GetString(data, 0, data.Length).PrettyPrintJson()); + } + + private class ConfigurationEnumFormatter<T> : IJsonFormatter<T> + where T : struct + { + public void Serialize(ref JsonWriter writer, T value, IJsonFormatterResolver formatterResolver) + { + formatterResolver.GetFormatterWithVerify<string>() + .Serialize(ref writer, value.ToString(), formatterResolver); + } + + public T Deserialize(ref JsonReader reader, IJsonFormatterResolver formatterResolver) + { + if (reader.ReadIsNull()) + { + return default(T); + } + + string enumName = formatterResolver.GetFormatterWithVerify<string>() + .Deserialize(ref reader, formatterResolver); + + if (Enum.TryParse<T>(enumName, out T result)) + { + return result; + } + + return default(T); + } + } + } +}
\ No newline at end of file diff --git a/Ryujinx.Common/Configuration/ConfigurationState.cs b/Ryujinx.Common/Configuration/ConfigurationState.cs new file mode 100644 index 00000000..050b4973 --- /dev/null +++ b/Ryujinx.Common/Configuration/ConfigurationState.cs @@ -0,0 +1,502 @@ +using Ryujinx.Common; +using Ryujinx.Common.Configuration.Hid; +using Ryujinx.Common.Logging; +using Ryujinx.Configuration.Hid; +using Ryujinx.Configuration.System; +using Ryujinx.Configuration.Ui; +using Ryujinx.UI.Input; +using System; +using System.Collections.Generic; + +namespace Ryujinx.Configuration +{ + public class ConfigurationState + { + /// <summary> + /// UI configuration section + /// </summary> + public class UiSection + { + public class Columns + { + public ReactiveObject<bool> FavColumn { get; private set; } + public ReactiveObject<bool> IconColumn { get; private set; } + public ReactiveObject<bool> AppColumn { get; private set; } + public ReactiveObject<bool> DevColumn { get; private set; } + public ReactiveObject<bool> VersionColumn { get; private set; } + public ReactiveObject<bool> TimePlayedColumn { get; private set; } + public ReactiveObject<bool> LastPlayedColumn { get; private set; } + public ReactiveObject<bool> FileExtColumn { get; private set; } + public ReactiveObject<bool> FileSizeColumn { get; private set; } + public ReactiveObject<bool> PathColumn { get; private set; } + + public Columns() + { + FavColumn = new ReactiveObject<bool>(); + IconColumn = new ReactiveObject<bool>(); + AppColumn = new ReactiveObject<bool>(); + DevColumn = new ReactiveObject<bool>(); + VersionColumn = new ReactiveObject<bool>(); + TimePlayedColumn = new ReactiveObject<bool>(); + LastPlayedColumn = new ReactiveObject<bool>(); + FileExtColumn = new ReactiveObject<bool>(); + FileSizeColumn = new ReactiveObject<bool>(); + PathColumn = new ReactiveObject<bool>(); + } + } + + /// <summary> + /// Used to toggle columns in the GUI + /// </summary> + public Columns GuiColumns { get; private set; } + + /// <summary> + /// A list of directories containing games to be used to load games into the games list + /// </summary> + public ReactiveObject<List<string>> GameDirs { get; private set; } + + /// <summary> + /// Enable or disable custom themes in the GUI + /// </summary> + public ReactiveObject<bool> EnableCustomTheme { get; private set; } + + /// <summary> + /// Path to custom GUI theme + /// </summary> + public ReactiveObject<string> CustomThemePath { get; private set; } + + public UiSection() + { + GuiColumns = new Columns(); + GameDirs = new ReactiveObject<List<string>>(); + EnableCustomTheme = new ReactiveObject<bool>(); + CustomThemePath = new ReactiveObject<string>(); + } + } + + /// <summary> + /// Logger configuration section + /// </summary> + public class LoggerSection + { + /// <summary> + /// Enables printing debug log messages + /// </summary> + public ReactiveObject<bool> EnableDebug { get; private set; } + + /// <summary> + /// Enables printing stub log messages + /// </summary> + public ReactiveObject<bool> EnableStub { get; private set; } + + /// <summary> + /// Enables printing info log messages + /// </summary> + public ReactiveObject<bool> EnableInfo { get; private set; } + + /// <summary> + /// Enables printing warning log messages + /// </summary> + public ReactiveObject<bool> EnableWarn { get; private set; } + + /// <summary> + /// Enables printing error log messages + /// </summary> + public ReactiveObject<bool> EnableError { get; private set; } + + /// <summary> + /// Enables printing guest log messages + /// </summary> + public ReactiveObject<bool> EnableGuest { get; private set; } + + /// <summary> + /// Enables printing FS access log messages + /// </summary> + public ReactiveObject<bool> EnableFsAccessLog { get; private set; } + + /// <summary> + /// Controls which log messages are written to the log targets + /// </summary> + public ReactiveObject<LogClass[]> FilteredClasses { get; private set; } + + /// <summary> + /// Enables or disables logging to a file on disk + /// </summary> + public ReactiveObject<bool> EnableFileLog { get; private set; } + + public LoggerSection() + { + EnableDebug = new ReactiveObject<bool>(); + EnableStub = new ReactiveObject<bool>(); + EnableInfo = new ReactiveObject<bool>(); + EnableWarn = new ReactiveObject<bool>(); + EnableError = new ReactiveObject<bool>(); + EnableGuest = new ReactiveObject<bool>(); + EnableFsAccessLog = new ReactiveObject<bool>(); + FilteredClasses = new ReactiveObject<LogClass[]>(); + EnableFileLog = new ReactiveObject<bool>(); + } + } + + /// <summary> + /// System configuration section + /// </summary> + public class SystemSection + { + /// <summary> + /// Change System Language + /// </summary> + public ReactiveObject<Language> Language { get; private set; } + + /// <summary> + /// Enables or disables Docked Mode + /// </summary> + public ReactiveObject<bool> EnableDockedMode { get; private set; } + + /// <summary> + /// Enables or disables multi-core scheduling of threads + /// </summary> + public ReactiveObject<bool> EnableMulticoreScheduling { get; private set; } + + /// <summary> + /// Enables integrity checks on Game content files + /// </summary> + public ReactiveObject<bool> EnableFsIntegrityChecks { get; private set; } + + /// <summary> + /// Enables FS access log output to the console. Possible modes are 0-3 + /// </summary> + public ReactiveObject<int> FsGlobalAccessLogMode { get; private set; } + + /// <summary> + /// Enable or disable ignoring missing services + /// </summary> + public ReactiveObject<bool> IgnoreMissingServices { get; private set; } + + public SystemSection() + { + Language = new ReactiveObject<Language>(); + EnableDockedMode = new ReactiveObject<bool>(); + EnableMulticoreScheduling = new ReactiveObject<bool>(); + EnableFsIntegrityChecks = new ReactiveObject<bool>(); + FsGlobalAccessLogMode = new ReactiveObject<int>(); + IgnoreMissingServices = new ReactiveObject<bool>(); + } + } + + /// <summary> + /// Hid configuration section + /// </summary> + public class HidSection + { + /// <summary> + /// The primary controller's type + /// </summary> + public ReactiveObject<ControllerType> ControllerType { get; private set; } + + /// <summary> + /// Enable or disable keyboard support (Independent from controllers binding) + /// </summary> + public ReactiveObject<bool> EnableKeyboard { get; private set; } + + /// <summary> + /// Keyboard control bindings + /// </summary> + public ReactiveObject<NpadKeyboard> KeyboardControls { get; private set; } + + /// <summary> + /// Controller control bindings + /// </summary> + public ReactiveObject<NpadController> JoystickControls { get; private set; } + + public HidSection() + { + ControllerType = new ReactiveObject<ControllerType>(); + EnableKeyboard = new ReactiveObject<bool>(); + KeyboardControls = new ReactiveObject<NpadKeyboard>(); + JoystickControls = new ReactiveObject<NpadController>(); + } + } + + /// <summary> + /// Graphics configuration section + /// </summary> + public class GraphicsSection + { + /// <summary> + /// Dumps shaders in this local directory + /// </summary> + public ReactiveObject<string> ShadersDumpPath { get; private set; } + + /// <summary> + /// Enables or disables Vertical Sync + /// </summary> + public ReactiveObject<bool> EnableVsync { get; private set; } + + public GraphicsSection() + { + ShadersDumpPath = new ReactiveObject<string>(); + EnableVsync = new ReactiveObject<bool>(); + } + } + + /// <summary> + /// The default configuration instance + /// </summary> + public static ConfigurationState Instance { get; private set; } + + /// <summary> + /// The Ui section + /// </summary> + public UiSection Ui { get; private set; } + + /// <summary> + /// The Logger section + /// </summary> + public LoggerSection Logger { get; private set; } + + /// <summary> + /// The System section + /// </summary> + public SystemSection System { get; private set; } + + /// <summary> + /// The Graphics section + /// </summary> + public GraphicsSection Graphics { get; private set; } + + /// <summary> + /// The Hid section + /// </summary> + public HidSection Hid { get; private set; } + + /// <summary> + /// Enables or disables Discord Rich Presence + /// </summary> + public ReactiveObject<bool> EnableDiscordIntegration { get; private set; } + + private ConfigurationState() + { + Ui = new UiSection(); + Logger = new LoggerSection(); + System = new SystemSection(); + Graphics = new GraphicsSection(); + Hid = new HidSection(); + EnableDiscordIntegration = new ReactiveObject<bool>(); + } + + public ConfigurationFileFormat ToFileFormat() + { + ConfigurationFileFormat configurationFile = new ConfigurationFileFormat + { + Version = 1, + GraphicsShadersDumpPath = Graphics.ShadersDumpPath, + LoggingEnableDebug = Logger.EnableDebug, + LoggingEnableStub = Logger.EnableStub, + LoggingEnableInfo = Logger.EnableInfo, + LoggingEnableWarn = Logger.EnableWarn, + LoggingEnableError = Logger.EnableError, + LoggingEnableGuest = Logger.EnableGuest, + LoggingEnableFsAccessLog = Logger.EnableFsAccessLog, + LoggingFilteredClasses = Logger.FilteredClasses, + EnableFileLog = Logger.EnableFileLog, + SystemLanguage = System.Language, + DockedMode = System.EnableDockedMode, + EnableDiscordIntegration = EnableDiscordIntegration, + EnableVsync = Graphics.EnableVsync, + EnableMulticoreScheduling = System.EnableMulticoreScheduling, + EnableFsIntegrityChecks = System.EnableFsIntegrityChecks, + FsGlobalAccessLogMode = System.FsGlobalAccessLogMode, + IgnoreMissingServices = System.IgnoreMissingServices, + ControllerType = Hid.ControllerType, + GuiColumns = new GuiColumns() + { + FavColumn = Ui.GuiColumns.FavColumn, + IconColumn = Ui.GuiColumns.IconColumn, + AppColumn = Ui.GuiColumns.AppColumn, + DevColumn = Ui.GuiColumns.DevColumn, + VersionColumn = Ui.GuiColumns.VersionColumn, + TimePlayedColumn = Ui.GuiColumns.TimePlayedColumn, + LastPlayedColumn = Ui.GuiColumns.LastPlayedColumn, + FileExtColumn = Ui.GuiColumns.FileExtColumn, + FileSizeColumn = Ui.GuiColumns.FileSizeColumn, + PathColumn = Ui.GuiColumns.PathColumn, + }, + GameDirs = Ui.GameDirs, + EnableCustomTheme = Ui.EnableCustomTheme, + CustomThemePath = Ui.CustomThemePath, + EnableKeyboard = Hid.EnableKeyboard, + KeyboardControls = Hid.KeyboardControls, + JoystickControls = Hid.JoystickControls + }; + + return configurationFile; + } + + public void LoadDefault() + { + Graphics.ShadersDumpPath.Value = ""; + Logger.EnableDebug.Value = false; + Logger.EnableStub.Value = true; + Logger.EnableInfo.Value = true; + Logger.EnableWarn.Value = true; + Logger.EnableError.Value = true; + Logger.EnableGuest.Value = true; + Logger.EnableFsAccessLog.Value = false; + Logger.FilteredClasses.Value = new LogClass[] { }; + Logger.EnableFileLog.Value = true; + System.Language.Value = Language.AmericanEnglish; + System.EnableDockedMode.Value = false; + EnableDiscordIntegration.Value = true; + Graphics.EnableVsync.Value = true; + System.EnableMulticoreScheduling.Value = true; + System.EnableFsIntegrityChecks.Value = true; + System.FsGlobalAccessLogMode.Value = 0; + System.IgnoreMissingServices.Value = false; + Hid.ControllerType.Value = ControllerType.Handheld; + Ui.GuiColumns.FavColumn.Value = true; + Ui.GuiColumns.IconColumn.Value = true; + Ui.GuiColumns.AppColumn.Value = true; + Ui.GuiColumns.DevColumn.Value = true; + Ui.GuiColumns.VersionColumn.Value = true; + Ui.GuiColumns.TimePlayedColumn.Value = true; + Ui.GuiColumns.LastPlayedColumn.Value = true; + Ui.GuiColumns.FileExtColumn.Value = true; + Ui.GuiColumns.FileSizeColumn.Value = true; + Ui.GuiColumns.PathColumn.Value = true; + Ui.GameDirs.Value = new List<string>(); + Ui.EnableCustomTheme.Value = false; + Ui.CustomThemePath.Value = ""; + Hid.EnableKeyboard.Value = false; + + Hid.KeyboardControls.Value = new NpadKeyboard + { + LeftJoycon = new NpadKeyboardLeft + { + StickUp = Key.W, + StickDown = Key.S, + StickLeft = Key.A, + StickRight = Key.D, + StickButton = Key.F, + DPadUp = Key.Up, + DPadDown = Key.Down, + DPadLeft = Key.Left, + DPadRight = Key.Right, + ButtonMinus = Key.Minus, + ButtonL = Key.E, + ButtonZl = Key.Q, + }, + RightJoycon = new NpadKeyboardRight + { + StickUp = Key.I, + StickDown = Key.K, + StickLeft = Key.J, + StickRight = Key.L, + StickButton = Key.H, + ButtonA = Key.Z, + ButtonB = Key.X, + ButtonX = Key.C, + ButtonY = Key.V, + ButtonPlus = Key.Plus, + ButtonR = Key.U, + ButtonZr = Key.O, + }, + Hotkeys = new KeyboardHotkeys + { + ToggleVsync = Key.Tab + } + }; + + Hid.JoystickControls.Value = new NpadController + { + Enabled = true, + Index = 0, + Deadzone = 0.05f, + TriggerThreshold = 0.5f, + LeftJoycon = new NpadControllerLeft + { + Stick = ControllerInputId.Axis0, + StickButton = ControllerInputId.Button8, + DPadUp = ControllerInputId.Hat0Up, + DPadDown = ControllerInputId.Hat0Down, + DPadLeft = ControllerInputId.Hat0Left, + DPadRight = ControllerInputId.Hat0Right, + ButtonMinus = ControllerInputId.Button6, + ButtonL = ControllerInputId.Button4, + ButtonZl = ControllerInputId.Axis2, + }, + RightJoycon = new NpadControllerRight + { + Stick = ControllerInputId.Axis3, + StickButton = ControllerInputId.Button9, + ButtonA = ControllerInputId.Button1, + ButtonB = ControllerInputId.Button0, + ButtonX = ControllerInputId.Button3, + ButtonY = ControllerInputId.Button2, + ButtonPlus = ControllerInputId.Button7, + ButtonR = ControllerInputId.Button5, + ButtonZr = ControllerInputId.Axis5, + } + }; + } + + public void Load(ConfigurationFileFormat configurationFileFormat) + { + if (configurationFileFormat.Version != 1 && configurationFileFormat.Version != 0) + { + Common.Logging.Logger.PrintWarning(LogClass.Application, $"Unsupported configuration version {configurationFileFormat.Version}, loading default."); + + LoadDefault(); + + return; + } + + Graphics.ShadersDumpPath.Value = configurationFileFormat.GraphicsShadersDumpPath; + Logger.EnableDebug.Value = configurationFileFormat.LoggingEnableDebug; + Logger.EnableStub.Value = configurationFileFormat.LoggingEnableStub; + Logger.EnableInfo.Value = configurationFileFormat.LoggingEnableInfo; + Logger.EnableWarn.Value = configurationFileFormat.LoggingEnableWarn; + Logger.EnableError.Value = configurationFileFormat.LoggingEnableError; + Logger.EnableGuest.Value = configurationFileFormat.LoggingEnableGuest; + Logger.EnableFsAccessLog.Value = configurationFileFormat.LoggingEnableFsAccessLog; + Logger.FilteredClasses.Value = configurationFileFormat.LoggingFilteredClasses; + Logger.EnableFileLog.Value = configurationFileFormat.EnableFileLog; + System.Language.Value = configurationFileFormat.SystemLanguage; + System.EnableDockedMode.Value = configurationFileFormat.DockedMode; + System.EnableDockedMode.Value = configurationFileFormat.DockedMode; + EnableDiscordIntegration.Value = configurationFileFormat.EnableDiscordIntegration; + Graphics.EnableVsync.Value = configurationFileFormat.EnableVsync; + System.EnableMulticoreScheduling.Value = configurationFileFormat.EnableMulticoreScheduling; + System.EnableFsIntegrityChecks.Value = configurationFileFormat.EnableFsIntegrityChecks; + System.FsGlobalAccessLogMode.Value = configurationFileFormat.FsGlobalAccessLogMode; + System.IgnoreMissingServices.Value = configurationFileFormat.IgnoreMissingServices; + Hid.ControllerType.Value = configurationFileFormat.ControllerType; + Ui.GuiColumns.FavColumn.Value = configurationFileFormat.GuiColumns.FavColumn; + Ui.GuiColumns.IconColumn.Value = configurationFileFormat.GuiColumns.IconColumn; + Ui.GuiColumns.AppColumn.Value = configurationFileFormat.GuiColumns.AppColumn; + Ui.GuiColumns.DevColumn.Value = configurationFileFormat.GuiColumns.DevColumn; + Ui.GuiColumns.VersionColumn.Value = configurationFileFormat.GuiColumns.VersionColumn; + Ui.GuiColumns.TimePlayedColumn.Value = configurationFileFormat.GuiColumns.TimePlayedColumn; + Ui.GuiColumns.LastPlayedColumn.Value = configurationFileFormat.GuiColumns.LastPlayedColumn; + Ui.GuiColumns.FileExtColumn.Value = configurationFileFormat.GuiColumns.FileExtColumn; + Ui.GuiColumns.FileSizeColumn.Value = configurationFileFormat.GuiColumns.FileSizeColumn; + Ui.GuiColumns.PathColumn.Value = configurationFileFormat.GuiColumns.PathColumn; + Ui.GameDirs.Value = configurationFileFormat.GameDirs; + Ui.EnableCustomTheme.Value = configurationFileFormat.EnableCustomTheme; + Ui.CustomThemePath.Value = configurationFileFormat.CustomThemePath; + Hid.EnableKeyboard.Value = configurationFileFormat.EnableKeyboard; + Hid.KeyboardControls.Value = configurationFileFormat.KeyboardControls; + Hid.JoystickControls.Value = configurationFileFormat.JoystickControls; + } + + public static void Initialize() + { + if (Instance != null) + { + throw new InvalidOperationException("Configuration is already initialized"); + } + + Instance = new ConfigurationState(); + } + } +} diff --git a/Ryujinx.Common/Configuration/Hid/ControllerInputId.cs b/Ryujinx.Common/Configuration/Hid/ControllerInputId.cs new file mode 100644 index 00000000..8969b6a4 --- /dev/null +++ b/Ryujinx.Common/Configuration/Hid/ControllerInputId.cs @@ -0,0 +1,45 @@ +namespace Ryujinx.Common.Configuration.Hid +{ + public enum ControllerInputId + { + Button0, + Button1, + Button2, + Button3, + Button4, + Button5, + Button6, + Button7, + Button8, + Button9, + Button10, + Button11, + Button12, + Button13, + Button14, + Button15, + Button16, + Button17, + Button18, + Button19, + Button20, + Axis0, + Axis1, + Axis2, + Axis3, + Axis4, + Axis5, + Hat0Up, + Hat0Down, + Hat0Left, + Hat0Right, + Hat1Up, + Hat1Down, + Hat1Left, + Hat1Right, + Hat2Up, + Hat2Down, + Hat2Left, + Hat2Right + } +} diff --git a/Ryujinx.Common/Configuration/Hid/ControllerType.cs b/Ryujinx.Common/Configuration/Hid/ControllerType.cs new file mode 100644 index 00000000..b0613b2d --- /dev/null +++ b/Ryujinx.Common/Configuration/Hid/ControllerType.cs @@ -0,0 +1,11 @@ +namespace Ryujinx.Configuration.Hid +{ + public enum ControllerType + { + ProController, + Handheld, + NpadPair, + NpadLeft, + NpadRight + } +} diff --git a/Ryujinx.Common/Configuration/Hid/Key.cs b/Ryujinx.Common/Configuration/Hid/Key.cs new file mode 100644 index 00000000..b658396b --- /dev/null +++ b/Ryujinx.Common/Configuration/Hid/Key.cs @@ -0,0 +1,153 @@ +namespace Ryujinx.Configuration.Hid +{ + public enum Key + { + Unknown = 0, + ShiftLeft = 1, + LShift = 1, + ShiftRight = 2, + RShift = 2, + ControlLeft = 3, + LControl = 3, + ControlRight = 4, + RControl = 4, + AltLeft = 5, + LAlt = 5, + AltRight = 6, + RAlt = 6, + WinLeft = 7, + LWin = 7, + WinRight = 8, + RWin = 8, + Menu = 9, + F1 = 10, + F2 = 11, + F3 = 12, + F4 = 13, + F5 = 14, + F6 = 15, + F7 = 16, + F8 = 17, + F9 = 18, + F10 = 19, + F11 = 20, + F12 = 21, + F13 = 22, + F14 = 23, + F15 = 24, + F16 = 25, + F17 = 26, + F18 = 27, + F19 = 28, + F20 = 29, + F21 = 30, + F22 = 31, + F23 = 32, + F24 = 33, + F25 = 34, + F26 = 35, + F27 = 36, + F28 = 37, + F29 = 38, + F30 = 39, + F31 = 40, + F32 = 41, + F33 = 42, + F34 = 43, + F35 = 44, + Up = 45, + Down = 46, + Left = 47, + Right = 48, + Enter = 49, + Escape = 50, + Space = 51, + Tab = 52, + BackSpace = 53, + Back = 53, + Insert = 54, + Delete = 55, + PageUp = 56, + PageDown = 57, + Home = 58, + End = 59, + CapsLock = 60, + ScrollLock = 61, + PrintScreen = 62, + Pause = 63, + NumLock = 64, + Clear = 65, + Sleep = 66, + Keypad0 = 67, + Keypad1 = 68, + Keypad2 = 69, + Keypad3 = 70, + Keypad4 = 71, + Keypad5 = 72, + Keypad6 = 73, + Keypad7 = 74, + Keypad8 = 75, + Keypad9 = 76, + KeypadDivide = 77, + KeypadMultiply = 78, + KeypadSubtract = 79, + KeypadMinus = 79, + KeypadAdd = 80, + KeypadPlus = 80, + KeypadDecimal = 81, + KeypadPeriod = 81, + KeypadEnter = 82, + A = 83, + B = 84, + C = 85, + D = 86, + E = 87, + F = 88, + G = 89, + H = 90, + I = 91, + J = 92, + K = 93, + L = 94, + M = 95, + N = 96, + O = 97, + P = 98, + Q = 99, + R = 100, + S = 101, + T = 102, + U = 103, + V = 104, + W = 105, + X = 106, + Y = 107, + Z = 108, + Number0 = 109, + Number1 = 110, + Number2 = 111, + Number3 = 112, + Number4 = 113, + Number5 = 114, + Number6 = 115, + Number7 = 116, + Number8 = 117, + Number9 = 118, + Tilde = 119, + Grave = 119, + Minus = 120, + Plus = 121, + BracketLeft = 122, + LBracket = 122, + BracketRight = 123, + RBracket = 123, + Semicolon = 124, + Quote = 125, + Comma = 126, + Period = 127, + Slash = 128, + BackSlash = 129, + NonUSBackSlash = 130, + LastKey = 131 + } +} diff --git a/Ryujinx.Common/Configuration/Hid/KeyboardHotkeys.cs b/Ryujinx.Common/Configuration/Hid/KeyboardHotkeys.cs new file mode 100644 index 00000000..1d0b0504 --- /dev/null +++ b/Ryujinx.Common/Configuration/Hid/KeyboardHotkeys.cs @@ -0,0 +1,7 @@ +namespace Ryujinx.Configuration.Hid +{ + public struct KeyboardHotkeys + { + public Key ToggleVsync; + } +} diff --git a/Ryujinx.Common/Configuration/Hid/NpadController.cs b/Ryujinx.Common/Configuration/Hid/NpadController.cs new file mode 100644 index 00000000..f00865d5 --- /dev/null +++ b/Ryujinx.Common/Configuration/Hid/NpadController.cs @@ -0,0 +1,35 @@ +namespace Ryujinx.Common.Configuration.Hid +{ + public class NpadController + { + /// <summary> + /// Enables or disables controller support + /// </summary> + public bool Enabled; + + /// <summary> + /// Controller Device Index + /// </summary> + public int Index; + + /// <summary> + /// Controller Analog Stick Deadzone + /// </summary> + public float Deadzone; + + /// <summary> + /// Controller Trigger Threshold + /// </summary> + public float TriggerThreshold; + + /// <summary> + /// Left JoyCon Controller Bindings + /// </summary> + public NpadControllerLeft LeftJoycon; + + /// <summary> + /// Right JoyCon Controller Bindings + /// </summary> + public NpadControllerRight RightJoycon; + } +} diff --git a/Ryujinx.Common/Configuration/Hid/NpadControllerLeft.cs b/Ryujinx.Common/Configuration/Hid/NpadControllerLeft.cs new file mode 100644 index 00000000..54ac0f03 --- /dev/null +++ b/Ryujinx.Common/Configuration/Hid/NpadControllerLeft.cs @@ -0,0 +1,15 @@ +namespace Ryujinx.Common.Configuration.Hid +{ + public struct NpadControllerLeft + { + public ControllerInputId Stick; + public ControllerInputId StickButton; + public ControllerInputId ButtonMinus; + public ControllerInputId ButtonL; + public ControllerInputId ButtonZl; + public ControllerInputId DPadUp; + public ControllerInputId DPadDown; + public ControllerInputId DPadLeft; + public ControllerInputId DPadRight; + } +} diff --git a/Ryujinx.Common/Configuration/Hid/NpadControllerRight.cs b/Ryujinx.Common/Configuration/Hid/NpadControllerRight.cs new file mode 100644 index 00000000..315136d9 --- /dev/null +++ b/Ryujinx.Common/Configuration/Hid/NpadControllerRight.cs @@ -0,0 +1,15 @@ +namespace Ryujinx.Common.Configuration.Hid +{ + public struct NpadControllerRight + { + public ControllerInputId Stick; + public ControllerInputId StickButton; + public ControllerInputId ButtonA; + public ControllerInputId ButtonB; + public ControllerInputId ButtonX; + public ControllerInputId ButtonY; + public ControllerInputId ButtonPlus; + public ControllerInputId ButtonR; + public ControllerInputId ButtonZr; + } +} diff --git a/Ryujinx.Common/Configuration/Hid/NpadKeyboard.cs b/Ryujinx.Common/Configuration/Hid/NpadKeyboard.cs new file mode 100644 index 00000000..911f5119 --- /dev/null +++ b/Ryujinx.Common/Configuration/Hid/NpadKeyboard.cs @@ -0,0 +1,20 @@ +namespace Ryujinx.UI.Input +{ + public class NpadKeyboard + { + /// <summary> + /// Left JoyCon Keyboard Bindings + /// </summary> + public Configuration.Hid.NpadKeyboardLeft LeftJoycon; + + /// <summary> + /// Right JoyCon Keyboard Bindings + /// </summary> + public Configuration.Hid.NpadKeyboardRight RightJoycon; + + /// <summary> + /// Hotkey Keyboard Bindings + /// </summary> + public Configuration.Hid.KeyboardHotkeys Hotkeys; + } +} diff --git a/Ryujinx.Common/Configuration/Hid/NpadKeyboardLeft.cs b/Ryujinx.Common/Configuration/Hid/NpadKeyboardLeft.cs new file mode 100644 index 00000000..799cdfdb --- /dev/null +++ b/Ryujinx.Common/Configuration/Hid/NpadKeyboardLeft.cs @@ -0,0 +1,18 @@ +namespace Ryujinx.Configuration.Hid +{ + public struct NpadKeyboardLeft + { + public Key StickUp; + public Key StickDown; + public Key StickLeft; + public Key StickRight; + public Key StickButton; + public Key DPadUp; + public Key DPadDown; + public Key DPadLeft; + public Key DPadRight; + public Key ButtonMinus; + public Key ButtonL; + public Key ButtonZl; + } +} diff --git a/Ryujinx.Common/Configuration/Hid/NpadKeyboardRight.cs b/Ryujinx.Common/Configuration/Hid/NpadKeyboardRight.cs new file mode 100644 index 00000000..311504bb --- /dev/null +++ b/Ryujinx.Common/Configuration/Hid/NpadKeyboardRight.cs @@ -0,0 +1,18 @@ +namespace Ryujinx.Configuration.Hid +{ + public struct NpadKeyboardRight + { + public Key StickUp; + public Key StickDown; + public Key StickLeft; + public Key StickRight; + public Key StickButton; + public Key ButtonA; + public Key ButtonB; + public Key ButtonX; + public Key ButtonY; + public Key ButtonPlus; + public Key ButtonR; + public Key ButtonZr; + } +} diff --git a/Ryujinx.Common/Configuration/LoggerModule.cs b/Ryujinx.Common/Configuration/LoggerModule.cs new file mode 100644 index 00000000..504a8141 --- /dev/null +++ b/Ryujinx.Common/Configuration/LoggerModule.cs @@ -0,0 +1,109 @@ +using Ryujinx.Common; +using Ryujinx.Common.Logging; +using System; +using System.IO; + +namespace Ryujinx.Configuration +{ + public static class LoggerModule + { + public static void Initialize() + { + AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; + AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit; + + ConfigurationState.Instance.Logger.EnableDebug.Event += ReloadEnableDebug; + ConfigurationState.Instance.Logger.EnableStub.Event += ReloadEnableStub; + ConfigurationState.Instance.Logger.EnableInfo.Event += ReloadEnableInfo; + ConfigurationState.Instance.Logger.EnableWarn.Event += ReloadEnableWarning; + ConfigurationState.Instance.Logger.EnableError.Event += ReloadEnableError; + ConfigurationState.Instance.Logger.EnableGuest.Event += ReloadEnableGuest; + ConfigurationState.Instance.Logger.EnableFsAccessLog.Event += ReloadEnableFsAccessLog; + ConfigurationState.Instance.Logger.FilteredClasses.Event += ReloadFilteredClasses; + ConfigurationState.Instance.Logger.EnableFileLog.Event += ReloadFileLogger; + } + + private static void ReloadEnableDebug(object sender, ReactiveEventArgs<bool> e) + { + Logger.SetEnable(LogLevel.Debug, e.NewValue); + } + + private static void ReloadEnableStub(object sender, ReactiveEventArgs<bool> e) + { + Logger.SetEnable(LogLevel.Stub, e.NewValue); + } + + private static void ReloadEnableInfo(object sender, ReactiveEventArgs<bool> e) + { + Logger.SetEnable(LogLevel.Info, e.NewValue); + } + + private static void ReloadEnableWarning(object sender, ReactiveEventArgs<bool> e) + { + Logger.SetEnable(LogLevel.Warning, e.NewValue); + } + + private static void ReloadEnableError(object sender, ReactiveEventArgs<bool> e) + { + Logger.SetEnable(LogLevel.Error, e.NewValue); + } + + private static void ReloadEnableGuest(object sender, ReactiveEventArgs<bool> e) + { + Logger.SetEnable(LogLevel.Guest, e.NewValue); + } + + private static void ReloadEnableFsAccessLog(object sender, ReactiveEventArgs<bool> e) + { + Logger.SetEnable(LogLevel.AccessLog, e.NewValue); + } + + private static void ReloadFilteredClasses(object sender, ReactiveEventArgs<LogClass[]> e) + { + bool noFilter = e.NewValue.Length == 0; + + foreach (var logClass in EnumExtensions.GetValues<LogClass>()) + { + Logger.SetEnable(logClass, noFilter); + } + + foreach (var logClass in e.NewValue) + { + Logger.SetEnable(logClass, true); + } + } + + private static void ReloadFileLogger(object sender, ReactiveEventArgs<bool> e) + { + if (e.NewValue) + { + Logger.AddTarget(new AsyncLogTargetWrapper( + new FileLogTarget(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Ryujinx.log"), "file"), + 1000, + AsyncLogTargetOverflowAction.Block + )); + } + else + { + Logger.RemoveTarget("file"); + } + } + + private static void CurrentDomain_ProcessExit(object sender, EventArgs e) + { + Logger.Shutdown(); + } + + private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) + { + var exception = e.ExceptionObject as Exception; + + Logger.PrintError(LogClass.Emulation, $"Unhandled exception caught: {exception}"); + + if (e.IsTerminating) + { + Logger.Shutdown(); + } + } + } +} diff --git a/Ryujinx.Common/Configuration/System/Language.cs b/Ryujinx.Common/Configuration/System/Language.cs new file mode 100644 index 00000000..d3af296b --- /dev/null +++ b/Ryujinx.Common/Configuration/System/Language.cs @@ -0,0 +1,23 @@ +namespace Ryujinx.Configuration.System +{ + public enum Language + { + Japanese, + AmericanEnglish, + French, + German, + Italian, + Spanish, + Chinese, + Korean, + Dutch, + Portuguese, + Russian, + Taiwanese, + BritishEnglish, + CanadianFrench, + LatinAmericanSpanish, + SimplifiedChinese, + TraditionalChinese + } +} diff --git a/Ryujinx.Common/Configuration/Ui/GuiColumns.cs b/Ryujinx.Common/Configuration/Ui/GuiColumns.cs new file mode 100644 index 00000000..2b3524aa --- /dev/null +++ b/Ryujinx.Common/Configuration/Ui/GuiColumns.cs @@ -0,0 +1,16 @@ +namespace Ryujinx.Configuration.Ui +{ + public struct GuiColumns + { + public bool FavColumn; + public bool IconColumn; + public bool AppColumn; + public bool DevColumn; + public bool VersionColumn; + public bool TimePlayedColumn; + public bool LastPlayedColumn; + public bool FileExtColumn; + public bool FileSizeColumn; + public bool PathColumn; + } +} |
