diff options
Diffstat (limited to 'Ryujinx.Common/Configuration/ConfigurationState.cs')
| -rw-r--r-- | Ryujinx.Common/Configuration/ConfigurationState.cs | 266 |
1 files changed, 122 insertions, 144 deletions
diff --git a/Ryujinx.Common/Configuration/ConfigurationState.cs b/Ryujinx.Common/Configuration/ConfigurationState.cs index 1e26b4f4..7063110f 100644 --- a/Ryujinx.Common/Configuration/ConfigurationState.cs +++ b/Ryujinx.Common/Configuration/ConfigurationState.cs @@ -1,8 +1,8 @@ using Ryujinx.Common; using Ryujinx.Common.Configuration; using Ryujinx.Common.Configuration.Hid; +using Ryujinx.Common.Configuration.Hid.Keyboard; using Ryujinx.Common.Logging; -using Ryujinx.Configuration.Hid; using Ryujinx.Configuration.System; using Ryujinx.Configuration.Ui; using System; @@ -405,21 +405,6 @@ namespace Ryujinx.Configuration public ConfigurationFileFormat ToFileFormat() { - List<ControllerConfig> controllerConfigList = new List<ControllerConfig>(); - List<KeyboardConfig> keyboardConfigList = new List<KeyboardConfig>(); - - foreach (InputConfig inputConfig in Hid.InputConfig.Value) - { - if (inputConfig is ControllerConfig controllerConfig) - { - controllerConfigList.Add(controllerConfig); - } - else if (inputConfig is KeyboardConfig keyboardConfig) - { - keyboardConfigList.Add(keyboardConfig); - } - } - ConfigurationFileFormat configurationFile = new ConfigurationFileFormat { Version = ConfigurationFileFormat.CurrentVersion, @@ -479,8 +464,9 @@ namespace Ryujinx.Configuration StartFullscreen = Ui.StartFullscreen, EnableKeyboard = Hid.EnableKeyboard, Hotkeys = Hid.Hotkeys, - KeyboardConfig = keyboardConfigList, - ControllerConfig = controllerConfigList + KeyboardConfig = new List<object>(), + ControllerConfig = new List<object>(), + InputConfig = Hid.InputConfig, }; return configurationFile; @@ -543,54 +529,57 @@ namespace Ryujinx.Configuration }; Hid.InputConfig.Value = new List<InputConfig> { - new KeyboardConfig - { - Index = 0, - ControllerType = ControllerType.JoyconPair, - PlayerIndex = PlayerIndex.Player1, - 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, - ButtonSl = Key.Home, - ButtonSr = Key.End - }, - 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, - ButtonSl = Key.PageUp, - ButtonSr = Key.PageDown - }, - EnableMotion = false, - MirrorInput = false, - Slot = 0, - AltSlot = 0, - Sensitivity = 100, - GyroDeadzone = 1, - DsuServerHost = "127.0.0.1", - DsuServerPort = 26760 - } + new StandardKeyboardInputConfig + { + Version = InputConfig.CurrentVersion, + Backend = InputBackendType.WindowKeyboard, + Id = "0", + PlayerIndex = PlayerIndex.Player1, + ControllerType = ControllerType.JoyconPair, + LeftJoycon = new LeftJoyconCommonConfig<Key> + { + DpadUp = Key.Up, + DpadDown = Key.Down, + DpadLeft = Key.Left, + DpadRight = Key.Right, + ButtonMinus = Key.Minus, + ButtonL = Key.E, + ButtonZl = Key.Q, + ButtonSl = Key.Unbound, + ButtonSr = Key.Unbound + }, + + LeftJoyconStick = new JoyconConfigKeyboardStick<Key> + { + StickUp = Key.W, + StickDown = Key.S, + StickLeft = Key.A, + StickRight = Key.D, + StickButton = Key.F, + }, + + RightJoycon = new RightJoyconCommonConfig<Key> + { + ButtonA = Key.Z, + ButtonB = Key.X, + ButtonX = Key.C, + ButtonY = Key.V, + ButtonPlus = Key.Plus, + ButtonR = Key.U, + ButtonZr = Key.O, + ButtonSl = Key.Unbound, + ButtonSr = Key.Unbound + }, + + RightJoyconStick = new JoyconConfigKeyboardStick<Key> + { + StickUp = Key.I, + StickDown = Key.K, + StickLeft = Key.J, + StickRight = Key.L, + StickButton = Key.H, + } + } }; } @@ -643,80 +632,6 @@ namespace Ryujinx.Configuration configurationFileUpdated = true; } - if (configurationFileFormat.Version < 6) - { - Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 6."); - - configurationFileFormat.ControllerConfig = new List<ControllerConfig>(); - configurationFileFormat.KeyboardConfig = new List<KeyboardConfig> - { - new KeyboardConfig - { - Index = 0, - ControllerType = ControllerType.JoyconPair, - PlayerIndex = PlayerIndex.Player1, - 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, - ButtonSl = Key.Unbound, - ButtonSr = Key.Unbound - }, - 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, - ButtonSl = Key.Unbound, - ButtonSr = Key.Unbound - }, - EnableMotion = false, - MirrorInput = false, - Slot = 0, - AltSlot = 0, - Sensitivity = 100, - GyroDeadzone = 1, - DsuServerHost = "127.0.0.1", - DsuServerPort = 26760 - } - }; - - configurationFileUpdated = true; - } - - // Only needed for version 6 configurations. - if (configurationFileFormat.Version == 6) - { - Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 7."); - - for (int i = 0; i < configurationFileFormat.KeyboardConfig.Count; i++) - { - if (configurationFileFormat.KeyboardConfig[i].Index != KeyboardConfig.AllKeyboardsIndex) - { - configurationFileFormat.KeyboardConfig[i].Index++; - } - } - } - if (configurationFileFormat.Version < 8) { Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 8."); @@ -826,9 +741,67 @@ namespace Ryujinx.Configuration configurationFileUpdated = true; } - List<InputConfig> inputConfig = new List<InputConfig>(); - inputConfig.AddRange(configurationFileFormat.ControllerConfig); - inputConfig.AddRange(configurationFileFormat.KeyboardConfig); + if (configurationFileFormat.Version < 24) + { + Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 24."); + + configurationFileFormat.InputConfig = new List<InputConfig> + { + new StandardKeyboardInputConfig + { + Version = InputConfig.CurrentVersion, + Backend = InputBackendType.WindowKeyboard, + Id = "0", + PlayerIndex = PlayerIndex.Player1, + ControllerType = ControllerType.JoyconPair, + LeftJoycon = new LeftJoyconCommonConfig<Key> + { + DpadUp = Key.Up, + DpadDown = Key.Down, + DpadLeft = Key.Left, + DpadRight = Key.Right, + ButtonMinus = Key.Minus, + ButtonL = Key.E, + ButtonZl = Key.Q, + ButtonSl = Key.Unbound, + ButtonSr = Key.Unbound + }, + + LeftJoyconStick = new JoyconConfigKeyboardStick<Key> + { + StickUp = Key.W, + StickDown = Key.S, + StickLeft = Key.A, + StickRight = Key.D, + StickButton = Key.F, + }, + + RightJoycon = new RightJoyconCommonConfig<Key> + { + ButtonA = Key.Z, + ButtonB = Key.X, + ButtonX = Key.C, + ButtonY = Key.V, + ButtonPlus = Key.Plus, + ButtonR = Key.U, + ButtonZr = Key.O, + ButtonSl = Key.Unbound, + ButtonSr = Key.Unbound + }, + + RightJoyconStick = new JoyconConfigKeyboardStick<Key> + { + StickUp = Key.I, + StickDown = Key.K, + StickLeft = Key.J, + StickRight = Key.L, + StickButton = Key.H, + } + } + }; + + configurationFileUpdated = true; + } Graphics.ResScale.Value = configurationFileFormat.ResScale; Graphics.ResScaleCustom.Value = configurationFileFormat.ResScaleCustom; @@ -880,7 +853,12 @@ namespace Ryujinx.Configuration Ui.StartFullscreen.Value = configurationFileFormat.StartFullscreen; Hid.EnableKeyboard.Value = configurationFileFormat.EnableKeyboard; Hid.Hotkeys.Value = configurationFileFormat.Hotkeys; - Hid.InputConfig.Value = inputConfig; + Hid.InputConfig.Value = configurationFileFormat.InputConfig; + + if (Hid.InputConfig.Value == null) + { + Hid.InputConfig.Value = new List<InputConfig>(); + } if (configurationFileUpdated) { |
