Updated device providers to make everything compile again

This commit is contained in:
DarthAffe committed 2021-02-01 23:13:15 +01:00
1 parent 6619539176
commit 57dc9afb32
67 files changed
+190 -661

No files matched your search

@@ -1,5 +1,4 @@
using System.Linq;
using RGB.NET.Core;
using RGB.NET.Core;
namespace RGB.NET.Devices.Logitech
{
@@ -45,31 +44,11 @@ namespace RGB.NET.Devices.Logitech
/// <summary>
/// Initializes the device.
/// </summary>
public void Initialize(UpdateQueue updateQueue)
public virtual void Initialize(UpdateQueue updateQueue)
{
InitializeLayout();
if (Size == Size.Invalid)
{
Rectangle ledRectangle = new Rectangle(this.Select(x => x.LedRectangle));
Size = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
}
UpdateQueue = updateQueue;
}
/// <summary>
/// Initializes the <see cref="Led"/> and <see cref="Size"/> of the device.
/// </summary>
protected virtual void InitializeLayout()
{
if (!(DeviceInfo is LogitechRGBDeviceInfo info)) return;
string layout = info.ImageLayout;
string layoutPath = info.LayoutPath;
ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Logitech", $"{layoutPath}.xml"), layout, true);
}
/// <inheritdoc />
public override void Dispose()
{
@@ -1,5 +1,4 @@
using System;
using RGB.NET.Core;
using RGB.NET.Core;
namespace RGB.NET.Devices.Logitech
{
@@ -23,24 +22,8 @@ namespace RGB.NET.Devices.Logitech
/// <inheritdoc />
public string Model { get; }
/// <inheritdoc />
public Uri Image { get; set; }
public object? LayoutMetadata { get; set; }
/// <inheritdoc />
public RGBDeviceLighting Lighting
{
get
{
if (DeviceCaps.HasFlag(LogitechDeviceCaps.PerKeyRGB))
return RGBDeviceLighting.Key;
if (DeviceCaps.HasFlag(LogitechDeviceCaps.DeviceRGB))
return RGBDeviceLighting.Device;
return RGBDeviceLighting.None;
}
}
/// <summary>
/// Gets a flag that describes device capabilities. (<see cref="LogitechDeviceCaps" />)
/// </summary>
@@ -1,24 +0,0 @@
using RGB.NET.Core;
namespace RGB.NET.Devices.Logitech
{
/// <summary>
/// Represents a device provider loaded used to dynamically load logitech devices into an application.
/// </summary>
public class LogitechDeviceProviderLoader : IRGBDeviceProviderLoader
{
#region Properties & Fields
/// <inheritdoc />
public bool RequiresInitialization => false;
#endregion
#region Methods
/// <inheritdoc />
public IRGBDeviceProvider GetDeviceProvider() => LogitechDeviceProvider.Instance;
#endregion
}
}
@@ -26,16 +26,14 @@ namespace RGB.NET.Devices.Logitech
#region Methods
/// <inheritdoc />
protected override void InitializeLayout()
public override void Initialize(UpdateQueue updateQueue)
{
base.InitializeLayout();
base.Initialize(updateQueue);
if (LedMapping.Count == 0)
InitializeLed(LedId.Custom1, new Rectangle(0, 0, 10, 10));
AddLed(LedId.Custom1, new Point(0, 0), new Size(10, 10));
}
/// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) => (ledId, LogitechLedId.DEVICE);
protected override object? GetLedCustomData(LedId ledId) => (ledId, LogitechLedId.DEVICE);
/// <inheritdoc />
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate) => UpdateQueue.SetData(ledsToUpdate.Where(x => x.Color.A > 0).Take(1));
@@ -26,7 +26,7 @@ namespace RGB.NET.Devices.Logitech
#region Methods
/// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) => (ledId, PerKeyIdMapping.DEFAULT.TryGetValue(ledId, out LogitechLedId logitechLedId) ? logitechLedId : LogitechLedId.Invalid);
protected override object? GetLedCustomData(LedId ledId) => (ledId, PerKeyIdMapping.DEFAULT.TryGetValue(ledId, out LogitechLedId logitechLedId) ? logitechLedId : LogitechLedId.Invalid);
/// <inheritdoc />
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate) => UpdateQueue.SetData(ledsToUpdate.Where(x => x.Color.A > 0));
@@ -47,16 +47,16 @@ namespace RGB.NET.Devices.Logitech
#region Methods
/// <inheritdoc />
protected override void InitializeLayout()
public override void Initialize(UpdateQueue updateQueue)
{
for (int i = 0; i < DeviceInfo.Zones; i++)
InitializeLed(_baseLedId + i, new Rectangle(i * 10, 0, 10, 10));
base.Initialize(updateQueue);
base.InitializeLayout();
for (int i = 0; i < DeviceInfo.Zones; i++)
AddLed(_baseLedId + i, new Point(i * 10, 0), new Size(10, 10));
}
/// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) => (int)(ledId - _baseLedId);
protected override object? GetLedCustomData(LedId ledId) => (int)(ledId - _baseLedId);
/// <inheritdoc />
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate) => UpdateQueue.SetData(ledsToUpdate.Where(x => x.Color.A > 0));