diff --git a/src/Ryujinx.Ava/UI/Views/Input/ControllerInputView.axaml.cs b/src/Ryujinx.Ava/UI/Views/Input/ControllerInputView.axaml.cs index 01b52c8f9..338e04b6a 100644 --- a/src/Ryujinx.Ava/UI/Views/Input/ControllerInputView.axaml.cs +++ b/src/Ryujinx.Ava/UI/Views/Input/ControllerInputView.axaml.cs @@ -9,6 +9,7 @@ using Ryujinx.Ava.UI.ViewModels.Input; using Ryujinx.Common.Configuration.Hid.Controller; using Ryujinx.Input; using Ryujinx.Input.Assigner; +using StickInputId = Ryujinx.Common.Configuration.Hid.Controller.StickInputId; namespace Ryujinx.Ava.UI.Views.Input { @@ -74,70 +75,70 @@ namespace Ryujinx.Ava.UI.Views.Input switch (button.Name) { case "ButtonZl": - viewModel.Config.ButtonZl = buttonValue.AsGamepadButtonInputId(); + viewModel.Config.ButtonZl = buttonValue.AsHidType(); break; case "ButtonL": - viewModel.Config.ButtonL = buttonValue.AsGamepadButtonInputId(); + viewModel.Config.ButtonL = buttonValue.AsHidType(); break; case "ButtonMinus": - viewModel.Config.ButtonMinus = buttonValue.AsGamepadButtonInputId(); + viewModel.Config.ButtonMinus = buttonValue.AsHidType(); break; case "LeftStickButton": - viewModel.Config.LeftStickButton = buttonValue.AsGamepadButtonInputId(); + viewModel.Config.LeftStickButton = buttonValue.AsHidType(); break; case "LeftJoystick": - viewModel.Config.LeftJoystick = buttonValue.AsGamepadStickId(); + viewModel.Config.LeftJoystick = buttonValue.AsHidType(); break; case "DpadUp": - viewModel.Config.DpadUp = buttonValue.AsGamepadButtonInputId(); + viewModel.Config.DpadUp = buttonValue.AsHidType(); break; case "DpadDown": - viewModel.Config.DpadDown = buttonValue.AsGamepadButtonInputId(); + viewModel.Config.DpadDown = buttonValue.AsHidType(); break; case "DpadLeft": - viewModel.Config.DpadLeft = buttonValue.AsGamepadButtonInputId(); + viewModel.Config.DpadLeft = buttonValue.AsHidType(); break; case "DpadRight": - viewModel.Config.DpadRight = buttonValue.AsGamepadButtonInputId(); + viewModel.Config.DpadRight = buttonValue.AsHidType(); break; case "LeftButtonSr": - viewModel.Config.LeftButtonSr = buttonValue.AsGamepadButtonInputId(); + viewModel.Config.LeftButtonSr = buttonValue.AsHidType(); break; case "LeftButtonSl": - viewModel.Config.LeftButtonSl = buttonValue.AsGamepadButtonInputId(); + viewModel.Config.LeftButtonSl = buttonValue.AsHidType(); break; case "RightButtonSr": - viewModel.Config.RightButtonSr = buttonValue.AsGamepadButtonInputId(); + viewModel.Config.RightButtonSr = buttonValue.AsHidType(); break; case "RightButtonSl": - viewModel.Config.RightButtonSl = buttonValue.AsGamepadButtonInputId(); + viewModel.Config.RightButtonSl = buttonValue.AsHidType(); break; case "ButtonZr": - viewModel.Config.ButtonZr = buttonValue.AsGamepadButtonInputId(); + viewModel.Config.ButtonZr = buttonValue.AsHidType(); break; case "ButtonR": - viewModel.Config.ButtonR = buttonValue.AsGamepadButtonInputId(); + viewModel.Config.ButtonR = buttonValue.AsHidType(); break; case "ButtonPlus": - viewModel.Config.ButtonPlus = buttonValue.AsGamepadButtonInputId(); + viewModel.Config.ButtonPlus = buttonValue.AsHidType(); break; case "ButtonA": - viewModel.Config.ButtonA = buttonValue.AsGamepadButtonInputId(); + viewModel.Config.ButtonA = buttonValue.AsHidType(); break; case "ButtonB": - viewModel.Config.ButtonB = buttonValue.AsGamepadButtonInputId(); + viewModel.Config.ButtonB = buttonValue.AsHidType(); break; case "ButtonX": - viewModel.Config.ButtonX = buttonValue.AsGamepadButtonInputId(); + viewModel.Config.ButtonX = buttonValue.AsHidType(); break; case "ButtonY": - viewModel.Config.ButtonY = buttonValue.AsGamepadButtonInputId(); + viewModel.Config.ButtonY = buttonValue.AsHidType(); break; case "RightStickButton": - viewModel.Config.RightStickButton = buttonValue.AsGamepadButtonInputId(); + viewModel.Config.RightStickButton = buttonValue.AsHidType(); break; case "RightJoystick": - viewModel.Config.RightJoystick = buttonValue.AsGamepadStickId(); + viewModel.Config.RightJoystick = buttonValue.AsHidType(); break; } } diff --git a/src/Ryujinx.Ava/UI/Views/Input/KeyboardInputView.axaml.cs b/src/Ryujinx.Ava/UI/Views/Input/KeyboardInputView.axaml.cs index fdeb282be..a5ccfc84b 100644 --- a/src/Ryujinx.Ava/UI/Views/Input/KeyboardInputView.axaml.cs +++ b/src/Ryujinx.Ava/UI/Views/Input/KeyboardInputView.axaml.cs @@ -8,6 +8,7 @@ using Ryujinx.Ava.UI.Helpers; using Ryujinx.Ava.UI.ViewModels.Input; using Ryujinx.Input; using Ryujinx.Input.Assigner; +using Key = Ryujinx.Common.Configuration.Hid.Key; namespace Ryujinx.Ava.UI.Views.Input { @@ -71,88 +72,88 @@ namespace Ryujinx.Ava.UI.Views.Input switch (button.Name) { case "ButtonZl": - viewModel.Config.ButtonZl = buttonValue.AsKey(); + viewModel.Config.ButtonZl = buttonValue.AsHidType(); break; case "ButtonL": - viewModel.Config.ButtonL = buttonValue.AsKey(); + viewModel.Config.ButtonL = buttonValue.AsHidType(); break; case "ButtonMinus": - viewModel.Config.ButtonMinus = buttonValue.AsKey(); + viewModel.Config.ButtonMinus = buttonValue.AsHidType(); break; case "LeftStickButton": - viewModel.Config.LeftStickButton = buttonValue.AsKey(); + viewModel.Config.LeftStickButton = buttonValue.AsHidType(); break; case "LeftStickUp": - viewModel.Config.LeftStickUp = buttonValue.AsKey(); + viewModel.Config.LeftStickUp = buttonValue.AsHidType(); break; case "LeftStickDown": - viewModel.Config.LeftStickDown = buttonValue.AsKey(); + viewModel.Config.LeftStickDown = buttonValue.AsHidType(); break; case "LeftStickRight": - viewModel.Config.LeftStickRight = buttonValue.AsKey(); + viewModel.Config.LeftStickRight = buttonValue.AsHidType(); break; case "LeftStickLeft": - viewModel.Config.LeftStickLeft = buttonValue.AsKey(); + viewModel.Config.LeftStickLeft = buttonValue.AsHidType(); break; case "DpadUp": - viewModel.Config.DpadUp = buttonValue.AsKey(); + viewModel.Config.DpadUp = buttonValue.AsHidType(); break; case "DpadDown": - viewModel.Config.DpadDown = buttonValue.AsKey(); + viewModel.Config.DpadDown = buttonValue.AsHidType(); break; case "DpadLeft": - viewModel.Config.DpadLeft = buttonValue.AsKey(); + viewModel.Config.DpadLeft = buttonValue.AsHidType(); break; case "DpadRight": - viewModel.Config.DpadRight = buttonValue.AsKey(); + viewModel.Config.DpadRight = buttonValue.AsHidType(); break; case "LeftButtonSr": - viewModel.Config.LeftButtonSr = buttonValue.AsKey(); + viewModel.Config.LeftButtonSr = buttonValue.AsHidType(); break; case "LeftButtonSl": - viewModel.Config.LeftButtonSl = buttonValue.AsKey(); + viewModel.Config.LeftButtonSl = buttonValue.AsHidType(); break; case "RightButtonSr": - viewModel.Config.RightButtonSr = buttonValue.AsKey(); + viewModel.Config.RightButtonSr = buttonValue.AsHidType(); break; case "RightButtonSl": - viewModel.Config.RightButtonSl = buttonValue.AsKey(); + viewModel.Config.RightButtonSl = buttonValue.AsHidType(); break; case "ButtonZr": - viewModel.Config.ButtonZr = buttonValue.AsKey(); + viewModel.Config.ButtonZr = buttonValue.AsHidType(); break; case "ButtonR": - viewModel.Config.ButtonR = buttonValue.AsKey(); + viewModel.Config.ButtonR = buttonValue.AsHidType(); break; case "ButtonPlus": - viewModel.Config.ButtonPlus = buttonValue.AsKey(); + viewModel.Config.ButtonPlus = buttonValue.AsHidType(); break; case "ButtonA": - viewModel.Config.ButtonA = buttonValue.AsKey(); + viewModel.Config.ButtonA = buttonValue.AsHidType(); break; case "ButtonB": - viewModel.Config.ButtonB = buttonValue.AsKey(); + viewModel.Config.ButtonB = buttonValue.AsHidType(); break; case "ButtonX": - viewModel.Config.ButtonX = buttonValue.AsKey(); + viewModel.Config.ButtonX = buttonValue.AsHidType(); break; case "ButtonY": - viewModel.Config.ButtonY = buttonValue.AsKey(); + viewModel.Config.ButtonY = buttonValue.AsHidType(); break; case "RightStickButton": - viewModel.Config.RightStickButton = buttonValue.AsKey(); + viewModel.Config.RightStickButton = buttonValue.AsHidType(); break; case "RightStickUp": - viewModel.Config.RightStickUp = buttonValue.AsKey(); + viewModel.Config.RightStickUp = buttonValue.AsHidType(); break; case "RightStickDown": - viewModel.Config.RightStickDown = buttonValue.AsKey(); + viewModel.Config.RightStickDown = buttonValue.AsHidType(); break; case "RightStickRight": - viewModel.Config.RightStickRight = buttonValue.AsKey(); + viewModel.Config.RightStickRight = buttonValue.AsHidType(); break; case "RightStickLeft": - viewModel.Config.RightStickLeft = buttonValue.AsKey(); + viewModel.Config.RightStickLeft = buttonValue.AsHidType(); break; } } diff --git a/src/Ryujinx.Ava/UI/Views/Settings/SettingsHotkeysView.axaml.cs b/src/Ryujinx.Ava/UI/Views/Settings/SettingsHotkeysView.axaml.cs index 10625ad8e..5f675c358 100644 --- a/src/Ryujinx.Ava/UI/Views/Settings/SettingsHotkeysView.axaml.cs +++ b/src/Ryujinx.Ava/UI/Views/Settings/SettingsHotkeysView.axaml.cs @@ -8,6 +8,7 @@ using Ryujinx.Ava.UI.Helpers; using Ryujinx.Ava.UI.ViewModels; using Ryujinx.Input; using Ryujinx.Input.Assigner; +using Key = Ryujinx.Common.Configuration.Hid.Key; namespace Ryujinx.Ava.UI.Views.Settings { @@ -81,31 +82,31 @@ namespace Ryujinx.Ava.UI.Views.Settings switch (button.Name) { case "ToggleVsync": - viewModel.KeyboardHotkeys.ToggleVsync = buttonValue.AsKey(); + viewModel.KeyboardHotkeys.ToggleVsync = buttonValue.AsHidType(); break; case "Screenshot": - viewModel.KeyboardHotkeys.Screenshot = buttonValue.AsKey(); + viewModel.KeyboardHotkeys.Screenshot = buttonValue.AsHidType(); break; case "ShowUI": - viewModel.KeyboardHotkeys.ShowUI = buttonValue.AsKey(); + viewModel.KeyboardHotkeys.ShowUI = buttonValue.AsHidType(); break; case "Pause": - viewModel.KeyboardHotkeys.Pause = buttonValue.AsKey(); + viewModel.KeyboardHotkeys.Pause = buttonValue.AsHidType(); break; case "ToggleMute": - viewModel.KeyboardHotkeys.ToggleMute = buttonValue.AsKey(); + viewModel.KeyboardHotkeys.ToggleMute = buttonValue.AsHidType(); break; case "ResScaleUp": - viewModel.KeyboardHotkeys.ResScaleUp = buttonValue.AsKey(); + viewModel.KeyboardHotkeys.ResScaleUp = buttonValue.AsHidType(); break; case "ResScaleDown": - viewModel.KeyboardHotkeys.ResScaleDown = buttonValue.AsKey(); + viewModel.KeyboardHotkeys.ResScaleDown = buttonValue.AsHidType(); break; case "VolumeUp": - viewModel.KeyboardHotkeys.VolumeUp = buttonValue.AsKey(); + viewModel.KeyboardHotkeys.VolumeUp = buttonValue.AsHidType(); break; case "VolumeDown": - viewModel.KeyboardHotkeys.VolumeDown = buttonValue.AsKey(); + viewModel.KeyboardHotkeys.VolumeDown = buttonValue.AsHidType(); break; } } diff --git a/src/Ryujinx.Input/ButtonValue.cs b/src/Ryujinx.Input/ButtonValue.cs index b8a49d174..d1c6efa1e 100644 --- a/src/Ryujinx.Input/ButtonValue.cs +++ b/src/Ryujinx.Input/ButtonValue.cs @@ -1,4 +1,4 @@ -using System.Diagnostics; +using System; namespace Ryujinx.Input { @@ -27,22 +27,9 @@ namespace Ryujinx.Input _rawValue = (uint)stick; } - public Common.Configuration.Hid.Key AsKey() + public T AsHidType() where T : Enum { - Debug.Assert(Type == ButtonValueType.Key); - return (Common.Configuration.Hid.Key)_rawValue; - } - - public Common.Configuration.Hid.Controller.GamepadInputId AsGamepadButtonInputId() - { - Debug.Assert(Type == ButtonValueType.GamepadButtonInputId); - return (Common.Configuration.Hid.Controller.GamepadInputId)_rawValue; - } - - public Common.Configuration.Hid.Controller.StickInputId AsGamepadStickId() - { - Debug.Assert(Type == ButtonValueType.StickId); - return (Common.Configuration.Hid.Controller.StickInputId)_rawValue; + return (T)Enum.ToObject(typeof(T), _rawValue); } } } diff --git a/src/Ryujinx/UI/Helper/ButtonValueHelper.cs b/src/Ryujinx/UI/Helper/ButtonValueHelper.cs index e927f1932..dca37a82e 100644 --- a/src/Ryujinx/UI/Helper/ButtonValueHelper.cs +++ b/src/Ryujinx/UI/Helper/ButtonValueHelper.cs @@ -123,9 +123,9 @@ namespace Ryujinx.UI.Helper if (buttonValue.Type == ButtonValueType.Key) { - var key = buttonValue.AsKey(); + var key = buttonValue.AsHidType(); - if (!_keysMap.TryGetValue(buttonValue.AsKey(), out keyString)) + if (!_keysMap.TryGetValue(buttonValue.AsHidType(), out keyString)) { keyString = key.ToString(); } @@ -133,9 +133,9 @@ namespace Ryujinx.UI.Helper if (buttonValue.Type == ButtonValueType.GamepadButtonInputId) { - var gamepadButton = buttonValue.AsGamepadButtonInputId(); + var gamepadButton = buttonValue.AsHidType(); - if (!_gamepadInputIdMap.TryGetValue(buttonValue.AsGamepadButtonInputId(), out keyString)) + if (!_gamepadInputIdMap.TryGetValue(buttonValue.AsHidType(), out keyString)) { keyString = gamepadButton.ToString(); } @@ -143,9 +143,9 @@ namespace Ryujinx.UI.Helper if (buttonValue.Type == ButtonValueType.StickId) { - var stickInput = buttonValue.AsGamepadStickId(); + var stickInput = buttonValue.AsHidType(); - if (!_stickInputIdMap.TryGetValue(buttonValue.AsGamepadStickId(), out keyString)) + if (!_stickInputIdMap.TryGetValue(buttonValue.AsHidType(), out keyString)) { keyString = stickInput.ToString(); }