From eff11f52a8f0864fe9eca6a54f74c4eadcfa3973 Mon Sep 17 00:00:00 2001 From: Otozinclus <58051309+Otozinclus@users.noreply.github.com> Date: Wed, 22 Jan 2025 21:55:53 +0100 Subject: [PATCH] Change controller LED color This changes the controller LED color. Now I need to add the option to change it in the settings --- src/Ryujinx.Input.SDL2/SDL2Gamepad.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Ryujinx.Input.SDL2/SDL2Gamepad.cs b/src/Ryujinx.Input.SDL2/SDL2Gamepad.cs index ed22c3661..16d1e070f 100644 --- a/src/Ryujinx.Input.SDL2/SDL2Gamepad.cs +++ b/src/Ryujinx.Input.SDL2/SDL2Gamepad.cs @@ -87,6 +87,11 @@ namespace Ryujinx.Input.SDL2 Features = GetFeaturesFlag(); _triggerThreshold = 0.0f; + //if (SDL_GameControllerHasLED(_gamepadHandle)) + { + _setControllerLedColor("000000"); + } + // Enable motion tracking if (Features.HasFlag(GamepadFeaturesFlag.Motion)) { @@ -102,6 +107,16 @@ namespace Ryujinx.Input.SDL2 } } + private void _setControllerLedColor(string hex) + { + ulong LEDcolor = Convert.ToUInt64(hex, 16); + byte red = (byte)((LEDcolor >> 16) % 256); + byte green = (byte)((LEDcolor >> 8) % 256); + byte blue = (byte)(LEDcolor % 256); + + SDL_GameControllerSetLED(_gamepadHandle, red, green, blue); + } + private GamepadFeaturesFlag GetFeaturesFlag() { GamepadFeaturesFlag result = GamepadFeaturesFlag.None;