Added Corsair support as a plugin

This commit is contained in:
SpoinkyNL committed 2019-08-11 16:58:43 +02:00
1 parent 1146de1fc5
commit 090c726880
25 files changed
+302 -131

No files matched your search

+1 -2
View File
@@ -40,7 +40,6 @@ namespace Artemis.Core.Services
// Initialize the services
await Task.Run(() => _pluginService.LoadPlugins());
await _rgbService.LoadDevices();
OnInitialized();
}
@@ -61,7 +60,7 @@ namespace Artemis.Core.Services
// Render all active modules
using (var g = _rgbService.GraphicsDecorator.GetGraphics())
{
g.Clear(Color.Red);
g.Clear(Color.Black);
foreach (var module in modules)
module.Render(args.DeltaTime, _rgbService.Surface, g);
@@ -1,5 +1,4 @@
using System;
using System.Threading.Tasks;
using Artemis.Core.Events;
using Artemis.Core.RGB.NET;
using RGB.NET.Core;
@@ -8,10 +7,9 @@ namespace Artemis.Core.Services.Interfaces
{
public interface IRgbService : IArtemisService
{
bool LoadingDevices { get; }
RGBSurface Surface { get; set; }
GraphicsDecorator GraphicsDecorator { get; }
Task LoadDevices();
void AddDeviceProvider(IRGBDeviceProvider deviceProvider);
void Dispose();
/// <summary>
@@ -23,15 +21,5 @@ namespace Artemis.Core.Services.Interfaces
/// Occurs when a single device has reloaded
/// </summary>
event EventHandler<DeviceEventArgs> DeviceReloaded;
/// <summary>
/// Occurs when loading all devices has started
/// </summary>
event EventHandler StartingLoadingDevices;
/// <summary>
/// Occurs when loading all devices has finished
/// </summary>
event EventHandler FinishedLoadedDevices;
}
}
+22 -56
View File
@@ -6,7 +6,6 @@ using Artemis.Core.RGB.NET;
using Artemis.Core.Services.Interfaces;
using RGB.NET.Brushes;
using RGB.NET.Core;
using RGB.NET.Devices.Corsair;
using RGB.NET.Groups;
namespace Artemis.Core.Services
@@ -39,49 +38,30 @@ namespace Artemis.Core.Services
public RGBSurface Surface { get; set; }
public GraphicsDecorator GraphicsDecorator { get; private set; }
/// <inheritdoc />
public async Task LoadDevices()
public void AddDeviceProvider(IRGBDeviceProvider deviceProvider)
{
OnStartedLoadingDevices();
Surface.LoadDevices(deviceProvider);
Surface.AlignDevices();
await Task.Run(() =>
{
// TODO SpoinkyNL 8-1-18: Keep settings into account
// This one doesn't work well without ASUS devices installed
// Surface.LoadDevices(AsusDeviceProvider.Instance);
// Surface.LoadDevices(CoolerMasterDeviceProvider.Instance);
Surface.LoadDevices(CorsairDeviceProvider.Instance);
// Surface.LoadDevices(DMXDeviceProvider.Instance);
// Surface.LoadDevices(LogitechDeviceProvider.Instance);
// Surface.LoadDevices(MsiDeviceProvider.Instance);
// Surface.LoadDevices(NovationDeviceProvider.Instance);
// Surface.LoadDevices(RazerDeviceProvider.Instance);
lock (_loadedDevices)
{
foreach (var surfaceDevice in deviceProvider.Devices)
{
if (!_loadedDevices.Contains(surfaceDevice))
{
_loadedDevices.Add(surfaceDevice);
OnDeviceLoaded(new DeviceEventArgs(surfaceDevice));
}
else
OnDeviceReloaded(new DeviceEventArgs(surfaceDevice));
}
}
// TODO SpoinkyNL 8-1-18: Load alignment
Surface.AlignDevices();
lock (_loadedDevices)
{
foreach (var surfaceDevice in Surface.Devices)
{
if (!_loadedDevices.Contains(surfaceDevice))
{
_loadedDevices.Add(surfaceDevice);
OnDeviceLoaded(new DeviceEventArgs(surfaceDevice));
}
else
OnDeviceReloaded(new DeviceEventArgs(surfaceDevice));
}
}
});
// Apply the application wide brush and decorator
var background = new ListLedGroup(Surface.Leds) {Brush = new SolidColorBrush(new Color(255, 255, 255, 255))};
GraphicsDecorator = new GraphicsDecorator(background);
background.Brush.AddDecorator(GraphicsDecorator);
OnFinishedLoadedDevices();
// Apply the application wide brush and decorator
var background = new ListLedGroup(Surface.Leds) { Brush = new SolidColorBrush(new Color(255, 255, 255, 255)) };
GraphicsDecorator = new GraphicsDecorator(background);
background.Brush.AddDecorator(GraphicsDecorator);
}
public void Dispose()
@@ -101,8 +81,6 @@ namespace Artemis.Core.Services
public event EventHandler<DeviceEventArgs> DeviceLoaded;
public event EventHandler<DeviceEventArgs> DeviceReloaded;
public event EventHandler StartingLoadingDevices;
public event EventHandler FinishedLoadedDevices;
private void OnDeviceLoaded(DeviceEventArgs e)
{
@@ -113,19 +91,7 @@ namespace Artemis.Core.Services
{
DeviceReloaded?.Invoke(this, e);
}
private void OnStartedLoadingDevices()
{
LoadingDevices = true;
StartingLoadingDevices?.Invoke(this, EventArgs.Empty);
}
private void OnFinishedLoadedDevices()
{
LoadingDevices = false;
FinishedLoadedDevices?.Invoke(this, EventArgs.Empty);
}
#endregion
}
}