From 38ecb3d5bc4fd17eb2562e960720b7b20fad0a8e Mon Sep 17 00:00:00 2001 From: uncavo-hdmi Date: Tue, 18 Feb 2025 13:40:34 +0100 Subject: [PATCH] added function to handle gamepad led while in settings; added rainbow color handling in the new function. --- src/Ryujinx/Program.cs | 1 - .../UI/ViewModels/Input/InputViewModel.cs | 35 ++++++++++++------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/Ryujinx/Program.cs b/src/Ryujinx/Program.cs index 853e87f0e..a6a991f84 100644 --- a/src/Ryujinx/Program.cs +++ b/src/Ryujinx/Program.cs @@ -19,7 +19,6 @@ using Ryujinx.Common.Logging; using Ryujinx.Common.SystemInterop; using Ryujinx.Graphics.Vulkan.MoltenVK; using Ryujinx.Headless; -using Ryujinx.Input.SDL2; using Ryujinx.SDL2.Common; using System; using System.Collections.Generic; diff --git a/src/Ryujinx/UI/ViewModels/Input/InputViewModel.cs b/src/Ryujinx/UI/ViewModels/Input/InputViewModel.cs index 427bdf4e2..db4d66f99 100644 --- a/src/Ryujinx/UI/ViewModels/Input/InputViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/Input/InputViewModel.cs @@ -379,22 +379,31 @@ namespace Ryujinx.Ava.UI.ViewModels.Input LoadDevice(); _isLoaded = true; - if (ConfigViewModel is not ControllerInputViewModel controllerInputViewModel) return; - GamepadInputConfig inputConfig = controllerInputViewModel.Config; - - if (inputConfig is not { EnableLedChanging: true }) return; - - if (inputConfig.TurnOffLed) - { - SelectedGamepad.ClearLed(); - } - else - { - SelectedGamepad.SetLed(inputConfig.LedColor.ToUInt32()); - } + UpdateGamepadLed(); }); } + private void UpdateGamepadLed() + { + if (ConfigViewModel is not ControllerInputViewModel controllerInputViewModel) return; + GamepadInputConfig inputConfig = controllerInputViewModel.Config; + + if (inputConfig is not { EnableLedChanging: true }) return; + + if (inputConfig.TurnOffLed) + { + SelectedGamepad.ClearLed(); + } + else if(inputConfig.UseRainbowLed) + { + SelectedGamepad.SetLed((uint)Rainbow.Color.ToArgb()); + } + else + { + SelectedGamepad.SetLed(inputConfig.LedColor.ToUInt32()); + } + } + private string GetCurrentGamepadId() { if (_device < 0)