1
0
mirror of https://github.com/DarthAffe/RGB.NET.git synced 2025-12-13 10:08:31 +00:00

Updated device providers to make everything compile again

This commit is contained in:
Darth Affe 2021-02-01 23:13:15 +01:00
parent 6619539176
commit 57dc9afb32
67 changed files with 190 additions and 661 deletions

View File

@ -172,7 +172,7 @@ namespace RGB.NET.Core
{ {
if ((ledId == LedId.Invalid) || LedMapping.ContainsKey(ledId)) return null; if ((ledId == LedId.Invalid) || LedMapping.ContainsKey(ledId)) return null;
Led led = new(this, ledId, location, size, customData); Led led = new(this, ledId, location, size, customData ?? GetLedCustomData(ledId));
LedMapping.Add(ledId, led); LedMapping.Add(ledId, led);
return led; return led;
} }
@ -186,6 +186,8 @@ namespace RGB.NET.Core
return led; return led;
} }
protected virtual object? GetLedCustomData(LedId ledId) => null;
#region Enumerator #region Enumerator
/// <inheritdoc /> /// <inheritdoc />

View File

@ -1,24 +0,0 @@
using RGB.NET.Core;
namespace RGB.NET.Devices.Asus
{
/// <summary>
/// Represents a device provider loaded used to dynamically load asus devices into an application.
/// </summary>
public class AsusDeviceProviderLoader : IRGBDeviceProviderLoader
{
#region Properties & Fields
/// <inheritdoc />
public bool RequiresInitialization => false;
#endregion
#region Methods
/// <inheritdoc />
public IRGBDeviceProvider GetDeviceProvider() => AsusDeviceProvider.Instance;
#endregion
}
}

View File

@ -26,18 +26,13 @@ namespace RGB.NET.Devices.Asus
/// <inheritdoc /> /// <inheritdoc />
protected override void InitializeLayout() protected override void InitializeLayout()
{ {
//TODO DarthAffe 07.10.2017: Look for a good default layout
int ledCount = DeviceInfo.Device.Lights.Count; int ledCount = DeviceInfo.Device.Lights.Count;
for (int i = 0; i < ledCount; i++) for (int i = 0; i < ledCount; i++)
InitializeLed(LedId.DRAM1 + i, new Rectangle(i * 10, 0, 10, 10)); AddLed(LedId.DRAM1 + i, new Point(i * 10, 0), new Size(10, 10));
//TODO DarthAffe 21.10.2017: We don't know the model, how to save layouts and images?
//TODO DarthAffe 07.10.2017: We don't know the model, how to save layouts and images?
ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Asus\Drams", $"{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null);
} }
/// <inheritdoc /> /// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.DRAM1; protected override object? GetLedCustomData(LedId ledId) => (int)ledId - (int)LedId.DRAM1;
#endregion #endregion
} }

View File

@ -1,5 +1,4 @@
using System; using AuraServiceLib;
using AuraServiceLib;
using RGB.NET.Core; using RGB.NET.Core;
namespace RGB.NET.Devices.Asus namespace RGB.NET.Devices.Asus
@ -24,11 +23,7 @@ namespace RGB.NET.Devices.Asus
/// <inheritdoc /> /// <inheritdoc />
public string Model { get; } public string Model { get; }
/// <inheritdoc /> public object? LayoutMetadata { get; set; }
public Uri Image { get; set; }
/// <inheritdoc />
public RGBDeviceLighting Lighting => RGBDeviceLighting.Key;
public IAuraSyncDevice Device { get; } public IAuraSyncDevice Device { get; }

View File

@ -36,14 +36,11 @@ namespace RGB.NET.Devices.Asus
{ {
int ledCount = DeviceInfo.Device.Lights.Count; int ledCount = DeviceInfo.Device.Lights.Count;
for (int i = 0; i < ledCount; i++) for (int i = 0; i < ledCount; i++)
InitializeLed(_baseLedId + i, new Rectangle(i * 10, 0, 10, 10)); AddLed(_baseLedId + i, new Point(i * 10, 0), new Size(10, 10));
//TODO DarthAffe 19.05.2019: Add a way to define a layout for this kind of devies
} }
/// <inheritdoc /> /// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)_baseLedId; protected override object? GetLedCustomData(LedId ledId) => (int)ledId - (int)_baseLedId;
#endregion #endregion
} }
} }

View File

@ -26,17 +26,13 @@ namespace RGB.NET.Devices.Asus
/// <inheritdoc /> /// <inheritdoc />
protected override void InitializeLayout() protected override void InitializeLayout()
{ {
//TODO DarthAffe 07.10.2017: Look for a good default layout
int ledCount = DeviceInfo.Device.Lights.Count; int ledCount = DeviceInfo.Device.Lights.Count;
for (int i = 0; i < ledCount; i++) for (int i = 0; i < ledCount; i++)
InitializeLed(LedId.GraphicsCard1 + i, new Rectangle(i * 10, 0, 10, 10)); AddLed(LedId.GraphicsCard1 + i, new Point(i * 10, 0), new Size(10, 10));
//TODO DarthAffe 07.10.2017: We don't know the model, how to save layouts and images?
ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Asus\GraphicsCards", $"{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null);
} }
/// <inheritdoc /> /// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.GraphicsCard1; protected override object? GetLedCustomData(LedId ledId) => (int)ledId - (int)LedId.GraphicsCard1;
#endregion #endregion
} }

View File

@ -26,17 +26,13 @@ namespace RGB.NET.Devices.Asus
/// <inheritdoc /> /// <inheritdoc />
protected override void InitializeLayout() protected override void InitializeLayout()
{ {
//TODO DarthAffe 07.10.2017: Look for a good default layout
int ledCount = DeviceInfo.Device.Lights.Count; int ledCount = DeviceInfo.Device.Lights.Count;
for (int i = 0; i < ledCount; i++) for (int i = 0; i < ledCount; i++)
InitializeLed(LedId.Headset1 + i, new Rectangle(i * 40, 0, 40, 8)); AddLed(LedId.Headset1 + i, new Point(i * 40, 0), new Size(40, 8));
//TODO DarthAffe 07.10.2017: We don't know the model, how to save layouts and images?
ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Asus\Headsets", $"{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null);
} }
/// <inheritdoc /> /// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Headset1; protected override object? GetLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Headset1;
#endregion #endregion
} }

View File

@ -35,26 +35,23 @@ namespace RGB.NET.Devices.Asus
{ {
int pos = 0; int pos = 0;
foreach (IAuraRgbKey key in ((IAuraSyncKeyboard)DeviceInfo.Device).Keys) foreach (IAuraRgbKey key in ((IAuraSyncKeyboard)DeviceInfo.Device).Keys)
InitializeLed(reversedMapping[(AsusLedId)key.Code], new Point(pos++ * 19, 0), new Size(19, 19)); AddLed(reversedMapping[(AsusLedId)key.Code], new Point(pos++ * 19, 0), new Size(19, 19));
//UK Layout //UK Layout
InitializeLed(reversedMapping[AsusLedId.KEY_OEM_102], new Point(pos++ * 19, 0), new Size(19, 19)); AddLed(reversedMapping[AsusLedId.KEY_OEM_102], new Point(pos++ * 19, 0), new Size(19, 19));
InitializeLed(reversedMapping[AsusLedId.UNDOCUMENTED_1], new Point(pos * 19, 0), new Size(19, 19)); AddLed(reversedMapping[AsusLedId.UNDOCUMENTED_1], new Point(pos * 19, 0), new Size(19, 19));
} }
else else
{ {
int ledCount = DeviceInfo.Device.Lights.Count; int ledCount = DeviceInfo.Device.Lights.Count;
for (int i = 0; i < ledCount; i++) for (int i = 0; i < ledCount; i++)
InitializeLed(LedId.Keyboard_Custom1 + i, new Point(i * 19, 0), new Size(19, 19)); AddLed(LedId.Keyboard_Custom1 + i, new Point(i * 19, 0), new Size(19, 19));
} }
string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper();
ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, $@"Layouts\Asus\Keyboards\{model}", $"{DeviceInfo.PhysicalLayout.ToString().ToUpper()}.xml"), DeviceInfo.LogicalLayout.ToString());
} }
/// <inheritdoc /> /// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) protected override object? GetLedCustomData(LedId ledId)
{ {
if (DeviceInfo.Device.Type == (uint)AsusDeviceType.NB_KB_4ZONE_RGB) if (DeviceInfo.Device.Type == (uint)AsusDeviceType.NB_KB_4ZONE_RGB)
return ledId - LedId.Keyboard_Custom1; return ledId - LedId.Keyboard_Custom1;

View File

@ -26,17 +26,13 @@ namespace RGB.NET.Devices.Asus
/// <inheritdoc /> /// <inheritdoc />
protected override void InitializeLayout() protected override void InitializeLayout()
{ {
//TODO DarthAffe 07.10.2017: Look for a good default layout
int ledCount = DeviceInfo.Device.Lights.Count; int ledCount = DeviceInfo.Device.Lights.Count;
for (int i = 0; i < ledCount; i++) for (int i = 0; i < ledCount; i++)
InitializeLed(LedId.Mainboard1 + i, new Rectangle(i * 40, 0, 40, 8)); AddLed(LedId.Mainboard1 + i, new Point(i * 40, 0), new Size(40, 8));
//TODO DarthAffe 07.10.2017: We don't know the model, how to save layouts and images?
ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Asus\Mainboards", $"{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null);
} }
/// <inheritdoc /> /// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Mainboard1; protected override object? GetLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Mainboard1;
#endregion #endregion
} }

View File

@ -26,16 +26,13 @@ namespace RGB.NET.Devices.Asus
/// <inheritdoc /> /// <inheritdoc />
protected override void InitializeLayout() protected override void InitializeLayout()
{ {
//TODO DarthAffe 07.10.2017: Look for a good default layout
int ledCount = DeviceInfo.Device.Lights.Count; int ledCount = DeviceInfo.Device.Lights.Count;
for (int i = 0; i < ledCount; i++) for (int i = 0; i < ledCount; i++)
InitializeLed(LedId.Mouse1 + i, new Rectangle(i * 10, 0, 10, 10)); AddLed(LedId.Mouse1 + i, new Point(i * 10, 0), new Size(10, 10));
ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Asus\Mouses", $"{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null);
} }
/// <inheritdoc /> /// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Mouse1; protected override object? GetLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Mouse1;
#endregion #endregion
} }

View File

@ -1,24 +0,0 @@
using RGB.NET.Core;
namespace RGB.NET.Devices.CoolerMaster
{
/// <summary>
/// Represents a device provider loaded used to dynamically load cooler-master devices into an application.
/// </summary>
public class CoolerMasterDeviceProviderLoader : IRGBDeviceProviderLoader
{
#region Properties & Fields
/// <inheritdoc />
public bool RequiresInitialization => false;
#endregion
#region Methods
/// <inheritdoc />
public IRGBDeviceProvider GetDeviceProvider() => CoolerMasterDeviceProvider.Instance;
#endregion
}
}

View File

@ -24,11 +24,7 @@ namespace RGB.NET.Devices.CoolerMaster
/// <inheritdoc /> /// <inheritdoc />
public string Model { get; } public string Model { get; }
/// <inheritdoc /> public object? LayoutMetadata { get; set; }
public Uri Image { get; set; }
/// <inheritdoc />
public RGBDeviceLighting Lighting => RGBDeviceLighting.Key;
/// <summary> /// <summary>
/// Gets the <see cref="CoolerMasterDevicesIndexes"/> of the <see cref="CoolerMasterRGBDevice{TDeviceInfo}"/>. /// Gets the <see cref="CoolerMasterDevicesIndexes"/> of the <see cref="CoolerMasterRGBDevice{TDeviceInfo}"/>.

View File

@ -33,15 +33,11 @@ namespace RGB.NET.Devices.CoolerMaster
throw new RGBDeviceException($"Failed to find a CoolerMasterKeyboardLedMapping for device index {DeviceInfo.DeviceIndex} with physical layout {DeviceInfo.PhysicalLayout}"); throw new RGBDeviceException($"Failed to find a CoolerMasterKeyboardLedMapping for device index {DeviceInfo.DeviceIndex} with physical layout {DeviceInfo.PhysicalLayout}");
foreach (KeyValuePair<LedId, (int row, int column)> led in mapping) foreach (KeyValuePair<LedId, (int row, int column)> led in mapping)
InitializeLed(led.Key, new Rectangle(led.Value.column * 19, led.Value.row * 19, 19, 19)); AddLed(led.Key, new Point(led.Value.column * 19, led.Value.row * 19), new Size(19, 19));
string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper();
ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, $@"Layouts\CoolerMaster\Keyboards\{model}", $"{DeviceInfo.PhysicalLayout.ToString().ToUpper()}.xml"),
DeviceInfo.LogicalLayout.ToString());
} }
/// <inheritdoc /> /// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) => CoolerMasterKeyboardLedMappings.Mapping[DeviceInfo.DeviceIndex][DeviceInfo.PhysicalLayout][ledId]; protected override object GetLedCustomData(LedId ledId) => CoolerMasterKeyboardLedMappings.Mapping[DeviceInfo.DeviceIndex][DeviceInfo.PhysicalLayout][ledId];
#endregion #endregion
} }

View File

@ -30,14 +30,11 @@ namespace RGB.NET.Devices.CoolerMaster
Dictionary<LedId, (int row, int column)> mapping = CoolerMasterMouseLedMappings.Mapping[DeviceInfo.DeviceIndex]; Dictionary<LedId, (int row, int column)> mapping = CoolerMasterMouseLedMappings.Mapping[DeviceInfo.DeviceIndex];
foreach (KeyValuePair<LedId, (int row, int column)> led in mapping) foreach (KeyValuePair<LedId, (int row, int column)> led in mapping)
InitializeLed(led.Key, new Rectangle(led.Value.column * 19, led.Value.row * 19, 19, 19)); AddLed(led.Key, new Point(led.Value.column * 19, led.Value.row * 19), new Size(19, 19));
string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper();
ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\CoolerMaster\Mice", $"{model}.xml"), null);
} }
/// <inheritdoc /> /// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) => CoolerMasterMouseLedMappings.Mapping[DeviceInfo.DeviceIndex][ledId]; protected override object GetLedCustomData(LedId ledId) => CoolerMasterMouseLedMappings.Mapping[DeviceInfo.DeviceIndex][ledId];
#endregion #endregion
} }

View File

@ -42,15 +42,11 @@ namespace RGB.NET.Devices.Corsair
{ {
LedId ledId = referenceId + i; LedId ledId = referenceId + i;
_idMapping.Add(ledId, DeviceInfo.ReferenceCorsairLed + i); _idMapping.Add(ledId, DeviceInfo.ReferenceCorsairLed + i);
InitializeLed(ledId, new Rectangle(i * 10, 0, 10, 10)); AddLed(ledId, new Point(i * 10, 0), new Size(10, 10));
}
} }
string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); protected override object? GetLedCustomData(LedId ledId) => _idMapping.TryGetValue(ledId, out CorsairLedId id) ? id : CorsairLedId.Invalid;
ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Corsair\Customs", $"{model}.xml"), null);
}
/// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) => _idMapping.TryGetValue(ledId, out CorsairLedId id) ? id : CorsairLedId.Invalid;
protected virtual LedId GetReferenceLed(RGBDeviceType deviceType) protected virtual LedId GetReferenceLed(RGBDeviceType deviceType)
{ {

View File

@ -37,11 +37,7 @@ namespace RGB.NET.Devices.Corsair
/// <inheritdoc /> /// <inheritdoc />
public string Model { get; } public string Model { get; }
/// <inheritdoc /> public object? LayoutMetadata { get; set; }
public Uri Image { get; set; }
/// <inheritdoc />
public RGBDeviceLighting Lighting => RGBDeviceLighting.Key;
/// <summary> /// <summary>
/// Gets a flag that describes device capabilities. (<see cref="CorsairDeviceCaps" />) /// Gets a flag that describes device capabilities. (<see cref="CorsairDeviceCaps" />)
@ -64,7 +60,7 @@ namespace RGB.NET.Devices.Corsair
this.CorsairDeviceIndex = deviceIndex; this.CorsairDeviceIndex = deviceIndex;
this.DeviceType = deviceType; this.DeviceType = deviceType;
this.CorsairDeviceType = nativeInfo.type; this.CorsairDeviceType = nativeInfo.type;
this.Model = nativeInfo.model == IntPtr.Zero ? null : Regex.Replace(Marshal.PtrToStringAnsi(nativeInfo.model) ?? string.Empty, " ?DEMO", string.Empty, RegexOptions.IgnoreCase); this.Model = nativeInfo.model == IntPtr.Zero ? string.Empty : Regex.Replace(Marshal.PtrToStringAnsi(nativeInfo.model) ?? string.Empty, " ?DEMO", string.Empty, RegexOptions.IgnoreCase);
this.CapsMask = (CorsairDeviceCaps)nativeInfo.capsMask; this.CapsMask = (CorsairDeviceCaps)nativeInfo.capsMask;
DeviceName = GetUniqueModelName(modelCounter); DeviceName = GetUniqueModelName(modelCounter);
@ -95,9 +91,9 @@ namespace RGB.NET.Devices.Corsair
private string GetUniqueModelName(Dictionary<string, int> modelCounter) private string GetUniqueModelName(Dictionary<string, int> modelCounter)
{ {
if (modelCounter.TryGetValue(Model, out int counter)) if (modelCounter.TryGetValue(Model, out int _))
{ {
counter = ++modelCounter[Model]; int counter = ++modelCounter[Model];
return $"{Manufacturer} {Model} {counter}"; return $"{Manufacturer} {Model} {counter}";
} }
else else

View File

@ -29,14 +29,11 @@ namespace RGB.NET.Devices.Corsair
/// <inheritdoc /> /// <inheritdoc />
protected override void InitializeLayout() protected override void InitializeLayout()
{ {
InitializeLed(LedId.Headset1, new Rectangle(0, 0, 10, 10)); AddLed(LedId.Headset1, new Point(0, 0), new Size(10, 10));
InitializeLed(LedId.Headset2, new Rectangle(10, 0, 10, 10)); AddLed(LedId.Headset2, new Point(10, 0), new Size(10, 10));
ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Corsair\Headsets", $"{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null);
} }
/// <inheritdoc /> protected override object GetLedCustomData(LedId ledId) => HeadsetIdMapping.DEFAULT.TryGetValue(ledId, out CorsairLedId id) ? id : CorsairLedId.Invalid;
protected override object CreateLedCustomData(LedId ledId) => HeadsetIdMapping.DEFAULT.TryGetValue(ledId, out CorsairLedId id) ? id : CorsairLedId.Invalid;
#endregion #endregion
} }

View File

@ -34,28 +34,33 @@ namespace RGB.NET.Devices.Corsair
/// <inheritdoc /> /// <inheritdoc />
protected override void InitializeLayout() protected override void InitializeLayout()
{ {
_CorsairLedPositions nativeLedPositions = (_CorsairLedPositions)Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositionsByDeviceIndex(DeviceInfo.CorsairDeviceIndex), typeof(_CorsairLedPositions)); _CorsairLedPositions? nativeLedPositions = (_CorsairLedPositions?)Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositionsByDeviceIndex(DeviceInfo.CorsairDeviceIndex), typeof(_CorsairLedPositions));
if (nativeLedPositions == null) return;
int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition)); int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition));
IntPtr ptr = nativeLedPositions.pLedPosition; IntPtr ptr = nativeLedPositions.pLedPosition;
List<_CorsairLedPosition> positions = new List<_CorsairLedPosition>(); List<_CorsairLedPosition> positions = new();
for (int i = 0; i < nativeLedPositions.numberOfLed; i++) for (int i = 0; i < nativeLedPositions.numberOfLed; i++)
{ {
_CorsairLedPosition ledPosition = (_CorsairLedPosition)Marshal.PtrToStructure(ptr, typeof(_CorsairLedPosition)); _CorsairLedPosition? ledPosition = (_CorsairLedPosition?)Marshal.PtrToStructure(ptr, typeof(_CorsairLedPosition));
if (ledPosition == null) continue;
ptr = new IntPtr(ptr.ToInt64() + structSize); ptr = new IntPtr(ptr.ToInt64() + structSize);
positions.Add(ledPosition); positions.Add(ledPosition);
} }
Dictionary<CorsairLedId, LedId> mapping = HeadsetStandIdMapping.DEFAULT.SwapKeyValue(); Dictionary<CorsairLedId, LedId> mapping = HeadsetStandIdMapping.DEFAULT.SwapKeyValue();
foreach (_CorsairLedPosition ledPosition in positions.OrderBy(p => p.LedId)) foreach (_CorsairLedPosition ledPosition in positions.OrderBy(p => p.LedId))
InitializeLed(mapping.TryGetValue(ledPosition.LedId, out LedId ledId) ? ledId : LedId.Invalid, ledPosition.ToRectangle()); {
LedId ledId = mapping.TryGetValue(ledPosition.LedId, out LedId id) ? id : LedId.Invalid;
ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Corsair\HeadsetStands", $"{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); Rectangle rectangle = ledPosition.ToRectangle();
AddLed(ledId, rectangle.Location, rectangle.Size);
}
} }
/// <inheritdoc /> /// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) => HeadsetStandIdMapping.DEFAULT.TryGetValue(ledId, out CorsairLedId id) ? id : CorsairLedId.Invalid; protected override object GetLedCustomData(LedId ledId) => HeadsetStandIdMapping.DEFAULT.TryGetValue(ledId, out CorsairLedId id) ? id : CorsairLedId.Invalid;
#endregion #endregion
} }

View File

@ -33,7 +33,8 @@ namespace RGB.NET.Devices.Corsair
/// <inheritdoc /> /// <inheritdoc />
protected override void InitializeLayout() protected override void InitializeLayout()
{ {
_CorsairLedPositions nativeLedPositions = (_CorsairLedPositions)Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositionsByDeviceIndex(DeviceInfo.CorsairDeviceIndex), typeof(_CorsairLedPositions)); _CorsairLedPositions? nativeLedPositions = (_CorsairLedPositions?)Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositionsByDeviceIndex(DeviceInfo.CorsairDeviceIndex), typeof(_CorsairLedPositions));
if (nativeLedPositions == null) return;
int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition)); int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition));
IntPtr ptr = nativeLedPositions.pLedPosition; IntPtr ptr = nativeLedPositions.pLedPosition;
@ -41,19 +42,18 @@ namespace RGB.NET.Devices.Corsair
Dictionary<CorsairLedId, LedId> mapping = KeyboardIdMapping.DEFAULT.SwapKeyValue(); Dictionary<CorsairLedId, LedId> mapping = KeyboardIdMapping.DEFAULT.SwapKeyValue();
for (int i = 0; i < nativeLedPositions.numberOfLed; i++) for (int i = 0; i < nativeLedPositions.numberOfLed; i++)
{ {
_CorsairLedPosition ledPosition = (_CorsairLedPosition)Marshal.PtrToStructure(ptr, typeof(_CorsairLedPosition)); _CorsairLedPosition? ledPosition = (_CorsairLedPosition?)Marshal.PtrToStructure(ptr, typeof(_CorsairLedPosition));
InitializeLed(mapping.TryGetValue(ledPosition.LedId, out LedId ledId) ? ledId : LedId.Invalid, ledPosition.ToRectangle()); if (ledPosition == null) continue;
LedId ledId = mapping.TryGetValue(ledPosition.LedId, out LedId id) ? id : LedId.Invalid;
Rectangle rectangle = ledPosition.ToRectangle();
AddLed(ledId, rectangle.Location, rectangle.Size);
ptr = new IntPtr(ptr.ToInt64() + structSize); ptr = new IntPtr(ptr.ToInt64() + structSize);
} }
string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper();
ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, $@"Layouts\Corsair\Keyboards\{model}", $"{DeviceInfo.PhysicalLayout.ToString().ToUpper()}.xml"),
DeviceInfo.LogicalLayout.ToString());
} }
/// <inheritdoc /> protected override object GetLedCustomData(LedId ledId) => KeyboardIdMapping.DEFAULT.TryGetValue(ledId, out CorsairLedId id) ? id : CorsairLedId.Invalid;
protected override object CreateLedCustomData(LedId ledId) => KeyboardIdMapping.DEFAULT.TryGetValue(ledId, out CorsairLedId id) ? id : CorsairLedId.Invalid;
#endregion #endregion
} }

View File

@ -33,7 +33,8 @@ namespace RGB.NET.Devices.Corsair
/// <inheritdoc /> /// <inheritdoc />
protected override void InitializeLayout() protected override void InitializeLayout()
{ {
_CorsairLedPositions nativeLedPositions = (_CorsairLedPositions)Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositionsByDeviceIndex(DeviceInfo.CorsairDeviceIndex), typeof(_CorsairLedPositions)); _CorsairLedPositions? nativeLedPositions = (_CorsairLedPositions?)Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositionsByDeviceIndex(DeviceInfo.CorsairDeviceIndex), typeof(_CorsairLedPositions));
if (nativeLedPositions == null) return;
int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition)); int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition));
IntPtr ptr = nativeLedPositions.pLedPosition; IntPtr ptr = nativeLedPositions.pLedPosition;
@ -41,18 +42,18 @@ namespace RGB.NET.Devices.Corsair
Dictionary<CorsairLedId, LedId> mapping = MemoryIdMapping.DEFAULT.SwapKeyValue(); Dictionary<CorsairLedId, LedId> mapping = MemoryIdMapping.DEFAULT.SwapKeyValue();
for (int i = 0; i < nativeLedPositions.numberOfLed; i++) for (int i = 0; i < nativeLedPositions.numberOfLed; i++)
{ {
_CorsairLedPosition ledPosition = (_CorsairLedPosition)Marshal.PtrToStructure(ptr, typeof(_CorsairLedPosition)); _CorsairLedPosition? ledPosition = (_CorsairLedPosition?)Marshal.PtrToStructure(ptr, typeof(_CorsairLedPosition));
InitializeLed(mapping.TryGetValue(ledPosition.LedId, out LedId ledId) ? ledId : LedId.Invalid, ledPosition.ToRectangle()); if (ledPosition == null) continue;
LedId ledId = mapping.TryGetValue(ledPosition.LedId, out LedId id) ? id : LedId.Invalid;
Rectangle rectangle = ledPosition.ToRectangle();
AddLed(ledId, rectangle.Location, rectangle.Size);
ptr = new IntPtr(ptr.ToInt64() + structSize); ptr = new IntPtr(ptr.ToInt64() + structSize);
} }
string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper();
ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Corsair\Memory", $"{model}.xml"), null);
} }
/// <inheritdoc /> protected override object GetLedCustomData(LedId ledId) => MemoryIdMapping.DEFAULT.TryGetValue(ledId, out CorsairLedId id) ? id : CorsairLedId.Invalid;
protected override object CreateLedCustomData(LedId ledId) => MemoryIdMapping.DEFAULT.TryGetValue(ledId, out CorsairLedId id) ? id : CorsairLedId.Invalid;
#endregion #endregion
} }

View File

@ -33,32 +33,29 @@ namespace RGB.NET.Devices.Corsair
switch (DeviceInfo.PhysicalLayout) switch (DeviceInfo.PhysicalLayout)
{ {
case CorsairPhysicalMouseLayout.Zones1: case CorsairPhysicalMouseLayout.Zones1:
InitializeLed(LedId.Mouse1, new Rectangle(0, 0, 10, 10)); AddLed(LedId.Mouse1, new Point(0, 0), new Size(10, 10));
break; break;
case CorsairPhysicalMouseLayout.Zones2: case CorsairPhysicalMouseLayout.Zones2:
InitializeLed(LedId.Mouse1, new Rectangle(0, 0, 10, 10)); AddLed(LedId.Mouse1, new Point(0, 0), new Size(10, 10));
InitializeLed(LedId.Mouse2, new Rectangle(10, 0, 10, 10)); AddLed(LedId.Mouse2, new Point(10, 0), new Size(10, 10));
break; break;
case CorsairPhysicalMouseLayout.Zones3: case CorsairPhysicalMouseLayout.Zones3:
InitializeLed(LedId.Mouse1, new Rectangle(0, 0, 10, 10)); AddLed(LedId.Mouse1, new Point(0, 0), new Size(10, 10));
InitializeLed(LedId.Mouse2, new Rectangle(10, 0, 10, 10)); AddLed(LedId.Mouse2, new Point(10, 0), new Size(10, 10));
InitializeLed(LedId.Mouse3, new Rectangle(20, 0, 10, 10)); AddLed(LedId.Mouse3, new Point(20, 0), new Size(10, 10));
break; break;
case CorsairPhysicalMouseLayout.Zones4: case CorsairPhysicalMouseLayout.Zones4:
InitializeLed(LedId.Mouse1, new Rectangle(0, 0, 10, 10)); AddLed(LedId.Mouse1, new Point(0, 0), new Size(10, 10));
InitializeLed(LedId.Mouse2, new Rectangle(10, 0, 10, 10)); AddLed(LedId.Mouse2, new Point(10, 0), new Size(10, 10));
InitializeLed(LedId.Mouse3, new Rectangle(20, 0, 10, 10)); AddLed(LedId.Mouse3, new Point(20, 0), new Size(10, 10));
InitializeLed(LedId.Mouse4, new Rectangle(30, 0, 10, 10)); AddLed(LedId.Mouse4, new Point(30, 0), new Size(10, 10));
break; break;
default: default:
throw new RGBDeviceException($"Can't initialize mouse with layout '{DeviceInfo.PhysicalLayout}'"); throw new RGBDeviceException($"Can't initialize mouse with layout '{DeviceInfo.PhysicalLayout}'");
} }
ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Corsair\Mice", $"{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null);
} }
/// <inheritdoc /> protected override object? GetLedCustomData(LedId ledId)
protected override object CreateLedCustomData(LedId ledId)
{ {
if (string.Equals(DeviceInfo.Model, "GLAIVE RGB", StringComparison.OrdinalIgnoreCase)) if (string.Equals(DeviceInfo.Model, "GLAIVE RGB", StringComparison.OrdinalIgnoreCase))
return MouseIdMapping.GLAIVE.TryGetValue(ledId, out CorsairLedId id) ? id : CorsairLedId.Invalid; return MouseIdMapping.GLAIVE.TryGetValue(ledId, out CorsairLedId id) ? id : CorsairLedId.Invalid;

View File

@ -34,28 +34,32 @@ namespace RGB.NET.Devices.Corsair
/// <inheritdoc /> /// <inheritdoc />
protected override void InitializeLayout() protected override void InitializeLayout()
{ {
_CorsairLedPositions nativeLedPositions = (_CorsairLedPositions)Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositionsByDeviceIndex(DeviceInfo.CorsairDeviceIndex), typeof(_CorsairLedPositions)); _CorsairLedPositions? nativeLedPositions = (_CorsairLedPositions?)Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositionsByDeviceIndex(DeviceInfo.CorsairDeviceIndex), typeof(_CorsairLedPositions));
if (nativeLedPositions == null) return;
int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition)); int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition));
IntPtr ptr = nativeLedPositions.pLedPosition; IntPtr ptr = nativeLedPositions.pLedPosition;
List<_CorsairLedPosition> positions = new List<_CorsairLedPosition>(); List<_CorsairLedPosition> positions = new();
for (int i = 0; i < nativeLedPositions.numberOfLed; i++) for (int i = 0; i < nativeLedPositions.numberOfLed; i++)
{ {
_CorsairLedPosition ledPosition = (_CorsairLedPosition)Marshal.PtrToStructure(ptr, typeof(_CorsairLedPosition)); _CorsairLedPosition? ledPosition = (_CorsairLedPosition?)Marshal.PtrToStructure(ptr, typeof(_CorsairLedPosition));
if (ledPosition == null) continue;
ptr = new IntPtr(ptr.ToInt64() + structSize); ptr = new IntPtr(ptr.ToInt64() + structSize);
positions.Add(ledPosition); positions.Add(ledPosition);
} }
Dictionary<CorsairLedId, LedId> mapping = MousepadIdMapping.DEFAULT.SwapKeyValue(); Dictionary<CorsairLedId, LedId> mapping = MousepadIdMapping.DEFAULT.SwapKeyValue();
foreach (_CorsairLedPosition ledPosition in positions.OrderBy(p => p.LedId)) foreach (_CorsairLedPosition ledPosition in positions.OrderBy(p => p.LedId))
InitializeLed(mapping.TryGetValue(ledPosition.LedId, out LedId ledId) ? ledId : LedId.Invalid, ledPosition.ToRectangle()); {
LedId ledId = mapping.TryGetValue(ledPosition.LedId, out LedId id) ? id : LedId.Invalid;
ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Corsair\Mousepads", $"{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); Rectangle rectangle = ledPosition.ToRectangle();
AddLed(ledId, rectangle.Location, rectangle.Size);
}
} }
/// <inheritdoc /> protected override object GetLedCustomData(LedId ledId) => MousepadIdMapping.DEFAULT.TryGetValue(ledId, out CorsairLedId id) ? id : CorsairLedId.Invalid;
protected override object CreateLedCustomData(LedId ledId) => MousepadIdMapping.DEFAULT.TryGetValue(ledId, out CorsairLedId id) ? id : CorsairLedId.Invalid;
#endregion #endregion
} }

View File

@ -1,24 +0,0 @@
using RGB.NET.Core;
namespace RGB.NET.Devices.DMX
{
/// <summary>
/// Represents a device provider loaded used to dynamically load DMX devices into an application.
/// </summary>
public class DMXDeviceProviderLoader : IRGBDeviceProviderLoader
{
#region Properties & Fields
/// <inheritdoc />
public bool RequiresInitialization => true;
#endregion
#region Methods
/// <inheritdoc />
public IRGBDeviceProvider GetDeviceProvider() => DMXDeviceProvider.Instance;
#endregion
}
}

View File

@ -38,9 +38,7 @@ namespace RGB.NET.Devices.DMX.E131
{ {
int count = 0; int count = 0;
foreach (LedId id in _ledMappings.Keys) foreach (LedId id in _ledMappings.Keys)
InitializeLed(id, new Rectangle((count++) * 10, 0, 10, 10)); AddLed(id, new Point((count++) * 10, 0), new Size(10, 10));
//TODO DarthAffe 18.02.2018: Allow to load a layout.
if (Size == Size.Invalid) if (Size == Size.Invalid)
{ {
@ -54,7 +52,8 @@ namespace RGB.NET.Devices.DMX.E131
} }
/// <inheritdoc /> /// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) => new LedChannelMapping(_ledMappings[ledId]); protected override object? GetLedCustomData(LedId ledId) => new LedChannelMapping(_ledMappings[ledId]);
/// <inheritdoc /> /// <inheritdoc />
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate) => _updateQueue.SetData(ledsToUpdate.Where(x => x.Color.A > 0)); protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate) => _updateQueue.SetData(ledsToUpdate.Where(x => x.Color.A > 0));

View File

@ -33,11 +33,7 @@ namespace RGB.NET.Devices.DMX.E131
/// <inheritdoc /> /// <inheritdoc />
public string Model { get; } public string Model { get; }
/// <inheritdoc /> public object? LayoutMetadata { get; set; }
public RGBDeviceLighting Lighting => RGBDeviceLighting.Key;
/// <inheritdoc />
public Uri Image { get; set; }
/// <summary> /// <summary>
/// The hostname of the device. /// The hostname of the device.

View File

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using RGB.NET.Core; using RGB.NET.Core;
using RGB.NET.Layout;
namespace RGB.NET.Devices.Debug namespace RGB.NET.Devices.Debug
{ {
@ -28,11 +29,8 @@ namespace RGB.NET.Devices.Debug
/// <inheritdoc /> /// <inheritdoc />
public IEnumerable<IRGBDevice> Devices { get; private set; } public IEnumerable<IRGBDevice> Devices { get; private set; }
/// <inheritdoc /> private List<(IDeviceLayout layout, string imageLayout, Action<IEnumerable<Led>>? updateLedsAction)> _fakeDeviceDefinitions
public bool HasExclusiveAccess { get; private set; } = new List<(IDeviceLayout layout, string imageLayout, Action<IEnumerable<Led>>? updateLedsAction)>();
private List<(string layout, string imageLayout, Action<IEnumerable<Led>> updateLedsAction)> _fakeDeviceDefinitions
= new List<(string layout, string imageLayout, Action<IEnumerable<Led>> updateLedsAction)>();
#endregion #endregion
@ -58,7 +56,7 @@ namespace RGB.NET.Devices.Debug
/// <param name="layout">The path of the layout file to be used.</param> /// <param name="layout">The path of the layout file to be used.</param>
/// <param name="imageLayout">The image-layout to load.</param> /// <param name="imageLayout">The image-layout to load.</param>
/// <param name="updateLedsAction">A action emulating led-updates.</param> /// <param name="updateLedsAction">A action emulating led-updates.</param>
public void AddFakeDeviceDefinition(string layout, string imageLayout, Action<IEnumerable<Led>> updateLedsAction = null) public void AddFakeDeviceDefinition(IDeviceLayout layout, string imageLayout, Action<IEnumerable<Led>>? updateLedsAction = null)
=> _fakeDeviceDefinitions.Add((layout, imageLayout, updateLedsAction)); => _fakeDeviceDefinitions.Add((layout, imageLayout, updateLedsAction));
/// <summary> /// <summary>
@ -67,18 +65,15 @@ namespace RGB.NET.Devices.Debug
public void ClearFakeDeviceDefinitions() => _fakeDeviceDefinitions.Clear(); public void ClearFakeDeviceDefinitions() => _fakeDeviceDefinitions.Clear();
/// <inheritdoc /> /// <inheritdoc />
public bool Initialize(RGBDeviceType loadFilter = RGBDeviceType.Unknown, bool exclusiveAccessIfPossible = false, bool throwExceptions = false) public bool Initialize(RGBDeviceType loadFilter = RGBDeviceType.Unknown, bool throwExceptions = false)
{ {
IsInitialized = false; IsInitialized = false;
try try
{ {
HasExclusiveAccess = exclusiveAccessIfPossible;
List<IRGBDevice> devices = new List<IRGBDevice>(); List<IRGBDevice> devices = new List<IRGBDevice>();
foreach ((string layout, string imageLayout, Action<IEnumerable<Led>> updateLedsAction) in _fakeDeviceDefinitions) foreach ((IDeviceLayout layout, string imageLayout, Action<IEnumerable<Led>>? updateLedsAction) in _fakeDeviceDefinitions)
{ {
DebugRGBDevice device = new DebugRGBDevice(layout, updateLedsAction); DebugRGBDevice device = new DebugRGBDevice(layout, updateLedsAction);
device.Initialize(layout, imageLayout);
devices.Add(device); devices.Add(device);
} }

View File

@ -1,24 +0,0 @@
using RGB.NET.Core;
namespace RGB.NET.Devices.Debug
{
/// <summary>
/// Represents a device provider loaded used to dynamically load debug devices into an application.
/// </summary>
public class DebugDeviceProviderLoader : IRGBDeviceProviderLoader
{
#region Properties & Fields
/// <inheritdoc />
public bool RequiresInitialization => true;
#endregion
#region Methods
/// <inheritdoc />
public IRGBDeviceProvider GetDeviceProvider() => DebugDeviceProvider.Instance;
#endregion
}
}

View File

@ -1,7 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using RGB.NET.Core; using RGB.NET.Core;
using RGB.NET.Core.Layout; using RGB.NET.Layout;
namespace RGB.NET.Devices.Debug namespace RGB.NET.Devices.Debug
{ {
@ -16,12 +16,9 @@ namespace RGB.NET.Devices.Debug
/// <inheritdoc /> /// <inheritdoc />
public override DebugRGBDeviceInfo DeviceInfo { get; } public override DebugRGBDeviceInfo DeviceInfo { get; }
/// <summary> public IDeviceLayout Layout { get; }
/// Gets the path of the layout used to mock this <see cref="DebugRGBDevice"/>
/// </summary>
public string LayoutPath { get; }
private Action<IEnumerable<Led>> _updateLedsAction; private Action<IEnumerable<Led>>? _updateLedsAction;
#endregion #endregion
@ -29,21 +26,20 @@ namespace RGB.NET.Devices.Debug
/// <summary> /// <summary>
/// Internal constructor of <see cref="DebugRGBDeviceInfo"/>. /// Internal constructor of <see cref="DebugRGBDeviceInfo"/>.
/// </summary> /// </summary>
internal DebugRGBDevice(string layoutPath, Action<IEnumerable<Led>> updateLedsAction = null) internal DebugRGBDevice(IDeviceLayout layout, Action<IEnumerable<Led>>? updateLedsAction = null)
{ {
this.LayoutPath = layoutPath; this.Layout = layout;
this._updateLedsAction = updateLedsAction; this._updateLedsAction = updateLedsAction;
DeviceLayout layout = DeviceLayout.Load(layoutPath); DeviceInfo = new DebugRGBDeviceInfo(layout.Type, layout.Vendor ?? "RGB.NET", layout.Model ?? "Debug", layout.CustomData);
DeviceInfo = new DebugRGBDeviceInfo(layout.Type, layout.Vendor, layout.Model, layout.Lighting);
Layout.ApplyTo(this);
} }
#endregion #endregion
#region Methods #region Methods
internal void Initialize(string layoutPath, string imageLayout) => ApplyLayoutFromFile(layoutPath, imageLayout, true);
/// <inheritdoc /> /// <inheritdoc />
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate) => _updateLedsAction?.Invoke(ledsToUpdate); protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate) => _updateLedsAction?.Invoke(ledsToUpdate);

View File

@ -23,11 +23,7 @@ namespace RGB.NET.Devices.Debug
/// <inheritdoc /> /// <inheritdoc />
public string Model { get; } public string Model { get; }
/// <inheritdoc /> public object? LayoutMetadata { get; set; }
public RGBDeviceLighting Lighting { get; }
/// <inheritdoc />
public Uri Image { get; set; }
#endregion #endregion
@ -39,15 +35,14 @@ namespace RGB.NET.Devices.Debug
/// <param name="deviceType">The <see cref="RGBDeviceType"/> of the device.</param> /// <param name="deviceType">The <see cref="RGBDeviceType"/> of the device.</param>
/// <param name="manufacturer">The manufacturer of the device.</param> /// <param name="manufacturer">The manufacturer of the device.</param>
/// <param name="model">The model of the device.</param> /// <param name="model">The model of the device.</param>
/// <param name="lighting">The <see cref="RGBDeviceLighting"/> of the device.</param> internal DebugRGBDeviceInfo(RGBDeviceType deviceType, string manufacturer, string model, object? customData)
internal DebugRGBDeviceInfo(RGBDeviceType deviceType, string manufacturer, string model, RGBDeviceLighting lighting, string deviceName = null)
{ {
this.DeviceType = deviceType; this.DeviceType = deviceType;
this.Manufacturer = manufacturer; this.Manufacturer = manufacturer;
this.Model = model; this.Model = model;
this.Lighting = lighting; this.LayoutMetadata = customData;
DeviceName = deviceName ?? $"{Manufacturer} {Model}"; DeviceName = $"{Manufacturer} {Model}";
} }
#endregion #endregion

View File

@ -52,5 +52,6 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\RGB.NET.Core\RGB.NET.Core.csproj" /> <ProjectReference Include="..\RGB.NET.Core\RGB.NET.Core.csproj" />
<ProjectReference Include="..\RGB.NET.Layout\RGB.NET.Layout.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -1,5 +1,4 @@
using System.Linq; using RGB.NET.Core;
using RGB.NET.Core;
namespace RGB.NET.Devices.Logitech namespace RGB.NET.Devices.Logitech
{ {
@ -45,31 +44,11 @@ namespace RGB.NET.Devices.Logitech
/// <summary> /// <summary>
/// Initializes the device. /// Initializes the device.
/// </summary> /// </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; 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 /> /// <inheritdoc />
public override void Dispose() public override void Dispose()
{ {

View File

@ -1,5 +1,4 @@
using System; using RGB.NET.Core;
using RGB.NET.Core;
namespace RGB.NET.Devices.Logitech namespace RGB.NET.Devices.Logitech
{ {
@ -23,23 +22,7 @@ namespace RGB.NET.Devices.Logitech
/// <inheritdoc /> /// <inheritdoc />
public string Model { get; } public string Model { get; }
/// <inheritdoc /> public object? LayoutMetadata { get; set; }
public Uri Image { 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> /// <summary>
/// Gets a flag that describes device capabilities. (<see cref="LogitechDeviceCaps" />) /// Gets a flag that describes device capabilities. (<see cref="LogitechDeviceCaps" />)

View File

@ -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
}
}

View File

@ -26,16 +26,14 @@ namespace RGB.NET.Devices.Logitech
#region Methods #region Methods
/// <inheritdoc /> /// <inheritdoc />
protected override void InitializeLayout() public override void Initialize(UpdateQueue updateQueue)
{ {
base.InitializeLayout(); base.Initialize(updateQueue);
if (LedMapping.Count == 0) AddLed(LedId.Custom1, new Point(0, 0), new Size(10, 10));
InitializeLed(LedId.Custom1, new Rectangle(0, 0, 10, 10));
} }
/// <inheritdoc /> /// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) => (ledId, LogitechLedId.DEVICE); protected override object? GetLedCustomData(LedId ledId) => (ledId, LogitechLedId.DEVICE);
/// <inheritdoc /> /// <inheritdoc />
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate) => UpdateQueue.SetData(ledsToUpdate.Where(x => x.Color.A > 0).Take(1)); protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate) => UpdateQueue.SetData(ledsToUpdate.Where(x => x.Color.A > 0).Take(1));

View File

@ -26,7 +26,7 @@ namespace RGB.NET.Devices.Logitech
#region Methods #region Methods
/// <inheritdoc /> /// <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 /> /// <inheritdoc />
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate) => UpdateQueue.SetData(ledsToUpdate.Where(x => x.Color.A > 0)); protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate) => UpdateQueue.SetData(ledsToUpdate.Where(x => x.Color.A > 0));

View File

@ -47,16 +47,16 @@ namespace RGB.NET.Devices.Logitech
#region Methods #region Methods
/// <inheritdoc /> /// <inheritdoc />
protected override void InitializeLayout() public override void Initialize(UpdateQueue updateQueue)
{ {
for (int i = 0; i < DeviceInfo.Zones; i++) base.Initialize(updateQueue);
InitializeLed(_baseLedId + i, new Rectangle(i * 10, 0, 10, 10));
base.InitializeLayout(); for (int i = 0; i < DeviceInfo.Zones; i++)
AddLed(_baseLedId + i, new Point(i * 10, 0), new Size(10, 10));
} }
/// <inheritdoc /> /// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) => (int)(ledId - _baseLedId); protected override object? GetLedCustomData(LedId ledId) => (int)(ledId - _baseLedId);
/// <inheritdoc /> /// <inheritdoc />
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate) => UpdateQueue.SetData(ledsToUpdate.Where(x => x.Color.A > 0)); protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate) => UpdateQueue.SetData(ledsToUpdate.Where(x => x.Color.A > 0));

View File

@ -29,10 +29,7 @@ namespace RGB.NET.Devices.Msi
public string Model { get; } public string Model { get; }
/// <inheritdoc /> /// <inheritdoc />
public Uri Image { get; set; } public object? LayoutMetadata { get; set; }
/// <inheritdoc />
public RGBDeviceLighting Lighting => RGBDeviceLighting.Key;
#endregion #endregion

View File

@ -37,15 +37,12 @@ namespace RGB.NET.Devices.Msi
//Hex3l: Every led is a video card adapter. //Hex3l: Every led is a video card adapter.
_MsiSDK.SetLedStyle(DeviceInfo.MsiDeviceType, i, LED_STYLE); _MsiSDK.SetLedStyle(DeviceInfo.MsiDeviceType, i, LED_STYLE);
InitializeLed(LedId.GraphicsCard1 + i, new Rectangle(i * 10, 0, 10, 10)); AddLed(LedId.GraphicsCard1 + i, new Point(i * 10, 0), new Size(10, 10));
} }
//TODO DarthAffe 07.10.2017: We don't know the model, how to save layouts and images?
ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, $@"Layouts\MSI\GraphicsCard\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null);
} }
/// <inheritdoc /> /// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.GraphicsCard1; protected override object? GetLedCustomData(LedId ledId) => (int)ledId - (int)LedId.GraphicsCard1;
#endregion #endregion
} }

View File

@ -35,15 +35,12 @@ namespace RGB.NET.Devices.Msi
const string LED_STYLE = "Steady"; const string LED_STYLE = "Steady";
_MsiSDK.SetLedStyle(DeviceInfo.MsiDeviceType, i, LED_STYLE); _MsiSDK.SetLedStyle(DeviceInfo.MsiDeviceType, i, LED_STYLE);
InitializeLed(LedId.Mainboard1 + i, new Rectangle(i * 40, 0, 40, 8)); AddLed(LedId.Mainboard1 + i, new Point(i * 40, 0), new Size(40, 8));
} }
//TODO DarthAffe 07.10.2017: We don't know the model, how to save layouts and images?
ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, $@"Layouts\MSI\Mainboards\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null);
} }
/// <inheritdoc /> /// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Mainboard1; protected override object? GetLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Mainboard1;
#endregion #endregion
} }

View File

@ -35,15 +35,12 @@ namespace RGB.NET.Devices.Msi
const string LED_STYLE = "Steady"; const string LED_STYLE = "Steady";
_MsiSDK.SetLedStyle(DeviceInfo.MsiDeviceType, i, LED_STYLE); _MsiSDK.SetLedStyle(DeviceInfo.MsiDeviceType, i, LED_STYLE);
InitializeLed(LedId.Mouse1 + i, new Rectangle(i * 10, 0, 10, 10)); AddLed(LedId.Mouse1 + i, new Point(i * 10, 0), new Size(10, 10));
} }
//TODO DarthAffe 07.10.2017: We don't know the model, how to save layouts and images?
ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, $@"Layouts\MSI\Mouses\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null);
} }
/// <inheritdoc /> /// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Mouse1; protected override object? GetLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Mouse1;
#endregion #endregion
} }

View File

@ -1,24 +0,0 @@
using RGB.NET.Core;
namespace RGB.NET.Devices.Msi
{
/// <summary>
/// Represents a device provider loaded used to dynamically load MSI devices into an application.
/// </summary>
public class MsiDeviceProviderLoader : IRGBDeviceProviderLoader
{
#region Properties & Fields
/// <inheritdoc />
public bool RequiresInitialization => false;
#endregion
#region Methods
/// <inheritdoc />
public IRGBDeviceProvider GetDeviceProvider() => MsiDeviceProvider.Instance;
#endregion
}
}

View File

@ -2,4 +2,5 @@
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=enum/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=enum/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=generic/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=generic/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=graphicscard/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=graphicscard/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=mainboard/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> <s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=mainboard/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=mouse/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

View File

@ -24,10 +24,7 @@ namespace RGB.NET.Devices.Novation
public string Model { get; } public string Model { get; }
/// <inheritdoc /> /// <inheritdoc />
public Uri Image { get; set; } public object? LayoutMetadata { get; set; }
/// <inheritdoc />
public RGBDeviceLighting Lighting => RGBDeviceLighting.Key;
/// <summary> /// <summary>
/// Gets the <see cref="NovationColorCapabilities"/> of the <see cref="IRGBDevice"/>. /// Gets the <see cref="NovationColorCapabilities"/> of the <see cref="IRGBDevice"/>.

View File

@ -34,15 +34,12 @@ namespace RGB.NET.Devices.Novation
foreach (LedId ledId in mapping.Keys) foreach (LedId ledId in mapping.Keys)
{ {
(_, _, int x, int y) = mapping[ledId]; (_, _, int x, int y) = mapping[ledId];
InitializeLed(ledId, new Point(BUTTON_SIZE * x, BUTTON_SIZE * y), new Size(BUTTON_SIZE)); AddLed(ledId, new Point(BUTTON_SIZE * x, BUTTON_SIZE * y), new Size(BUTTON_SIZE));
} }
string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper();
ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Novation\Launchpads", $"{model.ToUpper()}.xml"), "Default");
} }
/// <inheritdoc /> /// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) => GetDeviceMapping().TryGetValue(ledId, out (byte mode, byte id, int _, int __) data) ? (data.mode, data.id) : ((byte)0x00, (byte)0x00); protected override object GetLedCustomData(LedId ledId) => GetDeviceMapping().TryGetValue(ledId, out (byte mode, byte id, int _, int __) data) ? (data.mode, data.id) : ((byte)0x00, (byte)0x00);
protected virtual Dictionary<LedId, (byte mode, byte id, int x, int y)> GetDeviceMapping() protected virtual Dictionary<LedId, (byte mode, byte id, int x, int y)> GetDeviceMapping()
=> DeviceInfo.LedIdMapping switch => DeviceInfo.LedIdMapping switch

View File

@ -1,24 +0,0 @@
using RGB.NET.Core;
namespace RGB.NET.Devices.Novation
{
/// <summary>
/// Represents a device provider loaded used to dynamically load novation devices into an application.
/// </summary>
public class NovationDeviceProviderLoader : IRGBDeviceProviderLoader
{
#region Properties & Fields
/// <inheritdoc />
public bool RequiresInitialization => false;
#endregion
#region Methods
/// <inheritdoc />
public IRGBDeviceProvider GetDeviceProvider() => NovationDeviceProvider.Instance;
#endregion
}
}

View File

@ -30,16 +30,12 @@ namespace RGB.NET.Devices.Razer
/// <inheritdoc /> /// <inheritdoc />
protected override void InitializeLayout() protected override void InitializeLayout()
{ {
string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper();
ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Razer\ChromaLink", $"{model}.xml"), null);
if (LedMapping.Count == 0)
for (int i = 0; i < _Defines.CHROMALINK_MAX_LEDS; i++) for (int i = 0; i < _Defines.CHROMALINK_MAX_LEDS; i++)
InitializeLed(LedId.Custom1 + i, new Rectangle(i * 11, 0, 10, 10)); AddLed(LedId.Custom1 + i, new Point(i * 11, 0), new Size(10, 10));
} }
/// <inheritdoc /> /// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Custom1; protected override object? GetLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Custom1;
/// <inheritdoc /> /// <inheritdoc />
protected override RazerUpdateQueue CreateUpdateQueue(IDeviceUpdateTrigger updateTrigger) => new RazerChromaLinkUpdateQueue(updateTrigger, DeviceInfo.DeviceId); protected override RazerUpdateQueue CreateUpdateQueue(IDeviceUpdateTrigger updateTrigger) => new RazerChromaLinkUpdateQueue(updateTrigger, DeviceInfo.DeviceId);

View File

@ -29,10 +29,7 @@ namespace RGB.NET.Devices.Razer
public string Model { get; } public string Model { get; }
/// <inheritdoc /> /// <inheritdoc />
public Uri Image { get; set; } public object? LayoutMetadata { get; set; }
/// <inheritdoc />
public RGBDeviceLighting Lighting => RGBDeviceLighting.Key;
#endregion #endregion

View File

@ -30,16 +30,12 @@ namespace RGB.NET.Devices.Razer
/// <inheritdoc /> /// <inheritdoc />
protected override void InitializeLayout() protected override void InitializeLayout()
{ {
string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper();
ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Razer\Headset", $"{model}.xml"), null);
if (LedMapping.Count == 0)
for (int i = 0; i < _Defines.HEADSET_MAX_LEDS; i++) for (int i = 0; i < _Defines.HEADSET_MAX_LEDS; i++)
InitializeLed(LedId.Headset1 + i, new Rectangle(i * 11, 0, 10, 10)); AddLed(LedId.Headset1 + i, new Point(i * 11, 0), new Size(10, 10));
} }
/// <inheritdoc /> /// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Headset1; protected override object? GetLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Headset1;
/// <inheritdoc /> /// <inheritdoc />
protected override RazerUpdateQueue CreateUpdateQueue(IDeviceUpdateTrigger updateTrigger) => new RazerHeadsetUpdateQueue(updateTrigger, DeviceInfo.DeviceId); protected override RazerUpdateQueue CreateUpdateQueue(IDeviceUpdateTrigger updateTrigger) => new RazerHeadsetUpdateQueue(updateTrigger, DeviceInfo.DeviceId);

View File

@ -29,23 +29,14 @@ namespace RGB.NET.Devices.Razer
/// <inheritdoc /> /// <inheritdoc />
protected override void InitializeLayout() protected override void InitializeLayout()
{
//string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper();
//ApplyLayoutFromFile(PathHelper.GetAbsolutePath(
// $@"Layouts\Razer\Keyboards\{model}\{DeviceInfo.PhysicalLayout.ToString().ToUpper()}.xml"),
// DeviceInfo.LogicalLayout.ToString(), PathHelper.GetAbsolutePath(@"Images\Razer\Keyboards"));
//TODO DarthAffe 13.12.2017: Correctly select ids
if (LedMapping.Count == 0)
{ {
for (int i = 0; i < _Defines.KEYBOARD_MAX_ROW; i++) for (int i = 0; i < _Defines.KEYBOARD_MAX_ROW; i++)
for (int j = 0; j < _Defines.KEYBOARD_MAX_COLUMN; j++) for (int j = 0; j < _Defines.KEYBOARD_MAX_COLUMN; j++)
InitializeLed(LedId.Keyboard_Escape + ((i * _Defines.KEYBOARD_MAX_COLUMN) + j), new Rectangle(j * 20, i * 20, 19, 19)); AddLed(LedId.Keyboard_Escape + ((i * _Defines.KEYBOARD_MAX_COLUMN) + j), new Point(j * 20, i * 20), new Size(19, 19));
}
} }
/// <inheritdoc /> /// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Keyboard_Escape; protected override object? GetLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Keyboard_Escape;
/// <inheritdoc /> /// <inheritdoc />
protected override RazerUpdateQueue CreateUpdateQueue(IDeviceUpdateTrigger updateTrigger) => new RazerKeyboardUpdateQueue(updateTrigger, DeviceInfo.DeviceId); protected override RazerUpdateQueue CreateUpdateQueue(IDeviceUpdateTrigger updateTrigger) => new RazerKeyboardUpdateQueue(updateTrigger, DeviceInfo.DeviceId);

View File

@ -29,20 +29,14 @@ namespace RGB.NET.Devices.Razer
/// <inheritdoc /> /// <inheritdoc />
protected override void InitializeLayout() protected override void InitializeLayout()
{
string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper();
ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Razer\Keypad", $"{model}.xml"), null);
if (LedMapping.Count == 0)
{ {
for (int i = 0; i < _Defines.KEYPAD_MAX_ROW; i++) for (int i = 0; i < _Defines.KEYPAD_MAX_ROW; i++)
for (int j = 0; j < _Defines.KEYPAD_MAX_COLUMN; j++) for (int j = 0; j < _Defines.KEYPAD_MAX_COLUMN; j++)
InitializeLed(LedId.Keypad1 + ((i * _Defines.KEYPAD_MAX_COLUMN) + j), new Rectangle(j * 20, i * 20, 19, 19)); AddLed(LedId.Keypad1 + ((i * _Defines.KEYPAD_MAX_COLUMN) + j), new Point(j * 20, i * 20), new Size(19, 19));
}
} }
/// <inheritdoc /> /// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Keypad1; protected override object? GetLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Keypad1;
/// <inheritdoc /> /// <inheritdoc />
protected override RazerUpdateQueue CreateUpdateQueue(IDeviceUpdateTrigger updateTrigger) => new RazerKeypadUpdateQueue(updateTrigger, DeviceInfo.DeviceId); protected override RazerUpdateQueue CreateUpdateQueue(IDeviceUpdateTrigger updateTrigger) => new RazerKeypadUpdateQueue(updateTrigger, DeviceInfo.DeviceId);

View File

@ -29,20 +29,14 @@ namespace RGB.NET.Devices.Razer
/// <inheritdoc /> /// <inheritdoc />
protected override void InitializeLayout() protected override void InitializeLayout()
{
string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper();
ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Razer\Mice", $"{model}.xml"), null);
if (LedMapping.Count == 0)
{ {
for (int i = 0; i < _Defines.MOUSE_MAX_ROW; i++) for (int i = 0; i < _Defines.MOUSE_MAX_ROW; i++)
for (int j = 0; j < _Defines.MOUSE_MAX_COLUMN; j++) for (int j = 0; j < _Defines.MOUSE_MAX_COLUMN; j++)
InitializeLed(LedId.Mouse1 + ((i * _Defines.MOUSE_MAX_COLUMN) + j), new Rectangle(j * 11, i * 11, 10, 10)); AddLed(LedId.Mouse1 + ((i * _Defines.MOUSE_MAX_COLUMN) + j), new Point(j * 11, i * 11), new Size(10, 10));
}
} }
/// <inheritdoc /> /// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Mouse1; protected override object? GetLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Mouse1;
/// <inheritdoc /> /// <inheritdoc />
protected override RazerUpdateQueue CreateUpdateQueue(IDeviceUpdateTrigger updateTrigger) => new RazerMouseUpdateQueue(updateTrigger, DeviceInfo.DeviceId); protected override RazerUpdateQueue CreateUpdateQueue(IDeviceUpdateTrigger updateTrigger) => new RazerMouseUpdateQueue(updateTrigger, DeviceInfo.DeviceId);

View File

@ -30,16 +30,12 @@ namespace RGB.NET.Devices.Razer
/// <inheritdoc /> /// <inheritdoc />
protected override void InitializeLayout() protected override void InitializeLayout()
{ {
string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper();
ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Razer\Mousepad", $"{model}.xml"), null);
if (LedMapping.Count == 0)
for (int i = 0; i < _Defines.MOUSEPAD_MAX_LEDS; i++) for (int i = 0; i < _Defines.MOUSEPAD_MAX_LEDS; i++)
InitializeLed(LedId.Mousepad1 + i, new Rectangle(i * 11, 0, 10, 10)); AddLed(LedId.Mousepad1 + i, new Point(i * 11, 0), new Size(10, 10));
} }
/// <inheritdoc /> /// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Mousepad1; protected override object? GetLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Mousepad1;
/// <inheritdoc /> /// <inheritdoc />
protected override RazerUpdateQueue CreateUpdateQueue(IDeviceUpdateTrigger updateTrigger) => new RazerMousepadUpdateQueue(updateTrigger, DeviceInfo.DeviceId); protected override RazerUpdateQueue CreateUpdateQueue(IDeviceUpdateTrigger updateTrigger) => new RazerMousepadUpdateQueue(updateTrigger, DeviceInfo.DeviceId);

View File

@ -1,24 +0,0 @@
using RGB.NET.Core;
namespace RGB.NET.Devices.Razer
{
/// <summary>
/// Represents a device provider loaded used to dynamically load razer devices into an application.
/// </summary>
public class RazerDeviceProviderLoader : IRGBDeviceProviderLoader
{
#region Properties & Fields
/// <inheritdoc />
public bool RequiresInitialization => false;
#endregion
#region Methods
/// <inheritdoc />
public IRGBDeviceProvider GetDeviceProvider() => RazerDeviceProvider.Instance;
#endregion
}
}

View File

@ -53,36 +53,23 @@ namespace RGB.NET.Devices.SteelSeries
int counter = 0; int counter = 0;
foreach (KeyValuePair<LedId, SteelSeriesLedId> mapping in ledMapping) foreach (KeyValuePair<LedId, SteelSeriesLedId> mapping in ledMapping)
InitializeLed(mapping.Key, new Rectangle((counter++) * 10, 0, 10, 10)); AddLed(mapping.Key, new Point((counter++) * 10, 0), new Size(10, 10));
InitializeLayout();
if (Size == Size.Invalid) if (Size == Size.Invalid)
{ {
Rectangle ledRectangle = new Rectangle(this.Select(x => x.LedRectangle)); Rectangle ledRectangle = new(this.Select(x => x.LedRectangle));
Size = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y); Size = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
} }
UpdateQueue = updateQueue; UpdateQueue = updateQueue;
} }
protected override object CreateLedCustomData(LedId ledId) => _ledMapping[ledId]; /// <inheritdoc />
protected override object GetLedCustomData(LedId ledId) => _ledMapping[ledId];
/// <inheritdoc /> /// <inheritdoc />
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate) => UpdateQueue.SetData(ledsToUpdate.Where(x => x.Color.A > 0)); protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate) => UpdateQueue.SetData(ledsToUpdate.Where(x => x.Color.A > 0));
/// <summary>
/// Initializes the <see cref="Led"/> and <see cref="Size"/> of the device.
/// </summary>
protected virtual void InitializeLayout()
{
if (!(DeviceInfo is SteelSeriesRGBDeviceInfo info)) return;
string layout = info.ImageLayout;
string layoutPath = info.LayoutPath;
ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\SteelSeries", $"{layoutPath}.xml"), layout, true);
}
/// <inheritdoc /> /// <inheritdoc />
public override void Dispose() public override void Dispose()
{ {

View File

@ -24,10 +24,7 @@ namespace RGB.NET.Devices.SteelSeries
public string Model { get; } public string Model { get; }
/// <inheritdoc /> /// <inheritdoc />
public Uri Image { get; set; } public object? LayoutMetadata { get; set; }
/// <inheritdoc />
public RGBDeviceLighting Lighting => RGBDeviceLighting.Key;
public SteelSeriesDeviceType SteelSeriesDeviceType { get; } public SteelSeriesDeviceType SteelSeriesDeviceType { get; }

View File

@ -1,25 +0,0 @@
using RGB.NET.Core;
namespace RGB.NET.Devices.SteelSeries
{
/// <summary>
/// Represents a device provider loaded used to dynamically load steelseries devices into an application.
/// </summary>
// ReSharper disable once UnusedMember.Global
public class SteelSeriesDeviceProviderLoader : IRGBDeviceProviderLoader
{
#region Properties & Fields
/// <inheritdoc />
public bool RequiresInitialization => false;
#endregion
#region Methods
/// <inheritdoc />
public IRGBDeviceProvider GetDeviceProvider() => SteelSeriesDeviceProvider.Instance;
#endregion
}
}

View File

@ -53,19 +53,17 @@ namespace RGB.NET.Devices.WS281X.Arduino
internal void Initialize(int ledCount) internal void Initialize(int ledCount)
{ {
for (int i = 0; i < ledCount; i++) for (int i = 0; i < ledCount; i++)
InitializeLed(LedId.LedStripe1 + i, new Rectangle(i * 10, 0, 10, 10)); AddLed(LedId.LedStripe1 + i, new Point(i * 10, 0), new Size(10, 10));
//TODO DarthAffe 23.12.2018: Allow to load a layout.
if (Size == Size.Invalid) if (Size == Size.Invalid)
{ {
Rectangle ledRectangle = new Rectangle(this.Select(x => x.LedRectangle)); Rectangle ledRectangle = new(this.Select(x => x.LedRectangle));
Size = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y); Size = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
} }
} }
/// <inheritdoc /> /// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) => (Channel, (int)ledId - (int)LedId.LedStripe1); protected override object GetLedCustomData(LedId ledId) => (Channel, (int)ledId - (int)LedId.LedStripe1);
/// <inheritdoc /> /// <inheritdoc />
protected override IEnumerable<Led> GetLedsToUpdate(bool flushLeds) => (flushLeds || LedMapping.Values.Any(x => x.IsDirty)) ? LedMapping.Values : null; protected override IEnumerable<Led> GetLedsToUpdate(bool flushLeds) => (flushLeds || LedMapping.Values.Any(x => x.IsDirty)) ? LedMapping.Values : null;

View File

@ -25,10 +25,7 @@ namespace RGB.NET.Devices.WS281X.Arduino
public string Model => "WS2812 USB"; public string Model => "WS2812 USB";
/// <inheritdoc /> /// <inheritdoc />
public RGBDeviceLighting Lighting => RGBDeviceLighting.Key; public object? LayoutMetadata { get; set; }
/// <inheritdoc />
public Uri Image { get; set; }
#endregion #endregion

View File

@ -50,9 +50,7 @@ namespace RGB.NET.Devices.WS281X.Bitwizard
internal void Initialize(int ledCount) internal void Initialize(int ledCount)
{ {
for (int i = 0; i < ledCount; i++) for (int i = 0; i < ledCount; i++)
InitializeLed(LedId.LedStripe1 + i, new Rectangle(i * 10, 0, 10, 10)); AddLed(LedId.LedStripe1 + i, new Point(i * 10, 0), new Size(10, 10));
//TODO DarthAffe 23.12.2018: Allow to load a layout.
if (Size == Size.Invalid) if (Size == Size.Invalid)
{ {
@ -62,7 +60,7 @@ namespace RGB.NET.Devices.WS281X.Bitwizard
} }
/// <inheritdoc /> /// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) => _ledOffset + ((int)ledId - (int)LedId.LedStripe1); protected override object GetLedCustomData(LedId ledId) => _ledOffset + ((int)ledId - (int)LedId.LedStripe1);
/// <inheritdoc /> /// <inheritdoc />
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate) => UpdateQueue.SetData(ledsToUpdate.Where(x => x.Color.A > 0)); protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate) => UpdateQueue.SetData(ledsToUpdate.Where(x => x.Color.A > 0));

View File

@ -25,10 +25,7 @@ namespace RGB.NET.Devices.WS281X.Bitwizard
public string Model => "WS2812 USB"; public string Model => "WS2812 USB";
/// <inheritdoc /> /// <inheritdoc />
public RGBDeviceLighting Lighting => RGBDeviceLighting.Key; public object? LayoutMetadata { get; set; }
/// <inheritdoc />
public Uri Image { get; set; }
#endregion #endregion

View File

@ -53,9 +53,7 @@ namespace RGB.NET.Devices.WS281X.NodeMCU
internal void Initialize(int ledCount) internal void Initialize(int ledCount)
{ {
for (int i = 0; i < ledCount; i++) for (int i = 0; i < ledCount; i++)
InitializeLed(LedId.LedStripe1 + i, new Point(i * 10, 0), new Size(10, 10)); AddLed(LedId.LedStripe1 + i, new Point(i * 10, 0), new Size(10, 10));
//TODO DarthAffe 23.12.2018: Allow to load a layout.
if (Size == Size.Invalid) if (Size == Size.Invalid)
{ {
@ -65,7 +63,7 @@ namespace RGB.NET.Devices.WS281X.NodeMCU
} }
/// <inheritdoc /> /// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) => (Channel, (int)ledId - (int)LedId.LedStripe1); protected override object GetLedCustomData(LedId ledId) => (Channel, (int)ledId - (int)LedId.LedStripe1);
/// <inheritdoc /> /// <inheritdoc />
protected override IEnumerable<Led> GetLedsToUpdate(bool flushLeds) => (flushLeds || LedMapping.Values.Any(x => x.IsDirty)) ? LedMapping.Values : null; protected override IEnumerable<Led> GetLedsToUpdate(bool flushLeds) => (flushLeds || LedMapping.Values.Any(x => x.IsDirty)) ? LedMapping.Values : null;

View File

@ -25,10 +25,7 @@ namespace RGB.NET.Devices.WS281X.NodeMCU
public string Model => "WS2812 WLAN"; public string Model => "WS2812 WLAN";
/// <inheritdoc /> /// <inheritdoc />
public RGBDeviceLighting Lighting => RGBDeviceLighting.Key; public object? LayoutMetadata { get; set; }
/// <inheritdoc />
public Uri Image { get; set; }
#endregion #endregion

View File

@ -1,27 +0,0 @@
using RGB.NET.Core;
namespace RGB.NET.Devices.WS281X
{
/// <inheritdoc />
/// <summary>
/// Represents a device provider loaded used to dynamically load WS281X devices into an application.
/// </summary>
// ReSharper disable once UnusedMember.Global
// ReSharper disable once InconsistentNaming
public class WS281XDeviceProviderLoader : IRGBDeviceProviderLoader
{
#region Properties & Fields
/// <inheritdoc />
public bool RequiresInitialization => true;
#endregion
#region Methods
/// <inheritdoc />
public IRGBDeviceProvider GetDeviceProvider() => WS281XDeviceProvider.Instance;
#endregion
}
}

View File

@ -26,10 +26,7 @@ namespace RGB.NET.Devices.Wooting.Generic
public string Model { get; } public string Model { get; }
/// <inheritdoc /> /// <inheritdoc />
public Uri Image { get; set; } public object? LayoutMetadata { get; set; }
/// <inheritdoc />
public RGBDeviceLighting Lighting => RGBDeviceLighting.Key;
/// <summary> /// <summary>
/// Gets the <see cref="WootingDevicesIndexes"/> of the <see cref="WootingRGBDevice{TDeviceInfo}"/>. /// Gets the <see cref="WootingDevicesIndexes"/> of the <see cref="WootingRGBDevice{TDeviceInfo}"/>.

View File

@ -29,25 +29,18 @@ namespace RGB.NET.Devices.Wooting.Keyboard
/// <inheritdoc /> /// <inheritdoc />
protected override void InitializeLayout() protected override void InitializeLayout()
{ {
Dictionary<LedId, (int row, int column)> mapping = WootingKeyboardLedMappings.Mapping[DeviceInfo.DeviceIndex][DeviceInfo.PhysicalLayout]; Dictionary<LedId, (int row, int column)> mapping = WootingKeyboardLedMappings.Mapping[DeviceInfo.DeviceIndex][DeviceInfo.PhysicalLayout];
foreach (KeyValuePair<LedId, (int row, int column)> led in mapping) foreach (KeyValuePair<LedId, (int row, int column)> led in mapping)
{ AddLed(led.Key, new Point(led.Value.column * 19, led.Value.row * 19), new Size(19, 19));
InitializeLed(led.Key, new Point(led.Value.column * 19, led.Value.row * 19), new Size(19,19));
} }
string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); /// <inheritdoc />
ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, $@"Layouts\Wooting\Keyboards\{model}", $"{DeviceInfo.PhysicalLayout.ToString().ToUpper()}.xml"), protected override object GetLedCustomData(LedId ledId) => WootingKeyboardLedMappings.Mapping[DeviceInfo.DeviceIndex][DeviceInfo.PhysicalLayout][ledId];
DeviceInfo.LogicalLayout.ToString());
}
/// <inheritdoc /> /// <inheritdoc />
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate) => UpdateQueue.SetData(ledsToUpdate.Where(x => x.Color.A > 0)); protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate) => UpdateQueue.SetData(ledsToUpdate.Where(x => x.Color.A > 0));
/// <inheritdoc />
protected override object CreateLedCustomData(LedId ledId) => WootingKeyboardLedMappings.Mapping[DeviceInfo.DeviceIndex][DeviceInfo.PhysicalLayout][ledId];
#endregion #endregion
} }
} }

View File

@ -1,24 +0,0 @@
using RGB.NET.Core;
namespace RGB.NET.Devices.Wooting
{
/// <summary>
/// Represents a device provider loaded used to dynamically load Wooting devices into an application.
/// </summary>
public class WootingDeviceProviderLoader : IRGBDeviceProviderLoader
{
#region Properties & Fields
/// <inheritdoc />
public bool RequiresInitialization => false;
#endregion
#region Methods
/// <inheritdoc />
public IRGBDeviceProvider GetDeviceProvider() => WootingDeviceProvider.Instance;
#endregion
}
}

View File

@ -25,8 +25,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RGB.NET.Devices.Novation",
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RGB.NET.Devices.Razer", "RGB.NET.Devices.Razer\RGB.NET.Devices.Razer.csproj", "{2E162CB7-2C6C-4069-8356-06162F7BE0AA}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RGB.NET.Devices.Razer", "RGB.NET.Devices.Razer\RGB.NET.Devices.Razer.csproj", "{2E162CB7-2C6C-4069-8356-06162F7BE0AA}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RGB.NET.Devices.Roccat", "RGB.NET.Devices.Roccat\RGB.NET.Devices.Roccat.csproj", "{9DF256B9-1AB7-4D5B-B2E5-94AF6691DC9E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RGB.NET.Brushes", "RGB.NET.Brushes\RGB.NET.Brushes.csproj", "{B159FB51-5939-490E-A1BA-FB55D4D7ADDF}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RGB.NET.Brushes", "RGB.NET.Brushes\RGB.NET.Brushes.csproj", "{B159FB51-5939-490E-A1BA-FB55D4D7ADDF}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RGB.NET.Decorators", "RGB.NET.Decorators\RGB.NET.Decorators.csproj", "{8725C448-818C-41F7-B23F-F97E062BF233}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RGB.NET.Decorators", "RGB.NET.Decorators\RGB.NET.Decorators.csproj", "{8725C448-818C-41F7-B23F-F97E062BF233}"
@ -45,7 +43,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RGB.NET.Devices.Asus", "RGB
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RGB.NET.Devices.Wooting", "RGB.NET.Devices.Wooting\RGB.NET.Devices.Wooting.csproj", "{DD46DB2D-85BE-4962-86AE-E38C9053A548}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RGB.NET.Devices.Wooting", "RGB.NET.Devices.Wooting\RGB.NET.Devices.Wooting.csproj", "{DD46DB2D-85BE-4962-86AE-E38C9053A548}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RGB.NET.Layout", "RGB.NET.Layout\RGB.NET.Layout.csproj", "{8AAB3736-B443-402C-B8AC-63D1A6DAFCCB}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RGB.NET.Layout", "RGB.NET.Layout\RGB.NET.Layout.csproj", "{8AAB3736-B443-402C-B8AC-63D1A6DAFCCB}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -89,10 +87,6 @@ Global
{2E162CB7-2C6C-4069-8356-06162F7BE0AA}.Debug|Any CPU.Build.0 = Debug|Any CPU {2E162CB7-2C6C-4069-8356-06162F7BE0AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2E162CB7-2C6C-4069-8356-06162F7BE0AA}.Release|Any CPU.ActiveCfg = Release|Any CPU {2E162CB7-2C6C-4069-8356-06162F7BE0AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2E162CB7-2C6C-4069-8356-06162F7BE0AA}.Release|Any CPU.Build.0 = Release|Any CPU {2E162CB7-2C6C-4069-8356-06162F7BE0AA}.Release|Any CPU.Build.0 = Release|Any CPU
{9DF256B9-1AB7-4D5B-B2E5-94AF6691DC9E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9DF256B9-1AB7-4D5B-B2E5-94AF6691DC9E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9DF256B9-1AB7-4D5B-B2E5-94AF6691DC9E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9DF256B9-1AB7-4D5B-B2E5-94AF6691DC9E}.Release|Any CPU.Build.0 = Release|Any CPU
{B159FB51-5939-490E-A1BA-FB55D4D7ADDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B159FB51-5939-490E-A1BA-FB55D4D7ADDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B159FB51-5939-490E-A1BA-FB55D4D7ADDF}.Debug|Any CPU.Build.0 = Debug|Any CPU {B159FB51-5939-490E-A1BA-FB55D4D7ADDF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B159FB51-5939-490E-A1BA-FB55D4D7ADDF}.Release|Any CPU.ActiveCfg = Release|Any CPU {B159FB51-5939-490E-A1BA-FB55D4D7ADDF}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -142,7 +136,6 @@ Global
{00BA7E8E-822A-42DA-9EB4-DDBBC7CB0E46} = {D13032C6-432E-4F43-8A32-071133C22B16} {00BA7E8E-822A-42DA-9EB4-DDBBC7CB0E46} = {D13032C6-432E-4F43-8A32-071133C22B16}
{19F701FD-5577-4873-9BE6-6775676FA185} = {D13032C6-432E-4F43-8A32-071133C22B16} {19F701FD-5577-4873-9BE6-6775676FA185} = {D13032C6-432E-4F43-8A32-071133C22B16}
{2E162CB7-2C6C-4069-8356-06162F7BE0AA} = {D13032C6-432E-4F43-8A32-071133C22B16} {2E162CB7-2C6C-4069-8356-06162F7BE0AA} = {D13032C6-432E-4F43-8A32-071133C22B16}
{9DF256B9-1AB7-4D5B-B2E5-94AF6691DC9E} = {D13032C6-432E-4F43-8A32-071133C22B16}
{B159FB51-5939-490E-A1BA-FB55D4D7ADDF} = {EBC33090-8494-4DF4-B4B6-64D0E531E93F} {B159FB51-5939-490E-A1BA-FB55D4D7ADDF} = {EBC33090-8494-4DF4-B4B6-64D0E531E93F}
{8725C448-818C-41F7-B23F-F97E062BF233} = {EBC33090-8494-4DF4-B4B6-64D0E531E93F} {8725C448-818C-41F7-B23F-F97E062BF233} = {EBC33090-8494-4DF4-B4B6-64D0E531E93F}
{6FEBDC9E-909D-4EE2-B003-EDFBEF5FFF40} = {EBC33090-8494-4DF4-B4B6-64D0E531E93F} {6FEBDC9E-909D-4EE2-B003-EDFBEF5FFF40} = {EBC33090-8494-4DF4-B4B6-64D0E531E93F}