From 7ee9a00cf053fcedc2a78c05fce443c82c0389ce Mon Sep 17 00:00:00 2001 From: Thog Date: Fri, 22 Nov 2019 16:39:57 +0100 Subject: [PATCH] Move the configuration system to Common --- .../Configuration/Configuration.cs | 24 +-- .../Configuration/ConfigurationFileFormat.cs | 20 +- .../Configuration/Hid/ControllerInputId.cs | 45 +++++ .../Configuration/Hid/ControllerType.cs | 11 ++ Ryujinx.Common/Configuration/Hid/Key.cs | 153 +++++++++++++++ .../Configuration/Hid/KeyboardHotkeys.cs | 7 + .../Configuration/Hid/NpadController.cs | 35 ++++ .../Configuration/Hid/NpadControllerLeft.cs | 15 ++ .../Configuration/Hid/NpadControllerRight.cs | 16 ++ .../Configuration/Hid/NpadKeyboard.cs | 20 ++ .../Configuration/Hid/NpadKeyboardLeft.cs | 18 ++ .../Configuration/Hid/NpadKeyboardRight.cs | 18 ++ .../Configuration/LoggerModule.cs | 0 .../Configuration/System/Language.cs | 23 +++ .../Configuration}/Ui/GuiColumns.cs | 2 +- Ryujinx.Common/Ryujinx.Common.csproj | 1 + Ryujinx/Ryujinx.csproj | 1 - Ryujinx/Ui/GLScreen.cs | 21 +- .../{NpadKeyboard.cs => KeyboardControls.cs} | 119 ++++-------- Ryujinx/Ui/MainWindow.cs | 43 +++-- Ryujinx/Ui/NpadController.cs | 180 ++++-------------- Ryujinx/Ui/SwitchSettings.cs | 56 +++--- 22 files changed, 529 insertions(+), 299 deletions(-) rename {Ryujinx => Ryujinx.Common}/Configuration/Configuration.cs (95%) rename {Ryujinx => Ryujinx.Common}/Configuration/ConfigurationFileFormat.cs (94%) create mode 100644 Ryujinx.Common/Configuration/Hid/ControllerInputId.cs create mode 100644 Ryujinx.Common/Configuration/Hid/ControllerType.cs create mode 100644 Ryujinx.Common/Configuration/Hid/Key.cs create mode 100644 Ryujinx.Common/Configuration/Hid/KeyboardHotkeys.cs create mode 100644 Ryujinx.Common/Configuration/Hid/NpadController.cs create mode 100644 Ryujinx.Common/Configuration/Hid/NpadControllerLeft.cs create mode 100644 Ryujinx.Common/Configuration/Hid/NpadControllerRight.cs create mode 100644 Ryujinx.Common/Configuration/Hid/NpadKeyboard.cs create mode 100644 Ryujinx.Common/Configuration/Hid/NpadKeyboardLeft.cs create mode 100644 Ryujinx.Common/Configuration/Hid/NpadKeyboardRight.cs rename {Ryujinx => Ryujinx.Common}/Configuration/LoggerModule.cs (100%) create mode 100644 Ryujinx.Common/Configuration/System/Language.cs rename {Ryujinx => Ryujinx.Common/Configuration}/Ui/GuiColumns.cs (90%) rename Ryujinx/Ui/{NpadKeyboard.cs => KeyboardControls.cs} (74%) diff --git a/Ryujinx/Configuration/Configuration.cs b/Ryujinx.Common/Configuration/Configuration.cs similarity index 95% rename from Ryujinx/Configuration/Configuration.cs rename to Ryujinx.Common/Configuration/Configuration.cs index ca1870ccf2..c57f168389 100644 --- a/Ryujinx/Configuration/Configuration.cs +++ b/Ryujinx.Common/Configuration/Configuration.cs @@ -1,8 +1,10 @@ using Ryujinx.Common; +using Ryujinx.Common.Configuration.Hid; using Ryujinx.Common.Logging; -using Ryujinx.HLE.HOS.SystemState; -using Ryujinx.HLE.Input; -using Ryujinx.Ui.Input; +using Ryujinx.Configuration.Hid; +using Ryujinx.Configuration.System; +using Ryujinx.Configuration.Ui; +using Ryujinx.UI.Input; using System; using System.Collections.Generic; @@ -145,7 +147,7 @@ namespace Ryujinx.Configuration /// /// Change System Language /// - public ReactiveObject Language { get; private set; } + public ReactiveObject Language { get; private set; } /// /// Enables or disables Docked Mode @@ -174,7 +176,7 @@ namespace Ryujinx.Configuration public SystemSection() { - Language = new ReactiveObject(); + Language = new ReactiveObject(); EnableDockedMode = new ReactiveObject(); EnableMulticoreScheduling = new ReactiveObject(); EnableFsIntegrityChecks = new ReactiveObject(); @@ -191,7 +193,7 @@ namespace Ryujinx.Configuration /// /// The primary controller's type /// - public ReactiveObject ControllerType { get; private set; } + public ReactiveObject ControllerType { get; private set; } /// /// Enable or disable keyboard support (Independent from controllers binding) @@ -206,14 +208,14 @@ namespace Ryujinx.Configuration /// /// Controller control bindings /// - public ReactiveObject JoystickControls { get; private set; } + public ReactiveObject JoystickControls { get; private set; } public HidSection() { - ControllerType = new ReactiveObject(); + ControllerType = new ReactiveObject(); EnableKeyboard = new ReactiveObject(); KeyboardControls = new ReactiveObject(); - JoystickControls = new ReactiveObject(); + JoystickControls = new ReactiveObject(); } } @@ -308,7 +310,7 @@ namespace Ryujinx.Configuration FsGlobalAccessLogMode = System.FsGlobalAccessLogMode, IgnoreMissingServices = System.IgnoreMissingServices, ControllerType = Hid.ControllerType, - GuiColumns = new Ui.GuiColumns() + GuiColumns = new GuiColumns() { FavColumn = Ui.GuiColumns.FavColumn, IconColumn = Ui.GuiColumns.IconColumn, @@ -337,7 +339,7 @@ namespace Ryujinx.Configuration if (configurationFileFormat.Version != 1 && configurationFileFormat.Version != 0) { // TODO: load default configuration - throw new System.NotSupportedException($"Unsupported configuration version {configurationFileFormat.Version}"); + throw new NotSupportedException($"Unsupported configuration version {configurationFileFormat.Version}"); } Graphics.ShadersDumpPath.Value = configurationFileFormat.GraphicsShadersDumpPath; diff --git a/Ryujinx/Configuration/ConfigurationFileFormat.cs b/Ryujinx.Common/Configuration/ConfigurationFileFormat.cs similarity index 94% rename from Ryujinx/Configuration/ConfigurationFileFormat.cs rename to Ryujinx.Common/Configuration/ConfigurationFileFormat.cs index 4c9ec26ba8..1a9407cb2f 100644 --- a/Ryujinx/Configuration/ConfigurationFileFormat.cs +++ b/Ryujinx.Common/Configuration/ConfigurationFileFormat.cs @@ -1,20 +1,16 @@ using JsonPrettyPrinterPlus; -using LibHac.FsSystem; -using OpenTK.Input; -using Ryujinx.Common; using Ryujinx.Common.Logging; -using Ryujinx.HLE; -using Ryujinx.HLE.HOS.SystemState; -using Ryujinx.HLE.HOS.Services; -using Ryujinx.HLE.Input; -using Ryujinx.Ui; -using Ryujinx.Ui.Input; 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 { @@ -75,7 +71,7 @@ namespace Ryujinx.Configuration /// /// Change System Language /// - public SystemLanguage SystemLanguage { get; set; } + public Language SystemLanguage { get; set; } /// /// Enables or disables Docked Mode @@ -115,7 +111,7 @@ namespace Ryujinx.Configuration /// /// The primary controller's type /// - public ControllerStatus ControllerType { get; set; } + public ControllerType ControllerType { get; set; } /// /// Used to toggle columns in the GUI @@ -150,7 +146,7 @@ namespace Ryujinx.Configuration /// /// Controller control bindings /// - public Ui.Input.NpadController JoystickControls { get; set; } + public NpadController JoystickControls { get; set; } /// /// Loads a configuration file from disk diff --git a/Ryujinx.Common/Configuration/Hid/ControllerInputId.cs b/Ryujinx.Common/Configuration/Hid/ControllerInputId.cs new file mode 100644 index 0000000000..3cb5d9f6d5 --- /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 0000000000..4bbb04c7b0 --- /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 0000000000..6bc126694a --- /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 0000000000..1d0b050492 --- /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 0000000000..496d6a2645 --- /dev/null +++ b/Ryujinx.Common/Configuration/Hid/NpadController.cs @@ -0,0 +1,35 @@ +namespace Ryujinx.Common.Configuration.Hid +{ + public class NpadController + { + /// + /// Enables or disables controller support + /// + public bool Enabled { get; private set; } + + /// + /// Controller Device Index + /// + public int Index { get; private set; } + + /// + /// Controller Analog Stick Deadzone + /// + public float Deadzone { get; private set; } + + /// + /// Controller Trigger Threshold + /// + public float TriggerThreshold { get; private set; } + + /// + /// Left JoyCon Controller Bindings + /// + public NpadControllerLeft LeftJoycon { get; private set; } + + /// + /// Right JoyCon Controller Bindings + /// + public NpadControllerRight RightJoycon { get; private set; } + } +} diff --git a/Ryujinx.Common/Configuration/Hid/NpadControllerLeft.cs b/Ryujinx.Common/Configuration/Hid/NpadControllerLeft.cs new file mode 100644 index 0000000000..54ac0f03ae --- /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 0000000000..83f92544b4 --- /dev/null +++ b/Ryujinx.Common/Configuration/Hid/NpadControllerRight.cs @@ -0,0 +1,16 @@ +namespace Ryujinx.Common.Configuration.Hid +{ + public struct NpadControllerRight + { + public ControllerInputId Stick; + public ControllerInputId StickY; + 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 0000000000..bc74899f31 --- /dev/null +++ b/Ryujinx.Common/Configuration/Hid/NpadKeyboard.cs @@ -0,0 +1,20 @@ +namespace Ryujinx.UI.Input +{ + public class NpadKeyboard + { + /// + /// Left JoyCon Keyboard Bindings + /// + public Configuration.Hid.NpadKeyboardLeft LeftJoycon { get; set; } + + /// + /// Right JoyCon Keyboard Bindings + /// + public Configuration.Hid.NpadKeyboardRight RightJoycon { get; set; } + + /// + /// Hotkey Keyboard Bindings + /// + public Configuration.Hid.KeyboardHotkeys Hotkeys { get; private set; } + } +} diff --git a/Ryujinx.Common/Configuration/Hid/NpadKeyboardLeft.cs b/Ryujinx.Common/Configuration/Hid/NpadKeyboardLeft.cs new file mode 100644 index 0000000000..799cdfdb8a --- /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 0000000000..311504bb7e --- /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/Configuration/LoggerModule.cs b/Ryujinx.Common/Configuration/LoggerModule.cs similarity index 100% rename from Ryujinx/Configuration/LoggerModule.cs rename to Ryujinx.Common/Configuration/LoggerModule.cs diff --git a/Ryujinx.Common/Configuration/System/Language.cs b/Ryujinx.Common/Configuration/System/Language.cs new file mode 100644 index 0000000000..d3af296ba9 --- /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/Ui/GuiColumns.cs b/Ryujinx.Common/Configuration/Ui/GuiColumns.cs similarity index 90% rename from Ryujinx/Ui/GuiColumns.cs rename to Ryujinx.Common/Configuration/Ui/GuiColumns.cs index b86a273ea8..2b3524aa82 100644 --- a/Ryujinx/Ui/GuiColumns.cs +++ b/Ryujinx.Common/Configuration/Ui/GuiColumns.cs @@ -1,4 +1,4 @@ -namespace Ryujinx.Ui +namespace Ryujinx.Configuration.Ui { public struct GuiColumns { diff --git a/Ryujinx.Common/Ryujinx.Common.csproj b/Ryujinx.Common/Ryujinx.Common.csproj index c777b402cc..7f6fa32323 100644 --- a/Ryujinx.Common/Ryujinx.Common.csproj +++ b/Ryujinx.Common/Ryujinx.Common.csproj @@ -27,6 +27,7 @@ + diff --git a/Ryujinx/Ryujinx.csproj b/Ryujinx/Ryujinx.csproj index c54beffe47..b231ddb8d2 100644 --- a/Ryujinx/Ryujinx.csproj +++ b/Ryujinx/Ryujinx.csproj @@ -71,7 +71,6 @@ - diff --git a/Ryujinx/Ui/GLScreen.cs b/Ryujinx/Ui/GLScreen.cs index 3ed522e10d..b29d32587d 100644 --- a/Ryujinx/Ui/GLScreen.cs +++ b/Ryujinx/Ui/GLScreen.cs @@ -5,6 +5,7 @@ using Ryujinx.Configuration; using Ryujinx.Graphics.Gal; using Ryujinx.HLE; using Ryujinx.HLE.Input; +using Ryujinx.Ui; using System; using System.Threading; @@ -29,6 +30,8 @@ namespace Ryujinx.Ui private MouseState? _mouse = null; + private Input.NpadController _primaryController; + private Thread _renderThread; private bool _resizeEvent; @@ -50,6 +53,8 @@ namespace Ryujinx.Ui _device = device; _renderer = renderer; + _primaryController = new Input.NpadController(ConfigurationState.Instance.Hid.JoystickControls); + Location = new Point( (DisplayDevice.Default.Width / 2) - (Width / 2), (DisplayDevice.Default.Height / 2) - (Height / 2)); @@ -162,16 +167,16 @@ namespace Ryujinx.Ui #endif // Normal Input - currentHotkeyButtons = ConfigurationState.Instance.Hid.KeyboardControls.Value.GetHotkeyButtons(keyboard); - currentButton = ConfigurationState.Instance.Hid.KeyboardControls.Value.GetButtons(keyboard); + currentHotkeyButtons = KeyboardControls.GetHotkeyButtons(ConfigurationState.Instance.Hid.KeyboardControls, keyboard); + currentButton = KeyboardControls.GetButtons(ConfigurationState.Instance.Hid.KeyboardControls, keyboard); if (ConfigurationState.Instance.Hid.EnableKeyboard) { - hidKeyboard = ConfigurationState.Instance.Hid.KeyboardControls.Value.GetKeysDown(keyboard); + hidKeyboard = KeyboardControls.GetKeysDown(ConfigurationState.Instance.Hid.KeyboardControls, keyboard); } - (leftJoystickDx, leftJoystickDy) = ConfigurationState.Instance.Hid.KeyboardControls.Value.GetLeftStick(keyboard); - (rightJoystickDx, rightJoystickDy) = ConfigurationState.Instance.Hid.KeyboardControls.Value.GetRightStick(keyboard); + (leftJoystickDx, leftJoystickDy) = KeyboardControls.GetLeftStick(ConfigurationState.Instance.Hid.KeyboardControls, keyboard); + (rightJoystickDx, rightJoystickDy) = KeyboardControls.GetRightStick(ConfigurationState.Instance.Hid.KeyboardControls, keyboard); } if (!hidKeyboard.HasValue) @@ -183,17 +188,17 @@ namespace Ryujinx.Ui }; } - currentButton |= ConfigurationState.Instance.Hid.JoystickControls.Value.GetButtons(); + currentButton |= _primaryController.GetButtons(); // Keyboard has priority stick-wise if (leftJoystickDx == 0 && leftJoystickDy == 0) { - (leftJoystickDx, leftJoystickDy) = ConfigurationState.Instance.Hid.JoystickControls.Value.GetLeftStick(); + (leftJoystickDx, leftJoystickDy) = _primaryController.GetLeftStick(); } if (rightJoystickDx == 0 && rightJoystickDy == 0) { - (rightJoystickDx, rightJoystickDy) = ConfigurationState.Instance.Hid.JoystickControls.Value.GetRightStick(); + (rightJoystickDx, rightJoystickDy) = _primaryController.GetRightStick(); } leftJoystick = new JoystickPosition diff --git a/Ryujinx/Ui/NpadKeyboard.cs b/Ryujinx/Ui/KeyboardControls.cs similarity index 74% rename from Ryujinx/Ui/NpadKeyboard.cs rename to Ryujinx/Ui/KeyboardControls.cs index 95fb222183..db9c0cda8c 100644 --- a/Ryujinx/Ui/NpadKeyboard.cs +++ b/Ryujinx/Ui/KeyboardControls.cs @@ -1,118 +1,67 @@ -using OpenTK.Input; +using OpenTK.Input; using Ryujinx.HLE.Input; +using Ryujinx.UI.Input; -namespace Ryujinx.Ui.Input +namespace Ryujinx.Ui { - public struct NpadKeyboardLeft + public static class KeyboardControls { - 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; - } - - 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; - } - - public struct KeyboardHotkeys - { - public Key ToggleVsync; - } - - public class NpadKeyboard - { - /// - /// Left JoyCon Keyboard Bindings - /// - public NpadKeyboardLeft LeftJoycon { get; set; } - - /// - /// Right JoyCon Keyboard Bindings - /// - public NpadKeyboardRight RightJoycon { get; set; } - - /// - /// Hotkey Keyboard Bindings - /// - public KeyboardHotkeys Hotkeys { get; private set; } - - public ControllerButtons GetButtons(KeyboardState keyboard) + public static ControllerButtons GetButtons(NpadKeyboard npad, KeyboardState keyboard) { ControllerButtons buttons = 0; - if (keyboard[(Key)LeftJoycon.StickButton]) buttons |= ControllerButtons.StickLeft; - if (keyboard[(Key)LeftJoycon.DPadUp]) buttons |= ControllerButtons.DpadUp; - if (keyboard[(Key)LeftJoycon.DPadDown]) buttons |= ControllerButtons.DpadDown; - if (keyboard[(Key)LeftJoycon.DPadLeft]) buttons |= ControllerButtons.DpadLeft; - if (keyboard[(Key)LeftJoycon.DPadRight]) buttons |= ControllerButtons.DPadRight; - if (keyboard[(Key)LeftJoycon.ButtonMinus]) buttons |= ControllerButtons.Minus; - if (keyboard[(Key)LeftJoycon.ButtonL]) buttons |= ControllerButtons.L; - if (keyboard[(Key)LeftJoycon.ButtonZl]) buttons |= ControllerButtons.Zl; + if (keyboard[(Key)npad.LeftJoycon.StickButton]) buttons |= ControllerButtons.StickLeft; + if (keyboard[(Key)npad.LeftJoycon.DPadUp]) buttons |= ControllerButtons.DpadUp; + if (keyboard[(Key)npad.LeftJoycon.DPadDown]) buttons |= ControllerButtons.DpadDown; + if (keyboard[(Key)npad.LeftJoycon.DPadLeft]) buttons |= ControllerButtons.DpadLeft; + if (keyboard[(Key)npad.LeftJoycon.DPadRight]) buttons |= ControllerButtons.DPadRight; + if (keyboard[(Key)npad.LeftJoycon.ButtonMinus]) buttons |= ControllerButtons.Minus; + if (keyboard[(Key)npad.LeftJoycon.ButtonL]) buttons |= ControllerButtons.L; + if (keyboard[(Key)npad.LeftJoycon.ButtonZl]) buttons |= ControllerButtons.Zl; - if (keyboard[(Key)RightJoycon.StickButton]) buttons |= ControllerButtons.StickRight; - if (keyboard[(Key)RightJoycon.ButtonA]) buttons |= ControllerButtons.A; - if (keyboard[(Key)RightJoycon.ButtonB]) buttons |= ControllerButtons.B; - if (keyboard[(Key)RightJoycon.ButtonX]) buttons |= ControllerButtons.X; - if (keyboard[(Key)RightJoycon.ButtonY]) buttons |= ControllerButtons.Y; - if (keyboard[(Key)RightJoycon.ButtonPlus]) buttons |= ControllerButtons.Plus; - if (keyboard[(Key)RightJoycon.ButtonR]) buttons |= ControllerButtons.R; - if (keyboard[(Key)RightJoycon.ButtonZr]) buttons |= ControllerButtons.Zr; + if (keyboard[(Key)npad.RightJoycon.StickButton]) buttons |= ControllerButtons.StickRight; + if (keyboard[(Key)npad.RightJoycon.ButtonA]) buttons |= ControllerButtons.A; + if (keyboard[(Key)npad.RightJoycon.ButtonB]) buttons |= ControllerButtons.B; + if (keyboard[(Key)npad.RightJoycon.ButtonX]) buttons |= ControllerButtons.X; + if (keyboard[(Key)npad.RightJoycon.ButtonY]) buttons |= ControllerButtons.Y; + if (keyboard[(Key)npad.RightJoycon.ButtonPlus]) buttons |= ControllerButtons.Plus; + if (keyboard[(Key)npad.RightJoycon.ButtonR]) buttons |= ControllerButtons.R; + if (keyboard[(Key)npad.RightJoycon.ButtonZr]) buttons |= ControllerButtons.Zr; return buttons; } - public (short, short) GetLeftStick(KeyboardState keyboard) + public static (short, short) GetLeftStick(NpadKeyboard npad, KeyboardState keyboard) { short dx = 0; short dy = 0; - if (keyboard[(Key)LeftJoycon.StickUp]) dy = short.MaxValue; - if (keyboard[(Key)LeftJoycon.StickDown]) dy = -short.MaxValue; - if (keyboard[(Key)LeftJoycon.StickLeft]) dx = -short.MaxValue; - if (keyboard[(Key)LeftJoycon.StickRight]) dx = short.MaxValue; + if (keyboard[(Key)npad.LeftJoycon.StickUp]) dy = short.MaxValue; + if (keyboard[(Key)npad.LeftJoycon.StickDown]) dy = -short.MaxValue; + if (keyboard[(Key)npad.LeftJoycon.StickLeft]) dx = -short.MaxValue; + if (keyboard[(Key)npad.LeftJoycon.StickRight]) dx = short.MaxValue; return (dx, dy); } - public (short, short) GetRightStick(KeyboardState keyboard) + public static (short, short) GetRightStick(NpadKeyboard npad, KeyboardState keyboard) { short dx = 0; short dy = 0; - if (keyboard[(Key)RightJoycon.StickUp]) dy = short.MaxValue; - if (keyboard[(Key)RightJoycon.StickDown]) dy = -short.MaxValue; - if (keyboard[(Key)RightJoycon.StickLeft]) dx = -short.MaxValue; - if (keyboard[(Key)RightJoycon.StickRight]) dx = short.MaxValue; + if (keyboard[(Key)npad.RightJoycon.StickUp]) dy = short.MaxValue; + if (keyboard[(Key)npad.RightJoycon.StickDown]) dy = -short.MaxValue; + if (keyboard[(Key)npad.RightJoycon.StickLeft]) dx = -short.MaxValue; + if (keyboard[(Key)npad.RightJoycon.StickRight]) dx = short.MaxValue; return (dx, dy); } - public HotkeyButtons GetHotkeyButtons(KeyboardState keyboard) + public static HotkeyButtons GetHotkeyButtons(NpadKeyboard npad, KeyboardState keyboard) { HotkeyButtons buttons = 0; - if (keyboard[(Key)Hotkeys.ToggleVsync]) buttons |= HotkeyButtons.ToggleVSync; + if (keyboard[(Key)npad.Hotkeys.ToggleVsync]) buttons |= HotkeyButtons.ToggleVSync; return buttons; } @@ -267,7 +216,7 @@ namespace Ryujinx.Ui.Input new KeyMappingEntry { TargetKey = Key.NumLock, Target = 10 }, }; - public HLE.Input.Keyboard GetKeysDown(KeyboardState keyboard) + public static HLE.Input.Keyboard GetKeysDown(NpadKeyboard npad, KeyboardState keyboard) { HLE.Input.Keyboard hidKeyboard = new HLE.Input.Keyboard { diff --git a/Ryujinx/Ui/MainWindow.cs b/Ryujinx/Ui/MainWindow.cs index 58595f1d1c..e77e639d6e 100644 --- a/Ryujinx/Ui/MainWindow.cs +++ b/Ryujinx/Ui/MainWindow.cs @@ -13,14 +13,18 @@ using Ryujinx.Configuration; using System.Diagnostics; using OpenTK.Input; using Ryujinx.Ui.Input; - -using GUI = Gtk.Builder.ObjectAttribute; using System.Threading.Tasks; using Utf8Json; using JsonPrettyPrinterPlus; using Utf8Json.Resolvers; using Ryujinx.HLE.FileSystem; + +using GUI = Gtk.Builder.ObjectAttribute; +using Ryujinx.HLE.Input; +using Ryujinx.Configuration.Hid; +using Ryujinx.HLE.HOS.SystemState; + namespace Ryujinx.Ui { public class MainWindow : Window @@ -202,8 +206,7 @@ namespace Ryujinx.Ui { HLE.Switch instance = new HLE.Switch(_renderer, _audioOut); - instance.Initialize(ConfigurationState.Instance.System.Language, ConfigurationState.Instance.System.EnableMulticoreScheduling, ConfigurationState.Instance.System.EnableDockedMode, ConfigurationState.Instance.Graphics.EnableVsync, ConfigurationState.Instance.System.EnableFsIntegrityChecks, ConfigurationState.Instance.System.FsGlobalAccessLogMode, ConfigurationState.Instance.System.IgnoreMissingServices); - + instance.Initialize((SystemLanguage)ConfigurationState.Instance.System.Language.Value, ConfigurationState.Instance.System.EnableMulticoreScheduling, ConfigurationState.Instance.System.EnableDockedMode, ConfigurationState.Instance.Graphics.EnableVsync, ConfigurationState.Instance.System.EnableFsIntegrityChecks, ConfigurationState.Instance.System.FsGlobalAccessLogMode, ConfigurationState.Instance.System.IgnoreMissingServices); return instance; } @@ -233,7 +236,7 @@ namespace Ryujinx.Ui { Logger.RestartTime(); - // TODO: move this somewhere else + reloadable + // TODO: move this somewhere else + reloadable? GraphicsConfig.ShadersDumpPath = ConfigurationState.Instance.Graphics.ShadersDumpPath; if (Directory.Exists(path)) @@ -340,19 +343,29 @@ namespace Ryujinx.Ui // TODO: Make HLE.Switch handle the state itself + reloading private static void ConfigureHid() { - NpadController controller = ConfigurationState.Instance.Hid.JoystickControls.Value; - - if (controller.Enabled) - { - if (!Joystick.GetState(controller.Index).IsConnected) - { - controller.SetEnabled(false); - } - } - _device.Hid.InitializePrimaryController(ConfigurationState.Instance.Hid.ControllerType); + _device.Hid.InitializePrimaryController(ConvertControllerTypeToState(ConfigurationState.Instance.Hid.ControllerType)); _device.Hid.InitializeKeyboard(); } + private static ControllerStatus ConvertControllerTypeToState(ControllerType controllerType) + { + switch (controllerType) + { + case ControllerType.Handheld: + return ControllerStatus.Handheld; + case ControllerType.NpadLeft: + return ControllerStatus.NpadLeft; + case ControllerType.NpadRight: + return ControllerStatus.NpadRight; + case ControllerType.NpadPair: + return ControllerStatus.NpadPair; + case ControllerType.ProController: + return ControllerStatus.ProController; + default: + throw new NotImplementedException(); + } + } + private static void CreateGameWindow() { ConfigureHid(); diff --git a/Ryujinx/Ui/NpadController.cs b/Ryujinx/Ui/NpadController.cs index f72c407551..a566946a45 100644 --- a/Ryujinx/Ui/NpadController.cs +++ b/Ryujinx/Ui/NpadController.cs @@ -1,160 +1,62 @@ using OpenTK; using OpenTK.Input; +using Ryujinx.Common.Configuration.Hid; using Ryujinx.HLE.Input; using System; +using InnerNpadController = Ryujinx.Common.Configuration.Hid.NpadController; + namespace Ryujinx.Ui.Input { - 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, - } - - 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; - } - - 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; - } - public class NpadController { - /// - /// Enables or disables controller support - /// - public bool Enabled { get; private set; } + private InnerNpadController _inner; - /// - /// Controller Device Index - /// - public int Index { get; private set; } - - /// - /// Controller Analog Stick Deadzone - /// - public float Deadzone { get; private set; } - - /// - /// Controller Trigger Threshold - /// - public float TriggerThreshold { get; private set; } - - /// - /// Left JoyCon Controller Bindings - /// - public NpadControllerLeft LeftJoycon { get; private set; } - - /// - /// Right JoyCon Controller Bindings - /// - public NpadControllerRight RightJoycon { get; private set; } - - public NpadController( - bool enabled, - int index, - float deadzone, - float triggerThreshold, - NpadControllerLeft leftJoycon, - NpadControllerRight rightJoycon) + // NOTE: This should be initialized AFTER GTK for compat reasons with OpenTK SDL2 backend and GTK on Linux. + // BODY: Usage of Joystick.GetState must be defer to after GTK full initialization. Otherwise, GTK will segfault because SDL2 was already init *sighs* + public NpadController(InnerNpadController inner) { - Enabled = enabled; - Index = index; - Deadzone = deadzone; - TriggerThreshold = triggerThreshold; - LeftJoycon = leftJoycon; - RightJoycon = rightJoycon; + _inner = inner; } - public void SetEnabled(bool enabled) + private bool IsEnabled() { - Enabled = enabled; + return _inner.Enabled && Joystick.GetState(_inner.Index).IsConnected; + } + + public void Initialize() + { + } public ControllerButtons GetButtons() { - if (!Enabled) + if (!IsEnabled()) { return 0; } - JoystickState joystickState = Joystick.GetState(Index); + JoystickState joystickState = Joystick.GetState(_inner.Index); ControllerButtons buttons = 0; - if (IsActivated(joystickState, LeftJoycon.DPadUp)) buttons |= ControllerButtons.DpadUp; - if (IsActivated(joystickState, LeftJoycon.DPadDown)) buttons |= ControllerButtons.DpadDown; - if (IsActivated(joystickState, LeftJoycon.DPadLeft)) buttons |= ControllerButtons.DpadLeft; - if (IsActivated(joystickState, LeftJoycon.DPadRight)) buttons |= ControllerButtons.DPadRight; - if (IsActivated(joystickState, LeftJoycon.StickButton)) buttons |= ControllerButtons.StickLeft; - if (IsActivated(joystickState, LeftJoycon.ButtonMinus)) buttons |= ControllerButtons.Minus; - if (IsActivated(joystickState, LeftJoycon.ButtonL)) buttons |= ControllerButtons.L; - if (IsActivated(joystickState, LeftJoycon.ButtonZl)) buttons |= ControllerButtons.Zl; + if (IsActivated(joystickState, _inner.LeftJoycon.DPadUp)) buttons |= ControllerButtons.DpadUp; + if (IsActivated(joystickState, _inner.LeftJoycon.DPadDown)) buttons |= ControllerButtons.DpadDown; + if (IsActivated(joystickState, _inner.LeftJoycon.DPadLeft)) buttons |= ControllerButtons.DpadLeft; + if (IsActivated(joystickState, _inner.LeftJoycon.DPadRight)) buttons |= ControllerButtons.DPadRight; + if (IsActivated(joystickState, _inner.LeftJoycon.StickButton)) buttons |= ControllerButtons.StickLeft; + if (IsActivated(joystickState, _inner.LeftJoycon.ButtonMinus)) buttons |= ControllerButtons.Minus; + if (IsActivated(joystickState, _inner.LeftJoycon.ButtonL)) buttons |= ControllerButtons.L; + if (IsActivated(joystickState, _inner.LeftJoycon.ButtonZl)) buttons |= ControllerButtons.Zl; - if (IsActivated(joystickState, RightJoycon.ButtonA)) buttons |= ControllerButtons.A; - if (IsActivated(joystickState, RightJoycon.ButtonB)) buttons |= ControllerButtons.B; - if (IsActivated(joystickState, RightJoycon.ButtonX)) buttons |= ControllerButtons.X; - if (IsActivated(joystickState, RightJoycon.ButtonY)) buttons |= ControllerButtons.Y; - if (IsActivated(joystickState, RightJoycon.StickButton)) buttons |= ControllerButtons.StickRight; - if (IsActivated(joystickState, RightJoycon.ButtonPlus)) buttons |= ControllerButtons.Plus; - if (IsActivated(joystickState, RightJoycon.ButtonR)) buttons |= ControllerButtons.R; - if (IsActivated(joystickState, RightJoycon.ButtonZr)) buttons |= ControllerButtons.Zr; + if (IsActivated(joystickState, _inner.RightJoycon.ButtonA)) buttons |= ControllerButtons.A; + if (IsActivated(joystickState, _inner.RightJoycon.ButtonB)) buttons |= ControllerButtons.B; + if (IsActivated(joystickState, _inner.RightJoycon.ButtonX)) buttons |= ControllerButtons.X; + if (IsActivated(joystickState, _inner.RightJoycon.ButtonY)) buttons |= ControllerButtons.Y; + if (IsActivated(joystickState, _inner.RightJoycon.StickButton)) buttons |= ControllerButtons.StickRight; + if (IsActivated(joystickState, _inner.RightJoycon.ButtonPlus)) buttons |= ControllerButtons.Plus; + if (IsActivated(joystickState, _inner.RightJoycon.ButtonR)) buttons |= ControllerButtons.R; + if (IsActivated(joystickState, _inner.RightJoycon.ButtonZr)) buttons |= ControllerButtons.Zr; return buttons; } @@ -169,7 +71,7 @@ namespace Ryujinx.Ui.Input { int axis = controllerInputId - ControllerInputId.Axis0; - return joystickState.GetAxis(axis) > TriggerThreshold; + return joystickState.GetAxis(axis) > _inner.TriggerThreshold; } else if (controllerInputId <= ControllerInputId.Hat2Right) { @@ -190,22 +92,22 @@ namespace Ryujinx.Ui.Input public (short, short) GetLeftStick() { - if (!Enabled) + if (!IsEnabled()) { return (0, 0); } - return GetStick(LeftJoycon.Stick); + return GetStick(_inner.LeftJoycon.Stick); } public (short, short) GetRightStick() { - if (!Enabled) + if (!IsEnabled()) { return (0, 0); } - return GetStick(RightJoycon.Stick); + return GetStick(_inner.RightJoycon.Stick); } private (short, short) GetStick(ControllerInputId stickInputId) @@ -215,7 +117,7 @@ namespace Ryujinx.Ui.Input return (0, 0); } - JoystickState jsState = Joystick.GetState(Index); + JoystickState jsState = Joystick.GetState(_inner.Index); int xAxis = stickInputId - ControllerInputId.Axis0; @@ -227,8 +129,8 @@ namespace Ryujinx.Ui.Input private (short, short) ApplyDeadzone(Vector2 axis) { - return (ClampAxis(MathF.Abs(axis.X) > Deadzone ? axis.X : 0f), - ClampAxis(MathF.Abs(axis.Y) > Deadzone ? axis.Y : 0f)); + return (ClampAxis(MathF.Abs(axis.X) > _inner.Deadzone ? axis.X : 0f), + ClampAxis(MathF.Abs(axis.Y) > _inner.Deadzone ? axis.Y : 0f)); } private static short ClampAxis(float value) diff --git a/Ryujinx/Ui/SwitchSettings.cs b/Ryujinx/Ui/SwitchSettings.cs index 25aff2de06..b733f154cf 100644 --- a/Ryujinx/Ui/SwitchSettings.cs +++ b/Ryujinx/Ui/SwitchSettings.cs @@ -9,6 +9,8 @@ using System.Linq; using System.Reflection; using Ryujinx.Configuration; using Ryujinx.Common.Logging; +using Ryujinx.Configuration.System; +using Ryujinx.Configuration.Hid; using GUI = Gtk.Builder.ObjectAttribute; @@ -202,7 +204,7 @@ namespace Ryujinx.Ui string key = keyPressed.Event.Key.ToString(); string capKey = key.First().ToString().ToUpper() + key.Substring(1); - if (Enum.IsDefined(typeof(OpenTK.Input.Key), capKey)) + if (Enum.IsDefined(typeof(Configuration.Hid.Key), capKey)) { button.Label = capKey; } @@ -338,38 +340,38 @@ namespace Ryujinx.Ui ConfigurationState.Instance.Hid.KeyboardControls.Value.LeftJoycon = new NpadKeyboardLeft() { - StickUp = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _lStickUp1.Label), - StickDown = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _lStickDown1.Label), - StickLeft = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _lStickLeft1.Label), - StickRight = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _lStickRight1.Label), - StickButton = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _lStickButton1.Label), - DPadUp = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _dpadUp1.Label), - DPadDown = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _dpadDown1.Label), - DPadLeft = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _dpadLeft1.Label), - DPadRight = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _dpadRight1.Label), - ButtonMinus = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _minus1.Label), - ButtonL = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _l1.Label), - ButtonZl = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _zL1.Label), + StickUp = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _lStickUp1.Label), + StickDown = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _lStickDown1.Label), + StickLeft = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _lStickLeft1.Label), + StickRight = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _lStickRight1.Label), + StickButton = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _lStickButton1.Label), + DPadUp = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _dpadUp1.Label), + DPadDown = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _dpadDown1.Label), + DPadLeft = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _dpadLeft1.Label), + DPadRight = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _dpadRight1.Label), + ButtonMinus = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _minus1.Label), + ButtonL = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _l1.Label), + ButtonZl = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _zL1.Label), }; ConfigurationState.Instance.Hid.KeyboardControls.Value.RightJoycon = new NpadKeyboardRight() { - StickUp = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _rStickUp1.Label), - StickDown = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _rStickDown1.Label), - StickLeft = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _rStickLeft1.Label), - StickRight = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _rStickRight1.Label), - StickButton = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _rStickButton1.Label), - ButtonA = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _a1.Label), - ButtonB = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _b1.Label), - ButtonX = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _x1.Label), - ButtonY = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _y1.Label), - ButtonPlus = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _plus1.Label), - ButtonR = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _r1.Label), - ButtonZr = (OpenTK.Input.Key)Enum.Parse(typeof(OpenTK.Input.Key), _zR1.Label), + StickUp = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _rStickUp1.Label), + StickDown = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _rStickDown1.Label), + StickLeft = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _rStickLeft1.Label), + StickRight = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _rStickRight1.Label), + StickButton = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _rStickButton1.Label), + ButtonA = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _a1.Label), + ButtonB = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _b1.Label), + ButtonX = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _x1.Label), + ButtonY = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _y1.Label), + ButtonPlus = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _plus1.Label), + ButtonR = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _r1.Label), + ButtonZr = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _zR1.Label), }; - ConfigurationState.Instance.System.Language.Value = (SystemLanguage)Enum.Parse(typeof(SystemLanguage), _systemLanguageSelect.ActiveId); - ConfigurationState.Instance.Hid.ControllerType.Value = (ControllerStatus)Enum.Parse(typeof(ControllerStatus), _controller1Type.ActiveId); + ConfigurationState.Instance.System.Language.Value = (Language)Enum.Parse(typeof(Language), _systemLanguageSelect.ActiveId); + ConfigurationState.Instance.Hid.ControllerType.Value = (ControllerType)Enum.Parse(typeof(ControllerType), _controller1Type.ActiveId); ConfigurationState.Instance.Ui.CustomThemePath.Value = _custThemePath.Buffer.Text; ConfigurationState.Instance.Graphics.ShadersDumpPath.Value = _graphicsShadersDumpPath.Buffer.Text; ConfigurationState.Instance.Ui.GameDirs.Value = gameDirs;