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:
Robert committed 2020-03-02 23:42:33 +01:00
1 parent c3b2c981da
commit 16b221d2f8
13 files changed
+89 -24

No files matched your search

@@ -28,6 +28,9 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="HidSharp" Version="2.1.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Artemis.Core\Artemis.Core.csproj" />
</ItemGroup>
@@ -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);
}
}
}