From a41f11f79e9f3cf04a6188a569bf5fb82ea2c552 Mon Sep 17 00:00:00 2001 From: Thog Date: Fri, 22 Nov 2019 19:39:06 +0100 Subject: [PATCH] Generate a default configuration if version mismatch or not found Also remove JoystickY as it's not used in configuration or in any codepath. This also regenerate the Config.json as some fields were missing. --- Ryujinx.Common/Configuration/Configuration.cs | 115 ++++++++++- .../Configuration/Hid/NpadController.cs | 12 +- .../Configuration/Hid/NpadControllerRight.cs | 1 - .../Configuration/Hid/NpadKeyboard.cs | 6 +- Ryujinx/Config.json | 191 +++++++++--------- Ryujinx/Program.cs | 15 +- 6 files changed, 229 insertions(+), 111 deletions(-) diff --git a/Ryujinx.Common/Configuration/Configuration.cs b/Ryujinx.Common/Configuration/Configuration.cs index c57f168389..30b1294e77 100644 --- a/Ryujinx.Common/Configuration/Configuration.cs +++ b/Ryujinx.Common/Configuration/Configuration.cs @@ -334,12 +334,123 @@ namespace Ryujinx.Configuration 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(); + 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) { - // TODO: load default configuration - throw new NotSupportedException($"Unsupported configuration version {configurationFileFormat.Version}"); + Common.Logging.Logger.PrintWarning(LogClass.Application, $"Unsupported configuration version {configurationFileFormat.Version}, loading default!"); + + LoadDefault(); + + return; } Graphics.ShadersDumpPath.Value = configurationFileFormat.GraphicsShadersDumpPath; diff --git a/Ryujinx.Common/Configuration/Hid/NpadController.cs b/Ryujinx.Common/Configuration/Hid/NpadController.cs index 496d6a2645..f00865d556 100644 --- a/Ryujinx.Common/Configuration/Hid/NpadController.cs +++ b/Ryujinx.Common/Configuration/Hid/NpadController.cs @@ -5,31 +5,31 @@ /// /// Enables or disables controller support /// - public bool Enabled { get; private set; } + public bool Enabled; /// /// Controller Device Index /// - public int Index { get; private set; } + public int Index; /// /// Controller Analog Stick Deadzone /// - public float Deadzone { get; private set; } + public float Deadzone; /// /// Controller Trigger Threshold /// - public float TriggerThreshold { get; private set; } + public float TriggerThreshold; /// /// Left JoyCon Controller Bindings /// - public NpadControllerLeft LeftJoycon { get; private set; } + public NpadControllerLeft LeftJoycon; /// /// Right JoyCon Controller Bindings /// - public NpadControllerRight RightJoycon { get; private set; } + public NpadControllerRight RightJoycon; } } diff --git a/Ryujinx.Common/Configuration/Hid/NpadControllerRight.cs b/Ryujinx.Common/Configuration/Hid/NpadControllerRight.cs index 83f92544b4..315136d9f6 100644 --- a/Ryujinx.Common/Configuration/Hid/NpadControllerRight.cs +++ b/Ryujinx.Common/Configuration/Hid/NpadControllerRight.cs @@ -3,7 +3,6 @@ public struct NpadControllerRight { public ControllerInputId Stick; - public ControllerInputId StickY; public ControllerInputId StickButton; public ControllerInputId ButtonA; public ControllerInputId ButtonB; diff --git a/Ryujinx.Common/Configuration/Hid/NpadKeyboard.cs b/Ryujinx.Common/Configuration/Hid/NpadKeyboard.cs index bc74899f31..911f5119ea 100644 --- a/Ryujinx.Common/Configuration/Hid/NpadKeyboard.cs +++ b/Ryujinx.Common/Configuration/Hid/NpadKeyboard.cs @@ -5,16 +5,16 @@ namespace Ryujinx.UI.Input /// /// Left JoyCon Keyboard Bindings /// - public Configuration.Hid.NpadKeyboardLeft LeftJoycon { get; set; } + public Configuration.Hid.NpadKeyboardLeft LeftJoycon; /// /// Right JoyCon Keyboard Bindings /// - public Configuration.Hid.NpadKeyboardRight RightJoycon { get; set; } + public Configuration.Hid.NpadKeyboardRight RightJoycon; /// /// Hotkey Keyboard Bindings /// - public Configuration.Hid.KeyboardHotkeys Hotkeys { get; private set; } + public Configuration.Hid.KeyboardHotkeys Hotkeys; } } diff --git a/Ryujinx/Config.json b/Ryujinx/Config.json index 8463081fab..22342f2ffd 100644 --- a/Ryujinx/Config.json +++ b/Ryujinx/Config.json @@ -1,102 +1,99 @@ { - "graphics_shaders_dump_path": "", - "logging_enable_debug": false, - "logging_enable_stub": true, - "logging_enable_info": true, - "logging_enable_warn": true, - "logging_enable_error": true, - "logging_enable_guest": true, - "logging_enable_fs_access_log": false, - "logging_filtered_classes": [ - - ], - "enable_file_log": true, - "system_language": "AmericanEnglish", - "docked_mode": false, - "enable_discord_integration": true, - "enable_vsync": true, - "enable_multicore_scheduling": true, - "enable_fs_integrity_checks": true, - "fs_global_access_log_mode": 0, - "ignore_missing_services": false, - "controller_type": "Handheld", - "gui_columns": { - "fav_column": true, - "icon_column": true, - "app_column": true, - "dev_column": true, - "version_column": true, - "time_played_column": true, - "last_played_column": true, - "file_ext_column": true, - "file_size_column": true, - "path_column": true + "version": 1, + "graphics_shaders_dump_path": "", + "logging_enable_debug": false, + "logging_enable_stub": true, + "logging_enable_info": true, + "logging_enable_warn": true, + "logging_enable_error": true, + "logging_enable_guest": true, + "logging_enable_fs_access_log": false, + "logging_filtered_classes": [], + "enable_file_log": true, + "system_language": "AmericanEnglish", + "docked_mode": false, + "enable_discord_integration": true, + "enable_vsync": true, + "enable_multicore_scheduling": true, + "enable_fs_integrity_checks": true, + "fs_global_access_log_mode": 0, + "ignore_missing_services": false, + "controller_type": "Handheld", + "gui_columns": { + "fav_column": true, + "icon_column": true, + "app_column": true, + "dev_column": true, + "version_column": true, + "time_played_column": true, + "last_played_column": true, + "file_ext_column": true, + "file_size_column": true, + "path_column": true + }, + "game_dirs": [], + "enable_custom_theme": false, + "custom_theme_path": "", + "enable_keyboard": false, + "keyboard_controls": { + "left_joycon": { + "stick_up": "W", + "stick_down": "S", + "stick_left": "A", + "stick_right": "D", + "stick_button": "F", + "dpad_up": "Up", + "dpad_down": "Down", + "dpad_left": "Left", + "dpad_right": "Right", + "button_minus": "Minus", + "button_l": "E", + "button_zl": "Q" }, - "game_dirs": [ - - ], - "enable_custom_theme": false, - "custom_theme_path": "", - "enable_keyboard": false, - "keyboard_controls": { - "left_joycon": { - "stick_up": "W", - "stick_down": "S", - "stick_left": "A", - "stick_right": "D", - "stick_button": "F", - "dpad_up": "Up", - "dpad_down": "Down", - "dpad_left": "Left", - "dpad_right": "Right", - "button_minus": "Minus", - "button_l": "E", - "button_zl": "Q" - }, - "right_joycon": { - "stick_up": "I", - "stick_down": "K", - "stick_left": "J", - "stick_right": "L", - "stick_button": "H", - "button_a": "Z", - "button_b": "X", - "button_x": "C", - "button_y": "V", - "button_plus": "Plus", - "button_r": "U", - "button_zr": "O" - }, - "hotkeys": { - "toggle_vsync": "Tab" - } + "right_joycon": { + "stick_up": "I", + "stick_down": "K", + "stick_left": "J", + "stick_right": "L", + "stick_button": "H", + "button_a": "Z", + "button_b": "X", + "button_x": "C", + "button_y": "V", + "button_plus": "Plus", + "button_r": "U", + "button_zr": "O" }, - "joystick_controls": { - "enabled": true, - "index": 0, - "deadzone": 0.05, - "trigger_threshold": 0.5, - "left_joycon": { - "stick": "Axis0", - "stick_button": "Button8", - "button_minus": "Button6", - "button_l": "Button4", - "button_zl": "Axis2", - "dpad_up": "Hat0Up", - "dpad_down": "Hat0Down", - "dpad_left": "Hat0Left", - "dpad_right": "Hat0Right" - }, - "right_joycon": { - "stick": "Axis3", - "stick_button": "Button9", - "button_a": "Button1", - "button_b": "Button0", - "button_x": "Button3", - "button_y": "Button2", - "button_plus": "Button7", - "button_r": "Button5", - "button_zr": "Axis5" - } + "hotkeys": { + "toggle_vsync": "Tab" } + }, + "joystick_controls": { + "enabled": true, + "index": 0, + "deadzone": 0.05, + "trigger_threshold": 0.5, + "left_joycon": { + "stick": "Axis0", + "stick_button": "Button8", + "button_minus": "Button6", + "button_l": "Button4", + "button_zl": "Axis2", + "dpad_up": "Hat0Up", + "dpad_down": "Hat0Down", + "dpad_left": "Hat0Left", + "dpad_right": "Hat0Right" + }, + "right_joycon": { + "stick": "Axis3", + "stick_button": "Button9", + "button_a": "Button1", + "button_b": "Button0", + "button_x": "Button3", + "button_y": "Button2", + "button_plus": "Button7", + "button_r": "Button5", + "button_zr": "Axis5" + } + } } \ No newline at end of file diff --git a/Ryujinx/Program.cs b/Ryujinx/Program.cs index 1c02ec66c6..cbf3c1b92f 100644 --- a/Ryujinx/Program.cs +++ b/Ryujinx/Program.cs @@ -28,9 +28,20 @@ namespace Ryujinx // Initialize Discord integration DiscordIntegrationModule.Initialize(); + string configurationPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config.json"); + // Now load the configuration as the other subsystem are now registered - ConfigurationFileFormat configurationFileFormat = ConfigurationFileFormat.Load(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config.json")); - ConfigurationState.Instance.Load(configurationFileFormat); + if (File.Exists(configurationPath)) + { + ConfigurationFileFormat configurationFileFormat = ConfigurationFileFormat.Load(configurationPath); + ConfigurationState.Instance.Load(configurationFileFormat); + } + else + { + // No configuration, we load the default values. + ConfigurationState.Instance.LoadDefault(); + } + Profile.Initialize();