Skip to content
Snippets Groups Projects
Commit 3541e282 authored by Evan Husted's avatar Evan Husted
Browse files

Fully disconnect gamepad handler for rainbow color if configuration is set with UseRainbowLed false

Also check if its even enabled before setting the rainbow color
Fixes strobing
parent 1ce37ec3
No related branches found
Tags Canary-1.2.390
No related merge requests found
......@@ -5,17 +5,29 @@ namespace Ryujinx.Common.Utilities
{
public class Rainbow
{
public const float Speed = 1;
public static float Speed { get; set; } = 1;
public static Color Color { get; private set; } = Color.Blue;
private static float _lastHue;
public static void Tick()
{
float currentHue = Color.GetHue();
float nextHue = currentHue;
if (currentHue >= 360)
nextHue = 0;
else
nextHue += Speed;
Color = HsbToRgb(
(Color.GetHue() + Speed) / 360,
nextHue / 360,
1,
1
);
_lastHue = currentHue;
RainbowColorUpdated?.Invoke(Color.ToArgb());
}
......
......@@ -226,6 +226,13 @@ namespace Ryujinx.Input.SDL2
private static Vector3 GsToMs2(Vector3 gs) => gs / SDL_STANDARD_GRAVITY;
private void RainbowColorChanged(int packedRgb)
{
if (!_configuration.Led.UseRainbow) return;
SetLed((uint)packedRgb);
}
public void SetConfiguration(InputConfig configuration)
{
lock (_userMappingLock)
......@@ -237,10 +244,12 @@ namespace Ryujinx.Input.SDL2
if (_configuration.Led.TurnOffLed)
(this as IGamepad).ClearLed();
else if (_configuration.Led.UseRainbow)
Rainbow.RainbowColorUpdated += clr => SetLed((uint)clr);
Rainbow.RainbowColorUpdated += RainbowColorChanged;
else
SetLed(_configuration.Led.LedColor);
if (!_configuration.Led.UseRainbow)
Rainbow.RainbowColorUpdated -= RainbowColorChanged;
}
_buttonsUserMapping.Clear();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment