diff --git a/src/Ryujinx/UI/ViewModels/Input/LedInputViewModel.cs b/src/Ryujinx/UI/ViewModels/Input/LedInputViewModel.cs index a9d14d8945..8a04fe584c 100644 --- a/src/Ryujinx/UI/ViewModels/Input/LedInputViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/Input/LedInputViewModel.cs @@ -1,7 +1,13 @@ using Avalonia.Media; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; +using Gommon; +using Humanizer; using Ryujinx.Ava.UI.Helpers; +using Ryujinx.Ava.Utilities.Configuration; +using System; +using System.Globalization; +using System.Linq; namespace Ryujinx.Ava.UI.ViewModels.Input { @@ -21,6 +27,19 @@ public partial class LedInputViewModel : BaseModel [ObservableProperty] private bool _enableLedChanging; [ObservableProperty] private Color _ledColor; + + public string RainbowSpeedText => RainbowSpeed.ToString(CultureInfo.CurrentCulture); + + public float RainbowSpeed + { + get => ConfigurationState.Instance.Hid.RainbowSpeed; + set + { + ConfigurationState.Instance.Hid.RainbowSpeed.Value = value; + OnPropertyChanged(); + OnPropertyChanged(nameof(RainbowSpeedText)); + } + } public bool ShowLedColorPicker => !TurnOffLed && !UseRainbowLed; diff --git a/src/Ryujinx/UI/Views/Input/LedInputView.axaml b/src/Ryujinx/UI/Views/Input/LedInputView.axaml index 39e464224c..6a9cb1f053 100644 --- a/src/Ryujinx/UI/Views/Input/LedInputView.axaml +++ b/src/Ryujinx/UI/Views/Input/LedInputView.axaml @@ -11,7 +11,7 @@ x:Class="Ryujinx.UI.Views.Input.LedInputView"> - + - + + + + + + - + /// The current version of the file format /// - public const int CurrentVersion = 61; + public const int CurrentVersion = 62; /// /// Version of the configuration file format @@ -376,24 +374,15 @@ public class ConfigurationFileFormat /// public KeyboardHotkeys Hotkeys { get; set; } - /// - /// Legacy keyboard control bindings - /// - /// Kept for file format compatibility (to avoid possible failure when parsing configuration on old versions) - /// TODO: Remove this when those older versions aren't in use anymore. - public List KeyboardConfig { get; set; } - - /// - /// Legacy controller control bindings - /// - /// Kept for file format compatibility (to avoid possible failure when parsing configuration on old versions) - /// TODO: Remove this when those older versions aren't in use anymore. - public List ControllerConfig { get; set; } - /// /// Input configurations /// public List InputConfig { get; set; } + + /// + /// The speed of spectrum cycling for the Rainbow LED feature. + /// + public float RainbowSpeed { get; set; } /// /// Graphics backend diff --git a/src/Ryujinx/Utilities/Configuration/ConfigurationState.Migration.cs b/src/Ryujinx/Utilities/Configuration/ConfigurationState.Migration.cs index 3ccac2647b..2ce39ef545 100644 --- a/src/Ryujinx/Utilities/Configuration/ConfigurationState.Migration.cs +++ b/src/Ryujinx/Utilities/Configuration/ConfigurationState.Migration.cs @@ -140,6 +140,7 @@ in _migrations.OrderBy(x => x.Key)) Hid.EnableMouse.Value = cff.EnableMouse; Hid.Hotkeys.Value = cff.Hotkeys; Hid.InputConfig.Value = cff.InputConfig ?? []; + Hid.RainbowSpeed.Value = cff.RainbowSpeed; Multiplayer.LanInterfaceId.Value = cff.MultiplayerLanInterfaceId; Multiplayer.Mode.Value = cff.MultiplayerMode; @@ -427,7 +428,8 @@ in _migrations.OrderBy(x => x.Key)) LedColor = new Color(255, 5, 1, 253).ToUInt32() }; } - }) + }), + (62, static cff => cff.RainbowSpeed = 1f) ); } } diff --git a/src/Ryujinx/Utilities/Configuration/ConfigurationState.Model.cs b/src/Ryujinx/Utilities/Configuration/ConfigurationState.Model.cs index 2d77c139d3..3abacbbf17 100644 --- a/src/Ryujinx/Utilities/Configuration/ConfigurationState.Model.cs +++ b/src/Ryujinx/Utilities/Configuration/ConfigurationState.Model.cs @@ -7,6 +7,7 @@ using Ryujinx.Common.Configuration.Multiplayer; using Ryujinx.Common.Helper; using Ryujinx.Common.Logging; +using Ryujinx.Common.Utilities; using Ryujinx.HLE; using System.Collections.Generic; using System.Linq; @@ -444,6 +445,11 @@ public class HidSection /// TODO: Implement a ReactiveList class. /// public ReactiveObject> InputConfig { get; private set; } + + /// + /// The speed of spectrum cycling for the Rainbow LED feature. + /// + public ReactiveObject RainbowSpeed { get; } public HidSection() { @@ -451,6 +457,8 @@ public HidSection() EnableMouse = new ReactiveObject(); Hotkeys = new ReactiveObject(); InputConfig = new ReactiveObject>(); + RainbowSpeed = new ReactiveObject(); + RainbowSpeed.Event += (_, args) => Rainbow.Speed = args.NewValue; } } diff --git a/src/Ryujinx/Utilities/Configuration/ConfigurationState.cs b/src/Ryujinx/Utilities/Configuration/ConfigurationState.cs index b80a0c101e..4ab77a60fa 100644 --- a/src/Ryujinx/Utilities/Configuration/ConfigurationState.cs +++ b/src/Ryujinx/Utilities/Configuration/ConfigurationState.cs @@ -130,9 +130,8 @@ public ConfigurationFileFormat ToFileFormat() EnableKeyboard = Hid.EnableKeyboard, EnableMouse = Hid.EnableMouse, Hotkeys = Hid.Hotkeys, - KeyboardConfig = [], - ControllerConfig = [], InputConfig = Hid.InputConfig, + RainbowSpeed = Hid.RainbowSpeed, GraphicsBackend = Graphics.GraphicsBackend, PreferredGpu = Graphics.PreferredGpu, MultiplayerLanInterfaceId = Multiplayer.LanInterfaceId, @@ -255,6 +254,7 @@ public void LoadDefault() VolumeUp = Key.Unbound, VolumeDown = Key.Unbound, }; + Hid.RainbowSpeed.Value = 1f; Hid.InputConfig.Value = [ new StandardKeyboardInputConfig