diff --git a/src/Artemis.Plugins.LayerBrushes.Chroma/Artemis.Plugins.LayerBrushes.Chroma.csproj b/src/Artemis.Plugins.LayerBrushes.Chroma/Artemis.Plugins.LayerBrushes.Chroma.csproj index a651733..e03a3b5 100644 --- a/src/Artemis.Plugins.LayerBrushes.Chroma/Artemis.Plugins.LayerBrushes.Chroma.csproj +++ b/src/Artemis.Plugins.LayerBrushes.Chroma/Artemis.Plugins.LayerBrushes.Chroma.csproj @@ -8,7 +8,7 @@ - + diff --git a/src/Artemis.Plugins.LayerBrushes.Chroma/LayerBrushes/ChromaLayerBrush.cs b/src/Artemis.Plugins.LayerBrushes.Chroma/LayerBrushes/ChromaLayerBrush.cs index ca9ac6c..86cf273 100644 --- a/src/Artemis.Plugins.LayerBrushes.Chroma/LayerBrushes/ChromaLayerBrush.cs +++ b/src/Artemis.Plugins.LayerBrushes.Chroma/LayerBrushes/ChromaLayerBrush.cs @@ -43,10 +43,10 @@ public override void DisableLayerBrush() _chroma.AppListUpdated -= OnAppListUpdated; } - private void OnMatrixUpdated(object? sender, RzDeviceType deviceType) + private void OnMatrixUpdated(object? sender, MatrixUpdatedEventArgs e) { + var (deviceType, matrix) = e; var dict = DefaultChromaLedMap.GetDeviceMap(deviceType); - var matrix = _chroma.Matrices[(int) deviceType]; lock (_lock) { diff --git a/src/Artemis.Plugins.LayerBrushes.Chroma/Module/ChromaModule.cs b/src/Artemis.Plugins.LayerBrushes.Chroma/Module/ChromaModule.cs index 5dcb801..e9b219b 100644 --- a/src/Artemis.Plugins.LayerBrushes.Chroma/Module/ChromaModule.cs +++ b/src/Artemis.Plugins.LayerBrushes.Chroma/Module/ChromaModule.cs @@ -66,9 +66,9 @@ private void OnAppListUpdated(object? sender, EventArgs args) DataModel.PidList = _chroma.AppIds.Select(p => (int)p).ToList(); } - private void OnMatrixUpdated(object? sender, RzDeviceType deviceType) + private void OnMatrixUpdated(object? sender, MatrixUpdatedEventArgs e) { - var colors = _chroma.Matrices[(int)deviceType]; + var (deviceType, colors) = e; var map = DefaultChromaLedMap.GetDeviceMap(deviceType); diff --git a/src/Artemis.Plugins.LayerBrushes.Chroma/Services/ChromaService.cs b/src/Artemis.Plugins.LayerBrushes.Chroma/Services/ChromaService.cs index 2cd3da0..b59a3c5 100644 --- a/src/Artemis.Plugins.LayerBrushes.Chroma/Services/ChromaService.cs +++ b/src/Artemis.Plugins.LayerBrushes.Chroma/Services/ChromaService.cs @@ -2,13 +2,14 @@ using SkiaSharp; using System; using System.Collections.Generic; -using System.Runtime.InteropServices; using Artemis.Core; using RazerSdkReader; using RazerSdkReader.Structures; namespace Artemis.Plugins.LayerBrushes.Chroma.Services; +public readonly record struct MatrixUpdatedEventArgs(RzDeviceType DeviceType, SKColor[] Matrix); + public sealed class ChromaService : IPluginService, IDisposable { private readonly SKColor[][] _matrices; @@ -18,23 +19,21 @@ public sealed class ChromaService : IPluginService, IDisposable private readonly Profiler _profiler; private readonly object _lock; - public event EventHandler? MatrixUpdated; + public event EventHandler? MatrixUpdated; public event EventHandler? AppListUpdated; public bool IsActive => !string.IsNullOrWhiteSpace(CurrentApp) && CurrentApp != "Artemis.UI.Windows.exe"; public string? CurrentApp { get; private set; } public uint? CurrentAppId { get; private set; } public IEnumerable AppNames => _apps; - public IEnumerable AppIds => _pids; - - public SKColor[][] Matrices => _matrices; - + public IEnumerable AppIds => _pids; + public ChromaService(Plugin plugin) { _profiler = plugin.GetProfiler("Chroma Service"); _lock = new object(); - _apps = new(); - _pids = new(); + _apps = []; + _pids = []; var deviceTypes = Enum.GetValues(); _matrices = new SKColor[deviceTypes.Length][]; @@ -85,7 +84,7 @@ private void UpdateMatrix(RzDeviceType deviceType, in T data) where T : ICol matrix[i] = new SKColor(rzColor.R, rzColor.G, rzColor.B); } - MatrixUpdated?.Invoke(this, deviceType); + MatrixUpdated?.Invoke(this, new MatrixUpdatedEventArgs(deviceType, matrix)); } _profiler.StopMeasurement(profilerName); diff --git a/src/Artemis.Plugins.LayerBrushes.Chroma/plugin.json b/src/Artemis.Plugins.LayerBrushes.Chroma/plugin.json index 83d6ac6..1a669ec 100644 --- a/src/Artemis.Plugins.LayerBrushes.Chroma/plugin.json +++ b/src/Artemis.Plugins.LayerBrushes.Chroma/plugin.json @@ -5,7 +5,7 @@ "Author": "diogotr7", "Icon": "Snake", "Description": "Provides a layer that displays lighting from Razer Chroma supported games on all devices Artemis supports.", - "Version": "1.1.0.0", + "Version": "1.2.0.0", "Main": "Artemis.Plugins.LayerBrushes.Chroma.dll", "Platforms": "Windows" } \ No newline at end of file