Compare commits
1 Commits
Canary-1.2
...
Canary-1.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3b5f6170d1 |
@@ -42,7 +42,7 @@
|
||||
<PackageVersion Include="Ryujinx.Graphics.Nvdec.Dependencies" Version="5.0.3-build14" />
|
||||
<PackageVersion Include="Ryujinx.Graphics.Vulkan.Dependencies.MoltenVK" Version="1.2.0" />
|
||||
<PackageVersion Include="Ryujinx.SDL2-CS" Version="2.30.0-build32" />
|
||||
<PackageVersion Include="Gommon" Version="2.7.0.2" />
|
||||
<PackageVersion Include="Gommon" Version="2.7.1" />
|
||||
<PackageVersion Include="securifybv.ShellLink" Version="0.1.0" />
|
||||
<PackageVersion Include="Sep" Version="0.6.0" />
|
||||
<PackageVersion Include="shaderc.net" Version="0.1.0" />
|
||||
|
||||
@@ -1,40 +1,62 @@
|
||||
using System;
|
||||
using Gommon;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Ryujinx.Common.Utilities
|
||||
{
|
||||
public class Rainbow
|
||||
public static class Rainbow
|
||||
{
|
||||
public static bool CyclingEnabled { get; set; }
|
||||
|
||||
public static void Enable()
|
||||
{
|
||||
if (!CyclingEnabled)
|
||||
{
|
||||
CyclingEnabled = true;
|
||||
Executor.ExecuteBackgroundAsync(async () =>
|
||||
{
|
||||
while (CyclingEnabled)
|
||||
{
|
||||
await Task.Delay(15);
|
||||
Tick();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static void Disable()
|
||||
{
|
||||
CyclingEnabled = false;
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
|
||||
Color = HsbToRgb(
|
||||
nextHue / 360,
|
||||
1,
|
||||
1
|
||||
);
|
||||
|
||||
_lastHue = currentHue;
|
||||
|
||||
RainbowColorUpdated?.Invoke(Color.ToArgb());
|
||||
UpdatedHandler.Call(Color.ToArgb());
|
||||
}
|
||||
|
||||
public static event Action<int> RainbowColorUpdated;
|
||||
public static void Reset()
|
||||
{
|
||||
Color = Color.Blue;
|
||||
UpdatedHandler.Clear();
|
||||
}
|
||||
|
||||
private static Color HsbToRgb(float hue, float saturation, float brightness)
|
||||
public static event Action<int> Updated
|
||||
{
|
||||
add => UpdatedHandler.Add(value);
|
||||
remove => UpdatedHandler.Remove(value);
|
||||
}
|
||||
|
||||
internal static Event<int> UpdatedHandler = new();
|
||||
|
||||
private static Color HsbToRgb(float hue, float saturation = 1, float brightness = 1)
|
||||
{
|
||||
int r = 0, g = 0, b = 0;
|
||||
if (saturation == 0)
|
||||
|
||||
@@ -148,6 +148,8 @@ namespace Ryujinx.Input.SDL2
|
||||
{
|
||||
if (disposing && _gamepadHandle != nint.Zero)
|
||||
{
|
||||
Rainbow.Updated -= RainbowColorChanged;
|
||||
|
||||
SDL_GameControllerClose(_gamepadHandle);
|
||||
|
||||
_gamepadHandle = nint.Zero;
|
||||
@@ -232,6 +234,8 @@ namespace Ryujinx.Input.SDL2
|
||||
|
||||
SetLed((uint)packedRgb);
|
||||
}
|
||||
|
||||
private bool _rainbowColorEnabled;
|
||||
|
||||
public void SetConfiguration(InputConfig configuration)
|
||||
{
|
||||
@@ -243,13 +247,20 @@ namespace Ryujinx.Input.SDL2
|
||||
{
|
||||
if (_configuration.Led.TurnOffLed)
|
||||
(this as IGamepad).ClearLed();
|
||||
else if (_configuration.Led.UseRainbow)
|
||||
Rainbow.RainbowColorUpdated += RainbowColorChanged;
|
||||
else
|
||||
SetLed(_configuration.Led.LedColor);
|
||||
else switch (_configuration.Led.UseRainbow)
|
||||
{
|
||||
case true when !_rainbowColorEnabled:
|
||||
Rainbow.Updated += RainbowColorChanged;
|
||||
_rainbowColorEnabled = true;
|
||||
break;
|
||||
case false when _rainbowColorEnabled:
|
||||
Rainbow.Updated -= RainbowColorChanged;
|
||||
_rainbowColorEnabled = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!_configuration.Led.UseRainbow)
|
||||
Rainbow.RainbowColorUpdated -= RainbowColorChanged;
|
||||
if (!_configuration.Led.TurnOffLed && !_rainbowColorEnabled)
|
||||
SetLed(_configuration.Led.LedColor);
|
||||
}
|
||||
|
||||
_buttonsUserMapping.Clear();
|
||||
|
||||
@@ -168,8 +168,6 @@ namespace Ryujinx.SDL2.Common
|
||||
HandleSDLEvent(ref evnt);
|
||||
}
|
||||
});
|
||||
|
||||
Rainbow.Tick();
|
||||
|
||||
waitHandle.Wait(WaitTimeMs);
|
||||
}
|
||||
|
||||
@@ -501,6 +501,8 @@ namespace Ryujinx.Ava
|
||||
_renderingThread.Start();
|
||||
|
||||
_viewModel.Volume = ConfigurationState.Instance.System.AudioVolume.Value;
|
||||
|
||||
Rainbow.Enable();
|
||||
|
||||
MainLoop();
|
||||
|
||||
@@ -590,7 +592,11 @@ namespace Ryujinx.Ava
|
||||
foreach (IGamepad gamepad in RyujinxApp.MainWindow.InputManager.GamepadDriver.GetGamepads())
|
||||
{
|
||||
gamepad?.ClearLed();
|
||||
gamepad?.Dispose();
|
||||
}
|
||||
|
||||
Rainbow.Disable();
|
||||
Rainbow.Reset();
|
||||
|
||||
_isStopped = true;
|
||||
Stop();
|
||||
|
||||
Reference in New Issue
Block a user