mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Device providers - Let's actually include the SDKs!
Core - Enable exceptions during device provider init so that they can be logged
This commit is contained in:
1 parent
15bac30362
commit
fbc9d20db7
13 files changed
+89
-24
No files matched your search
@@ -1,19 +1,26 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using HidSharp;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.Logitech;
|
||||
using Serilog;
|
||||
using Serilog.Events;
|
||||
|
||||
namespace Artemis.Plugins.Devices.Logitech
|
||||
{
|
||||
public class LogitechDeviceProvider : DeviceProvider
|
||||
{
|
||||
private const int VENDOR_ID = 0x046D;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IRgbService _rgbService;
|
||||
|
||||
public LogitechDeviceProvider(PluginInfo pluginInfo, IRgbService rgbService) : base(pluginInfo, RGB.NET.Devices.Logitech.LogitechDeviceProvider.Instance)
|
||||
public LogitechDeviceProvider(PluginInfo pluginInfo, IRgbService rgbService, ILogger logger) : base(pluginInfo, RGB.NET.Devices.Logitech.LogitechDeviceProvider.Instance)
|
||||
{
|
||||
_rgbService = rgbService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public override void EnablePlugin()
|
||||
@@ -22,6 +29,9 @@ namespace Artemis.Plugins.Devices.Logitech
|
||||
RGB.NET.Devices.Logitech.LogitechDeviceProvider.PossibleX64NativePaths.Add(Path.Combine(PluginInfo.Directory.FullName, "x64", "LogitechLedEnginesWrapper.dll"));
|
||||
RGB.NET.Devices.Logitech.LogitechDeviceProvider.PossibleX86NativePaths.Add(Path.Combine(PluginInfo.Directory.FullName, "x86", "LogitechLedEnginesWrapper.dll"));
|
||||
_rgbService.AddDeviceProvider(RgbDeviceProvider);
|
||||
|
||||
if (_logger.IsEnabled(LogEventLevel.Debug))
|
||||
LogDeviceIds();
|
||||
}
|
||||
|
||||
public override void DisablePlugin()
|
||||
@@ -31,5 +41,13 @@ namespace Artemis.Plugins.Devices.Logitech
|
||||
public override void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
private void LogDeviceIds()
|
||||
{
|
||||
var devices = DeviceList.Local.GetHidDevices(VENDOR_ID).ToList();
|
||||
_logger.Debug("Found {count} Logitech device(s)", devices.Count);
|
||||
foreach (var hidDevice in devices)
|
||||
_logger.Debug("Found Logitech device {name} with PID {pid}", hidDevice.GetFriendlyName(), hidDevice.ProductID);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user