From 1a42d1396cd9e3a88cfcf69b82631b95160e57e5 Mon Sep 17 00:00:00 2001 From: Evan Husted Date: Thu, 30 Jan 2025 03:18:34 -0600 Subject: [PATCH] UI: Rainbow cycling speed settings Note: this setting is global, even though it appears in the settings for the individual gamepad. This is simply for consistency; you access all the rainbow stuff in one place. --- .../UI/ViewModels/Input/LedInputViewModel.cs | 19 +++++++++++++++ src/Ryujinx/UI/Views/Input/LedInputView.axaml | 23 ++++++++++++++++--- .../Configuration/ConfigurationFileFormat.cs | 23 +++++-------------- .../ConfigurationState.Migration.cs | 4 +++- .../Configuration/ConfigurationState.Model.cs | 8 +++++++ .../Configuration/ConfigurationState.cs | 4 ++-- 6 files changed, 58 insertions(+), 23 deletions(-) diff --git a/src/Ryujinx/UI/ViewModels/Input/LedInputViewModel.cs b/src/Ryujinx/UI/ViewModels/Input/LedInputViewModel.cs index a9d14d894..8a04fe584 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 @@ namespace Ryujinx.Ava.UI.ViewModels.Input [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 39e464224..6a9cb1f05 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 @@ namespace Ryujinx.Ava.Utilities.Configuration /// 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 3ccac2647..2ce39ef54 100644 --- a/src/Ryujinx/Utilities/Configuration/ConfigurationState.Migration.cs +++ b/src/Ryujinx/Utilities/Configuration/ConfigurationState.Migration.cs @@ -140,6 +140,7 @@ namespace Ryujinx.Ava.Utilities.Configuration 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 @@ namespace Ryujinx.Ava.Utilities.Configuration 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 2d77c139d..3abacbbf1 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.Hid; 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 @@ namespace Ryujinx.Ava.Utilities.Configuration /// 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 @@ namespace Ryujinx.Ava.Utilities.Configuration 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 b80a0c101..4ab77a60f 100644 --- a/src/Ryujinx/Utilities/Configuration/ConfigurationState.cs +++ b/src/Ryujinx/Utilities/Configuration/ConfigurationState.cs @@ -130,9 +130,8 @@ namespace Ryujinx.Ava.Utilities.Configuration 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 @@ namespace Ryujinx.Ava.Utilities.Configuration VolumeUp = Key.Unbound, VolumeDown = Key.Unbound, }; + Hid.RainbowSpeed.Value = 1f; Hid.InputConfig.Value = [ new StandardKeyboardInputConfig