mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2026-11-11 13:06:24 +00:00
Added OpenRGB device provider
This commit is contained in:
1 parent
a9adf9763c
commit
2d203d31ab
14 files changed
+770
No files matched your search
@@ -0,0 +1,68 @@
|
||||
using OpenRGB.NET.Enums;
|
||||
using OpenRGB.NET.Models;
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.OpenRGB
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public class OpenRGBZoneDevice : AbstractOpenRGBDevice<OpenRGBZoneDeviceInfo>
|
||||
{
|
||||
private readonly int _initialLed;
|
||||
private readonly Zone _zone;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="OpenRGBZoneDevice"/> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The information provided by OpenRGB</param>
|
||||
/// <param name="initialLed">The ledId of the first led in the device that belongs to this zone.</param>
|
||||
/// <param name="zone">The Zone information provided by OpenRGB.</param>
|
||||
/// <param name="updateQueue">The queu used to update this zone.</param>
|
||||
public OpenRGBZoneDevice(OpenRGBZoneDeviceInfo info, int initialLed, Zone zone, IUpdateQueue updateQueue)
|
||||
: base(info, updateQueue)
|
||||
{
|
||||
_initialLed = initialLed;
|
||||
_zone = zone;
|
||||
|
||||
InitializeLayout();
|
||||
}
|
||||
|
||||
private void InitializeLayout()
|
||||
{
|
||||
Size ledSize = new Size(19);
|
||||
const int ledSpacing = 20;
|
||||
LedId initial = Helper.GetInitialLedIdForDeviceType(DeviceInfo.DeviceType) + _initialLed;
|
||||
|
||||
if (_zone.Type == ZoneType.Matrix)
|
||||
{
|
||||
for (int row = 0; row < _zone.MatrixMap.Height; row++)
|
||||
{
|
||||
for (int column = 0; column < _zone.MatrixMap.Width; column++)
|
||||
{
|
||||
uint index = _zone.MatrixMap.Matrix[row, column];
|
||||
|
||||
//will be max value if the position does not have an associated key
|
||||
if (index == uint.MaxValue)
|
||||
continue;
|
||||
|
||||
LedId ledId = StandardKeyNames.Default.TryGetValue(DeviceInfo.OpenRGBDevice.Leds[_initialLed + index].Name, out LedId l)
|
||||
? l
|
||||
: initial++;
|
||||
|
||||
while (AddLed(ledId, new Point(ledSpacing * column, ledSpacing * row), ledSize, _initialLed + (int)index) == null)
|
||||
ledId = initial++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < _zone.LedCount; i++)
|
||||
{
|
||||
LedId ledId = initial++;
|
||||
|
||||
while (AddLed(ledId, new Point(ledSpacing * i, 0), ledSize, _initialLed + i) == null)
|
||||
ledId = initial++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using RGB.NET.Core;
|
||||
using System.Collections.Generic;
|
||||
using OpenRGBDevice = OpenRGB.NET.Models.Device;
|
||||
|
||||
namespace RGB.NET.Devices.OpenRGB
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Wooting.Keyboard.WootingKeyboardRGBDevice" />.
|
||||
/// </summary>
|
||||
public class OpenRGBZoneDeviceInfo : AbstractOpenRGBDeviceInfo
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="device"></param>
|
||||
public OpenRGBZoneDeviceInfo(OpenRGBDevice device) : base(device)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user