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

Merge pull request #157 from DarthAffe/Development

Merge development to master
This commit is contained in:
DarthAffe 2020-11-10 20:42:43 +01:00 committed by GitHub
commit 25534c1a7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
176 changed files with 3612 additions and 704 deletions

View File

@ -12,6 +12,10 @@ This is the easiest and therefore preferred way to include RGB.NET in your proje
Since there aren't any release-packages right now you'll have to use the CI-feed from [http://nuget.arge.be](http://nuget.arge.be).
You can include it either by adding ```http://nuget.arge.be/v3/index.json``` to your Visual Studio package sources or by adding this [NuGet.Config](https://github.com/DarthAffe/RGB.NET/tree/master/Documentation/NuGet.Config) to your project (at the same level as your solution).
### .NET 4.5 Support ###
At the end of the year with the release of .NET 5 the support for old .NET-Framwork versions will be droppped!
It's not recommended to use RGB.NET in projects targeting .NET 4.x that aren't planned to be moved to Core/.NET 5 in the future.
### Device-Layouts
To be able to have devices with correct LED-locations and sizes they need to be layouted. Pre-created layouts can be found at https://github.com/DarthAffe/RGB.NET-Resources.

View File

@ -14,8 +14,8 @@
<RootNamespace>RGB.NET.Brushes</RootNamespace>
<Description>Brushes-Presets of RGB.NET</Description>
<Summary>Brushes-Presets of RGB.NET, a C# (.NET) library for accessing various RGB-peripherals</Summary>
<Copyright>Copyright © Wyrez 2017</Copyright>
<PackageCopyright>Copyright © Wyrez 2017</PackageCopyright>
<Copyright>Copyright © Darth Affe 2020</Copyright>
<PackageCopyright>Copyright © Darth Affe 2020</PackageCopyright>
<PackageIconUrl>http://lib.arge.be/icon.png</PackageIconUrl>
<PackageProjectUrl>https://github.com/DarthAffe/RGB.NET</PackageProjectUrl>
<PackageLicenseUrl>https://raw.githubusercontent.com/DarthAffe/RGB.NET/master/LICENSE</PackageLicenseUrl>
@ -63,6 +63,6 @@
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
<PackageReference Include="System.ValueTuple" Version="4.4.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>
</Project>

View File

@ -110,14 +110,20 @@ namespace RGB.NET.Core
/// <returns>The finalized color.</returns>
protected virtual Color FinalizeColor(Color color)
{
foreach (IColorCorrection colorCorrection in ColorCorrections)
color = colorCorrection.ApplyTo(color);
if (ColorCorrections.Count > 0)
foreach (IColorCorrection colorCorrection in ColorCorrections)
color = colorCorrection.ApplyTo(color);
// Since we use HSV to calculate there is no way to make a color 'brighter' than 100%
// Be carefull with the naming: Since we use HSV the correct term is 'value' but outside we call it 'brightness'
// THIS IS NOT A HSB CALCULATION!!!
return color.MultiplyHSV(value: Brightness.Clamp(0, 1))
.MultiplyA(Opacity.Clamp(0, 1));
if (Brightness < 1)
color = color.MultiplyHSV(value: Brightness.Clamp(0, 1));
if (Opacity < 1)
color = color.MultiplyA(Opacity.Clamp(0, 1));
return color;
}
#endregion

View File

@ -12,18 +12,15 @@ namespace RGB.NET.Core
#region Properties & Fields
private readonly List<T> _decorators = new List<T>();
/// <summary>
/// Gets a readonly-list of all <see cref="IDecorator"/> attached to this <see cref="IDecoratable{T}"/>.
/// </summary>
protected IReadOnlyCollection<T> Decorators { get; }
#endregion
#region Constructors
protected AbstractDecoratable()
/// <inheritdoc />
public IReadOnlyCollection<T> Decorators
{
Decorators = new ReadOnlyCollection<T>(_decorators);
get
{
lock (_decorators)
return new ReadOnlyCollection<T>(_decorators);
}
}
#endregion

View File

@ -1,4 +1,6 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
namespace RGB.NET.Core
{
@ -42,16 +44,17 @@ namespace RGB.NET.Core
/// <summary>
/// Detaches the decorator from all <see cref="IDecoratable"/> it is currently attached to.
/// </summary>
/// <typeparam name="TDecoratable">The type of the <see cref="IDecoratable"/> this decorator is attached to.</typeparam>
/// <typeparam name="TDecorator">The type of this <see cref="IDecorator"/>.</typeparam>
protected virtual void Detach<TDecoratable, TDecorator>()
where TDecoratable : IDecoratable<TDecorator>
where TDecorator : AbstractDecorator
protected virtual void Detach()
{
List<IDecoratable> decoratables = new List<IDecoratable>(DecoratedObjects);
foreach (IDecoratable decoratable in decoratables)
if (decoratable is TDecoratable typedDecoratable)
typedDecoratable.RemoveDecorator((TDecorator)this);
{
IEnumerable<Type> types = decoratable.GetType().GetInterfaces().Where(t => t.IsGenericType
&& (t.Name == typeof(IDecoratable<>).Name)
&& t.GenericTypeArguments[0].IsInstanceOfType(this));
foreach (Type decoratableType in types)
decoratableType.GetMethod(nameof(IDecoratable<IDecorator>.RemoveDecorator))?.Invoke(decoratable, new object[] { this });
}
}
#endregion

View File

@ -1,4 +1,5 @@
using System.ComponentModel;
using System.Collections.Generic;
using System.ComponentModel;
namespace RGB.NET.Core
{
@ -13,9 +14,14 @@ namespace RGB.NET.Core
/// Represents a basic decoratable for a specific type of <see cref="T:RGB.NET.Core.IDecorator" />
/// </summary>
/// <typeparam name="T"></typeparam>
public interface IDecoratable<in T> : IDecoratable
public interface IDecoratable<T> : IDecoratable
where T : IDecorator
{
/// <summary>
/// Gets a readonly-list of all <see cref="IDecorator"/> attached to this <see cref="IDecoratable{T}"/>.
/// </summary>
IReadOnlyCollection<T> Decorators { get; }
/// <summary>
/// Adds an <see cref="IDecorator"/> to the <see cref="IDecoratable"/>.
/// </summary>

View File

@ -157,8 +157,12 @@ namespace RGB.NET.Core
/// <inheritdoc />
public virtual void Dispose()
{
SpecialDeviceParts.Clear();
LedMapping.Clear();
try
{
SpecialDeviceParts.Clear();
LedMapping.Clear();
}
catch { /* this really shouldn't happen */ }
}
/// <summary>

View File

@ -0,0 +1,8 @@
namespace RGB.NET.Core
{
/// <summary>
/// Represents a cooler-device
/// </summary>
public interface ICooler : IRGBDevice
{ }
}

View File

@ -0,0 +1,8 @@
namespace RGB.NET.Core
{
/// <summary>
/// Represents a DRAM-device
/// </summary>
public interface IDRAM : IRGBDevice
{ }
}

View File

@ -0,0 +1,8 @@
namespace RGB.NET.Core
{
/// <summary>
/// represents a fan-device
/// </summary>
public interface IFan : IRGBDevice
{ }
}

View File

@ -0,0 +1,8 @@
namespace RGB.NET.Core
{
/// <summary>
/// Represents a graphics-card-device
/// </summary>
public interface IGraphicsCard : IRGBDevice
{ }
}

View File

@ -0,0 +1,8 @@
namespace RGB.NET.Core
{
/// <summary>
/// Represents a headset-device
/// </summary>
public interface IHeadset : IRGBDevice
{ }
}

View File

@ -0,0 +1,8 @@
namespace RGB.NET.Core
{
/// <summary>
/// Represents a headset-stand-device
/// </summary>
public interface IHeadsetStand : IRGBDevice
{ }
}

View File

@ -0,0 +1,8 @@
namespace RGB.NET.Core
{
/// <summary>
/// Represents a keyboard-device
/// </summary>
public interface IKeyboard : IRGBDevice
{ }
}

View File

@ -0,0 +1,8 @@
namespace RGB.NET.Core
{
/// <summary>
/// Represents a keypad-device
/// </summary>
public interface IKeypad : IRGBDevice
{ }
}

View File

@ -0,0 +1,8 @@
namespace RGB.NET.Core
{
/// <summary>
/// Represents a led-matrix-device
/// </summary>
public interface ILedMatrix : IRGBDevice
{ }
}

View File

@ -0,0 +1,8 @@
namespace RGB.NET.Core
{
/// <summary>
/// Represents a led-stripe-device
/// </summary>
public interface ILedStripe : IRGBDevice
{ }
}

View File

@ -0,0 +1,8 @@
namespace RGB.NET.Core
{
/// <summary>
/// Represents a mainboard-device
/// </summary>
public interface IMainboard : IRGBDevice
{ }
}

View File

@ -0,0 +1,8 @@
namespace RGB.NET.Core
{
/// <summary>
/// Represents a mouse-device
/// </summary>
public interface IMouse : IRGBDevice
{ }
}

View File

@ -0,0 +1,8 @@
namespace RGB.NET.Core
{
/// <summary>
/// Represents a mousepad-device
/// </summary>
public interface IMousepad : IRGBDevice
{ }
}

View File

@ -0,0 +1,8 @@
namespace RGB.NET.Core
{
/// <summary>
/// Represents a speaker-device
/// </summary>
public interface ISpeaker : IRGBDevice
{ }
}

View File

@ -0,0 +1,8 @@
namespace RGB.NET.Core
{
/// <summary>
/// Represents a device with unkown or not specified type.
/// </summary>
public interface IUnknownDevice : IRGBDevice
{ }
}

View File

@ -0,0 +1,30 @@
using System;
namespace RGB.NET.Core
{
public static class ColorExtensions
{
#region Methods
/// <summary>
/// Calculates the distance between the two given colors using the redmean algorithm.
/// For more infos check https://www.compuphase.com/cmetric.htm
/// </summary>
/// <param name="color1">The start color of the distance calculation.</param>
/// <param name="color2">The end color fot the distance calculation.</param>
/// <returns></returns>
public static double DistanceTo(this Color color1, Color color2)
{
(_, byte r1, byte g1, byte b1) = color1.GetRGBBytes();
(_, byte r2, byte g2, byte b2) = color2.GetRGBBytes();
long rmean = (r1 + r2) / 2;
long r = r1 - r2;
long g = g1 - g2;
long b = b1 - b2;
return Math.Sqrt((((512 + rmean) * r * r) >> 8) + (4 * g * g) + (((767 - rmean) * b * b) >> 8));
}
#endregion
}
}

View File

@ -36,7 +36,7 @@ namespace RGB.NET.Core
#region Methods
/// <inheritdoc />
public abstract IEnumerable<Led> GetLeds();
public abstract IList<Led> GetLeds();
/// <inheritdoc />
public virtual void OnAttach()

View File

@ -25,7 +25,7 @@ namespace RGB.NET.Core
/// Gets a list containing all <see cref="Led"/> of this <see cref="ILedGroup"/>.
/// </summary>
/// <returns>The list containing all <see cref="Led"/> of this <see cref="ILedGroup"/>.</returns>
IEnumerable<Led> GetLeds();
IList<Led> GetLeds();
/// <summary>
/// Called when the <see cref="ILedGroup"/> is attached to the <see cref="RGBSurface"/>.

View File

@ -213,6 +213,38 @@ namespace RGB.NET.Core
Keyboard_Custom30 = 0x0000701E,
Keyboard_Custom31 = 0x0000701F,
Keyboard_Custom32 = 0x00007020,
Keyboard_Custom33 = 0x00007021,
Keyboard_Custom34 = 0x00007022,
Keyboard_Custom35 = 0x00007023,
Keyboard_Custom36 = 0x00007024,
Keyboard_Custom37 = 0x00007025,
Keyboard_Custom38 = 0x00007026,
Keyboard_Custom39 = 0x00007027,
Keyboard_Custom40 = 0x00007028,
Keyboard_Custom41 = 0x00007029,
Keyboard_Custom42 = 0x0000702A,
Keyboard_Custom43 = 0x0000702B,
Keyboard_Custom44 = 0x0000702C,
Keyboard_Custom45 = 0x0000702D,
Keyboard_Custom46 = 0x0000702E,
Keyboard_Custom47 = 0x0000702F,
Keyboard_Custom48 = 0x00007030,
Keyboard_Custom49 = 0x00007031,
Keyboard_Custom50 = 0x00007032,
Keyboard_Custom51 = 0x00007033,
Keyboard_Custom52 = 0x00007034,
Keyboard_Custom53 = 0x00007035,
Keyboard_Custom54 = 0x00007036,
Keyboard_Custom55 = 0x00007037,
Keyboard_Custom56 = 0x00007038,
Keyboard_Custom57 = 0x00007039,
Keyboard_Custom58 = 0x0000703A,
Keyboard_Custom59 = 0x0000703B,
Keyboard_Custom60 = 0x0000703C,
Keyboard_Custom61 = 0x0000703D,
Keyboard_Custom62 = 0x0000703E,
Keyboard_Custom63 = 0x0000703F,
Keyboard_Custom64 = 0x00007040,
/*### Mouse ###*/
Mouse1 = 0x00100001,

View File

@ -14,8 +14,8 @@
<RootNamespace>RGB.NET.Core</RootNamespace>
<Description>Core-Module of RGB.NET</Description>
<Summary>Core-Module of RGB.NET, a C# (.NET) library for accessing various RGB-peripherals</Summary>
<Copyright>Copyright © Wyrez 2017</Copyright>
<PackageCopyright>Copyright © Wyrez 2017</PackageCopyright>
<Copyright>Copyright © Darth Affe 2020</Copyright>
<PackageCopyright>Copyright © Darth Affe 2020</PackageCopyright>
<PackageIconUrl>http://lib.arge.be/icon.png</PackageIconUrl>
<PackageProjectUrl>https://github.com/DarthAffe/RGB.NET</PackageProjectUrl>
<PackageLicenseUrl>https://raw.githubusercontent.com/DarthAffe/RGB.NET/master/LICENSE</PackageLicenseUrl>
@ -59,6 +59,6 @@
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
<PackageReference Include="System.ValueTuple" Version="4.4.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>
</Project>

View File

@ -5,6 +5,7 @@
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=color_005Cbehaviors/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=decorators/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=devices/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=devices_005Ctypeinterfaces/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=devices_005Cupdate/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=effects/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=events/@EntryIndexedValue">True</s:Boolean>

View File

@ -38,7 +38,14 @@ namespace RGB.NET.Core
/// <summary>
/// Gets a readonly list containing all loaded <see cref="IRGBDevice"/>.
/// </summary>
public IEnumerable<IRGBDevice> Devices => new ReadOnlyCollection<IRGBDevice>(_devices);
public IEnumerable<IRGBDevice> Devices
{
get
{
lock (_devices)
return new ReadOnlyCollection<IRGBDevice>(_devices);
}
}
/// <summary>
/// Gets a readonly list containing all registered <see cref="IUpdateTrigger"/>.
@ -53,7 +60,14 @@ namespace RGB.NET.Core
/// <summary>
/// Gets a list of all <see cref="Led"/> on this <see cref="RGBSurface"/>.
/// </summary>
public IEnumerable<Led> Leds => _devices.SelectMany(x => x);
public IEnumerable<Led> Leds
{
get
{
lock (_devices)
return _devices.SelectMany(x => x);
}
}
#endregion
@ -92,32 +106,33 @@ namespace RGB.NET.Core
bool updateDevices = customData["updateDevices"] as bool? ?? true;
lock (_updateTriggers)
{
OnUpdating(updateTrigger, customData);
lock (_devices)
{
OnUpdating(updateTrigger, customData);
if (syncBack)
foreach (IRGBDevice device in Devices)
if (device.UpdateMode.HasFlag(DeviceUpdateMode.SyncBack) && device.DeviceInfo.SupportsSyncBack)
try { device.SyncBack(); }
catch (Exception ex) { OnException(ex); }
if (syncBack)
foreach (IRGBDevice device in _devices)
if (device.UpdateMode.HasFlag(DeviceUpdateMode.SyncBack) && device.DeviceInfo.SupportsSyncBack)
try { device.SyncBack(); }
catch (Exception ex) { OnException(ex); }
if (render)
lock (_ledGroups)
{
// Render brushes
foreach (ILedGroup ledGroup in _ledGroups.OrderBy(x => x.ZIndex))
try { Render(ledGroup); }
catch (Exception ex) { OnException(ex); }
}
if (render)
lock (_ledGroups)
{
// Render brushes
foreach (ILedGroup ledGroup in _ledGroups.OrderBy(x => x.ZIndex))
try { Render(ledGroup); }
catch (Exception ex) { OnException(ex); }
}
if (updateDevices)
foreach (IRGBDevice device in Devices)
if (!device.UpdateMode.HasFlag(DeviceUpdateMode.NoUpdate))
try { device.Update(flushLeds); }
catch (Exception ex) { OnException(ex); }
if (updateDevices)
foreach (IRGBDevice device in _devices)
if (!device.UpdateMode.HasFlag(DeviceUpdateMode.NoUpdate))
try { device.Update(flushLeds); }
catch (Exception ex) { OnException(ex); }
OnUpdated();
}
OnUpdated();
}
}
catch (Exception ex)
{
@ -128,16 +143,19 @@ namespace RGB.NET.Core
/// <inheritdoc />
public void Dispose()
{
//if (_updateTokenSource?.IsCancellationRequested == false)
// _updateTokenSource.Cancel();
lock (_devices)
foreach (IRGBDevice device in _devices)
try { device.Dispose(); }
catch { /* We do what we can */}
foreach (IRGBDevice device in _devices)
try { device.Dispose(); }
catch { /* We do what we can */ }
lock (_deviceProvider)
foreach (IRGBDeviceProvider deviceProvider in _deviceProvider)
try { deviceProvider.Dispose(); }
catch { /* We do what we can */}
foreach (IRGBDeviceProvider deviceProvider in _deviceProvider)
try { deviceProvider.Dispose(); }
catch { /* We do what we can */ }
foreach (IUpdateTrigger updateTrigger in _updateTriggers)
try { updateTrigger.Dispose(); }
catch { /* We do what we can */}
_ledGroups.Clear();
_devices = null;
@ -220,8 +238,11 @@ namespace RGB.NET.Core
private void UpdateSurfaceRectangle()
{
Rectangle devicesRectangle = new Rectangle(_devices.Select(d => d.DeviceRectangle));
SurfaceRectangle = SurfaceRectangle.SetSize(new Size(devicesRectangle.Location.X + devicesRectangle.Size.Width, devicesRectangle.Location.Y + devicesRectangle.Size.Height));
lock (_devices)
{
Rectangle devicesRectangle = new Rectangle(_devices.Select(d => d.DeviceRectangle));
SurfaceRectangle = SurfaceRectangle.SetSize(new Size(devicesRectangle.Location.X + devicesRectangle.Size.Width, devicesRectangle.Location.Y + devicesRectangle.Size.Height));
}
}
/// <summary>
@ -231,7 +252,10 @@ namespace RGB.NET.Core
/// <returns>A list of devices with the specified type.</returns>
public IList<T> GetDevices<T>()
where T : class
=> new ReadOnlyCollection<T>(_devices.Select(x => x as T).Where(x => x != null).ToList());
{
lock (_devices)
return new ReadOnlyCollection<T>(_devices.Select(x => x as T).Where(x => x != null).ToList());
}
/// <summary>
/// Gets all devices of the specified <see cref="RGBDeviceType"/>.
@ -239,7 +263,10 @@ namespace RGB.NET.Core
/// <param name="deviceType">The <see cref="RGBDeviceType"/> of the devices to get.</param>
/// <returns>a list of devices matching the specified <see cref="RGBDeviceType"/>.</returns>
public IList<IRGBDevice> GetDevices(RGBDeviceType deviceType)
=> new ReadOnlyCollection<IRGBDevice>(_devices.Where(d => deviceType.HasFlag(d.DeviceInfo.DeviceType)).ToList());
{
lock (_devices)
return new ReadOnlyCollection<IRGBDevice>(_devices.Where(d => deviceType.HasFlag(d.DeviceInfo.DeviceType)).ToList());
}
/// <summary>
/// Registers the provided <see cref="IUpdateTrigger"/>.

View File

@ -29,28 +29,31 @@ namespace RGB.NET.Core
/// <param name="throwExceptions">Specifies whether exception during the initialization sequence should be thrown or not.</param>
public void LoadDevices(IRGBDeviceProvider deviceProvider, RGBDeviceType loadFilter = RGBDeviceType.All, bool exclusiveAccessIfPossible = false, bool throwExceptions = false)
{
if (_deviceProvider.Contains(deviceProvider) || _deviceProvider.Any(x => x.GetType() == deviceProvider.GetType())) return;
List<IRGBDevice> addedDevices = new List<IRGBDevice>();
if (deviceProvider.IsInitialized || deviceProvider.Initialize(loadFilter, exclusiveAccessIfPossible, throwExceptions))
lock (_deviceProvider)
{
_deviceProvider.Add(deviceProvider);
if (_deviceProvider.Contains(deviceProvider) || _deviceProvider.Any(x => x.GetType() == deviceProvider.GetType())) return;
foreach (IRGBDevice device in deviceProvider.Devices)
List<IRGBDevice> addedDevices = new List<IRGBDevice>();
if (deviceProvider.IsInitialized || deviceProvider.Initialize(loadFilter, exclusiveAccessIfPossible, throwExceptions))
{
if (_devices.Contains(device)) continue;
_deviceProvider.Add(deviceProvider);
lock (_devices)
foreach (IRGBDevice device in deviceProvider.Devices)
{
if (_devices.Contains(device)) continue;
addedDevices.Add(device);
addedDevices.Add(device);
device.PropertyChanged += DeviceOnPropertyChanged;
_devices.Add(device);
device.PropertyChanged += DeviceOnPropertyChanged;
_devices.Add(device);
}
}
}
if (addedDevices.Any())
{
UpdateSurfaceRectangle();
SurfaceLayoutChanged?.Invoke(new SurfaceLayoutChangedEventArgs(addedDevices, true, false));
if (addedDevices.Any())
{
UpdateSurfaceRectangle();
SurfaceLayoutChanged?.Invoke(new SurfaceLayoutChangedEventArgs(addedDevices, true, false));
}
}
}

View File

@ -5,7 +5,7 @@ namespace RGB.NET.Core
/// <summary>
/// Represents a generic update trigger.
/// </summary>
public class AbstractUpdateTrigger : AbstractBindable, IUpdateTrigger
public abstract class AbstractUpdateTrigger : AbstractBindable, IUpdateTrigger
{
#region Events
@ -31,8 +31,7 @@ namespace RGB.NET.Core
protected virtual void OnUpdate(CustomUpdateData updateData = null) => Update?.Invoke(this, updateData);
/// <inheritdoc />
public virtual void Dispose()
{ }
public abstract void Dispose();
#endregion
}

View File

@ -144,6 +144,9 @@ namespace RGB.NET.Core
UpdateFrequency = UpdateRateHardLimit;
}
/// <inheritdoc />
public override void Dispose() => Stop();
#endregion
}
}

View File

@ -100,7 +100,8 @@ namespace RGB.NET.Core
_currentDataSet = null;
}
public void Dispose()
/// <inheritdoc />
public virtual void Dispose()
{
_updateTrigger.Starting -= OnStartup;
_updateTrigger.Update -= OnUpdate;

View File

@ -106,6 +106,9 @@ namespace RGB.NET.Core
}
}
/// <inheritdoc />
public override void Dispose() => Stop();
#endregion
}
}

View File

@ -129,7 +129,7 @@ namespace RGB.NET.Decorators.Brush
else
{
if ((++_repetitionCount >= Repetitions) && (Repetitions > 0))
Detach<IBrush, FlashDecorator>();
Detach();
_currentPhaseValue = Attack;
_currentPhase = ADSRPhase.Attack;
}

View File

@ -14,8 +14,8 @@
<RootNamespace>RGB.NET.Decorators</RootNamespace>
<Description>Decorators-Presets of RGB.NET</Description>
<Summary>Decorators-Presets of RGB.NET, a C# (.NET) library for accessing various RGB-peripherals</Summary>
<Copyright>Copyright © Wyrez 2017</Copyright>
<PackageCopyright>Copyright © Wyrez 2017</PackageCopyright>
<Copyright>Copyright © Darth Affe 2020</Copyright>
<PackageCopyright>Copyright © Darth Affe 2020</PackageCopyright>
<PackageIconUrl>http://lib.arge.be/icon.png</PackageIconUrl>
<PackageProjectUrl>https://github.com/DarthAffe/RGB.NET</PackageProjectUrl>
<PackageLicenseUrl>https://raw.githubusercontent.com/DarthAffe/RGB.NET/master/LICENSE</PackageLicenseUrl>
@ -64,6 +64,6 @@
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
<PackageReference Include="System.ValueTuple" Version="4.4.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>
</Project>

View File

@ -90,52 +90,45 @@ namespace RGB.NET.Devices.Asus
{
try
{
IAsusRGBDevice rgbDevice = null;
switch (device.Type)
IAsusRGBDevice rgbDevice;
switch ((AsusDeviceType)device.Type)
{
case 0x00010000: //Motherboard
case AsusDeviceType.MB_RGB:
rgbDevice = new AsusMainboardRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Mainboard, device, WMIHelper.GetMainboardInfo()?.model ?? device.Name));
break;
case 0x00011000: //Motherboard LED Strip
case AsusDeviceType.MB_ADDRESABLE:
rgbDevice = new AsusUnspecifiedRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.LedStripe, device), LedId.LedStripe1);
break;
case 0x00020000: //VGA
case AsusDeviceType.VGA_RGB:
rgbDevice = new AsusGraphicsCardRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.GraphicsCard, device));
break;
case 0x00040000: //Headset
case AsusDeviceType.HEADSET_RGB:
rgbDevice = new AsusHeadsetRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Headset, device));
break;
case 0x00070000: //DRAM
case AsusDeviceType.DRAM_RGB:
rgbDevice = new AsusDramRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.DRAM, device));
break;
case 0x00080000: //Keyboard
case 0x00081000: //Notebook Keyboard
case 0x00081001: //Notebook Keyboard(4 - zone type)
case AsusDeviceType.KEYBOARD_RGB:
case AsusDeviceType.NB_KB_RGB:
case AsusDeviceType.NB_KB_4ZONE_RGB:
rgbDevice = new AsusKeyboardRGBDevice(new AsusKeyboardRGBDeviceInfo(device, CultureInfo.CurrentCulture));
break;
case 0x00090000: //Mouse
case AsusDeviceType.MOUSE_RGB:
rgbDevice = new AsusMouseRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Mouse, device));
break;
case 0x00000000: //All
case 0x00012000: //All - In - One PC
case 0x00030000: //Display
case 0x00050000: //Microphone
case 0x00060000: //External HDD
case 0x00061000: //External BD Drive
case 0x000B0000: //Chassis
case 0x000C0000: //Projector
default:
rgbDevice = new AsusUnspecifiedRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Unknown, device), LedId.Custom1);
break;
}
if ((rgbDevice != null) && loadFilter.HasFlag(rgbDevice.DeviceInfo.DeviceType))
if (loadFilter.HasFlag(rgbDevice.DeviceInfo.DeviceType))
{
rgbDevice.Initialize(UpdateTrigger);
devices.Add(rgbDevice);
@ -172,7 +165,12 @@ namespace RGB.NET.Devices.Asus
/// <inheritdoc />
public void Dispose()
{
_sdk?.ReleaseControl(0);
try { UpdateTrigger?.Dispose(); }
catch { /* at least we tried */ }
try { _sdk?.ReleaseControl(0); }
catch { /* at least we tried */ }
_sdk = null;
}

View File

@ -2,11 +2,11 @@
namespace RGB.NET.Devices.Asus
{
/// <inheritdoc />
/// <inheritdoc cref="AsusRGBDevice{TDeviceInfo}" />
/// <summary>
/// Represents a Asus dram.
/// </summary>
public class AsusDramRGBDevice : AsusRGBDevice<AsusRGBDeviceInfo>
public class AsusDramRGBDevice : AsusRGBDevice<AsusRGBDeviceInfo>, IDRAM
{
#region Constructors

View File

@ -0,0 +1,25 @@
// ReSharper disable InconsistentNaming
namespace RGB.NET.Devices.Asus
{
internal enum AsusDeviceType : uint
{
ALL = 0,
MB_RGB = 0x10000,
MB_ADDRESABLE = 0x11000,
DESKTOP_RGB = 0x12000,
VGA_RGB = 0x20000,
DISPLAY_RGB = 0x30000,
HEADSET_RGB = 0x40000,
MICROPHONE_RGB = 0x50000,
EXTERNAL_HARD_DRIVER_RGB = 0x60000,
EXTERNAL_BLUE_RAY_RGB = 0x61000,
DRAM_RGB = 0x70000,
KEYBOARD_RGB = 0x80000,
NB_KB_RGB = 0x81000,
NB_KB_4ZONE_RGB = 0x81001,
MOUSE_RGB = 0x90000,
CHASSIS_RGB = 0xB0000,
PROJECTOR_RGB = 0xC0000
}
}

View File

@ -0,0 +1,160 @@
// ReSharper disable InconsistentNaming
namespace RGB.NET.Devices.Asus
{
internal enum AsusLedId : ushort
{
KEY_ESCAPE = 0x01,
KEY_1 = 0x02,
KEY_2 = 0x03,
KEY_3 = 0x04,
KEY_4 = 0x05,
KEY_5 = 0x06,
KEY_6 = 0x07,
KEY_7 = 0x08,
KEY_8 = 0x09,
KEY_9 = 0x0A,
KEY_0 = 0x0B,
KEY_MINUS = 0x0C, // - on main keyboard
KEY_EQUALS = 0x0D,
KEY_BACK = 0x0E, // backspace
KEY_TAB = 0x0F,
KEY_Q = 0x10,
KEY_W = 0x11,
KEY_E = 0x12,
KEY_R = 0x13,
KEY_T = 0x14,
KEY_Y = 0x15,
KEY_U = 0x16,
KEY_I = 0x17,
KEY_O = 0x18,
KEY_P = 0x19,
KEY_LBRACKET = 0x1A,
KEY_RBRACKET = 0x1B,
KEY_RETURN = 0x1C, // Enter on main keyboard
KEY_LCONTROL = 0x1D,
KEY_A = 0x1E,
KEY_S = 0x1F,
KEY_D = 0x20,
KEY_F = 0x21,
KEY_G = 0x22,
KEY_H = 0x23,
KEY_J = 0x24,
KEY_K = 0x25,
KEY_L = 0x26,
KEY_SEMICOLON = 0x27,
KEY_APOSTROPHE = 0x28,
KEY_GRAVE = 0x29, // accent grave
KEY_LSHIFT = 0x2A,
KEY_BACKSLASH = 0x2B,
KEY_Z = 0x2C,
KEY_X = 0x2D,
KEY_C = 0x2E,
KEY_V = 0x2F,
KEY_B = 0x30,
KEY_N = 0x31,
KEY_M = 0x32,
KEY_COMMA = 0x33,
KEY_PERIOD = 0x34, // . on main keyboard
KEY_SLASH = 0x35, // / on main keyboard
KEY_RSHIFT = 0x36,
KEY_MULTIPLY = 0x37, // * on numeric keypad
KEY_LMENU = 0x38, // left Alt
KEY_SPACE = 0x39,
KEY_CAPITAL = 0x3A,
KEY_F1 = 0x3B,
KEY_F2 = 0x3C,
KEY_F3 = 0x3D,
KEY_F4 = 0x3E,
KEY_F5 = 0x3F,
KEY_F6 = 0x40,
KEY_F7 = 0x41,
KEY_F8 = 0x42,
KEY_F9 = 0x43,
KEY_F10 = 0x44,
KEY_NUMLOCK = 0x45,
KEY_SCROLL = 0x46, // Scroll Lock
KEY_NUMPAD7 = 0x47,
KEY_NUMPAD8 = 0x48,
KEY_NUMPAD9 = 0x49,
KEY_SUBTRACT = 0x4A, // - on numeric keypad
KEY_NUMPAD4 = 0x4B,
KEY_NUMPAD5 = 0x4C,
KEY_NUMPAD6 = 0x4D,
KEY_ADD = 0x4E, // + on numeric keypad
KEY_NUMPAD1 = 0x4F,
KEY_NUMPAD2 = 0x50,
KEY_NUMPAD3 = 0x51,
KEY_NUMPAD0 = 0x52,
KEY_DECIMAL = 0x53, // . on numeric keypad
KEY_OEM_102 = 0x56, // < > | on UK/Germany keyboards
KEY_F11 = 0x57,
KEY_F12 = 0x58,
KEY_F13 = 0x64, // (NEC PC98)
KEY_F14 = 0x65, // (NEC PC98)
KEY_F15 = 0x66, // (NEC PC98)
KEY_KANA = 0x70, // (Japanese keyboard)
KEY_ABNT_C1 = 0x73, // / ? on Portugese (Brazilian) keyboards
KEY_CONVERT = 0x79, // (Japanese keyboard)
KEY_NOCONVERT = 0x7B, // (Japanese keyboard)
KEY_YEN = 0x7D, // (Japanese keyboard)
KEY_ABNT_C2 = 0x7E, // Numpad . on Portugese (Brazilian) keyboards
KEY_NUMPADEQUALS = 0x8D, // = on numeric keypad (NEC PC98)
KEY_CIRCUMFLEX = 0x90, // (Japanese keyboard)
KEY_AT = 0x91, // (NEC PC98)
KEY_COLON = 0x92, // (NEC PC98)
KEY_UNDERLINE = 0x93, // (NEC PC98)
KEY_KANJI = 0x94, // (Japanese keyboard)
KEY_STOP = 0x95, // (NEC PC98)
KEY_AX = 0x96, // (Japan AX)
KEY_UNLABELED = 0x97, // (J3100)
KEY_NEXTTRACK = 0x99, // Next Track
KEY_NUMPADENTER = 0x9C, // Enter on numeric keypad
KEY_RCONTROL = 0x9D, //
KEY_MUTE = 0xA0, // Mute
KEY_CALCULATOR = 0xA1, // Calculator
KEY_PLAYPAUSE = 0xA2, // Play / Pause
KEY_MEDIASTOP = 0xA4, // Media Stop
KEY_VOLUMEDOWN = 0xAE, // Volume -
KEY_VOLUMEUP = 0xB0, // Volume +
KEY_WEBHOME = 0xB2, // Web home
KEY_NUMPADCOMMA = 0xB3, // , on numeric keypad (NEC PC98)
KEY_DIVIDE = 0xB5, // / on numeric keypad
KEY_SYSRQ = 0xB7, //
KEY_RMENU = 0xB8, // right Alt
KEY_PAUSE = 0xC5, // Pause
KEY_HOME = 0xC7, // Home on arrow keypad
KEY_UP = 0xC8, // UpArrow on arrow keypad
KEY_PRIOR = 0xC9, // PgUp on arrow keypad
KEY_LEFT = 0xCB, // LeftArrow on arrow keypad
KEY_RIGHT = 0xCD, // RightArrow on arrow keypad
KEY_END = 0xCF, // End on arrow keypad
KEY_DOWN = 0xD0, // DownArrow on arrow keypad
KEY_NEXT = 0xD1, // PgDn on arrow keypad
KEY_INSERT = 0xD2, // Insert on arrow keypad
KEY_DELETE = 0xD3, // Delete on arrow keypad
KEY_LWIN = 0xDB, // Left Windows key
KEY_RWIN = 0xDC, // Right Windows key
KEY_APPS = 0xDD, // AppMenu key
KEY_POWER = 0xDE, //
KEY_SLEEP = 0xDF, //
KEY_WAKE = 0xE3, // System Wake
KEY_WEBSEARCH = 0xE5, // Web Search
KEY_WEBFAVORITES = 0xE6, // Web Favorites
KEY_WEBREFRESH = 0xE7, // Web Refresh
KEY_WEBSTOP = 0xE8, // Web Stop
KEY_WEBFORWARD = 0xE9, // Web Forward
KEY_WEBBACK = 0xEA, // Web Back
KEY_MYCOMPUTER = 0xEB, // My Computer
KEY_MAIL = 0xEC, // Mail
KEY_MEDIASELECT = 0xED, // Media Select
KEY_FN = 0x100, // Function key
// Undocumented
UNDOCUMENTED_1 = 0x59,
UNDOCUMENTED_2 = 0x56,
UNDOCUMENTED_3 = 0x101,
UNDOCUMENTED_4 = 0x102,
UNDOCUMENTED_5 = 0x103,
}
}

View File

@ -80,6 +80,15 @@ namespace RGB.NET.Devices.Asus
//}
}
/// <inheritdoc />
public override void Dispose()
{
try { UpdateQueue?.Dispose(); }
catch { /* at least we tried */ }
base.Dispose();
}
#endregion
}
}

View File

@ -2,11 +2,11 @@
namespace RGB.NET.Devices.Asus
{
/// <inheritdoc />
/// <inheritdoc cref="AsusRGBDevice{TDeviceInfo}" />
/// <summary>
/// Represents a Asus headset.
/// </summary>
public class AsusUnspecifiedRGBDevice : AsusRGBDevice<AsusRGBDeviceInfo>
public class AsusUnspecifiedRGBDevice : AsusRGBDevice<AsusRGBDeviceInfo>, IUnknownDevice
{
#region Properties & Fields

View File

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using AuraServiceLib;
using RGB.NET.Core;
@ -48,22 +47,57 @@ namespace RGB.NET.Devices.Asus
{
try
{
foreach (KeyValuePair<object, Color> data in dataSet)
if ((Device.Type == (uint)AsusDeviceType.KEYBOARD_RGB) || (Device.Type == (uint)AsusDeviceType.NB_KB_RGB))
{
int index = (int)data.Key;
IAuraRgbLight light = Device.Lights[index];
(_, byte r, byte g, byte b) = data.Value.GetRGBBytes();
light.Red = r;
light.Green = g;
light.Blue = b;
foreach (KeyValuePair<object, Color> data in dataSet)
{
AsusLedId index = (AsusLedId)data.Key;
IAuraSyncKeyboard keyboard = (IAuraSyncKeyboard)Device;
if (keyboard != null)
{
IAuraRgbLight light = index switch
{
//UK keyboard Layout
AsusLedId.KEY_OEM_102 => keyboard.Lights[(int)((3 * keyboard.Width) + 13)],
AsusLedId.UNDOCUMENTED_1 => keyboard.Lights[(int)((4 * keyboard.Width) + 1)],
_ => keyboard.Key[(ushort)index]
};
// Asus Strix Scope
if (keyboard.Name == "Charm")
light = index switch
{
AsusLedId.KEY_LWIN => keyboard.Lights[(int)((5 * keyboard.Width) + 2)],
AsusLedId.KEY_LMENU => keyboard.Lights[(int)((5 * keyboard.Width) + 3)],
_ => light
};
(_, byte r, byte g, byte b) = data.Value.GetRGBBytes();
light.Red = r;
light.Green = g;
light.Blue = b;
}
}
}
else
{
foreach (KeyValuePair<object, Color> data in dataSet)
{
int index = (int)data.Key;
IAuraRgbLight light = Device.Lights[index];
(_, byte r, byte g, byte b) = data.Value.GetRGBBytes();
light.Red = r;
light.Green = g;
light.Blue = b;
}
}
Device.Apply();
}
catch (Exception ex)
catch
{ /* "The server threw an exception." seems to be a thing here ... */ }
}
#endregion
}
}

View File

@ -2,11 +2,11 @@
namespace RGB.NET.Devices.Asus
{
/// <inheritdoc />
/// <inheritdoc cref="AsusRGBDevice{TDeviceInfo}" />
/// <summary>
/// Represents a Asus graphicsCard.
/// </summary>
public class AsusGraphicsCardRGBDevice : AsusRGBDevice<AsusRGBDeviceInfo>
public class AsusGraphicsCardRGBDevice : AsusRGBDevice<AsusRGBDeviceInfo>, IGraphicsCard
{
#region Constructors

View File

@ -2,11 +2,11 @@
namespace RGB.NET.Devices.Asus
{
/// <inheritdoc />
/// <inheritdoc cref="AsusRGBDevice{TDeviceInfo}" />
/// <summary>
/// Represents a Asus headset.
/// </summary>
public class AsusHeadsetRGBDevice : AsusRGBDevice<AsusRGBDeviceInfo>
public class AsusHeadsetRGBDevice : AsusRGBDevice<AsusRGBDeviceInfo>, IHeadset
{
#region Constructors

View File

@ -0,0 +1,161 @@
using System.Collections.Generic;
using RGB.NET.Core;
namespace RGB.NET.Devices.Asus
{
internal static class AsusKeyboardLedMapping
{
public static readonly Dictionary<LedId, AsusLedId> MAPPING = new Dictionary<LedId, AsusLedId>
{
{ LedId.Keyboard_Escape, AsusLedId.KEY_ESCAPE },
{ LedId.Keyboard_F1, AsusLedId.KEY_F1 },
{ LedId.Keyboard_F2, AsusLedId.KEY_F2 },
{ LedId.Keyboard_F3, AsusLedId.KEY_F3 },
{ LedId.Keyboard_F4, AsusLedId.KEY_F4 },
{ LedId.Keyboard_F5, AsusLedId.KEY_F5 },
{ LedId.Keyboard_F6, AsusLedId.KEY_F6 },
{ LedId.Keyboard_F7, AsusLedId.KEY_F7 },
{ LedId.Keyboard_F8, AsusLedId.KEY_F8 },
{ LedId.Keyboard_F9, AsusLedId.KEY_F9 },
{ LedId.Keyboard_F10, AsusLedId.KEY_F10 },
{ LedId.Keyboard_F11, AsusLedId.KEY_F11 },
{ LedId.Keyboard_F12, AsusLedId.KEY_F12 },
{ LedId.Keyboard_1, AsusLedId.KEY_1 },
{ LedId.Keyboard_2, AsusLedId.KEY_2 },
{ LedId.Keyboard_3, AsusLedId.KEY_3 },
{ LedId.Keyboard_4, AsusLedId.KEY_4 },
{ LedId.Keyboard_5, AsusLedId.KEY_5 },
{ LedId.Keyboard_6, AsusLedId.KEY_6 },
{ LedId.Keyboard_7, AsusLedId.KEY_7 },
{ LedId.Keyboard_8, AsusLedId.KEY_8 },
{ LedId.Keyboard_9, AsusLedId.KEY_9 },
{ LedId.Keyboard_0, AsusLedId.KEY_0 },
{ LedId.Keyboard_MinusAndUnderscore, AsusLedId.KEY_MINUS },
{ LedId.Keyboard_EqualsAndPlus, AsusLedId.KEY_EQUALS },
{ LedId.Keyboard_Backspace, AsusLedId.KEY_BACK },
{ LedId.Keyboard_Tab, AsusLedId.KEY_TAB },
{ LedId.Keyboard_Q, AsusLedId.KEY_Q },
{ LedId.Keyboard_W, AsusLedId.KEY_W },
{ LedId.Keyboard_E, AsusLedId.KEY_E },
{ LedId.Keyboard_R, AsusLedId.KEY_R },
{ LedId.Keyboard_T, AsusLedId.KEY_T },
{ LedId.Keyboard_Y, AsusLedId.KEY_Y },
{ LedId.Keyboard_U, AsusLedId.KEY_U },
{ LedId.Keyboard_I, AsusLedId.KEY_I },
{ LedId.Keyboard_O, AsusLedId.KEY_O },
{ LedId.Keyboard_P, AsusLedId.KEY_P },
{ LedId.Keyboard_BracketLeft, AsusLedId.KEY_LBRACKET },
{ LedId.Keyboard_BracketRight, AsusLedId.KEY_RBRACKET },
{ LedId.Keyboard_Enter, AsusLedId.KEY_RETURN },
{ LedId.Keyboard_CapsLock, AsusLedId.KEY_CAPITAL },
{ LedId.Keyboard_A, AsusLedId.KEY_A },
{ LedId.Keyboard_S, AsusLedId.KEY_S },
{ LedId.Keyboard_D, AsusLedId.KEY_D },
{ LedId.Keyboard_F, AsusLedId.KEY_F },
{ LedId.Keyboard_G, AsusLedId.KEY_G },
{ LedId.Keyboard_H, AsusLedId.KEY_H },
{ LedId.Keyboard_J, AsusLedId.KEY_J },
{ LedId.Keyboard_K, AsusLedId.KEY_K },
{ LedId.Keyboard_L, AsusLedId.KEY_L },
{ LedId.Keyboard_SemicolonAndColon, AsusLedId.KEY_SEMICOLON },
{ LedId.Keyboard_ApostropheAndDoubleQuote, AsusLedId.KEY_APOSTROPHE },
{ LedId.Keyboard_GraveAccentAndTilde, AsusLedId.KEY_GRAVE },
{ LedId.Keyboard_LeftShift, AsusLedId.KEY_LSHIFT },
{ LedId.Keyboard_Backslash, AsusLedId.KEY_BACKSLASH },
{ LedId.Keyboard_Z, AsusLedId.KEY_Z },
{ LedId.Keyboard_X, AsusLedId.KEY_X },
{ LedId.Keyboard_C, AsusLedId.KEY_C },
{ LedId.Keyboard_V, AsusLedId.KEY_V },
{ LedId.Keyboard_B, AsusLedId.KEY_B },
{ LedId.Keyboard_N, AsusLedId.KEY_N },
{ LedId.Keyboard_M, AsusLedId.KEY_M },
{ LedId.Keyboard_CommaAndLessThan, AsusLedId.KEY_COMMA },
{ LedId.Keyboard_PeriodAndBiggerThan, AsusLedId.KEY_PERIOD },
{ LedId.Keyboard_SlashAndQuestionMark, AsusLedId.KEY_SLASH },
{ LedId.Keyboard_RightShift, AsusLedId.KEY_RSHIFT },
{ LedId.Keyboard_LeftCtrl, AsusLedId.KEY_LCONTROL },
{ LedId.Keyboard_LeftGui, AsusLedId.KEY_LWIN },
{ LedId.Keyboard_LeftAlt, AsusLedId.KEY_LMENU },
{ LedId.Keyboard_Space, AsusLedId.KEY_SPACE },
{ LedId.Keyboard_RightAlt, AsusLedId.KEY_RMENU },
{ LedId.Keyboard_RightGui, AsusLedId.KEY_RWIN },
{ LedId.Keyboard_Application, AsusLedId.KEY_APPS },
{ LedId.Keyboard_RightCtrl, AsusLedId.KEY_RCONTROL },
{ LedId.Keyboard_PrintScreen, AsusLedId.KEY_SYSRQ },
{ LedId.Keyboard_ScrollLock, AsusLedId.KEY_SCROLL },
{ LedId.Keyboard_PauseBreak, AsusLedId.KEY_PAUSE },
{ LedId.Keyboard_Insert, AsusLedId.KEY_INSERT },
{ LedId.Keyboard_Home, AsusLedId.KEY_HOME },
{ LedId.Keyboard_PageUp, AsusLedId.KEY_PRIOR },
{ LedId.Keyboard_Delete, AsusLedId.KEY_DELETE },
{ LedId.Keyboard_End, AsusLedId.KEY_END },
{ LedId.Keyboard_PageDown, AsusLedId.KEY_NEXT },
{ LedId.Keyboard_ArrowUp, AsusLedId.KEY_UP },
{ LedId.Keyboard_ArrowLeft, AsusLedId.KEY_LEFT },
{ LedId.Keyboard_ArrowDown, AsusLedId.KEY_DOWN },
{ LedId.Keyboard_ArrowRight, AsusLedId.KEY_RIGHT },
{ LedId.Keyboard_NumLock, AsusLedId.KEY_NUMLOCK },
{ LedId.Keyboard_NumSlash, AsusLedId.KEY_DIVIDE },
{ LedId.Keyboard_NumAsterisk, AsusLedId.KEY_MULTIPLY },
{ LedId.Keyboard_NumMinus, AsusLedId.KEY_SUBTRACT },
{ LedId.Keyboard_Num7, AsusLedId.KEY_NUMPAD7 },
{ LedId.Keyboard_Num8, AsusLedId.KEY_NUMPAD8 },
{ LedId.Keyboard_Num9, AsusLedId.KEY_NUMPAD9 },
{ LedId.Keyboard_NumPeriodAndDelete, AsusLedId.KEY_DECIMAL },
{ LedId.Keyboard_NumPlus, AsusLedId.KEY_ADD },
{ LedId.Keyboard_Num4, AsusLedId.KEY_NUMPAD4 },
{ LedId.Keyboard_Num5, AsusLedId.KEY_NUMPAD5 },
{ LedId.Keyboard_Num6, AsusLedId.KEY_NUMPAD6 },
{ LedId.Keyboard_Num1, AsusLedId.KEY_NUMPAD1 },
{ LedId.Keyboard_Num2, AsusLedId.KEY_NUMPAD2 },
{ LedId.Keyboard_Num3, AsusLedId.KEY_NUMPAD3 },
{ LedId.Keyboard_Num0, AsusLedId.KEY_NUMPAD0 },
{ LedId.Keyboard_NumEnter, AsusLedId.KEY_NUMPADENTER },
{ LedId.Keyboard_NonUsBackslash, AsusLedId.UNDOCUMENTED_1 },
{ LedId.Keyboard_NonUsTilde, AsusLedId.UNDOCUMENTED_2 },
{ LedId.Keyboard_NumComma, AsusLedId.KEY_NUMPADCOMMA },
{ LedId.Logo, AsusLedId.UNDOCUMENTED_3 },
{ LedId.Keyboard_Custom1, AsusLedId.UNDOCUMENTED_4 },
{ LedId.Keyboard_Custom2, AsusLedId.UNDOCUMENTED_5 },
{ LedId.Keyboard_Custom3, AsusLedId.KEY_F13 },
{ LedId.Keyboard_Custom4, AsusLedId.KEY_F14 },
{ LedId.Keyboard_Custom5, AsusLedId.KEY_F15 },
{ LedId.Keyboard_Custom6, AsusLedId.KEY_KANA },
{ LedId.Keyboard_Custom7, AsusLedId.KEY_ABNT_C1 },
{ LedId.Keyboard_Custom8, AsusLedId.KEY_CONVERT },
{ LedId.Keyboard_Custom9, AsusLedId.KEY_NOCONVERT },
{ LedId.Keyboard_Custom10, AsusLedId.KEY_YEN },
{ LedId.Keyboard_Custom11, AsusLedId.KEY_ABNT_C2 },
{ LedId.Keyboard_Custom12, AsusLedId.KEY_NUMPADEQUALS },
{ LedId.Keyboard_Custom13, AsusLedId.KEY_CIRCUMFLEX },
{ LedId.Keyboard_Custom14, AsusLedId.KEY_AT },
{ LedId.Keyboard_Custom15, AsusLedId.KEY_COLON },
{ LedId.Keyboard_Custom16, AsusLedId.KEY_UNDERLINE },
{ LedId.Keyboard_Custom17, AsusLedId.KEY_KANJI },
{ LedId.Keyboard_Custom18, AsusLedId.KEY_STOP },
{ LedId.Keyboard_Custom19, AsusLedId.KEY_AX },
{ LedId.Keyboard_Custom20, AsusLedId.KEY_UNLABELED },
{ LedId.Keyboard_Custom21, AsusLedId.KEY_NEXTTRACK },
{ LedId.Keyboard_Custom22, AsusLedId.KEY_CALCULATOR },
{ LedId.Keyboard_Custom23, AsusLedId.KEY_POWER },
{ LedId.Keyboard_Custom24, AsusLedId.KEY_SLEEP },
{ LedId.Keyboard_Custom25, AsusLedId.KEY_WAKE },
{ LedId.Keyboard_Custom26, AsusLedId.KEY_WEBSEARCH },
{ LedId.Keyboard_Custom27, AsusLedId.KEY_WEBFAVORITES },
{ LedId.Keyboard_Custom28, AsusLedId.KEY_WEBREFRESH },
{ LedId.Keyboard_Custom29, AsusLedId.KEY_WEBSTOP },
{ LedId.Keyboard_Custom30, AsusLedId.KEY_WEBFORWARD },
{ LedId.Keyboard_Custom31, AsusLedId.KEY_WEBHOME },
{ LedId.Keyboard_Custom32, AsusLedId.KEY_WEBBACK },
{ LedId.Keyboard_Custom33, AsusLedId.KEY_MYCOMPUTER },
{ LedId.Keyboard_Custom34, AsusLedId.KEY_MAIL },
{ LedId.Keyboard_Custom35, AsusLedId.KEY_MEDIASELECT },
{ LedId.Keyboard_Custom36, AsusLedId.KEY_FN },
{ LedId.Keyboard_MediaMute, AsusLedId.KEY_MUTE },
{ LedId.Keyboard_MediaPlay, AsusLedId.KEY_PLAYPAUSE },
{ LedId.Keyboard_MediaStop, AsusLedId.KEY_MEDIASTOP },
{ LedId.Keyboard_MediaVolumeDown, AsusLedId.KEY_VOLUMEDOWN },
{ LedId.Keyboard_MediaVolumeUp, AsusLedId.KEY_VOLUMEUP },
};
}
}

View File

@ -1,12 +1,15 @@
using RGB.NET.Core;
using System.Collections.Generic;
using System.Linq;
using AuraServiceLib;
using RGB.NET.Core;
namespace RGB.NET.Devices.Asus
{
/// <inheritdoc />
/// <inheritdoc cref="AsusRGBDevice{TDeviceInfo}" />
/// <summary>
/// Represents a Asus keyboard.
/// </summary>
public class AsusKeyboardRGBDevice : AsusRGBDevice<AsusKeyboardRGBDeviceInfo>
public class AsusKeyboardRGBDevice : AsusRGBDevice<AsusKeyboardRGBDeviceInfo>, IKeyboard
{
#region Constructors
@ -26,17 +29,38 @@ namespace RGB.NET.Devices.Asus
/// <inheritdoc />
protected override void InitializeLayout()
{
//TODO DarthAffe 07.10.2017: This doesn't make sense at all ... Find someone with such a keyboard!
int ledCount = DeviceInfo.Device.Lights.Count;
for (int i = 0; i < ledCount; i++)
InitializeLed(LedId.Keyboard_Escape + i, new Rectangle(i * 19, 0, 19, 19));
Dictionary<AsusLedId, LedId> reversedMapping = AsusKeyboardLedMapping.MAPPING.ToDictionary(x => x.Value, x => x.Key);
if (DeviceInfo.Device.Type != (uint)AsusDeviceType.NB_KB_4ZONE_RGB)
{
int pos = 0;
foreach (IAuraRgbKey key in ((IAuraSyncKeyboard)DeviceInfo.Device).Keys)
InitializeLed(reversedMapping[(AsusLedId)key.Code], new Point(pos++ * 19, 0), new Size(19, 19));
//UK Layout
InitializeLed(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));
}
else
{
int ledCount = DeviceInfo.Device.Lights.Count;
for (int i = 0; i < ledCount; i++)
InitializeLed(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 />
protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Keyboard_Escape;
protected override object CreateLedCustomData(LedId ledId)
{
if (DeviceInfo.Device.Type == (uint)AsusDeviceType.NB_KB_4ZONE_RGB)
return ledId - LedId.Keyboard_Custom1;
return AsusKeyboardLedMapping.MAPPING[ledId];
}
#endregion
}

View File

@ -33,7 +33,7 @@ namespace RGB.NET.Devices.Asus
/// <param name="device">The <see cref="IAuraSyncDevice"/> backing this RGB.NET device.</param>
/// <param name="culture">The <see cref="T:System.Globalization.CultureInfo" /> of the layout this keyboard is using.</param>
internal AsusKeyboardRGBDeviceInfo(IAuraSyncDevice device, CultureInfo culture)
: base(RGBDeviceType.Keyboard, device, "Claymore")
: base(RGBDeviceType.Keyboard, device, device.Name)
{
SetLayouts(culture.KeyboardLayoutId);
}

View File

@ -2,11 +2,11 @@
namespace RGB.NET.Devices.Asus
{
/// <inheritdoc />
/// <inheritdoc cref="AsusRGBDevice{TDeviceInfo}" />
/// <summary>
/// Represents a Asus mainboard.
/// </summary>
public class AsusMainboardRGBDevice : AsusRGBDevice<AsusRGBDeviceInfo>
public class AsusMainboardRGBDevice : AsusRGBDevice<AsusRGBDeviceInfo>, IKeyboard
{
#region Constructors

View File

@ -2,11 +2,11 @@
namespace RGB.NET.Devices.Asus
{
/// <inheritdoc />
/// <inheritdoc cref="AsusRGBDevice{TDeviceInfo}" />
/// <summary>
/// Represents a Asus mouse.
/// </summary>
public class AsusMouseRGBDevice : AsusRGBDevice<AsusRGBDeviceInfo>
public class AsusMouseRGBDevice : AsusRGBDevice<AsusRGBDeviceInfo>, IMouse
{
#region Constructors

View File

@ -14,8 +14,8 @@
<RootNamespace>RGB.NET.Devices.Asus</RootNamespace>
<Description>Asus-Device-Implementations of RGB.NET</Description>
<Summary>Asus-Device-Implementations of RGB.NET, a C# (.NET) library for accessing various RGB-peripherals</Summary>
<Copyright>Copyright © Wyrez 2017</Copyright>
<PackageCopyright>Copyright © Wyrez 2017</PackageCopyright>
<Copyright>Copyright © Darth Affe 2020</Copyright>
<PackageCopyright>Copyright © Darth Affe 2020</PackageCopyright>
<PackageIconUrl>http://lib.arge.be/icon.png</PackageIconUrl>
<PackageProjectUrl>https://github.com/DarthAffe/RGB.NET</PackageProjectUrl>
<PackageLicenseUrl>https://raw.githubusercontent.com/DarthAffe/RGB.NET/master/LICENSE</PackageLicenseUrl>
@ -77,8 +77,8 @@
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
<PackageReference Include="System.ValueTuple" Version="4.4.0" />
<PackageReference Include="System.Management" Version="4.0.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="System.Management" Version="4.7.0" />
</ItemGroup>
<ItemGroup>

View File

@ -228,7 +228,7 @@ namespace RGB.NET.Devices.Asus
catch { if (throwExceptions) throw; }
#endregion
UpdateTrigger?.Start();
Devices = new ReadOnlyCollection<IRGBDevice>(devices);
@ -267,7 +267,13 @@ namespace RGB.NET.Devices.Asus
/// <inheritdoc />
public void Dispose()
{ }
{
try { UpdateTrigger?.Dispose(); }
catch { /* at least we tried */ }
try { _AsusSDK.UnloadAsusSDK(); }
catch { /* at least we tried */ }
}
#endregion
}

View File

@ -80,6 +80,9 @@ namespace RGB.NET.Devices.Asus
/// <inheritdoc cref="AbstractRGBDevice{TDeviceInfo}.Dispose" />
public override void Dispose()
{
try { UpdateQueue?.Dispose(); }
catch { /* at least we tried */ }
if ((DeviceInfo is AsusRGBDeviceInfo deviceInfo) && (deviceInfo.Handle != IntPtr.Zero))
Marshal.FreeHGlobal(deviceInfo.Handle);

View File

@ -4,11 +4,11 @@ using RGB.NET.Devices.Asus.Native;
namespace RGB.NET.Devices.Asus
{
/// <inheritdoc />
/// <inheritdoc cref="AsusRGBDevice{TDeviceInfo}" />
/// <summary>
/// Represents a Asus graphicsCard.
/// </summary>
public class AsusGraphicsCardRGBDevice : AsusRGBDevice<AsusGraphicsCardRGBDeviceInfo>
public class AsusGraphicsCardRGBDevice : AsusRGBDevice<AsusGraphicsCardRGBDeviceInfo>, IGraphicsCard
{
#region Constructors

View File

@ -4,11 +4,11 @@ using RGB.NET.Devices.Asus.Native;
namespace RGB.NET.Devices.Asus
{
/// <inheritdoc />
/// <inheritdoc cref="AsusRGBDevice{TDeviceInfo}" />
/// <summary>
/// Represents a Asus keyboard.
/// </summary>
public class AsusKeyboardRGBDevice : AsusRGBDevice<AsusKeyboardRGBDeviceInfo>
public class AsusKeyboardRGBDevice : AsusRGBDevice<AsusKeyboardRGBDeviceInfo>, IKeyboard
{
#region Constructors

View File

@ -4,11 +4,11 @@ using RGB.NET.Devices.Asus.Native;
namespace RGB.NET.Devices.Asus
{
/// <inheritdoc />
/// <inheritdoc cref="AsusRGBDevice{TDeviceInfo}" />
/// <summary>
/// Represents a Asus mainboard.
/// </summary>
public class AsusMainboardRGBDevice : AsusRGBDevice<AsusMainboardRGBDeviceInfo>
public class AsusMainboardRGBDevice : AsusRGBDevice<AsusMainboardRGBDeviceInfo>, IMainboard
{
#region Constructors

View File

@ -4,11 +4,11 @@ using RGB.NET.Devices.Asus.Native;
namespace RGB.NET.Devices.Asus
{
/// <inheritdoc />
/// <inheritdoc cref="AsusRGBDevice{TDeviceInfo}" />
/// <summary>
/// Represents a Asus mouse.
/// </summary>
public class AsusMouseRGBDevice : AsusRGBDevice<AsusMouseRGBDeviceInfo>
public class AsusMouseRGBDevice : AsusRGBDevice<AsusMouseRGBDeviceInfo>, IMouse
{
#region Constructors

View File

@ -75,7 +75,7 @@ namespace RGB.NET.Devices.Asus.Native
//_getDramColorPointer = (GetDramColorPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "GetDramColor"), typeof(GetDramColorPointer));
}
private static void UnloadAsusSDK()
internal static void UnloadAsusSDK()
{
if (_dllHandle == IntPtr.Zero) return;

View File

@ -14,8 +14,8 @@
<RootNamespace>RGB.NET.Devices.Asus</RootNamespace>
<Description>Asus-Device-Implementations of RGB.NET based on the v2-SDK</Description>
<Summary>Asus-Device-Implementations of RGB.NET, a C# (.NET) library for accessing various RGB-peripherals</Summary>
<Copyright>Copyright © Wyrez 2017</Copyright>
<PackageCopyright>Copyright © Wyrez 2017</PackageCopyright>
<Copyright>Copyright © Darth Affe 2020</Copyright>
<PackageCopyright>Copyright © Darth Affe 2020</PackageCopyright>
<PackageIconUrl>http://lib.arge.be/icon.png</PackageIconUrl>
<PackageProjectUrl>https://github.com/DarthAffe/RGB.NET</PackageProjectUrl>
<PackageLicenseUrl>https://raw.githubusercontent.com/DarthAffe/RGB.NET/master/LICENSE</PackageLicenseUrl>
@ -63,7 +63,7 @@
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
<PackageReference Include="System.ValueTuple" Version="4.4.0" />
<PackageReference Include="System.Management" Version="4.0.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="System.Management" Version="4.7.0" />
</ItemGroup>
</Project>

View File

@ -108,7 +108,7 @@ namespace RGB.NET.Devices.CoolerMaster
{
RGBDeviceType deviceType = index.GetDeviceType();
if (deviceType == RGBDeviceType.None) continue;
if (_CoolerMasterSDK.IsDevicePlugged(index))
{
if (!loadFilter.HasFlag(deviceType)) continue;
@ -132,7 +132,8 @@ namespace RGB.NET.Devices.CoolerMaster
continue;
}
_CoolerMasterSDK.EnableLedControl(true, index);
if (!_CoolerMasterSDK.EnableLedControl(true, index))
throw new RGBDeviceException("Failed to enable LED control for device " + index);
device.Initialize(UpdateTrigger);
devices.Add(device);
@ -175,6 +176,9 @@ namespace RGB.NET.Devices.CoolerMaster
/// <inheritdoc />
public void Dispose()
{
try { UpdateTrigger?.Dispose(); }
catch { /* at least we tried */ }
if (IsInitialized)
foreach (IRGBDevice device in Devices)
{
@ -185,6 +189,10 @@ namespace RGB.NET.Devices.CoolerMaster
}
catch {/* shit happens */}
}
// DarthAffe 03.03.2020: Should be done but isn't possible due to an weird winodws-hook inside the sdk which corrupts the stack when unloading the dll
//try { _CoolerMasterSDK.UnloadCMSDK(); }
//catch { /* at least we tried */ }
}
#endregion

View File

@ -69,6 +69,18 @@ namespace RGB.NET.Devices.CoolerMaster
[DeviceType(RGBDeviceType.Keyboard)]
CK551 = 13,
[Description("MM830")]
[DeviceType(RGBDeviceType.Mouse)]
MM830 = 14,
[Description("CK530")]
[DeviceType(RGBDeviceType.Keyboard)]
CK530 = 15,
[Description("MK850")]
[DeviceType(RGBDeviceType.Keyboard)]
MK850 = 16,
[DeviceType(RGBDeviceType.None)]
Default = 0xFFFF
}

View File

@ -74,6 +74,9 @@ namespace RGB.NET.Devices.CoolerMaster
/// <inheritdoc cref="AbstractRGBDevice{TDeviceInfo}.Dispose" />
public override void Dispose()
{
try { UpdateQueue?.Dispose(); }
catch { /* at least we tried */ }
_CoolerMasterSDK.EnableLedControl(false, DeviceInfo.DeviceIndex);
base.Dispose();

View File

@ -13,6 +13,7 @@ namespace RGB.NET.Devices.CoolerMaster
#region Properties & Fields
private CoolerMasterDevicesIndexes _deviceIndex;
private readonly _CoolerMasterColorMatrix _deviceMatrix;
#endregion
@ -27,6 +28,9 @@ namespace RGB.NET.Devices.CoolerMaster
: base(updateTrigger)
{
this._deviceIndex = deviceIndex;
_deviceMatrix = new _CoolerMasterColorMatrix();
_deviceMatrix.KeyColor = new _CoolerMasterKeyColor[_CoolerMasterColorMatrix.ROWS, _CoolerMasterColorMatrix.COLUMNS];
}
#endregion
@ -39,10 +43,10 @@ namespace RGB.NET.Devices.CoolerMaster
foreach (KeyValuePair<object, Color> data in dataSet)
{
(int row, int column) = ((int, int))data.Key;
_CoolerMasterSDK.SetLedColor(row, column, data.Value.GetR(), data.Value.GetG(), data.Value.GetB(), _deviceIndex);
_deviceMatrix.KeyColor[row, column] = new _CoolerMasterKeyColor(data.Value.GetR(), data.Value.GetG(), data.Value.GetB());
}
_CoolerMasterSDK.RefreshLed(false, _deviceIndex);
_CoolerMasterSDK.SetAllLedColor(_deviceMatrix, _deviceIndex);
}
#endregion

View File

@ -3,11 +3,11 @@ using RGB.NET.Core;
namespace RGB.NET.Devices.CoolerMaster
{
/// <inheritdoc />
/// <inheritdoc cref="CoolerMasterRGBDevice{TDeviceInfo}" />
/// <summary>
/// Represents a CoolerMaster keyboard.
/// </summary>
public class CoolerMasterKeyboardRGBDevice : CoolerMasterRGBDevice<CoolerMasterKeyboardRGBDeviceInfo>
public class CoolerMasterKeyboardRGBDevice : CoolerMasterRGBDevice<CoolerMasterKeyboardRGBDeviceInfo>, IKeyboard
{
#region Constructors
@ -27,8 +27,11 @@ namespace RGB.NET.Devices.CoolerMaster
/// <inheritdoc />
protected override void InitializeLayout()
{
Dictionary<LedId, (int row, int column)> mapping = CoolerMasterKeyboardLedMappings.Mapping[DeviceInfo.DeviceIndex][DeviceInfo.PhysicalLayout];
if (!CoolerMasterKeyboardLedMappings.Mapping.TryGetValue(DeviceInfo.DeviceIndex, out Dictionary<CoolerMasterPhysicalKeyboardLayout, Dictionary<LedId, (int row, int column)>> deviceMappings))
throw new RGBDeviceException($"Failed to find a CoolerMasterKeyboardLedMapping for device index {DeviceInfo.DeviceIndex}");
if (!deviceMappings.TryGetValue(DeviceInfo.PhysicalLayout, out Dictionary<LedId, (int row, int column)> mapping))
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)
InitializeLed(led.Key, new Rectangle(led.Value.column * 19, led.Value.row * 19, 19, 19));

View File

@ -3,11 +3,11 @@ using RGB.NET.Core;
namespace RGB.NET.Devices.CoolerMaster
{
/// <inheritdoc />
/// <inheritdoc cref="CoolerMasterRGBDevice{TDeviceInfo}" />
/// <summary>
/// Represents a CoolerMaster mouse.
/// </summary>
public class CoolerMasterMouseRGBDevice : CoolerMasterRGBDevice<CoolerMasterMouseRGBDeviceInfo>
public class CoolerMasterMouseRGBDevice : CoolerMasterRGBDevice<CoolerMasterMouseRGBDeviceInfo>, IMouse
{
#region Constructors

View File

@ -52,7 +52,7 @@ namespace RGB.NET.Devices.CoolerMaster.Native
_setAllLedColorPointer = (SetAllLedColorPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "SetAllLedColor"), typeof(SetAllLedColorPointer));
}
private static void UnloadCMSDK()
internal static void UnloadCMSDK()
{
if (_dllHandle == IntPtr.Zero) return;

View File

@ -14,8 +14,8 @@
<RootNamespace>RGB.NET.Devices.CoolerMaster</RootNamespace>
<Description>Cooler Master-Device-Implementations of RGB.NET</Description>
<Summary>Cooler Master-Device-Implementations of RGB.NET, a C# (.NET) library for accessing various RGB-peripherals</Summary>
<Copyright>Copyright © Wyrez 2017</Copyright>
<PackageCopyright>Copyright © Wyrez 2017</PackageCopyright>
<Copyright>Copyright © Darth Affe 2020</Copyright>
<PackageCopyright>Copyright © Darth Affe 2020</PackageCopyright>
<PackageIconUrl>http://lib.arge.be/icon.png</PackageIconUrl>
<PackageProjectUrl>https://github.com/DarthAffe/RGB.NET</PackageProjectUrl>
<PackageLicenseUrl>https://raw.githubusercontent.com/DarthAffe/RGB.NET/master/LICENSE</PackageLicenseUrl>
@ -63,6 +63,6 @@
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
<PackageReference Include="System.ValueTuple" Version="4.4.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>
</Project>

View File

@ -227,7 +227,7 @@ namespace RGB.NET.Devices.Corsair
{
_CorsairChannelDeviceInfo channelDeviceInfo = (_CorsairChannelDeviceInfo)Marshal.PtrToStructure(channelDeviceInfoPtr, typeof(_CorsairChannelDeviceInfo));
yield return new CorsairCustomRGBDevice(new CorsairCustomRGBDeviceInfo(info.CorsairDeviceIndex, nativeDeviceInfo, channelDeviceInfo, referenceLed, modelCounter));
yield return new CorsairCustomRGBDevice(new CorsairCustomRGBDeviceInfo(info, nativeDeviceInfo, channelDeviceInfo, referenceLed, modelCounter));
referenceLed += channelDeviceInfo.deviceLedCount;
channelDeviceInfoPtr = new IntPtr(channelDeviceInfoPtr.ToInt64() + channelDeviceInfoStructSize);
@ -292,7 +292,13 @@ namespace RGB.NET.Devices.Corsair
/// <inheritdoc />
public void Dispose()
{ }
{
try { UpdateTrigger?.Dispose(); }
catch { /* at least we tried */ }
try { _CUESDK.UnloadCUESDK(); }
catch { /* at least we tried */ }
}
#endregion
}

View File

@ -6,11 +6,11 @@ using RGB.NET.Core;
namespace RGB.NET.Devices.Corsair
{
/// <inheritdoc />
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
/// <summary>
/// Represents a corsair custom.
/// </summary>
public class CorsairCustomRGBDevice : CorsairRGBDevice<CorsairCustomRGBDeviceInfo>
public class CorsairCustomRGBDevice : CorsairRGBDevice<CorsairCustomRGBDeviceInfo>, IUnknownDevice
{
#region Properties & Fields

View File

@ -28,15 +28,16 @@ namespace RGB.NET.Devices.Corsair
/// <summary>
/// Internal constructor of managed <see cref="T:RGB.NET.Devices.Corsair.CorsairCustomRGBDeviceInfo" />.
/// </summary>
/// <param name="deviceIndex">The index of the <see cref="T:RGB.NET.Devices.Corsair.CorsairCustomRGBDevice" />.</param>
/// <param name="info">The info describing the the <see cref="T:RGB.NET.Devices.Corsair.CorsairCustomRGBDevice" />.</param>
/// <param name="nativeInfo">The native <see cref="T:RGB.NET.Devices.Corsair.Native._CorsairDeviceInfo" />-struct</param>
/// <param name="channelDeviceInfo">The native <see cref="T:RGB.NET.Devices.Corsair.Native._CorsairChannelDeviceInfo"/> representing this device.</param>
/// <param name="referenceCorsairLed">The id of the first led of this device.</param>
/// <param name="modelCounter">A dictionary containing counters to create unique names for equal devices models.</param>
internal CorsairCustomRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo, _CorsairChannelDeviceInfo channelDeviceInfo,
internal CorsairCustomRGBDeviceInfo(CorsairRGBDeviceInfo info, _CorsairDeviceInfo nativeInfo,
_CorsairChannelDeviceInfo channelDeviceInfo,
CorsairLedId referenceCorsairLed, Dictionary<string, int> modelCounter)
: base(deviceIndex, GetDeviceType(channelDeviceInfo.type), nativeInfo,
GetModelName(channelDeviceInfo.type), modelCounter)
: base(info.CorsairDeviceIndex, GetDeviceType(channelDeviceInfo.type), nativeInfo,
GetModelName(info, channelDeviceInfo), modelCounter)
{
this.ReferenceCorsairLed = referenceCorsairLed;
@ -59,6 +60,7 @@ namespace RGB.NET.Devices.Corsair
case CorsairChannelDeviceType.FanLL:
case CorsairChannelDeviceType.FanML:
case CorsairChannelDeviceType.DAP:
case CorsairChannelDeviceType.FanQL:
return RGBDeviceType.Fan;
case CorsairChannelDeviceType.Strip:
@ -72,9 +74,9 @@ namespace RGB.NET.Devices.Corsair
}
}
private static string GetModelName(CorsairChannelDeviceType deviceType)
private static string GetModelName(IRGBDeviceInfo info, _CorsairChannelDeviceInfo channelDeviceInfo)
{
switch (deviceType)
switch (channelDeviceInfo.type)
{
case CorsairChannelDeviceType.Invalid:
return "Invalid";
@ -92,7 +94,19 @@ namespace RGB.NET.Devices.Corsair
return "ML Fan";
case CorsairChannelDeviceType.Strip:
return "Led Strip";
// LS100 Led Strips are reported as one big strip if configured in monitor mode in iCUE, 138 LEDs for dual monitor, 84 for single
if ((info.Model == "LS100 Starter Kit") && (channelDeviceInfo.deviceLedCount == 138))
return "LS100 LED Strip (dual monitor)";
else if ((info.Model == "LS100 Starter Kit") && (channelDeviceInfo.deviceLedCount == 84))
return "LS100 LED Strip (single monitor)";
// Any other value means an "External LED Strip" in iCUE, these are reported per-strip, 15 for short strips, 27 for long
else if ((info.Model == "LS100 Starter Kit") && (channelDeviceInfo.deviceLedCount == 15))
return "LS100 LED Strip (short)";
else if ((info.Model == "LS100 Starter Kit") && (channelDeviceInfo.deviceLedCount == 27))
return "LS100 LED Strip (long)";
// Device model is "Commander Pro" for regular LED strips
else
return "LED Strip";
case CorsairChannelDeviceType.DAP:
return "DAP Fan";
@ -100,8 +114,11 @@ namespace RGB.NET.Devices.Corsair
case CorsairChannelDeviceType.Pump:
return "Pump";
case CorsairChannelDeviceType.FanQL:
return "QL Fan";
default:
throw new ArgumentOutOfRangeException(nameof(deviceType), deviceType, null);
throw new ArgumentOutOfRangeException(nameof(channelDeviceInfo.type), channelDeviceInfo.type, null);
}
}

View File

@ -18,6 +18,7 @@ namespace RGB.NET.Devices.Corsair
FanML = 4,
Strip = 5,
DAP = 6,
Pump = 7
Pump = 7,
FanQL = 8
};
}

View File

@ -20,6 +20,8 @@ namespace RGB.NET.Devices.Corsair
CommanderPro = 6,
LightningNodePro = 7,
MemoryModule = 8,
Cooler = 9
Cooler = 9,
Mainboard = 10,
GraphicsCard = 11
};
}

View File

@ -933,5 +933,644 @@ namespace RGB.NET.Devices.Corsair
CustomLiquidCoolerChannel1Led148 = 909,
CustomLiquidCoolerChannel1Led149 = 910,
CustomLiquidCoolerChannel1Led150 = 911,
CustomDeviceChannel1Led151 = 912,
CustomDeviceChannel1Led152 = 913,
CustomDeviceChannel1Led153 = 914,
CustomDeviceChannel1Led154 = 915,
CustomDeviceChannel1Led155 = 916,
CustomDeviceChannel1Led156 = 917,
CustomDeviceChannel1Led157 = 918,
CustomDeviceChannel1Led158 = 919,
CustomDeviceChannel1Led159 = 920,
CustomDeviceChannel1Led160 = 921,
CustomDeviceChannel1Led161 = 922,
CustomDeviceChannel1Led162 = 923,
CustomDeviceChannel1Led163 = 924,
CustomDeviceChannel1Led164 = 925,
CustomDeviceChannel1Led165 = 926,
CustomDeviceChannel1Led166 = 927,
CustomDeviceChannel1Led167 = 928,
CustomDeviceChannel1Led168 = 929,
CustomDeviceChannel1Led169 = 930,
CustomDeviceChannel1Led170 = 931,
CustomDeviceChannel1Led171 = 932,
CustomDeviceChannel1Led172 = 933,
CustomDeviceChannel1Led173 = 934,
CustomDeviceChannel1Led174 = 935,
CustomDeviceChannel1Led175 = 936,
CustomDeviceChannel1Led176 = 937,
CustomDeviceChannel1Led177 = 938,
CustomDeviceChannel1Led178 = 939,
CustomDeviceChannel1Led179 = 940,
CustomDeviceChannel1Led180 = 941,
CustomDeviceChannel1Led181 = 942,
CustomDeviceChannel1Led182 = 943,
CustomDeviceChannel1Led183 = 944,
CustomDeviceChannel1Led184 = 945,
CustomDeviceChannel1Led185 = 946,
CustomDeviceChannel1Led186 = 947,
CustomDeviceChannel1Led187 = 948,
CustomDeviceChannel1Led188 = 949,
CustomDeviceChannel1Led189 = 950,
CustomDeviceChannel1Led190 = 951,
CustomDeviceChannel1Led191 = 952,
CustomDeviceChannel1Led192 = 953,
CustomDeviceChannel1Led193 = 954,
CustomDeviceChannel1Led194 = 955,
CustomDeviceChannel1Led195 = 956,
CustomDeviceChannel1Led196 = 957,
CustomDeviceChannel1Led197 = 958,
CustomDeviceChannel1Led198 = 959,
CustomDeviceChannel1Led199 = 960,
CustomDeviceChannel1Led200 = 961,
CustomDeviceChannel1Led201 = 962,
CustomDeviceChannel1Led202 = 963,
CustomDeviceChannel1Led203 = 964,
CustomDeviceChannel1Led204 = 965,
CustomDeviceChannel1Led205 = 966,
CustomDeviceChannel1Led206 = 967,
CustomDeviceChannel1Led207 = 968,
CustomDeviceChannel1Led208 = 969,
CustomDeviceChannel1Led209 = 970,
CustomDeviceChannel1Led210 = 971,
CustomDeviceChannel1Led211 = 972,
CustomDeviceChannel1Led212 = 973,
CustomDeviceChannel1Led213 = 974,
CustomDeviceChannel1Led214 = 975,
CustomDeviceChannel1Led215 = 976,
CustomDeviceChannel1Led216 = 977,
CustomDeviceChannel1Led217 = 978,
CustomDeviceChannel1Led218 = 979,
CustomDeviceChannel1Led219 = 980,
CustomDeviceChannel1Led220 = 981,
CustomDeviceChannel1Led221 = 982,
CustomDeviceChannel1Led222 = 983,
CustomDeviceChannel1Led223 = 984,
CustomDeviceChannel1Led224 = 985,
CustomDeviceChannel1Led225 = 986,
CustomDeviceChannel1Led226 = 987,
CustomDeviceChannel1Led227 = 988,
CustomDeviceChannel1Led228 = 989,
CustomDeviceChannel1Led229 = 990,
CustomDeviceChannel1Led230 = 991,
CustomDeviceChannel1Led231 = 992,
CustomDeviceChannel1Led232 = 993,
CustomDeviceChannel1Led233 = 994,
CustomDeviceChannel1Led234 = 995,
CustomDeviceChannel1Led235 = 996,
CustomDeviceChannel1Led236 = 997,
CustomDeviceChannel1Led237 = 998,
CustomDeviceChannel1Led238 = 999,
CustomDeviceChannel1Led239 = 1000,
CustomDeviceChannel1Led240 = 1001,
CustomDeviceChannel1Led241 = 1002,
CustomDeviceChannel1Led242 = 1003,
CustomDeviceChannel1Led243 = 1004,
CustomDeviceChannel1Led244 = 1005,
CustomDeviceChannel1Led245 = 1006,
CustomDeviceChannel1Led246 = 1007,
CustomDeviceChannel1Led247 = 1008,
CustomDeviceChannel1Led248 = 1009,
CustomDeviceChannel1Led249 = 1010,
CustomDeviceChannel1Led250 = 1011,
CustomDeviceChannel1Led251 = 1012,
CustomDeviceChannel1Led252 = 1013,
CustomDeviceChannel1Led253 = 1014,
CustomDeviceChannel1Led254 = 1015,
CustomDeviceChannel1Led255 = 1016,
CustomDeviceChannel1Led256 = 1017,
CustomDeviceChannel1Led257 = 1018,
CustomDeviceChannel1Led258 = 1019,
CustomDeviceChannel1Led259 = 1020,
CustomDeviceChannel1Led260 = 1021,
CustomDeviceChannel1Led261 = 1022,
CustomDeviceChannel1Led262 = 1023,
CustomDeviceChannel1Led263 = 1024,
CustomDeviceChannel1Led264 = 1025,
CustomDeviceChannel1Led265 = 1026,
CustomDeviceChannel1Led266 = 1027,
CustomDeviceChannel1Led267 = 1028,
CustomDeviceChannel1Led268 = 1029,
CustomDeviceChannel1Led269 = 1030,
CustomDeviceChannel1Led270 = 1031,
CustomDeviceChannel1Led271 = 1032,
CustomDeviceChannel1Led272 = 1033,
CustomDeviceChannel1Led273 = 1034,
CustomDeviceChannel1Led274 = 1035,
CustomDeviceChannel1Led275 = 1036,
CustomDeviceChannel1Led276 = 1037,
CustomDeviceChannel1Led277 = 1038,
CustomDeviceChannel1Led278 = 1039,
CustomDeviceChannel1Led279 = 1040,
CustomDeviceChannel1Led280 = 1041,
CustomDeviceChannel1Led281 = 1042,
CustomDeviceChannel1Led282 = 1043,
CustomDeviceChannel1Led283 = 1044,
CustomDeviceChannel1Led284 = 1045,
CustomDeviceChannel1Led285 = 1046,
CustomDeviceChannel1Led286 = 1047,
CustomDeviceChannel1Led287 = 1048,
CustomDeviceChannel1Led288 = 1049,
CustomDeviceChannel1Led289 = 1050,
CustomDeviceChannel1Led290 = 1051,
CustomDeviceChannel1Led291 = 1052,
CustomDeviceChannel1Led292 = 1053,
CustomDeviceChannel1Led293 = 1054,
CustomDeviceChannel1Led294 = 1055,
CustomDeviceChannel1Led295 = 1056,
CustomDeviceChannel1Led296 = 1057,
CustomDeviceChannel1Led297 = 1058,
CustomDeviceChannel1Led298 = 1059,
CustomDeviceChannel1Led299 = 1060,
CustomDeviceChannel1Led300 = 1061,
CustomDeviceChannel2Led151 = 1062,
CustomDeviceChannel2Led152 = 1063,
CustomDeviceChannel2Led153 = 1064,
CustomDeviceChannel2Led154 = 1065,
CustomDeviceChannel2Led155 = 1066,
CustomDeviceChannel2Led156 = 1067,
CustomDeviceChannel2Led157 = 1068,
CustomDeviceChannel2Led158 = 1069,
CustomDeviceChannel2Led159 = 1070,
CustomDeviceChannel2Led160 = 1071,
CustomDeviceChannel2Led161 = 1072,
CustomDeviceChannel2Led162 = 1073,
CustomDeviceChannel2Led163 = 1074,
CustomDeviceChannel2Led164 = 1075,
CustomDeviceChannel2Led165 = 1076,
CustomDeviceChannel2Led166 = 1077,
CustomDeviceChannel2Led167 = 1078,
CustomDeviceChannel2Led168 = 1079,
CustomDeviceChannel2Led169 = 1080,
CustomDeviceChannel2Led170 = 1081,
CustomDeviceChannel2Led171 = 1082,
CustomDeviceChannel2Led172 = 1083,
CustomDeviceChannel2Led173 = 1084,
CustomDeviceChannel2Led174 = 1085,
CustomDeviceChannel2Led175 = 1086,
CustomDeviceChannel2Led176 = 1087,
CustomDeviceChannel2Led177 = 1088,
CustomDeviceChannel2Led178 = 1089,
CustomDeviceChannel2Led179 = 1090,
CustomDeviceChannel2Led180 = 1091,
CustomDeviceChannel2Led181 = 1092,
CustomDeviceChannel2Led182 = 1093,
CustomDeviceChannel2Led183 = 1094,
CustomDeviceChannel2Led184 = 1095,
CustomDeviceChannel2Led185 = 1096,
CustomDeviceChannel2Led186 = 1097,
CustomDeviceChannel2Led187 = 1098,
CustomDeviceChannel2Led188 = 1099,
CustomDeviceChannel2Led189 = 1100,
CustomDeviceChannel2Led190 = 1101,
CustomDeviceChannel2Led191 = 1102,
CustomDeviceChannel2Led192 = 1103,
CustomDeviceChannel2Led193 = 1104,
CustomDeviceChannel2Led194 = 1105,
CustomDeviceChannel2Led195 = 1106,
CustomDeviceChannel2Led196 = 1107,
CustomDeviceChannel2Led197 = 1108,
CustomDeviceChannel2Led198 = 1109,
CustomDeviceChannel2Led199 = 1110,
CustomDeviceChannel2Led200 = 1111,
CustomDeviceChannel2Led201 = 1112,
CustomDeviceChannel2Led202 = 1113,
CustomDeviceChannel2Led203 = 1114,
CustomDeviceChannel2Led204 = 1115,
CustomDeviceChannel2Led205 = 1116,
CustomDeviceChannel2Led206 = 1117,
CustomDeviceChannel2Led207 = 1118,
CustomDeviceChannel2Led208 = 1119,
CustomDeviceChannel2Led209 = 1120,
CustomDeviceChannel2Led210 = 1121,
CustomDeviceChannel2Led211 = 1122,
CustomDeviceChannel2Led212 = 1123,
CustomDeviceChannel2Led213 = 1124,
CustomDeviceChannel2Led214 = 1125,
CustomDeviceChannel2Led215 = 1126,
CustomDeviceChannel2Led216 = 1127,
CustomDeviceChannel2Led217 = 1128,
CustomDeviceChannel2Led218 = 1129,
CustomDeviceChannel2Led219 = 1130,
CustomDeviceChannel2Led220 = 1131,
CustomDeviceChannel2Led221 = 1132,
CustomDeviceChannel2Led222 = 1133,
CustomDeviceChannel2Led223 = 1134,
CustomDeviceChannel2Led224 = 1135,
CustomDeviceChannel2Led225 = 1136,
CustomDeviceChannel2Led226 = 1137,
CustomDeviceChannel2Led227 = 1138,
CustomDeviceChannel2Led228 = 1139,
CustomDeviceChannel2Led229 = 1140,
CustomDeviceChannel2Led230 = 1141,
CustomDeviceChannel2Led231 = 1142,
CustomDeviceChannel2Led232 = 1143,
CustomDeviceChannel2Led233 = 1144,
CustomDeviceChannel2Led234 = 1145,
CustomDeviceChannel2Led235 = 1146,
CustomDeviceChannel2Led236 = 1147,
CustomDeviceChannel2Led237 = 1148,
CustomDeviceChannel2Led238 = 1149,
CustomDeviceChannel2Led239 = 1150,
CustomDeviceChannel2Led240 = 1151,
CustomDeviceChannel2Led241 = 1152,
CustomDeviceChannel2Led242 = 1153,
CustomDeviceChannel2Led243 = 1154,
CustomDeviceChannel2Led244 = 1155,
CustomDeviceChannel2Led245 = 1156,
CustomDeviceChannel2Led246 = 1157,
CustomDeviceChannel2Led247 = 1158,
CustomDeviceChannel2Led248 = 1159,
CustomDeviceChannel2Led249 = 1160,
CustomDeviceChannel2Led250 = 1161,
CustomDeviceChannel2Led251 = 1162,
CustomDeviceChannel2Led252 = 1163,
CustomDeviceChannel2Led253 = 1164,
CustomDeviceChannel2Led254 = 1165,
CustomDeviceChannel2Led255 = 1166,
CustomDeviceChannel2Led256 = 1167,
CustomDeviceChannel2Led257 = 1168,
CustomDeviceChannel2Led258 = 1169,
CustomDeviceChannel2Led259 = 1170,
CustomDeviceChannel2Led260 = 1171,
CustomDeviceChannel2Led261 = 1172,
CustomDeviceChannel2Led262 = 1173,
CustomDeviceChannel2Led263 = 1174,
CustomDeviceChannel2Led264 = 1175,
CustomDeviceChannel2Led265 = 1176,
CustomDeviceChannel2Led266 = 1177,
CustomDeviceChannel2Led267 = 1178,
CustomDeviceChannel2Led268 = 1179,
CustomDeviceChannel2Led269 = 1180,
CustomDeviceChannel2Led270 = 1181,
CustomDeviceChannel2Led271 = 1182,
CustomDeviceChannel2Led272 = 1183,
CustomDeviceChannel2Led273 = 1184,
CustomDeviceChannel2Led274 = 1185,
CustomDeviceChannel2Led275 = 1186,
CustomDeviceChannel2Led276 = 1187,
CustomDeviceChannel2Led277 = 1188,
CustomDeviceChannel2Led278 = 1189,
CustomDeviceChannel2Led279 = 1190,
CustomDeviceChannel2Led280 = 1191,
CustomDeviceChannel2Led281 = 1192,
CustomDeviceChannel2Led282 = 1193,
CustomDeviceChannel2Led283 = 1194,
CustomDeviceChannel2Led284 = 1195,
CustomDeviceChannel2Led285 = 1196,
CustomDeviceChannel2Led286 = 1197,
CustomDeviceChannel2Led287 = 1198,
CustomDeviceChannel2Led288 = 1199,
CustomDeviceChannel2Led289 = 1200,
CustomDeviceChannel2Led290 = 1201,
CustomDeviceChannel2Led291 = 1202,
CustomDeviceChannel2Led292 = 1203,
CustomDeviceChannel2Led293 = 1204,
CustomDeviceChannel2Led294 = 1205,
CustomDeviceChannel2Led295 = 1206,
CustomDeviceChannel2Led296 = 1207,
CustomDeviceChannel2Led297 = 1208,
CustomDeviceChannel2Led298 = 1209,
CustomDeviceChannel2Led299 = 1210,
CustomDeviceChannel2Led300 = 1211,
CustomDeviceChannel3Led151 = 1212,
CustomDeviceChannel3Led152 = 1213,
CustomDeviceChannel3Led153 = 1214,
CustomDeviceChannel3Led154 = 1215,
CustomDeviceChannel3Led155 = 1216,
CustomDeviceChannel3Led156 = 1217,
CustomDeviceChannel3Led157 = 1218,
CustomDeviceChannel3Led158 = 1219,
CustomDeviceChannel3Led159 = 1220,
CustomDeviceChannel3Led160 = 1221,
CustomDeviceChannel3Led161 = 1222,
CustomDeviceChannel3Led162 = 1223,
CustomDeviceChannel3Led163 = 1224,
CustomDeviceChannel3Led164 = 1225,
CustomDeviceChannel3Led165 = 1226,
CustomDeviceChannel3Led166 = 1227,
CustomDeviceChannel3Led167 = 1228,
CustomDeviceChannel3Led168 = 1229,
CustomDeviceChannel3Led169 = 1230,
CustomDeviceChannel3Led170 = 1231,
CustomDeviceChannel3Led171 = 1232,
CustomDeviceChannel3Led172 = 1233,
CustomDeviceChannel3Led173 = 1234,
CustomDeviceChannel3Led174 = 1235,
CustomDeviceChannel3Led175 = 1236,
CustomDeviceChannel3Led176 = 1237,
CustomDeviceChannel3Led177 = 1238,
CustomDeviceChannel3Led178 = 1239,
CustomDeviceChannel3Led179 = 1240,
CustomDeviceChannel3Led180 = 1241,
CustomDeviceChannel3Led181 = 1242,
CustomDeviceChannel3Led182 = 1243,
CustomDeviceChannel3Led183 = 1244,
CustomDeviceChannel3Led184 = 1245,
CustomDeviceChannel3Led185 = 1246,
CustomDeviceChannel3Led186 = 1247,
CustomDeviceChannel3Led187 = 1248,
CustomDeviceChannel3Led188 = 1249,
CustomDeviceChannel3Led189 = 1250,
CustomDeviceChannel3Led190 = 1251,
CustomDeviceChannel3Led191 = 1252,
CustomDeviceChannel3Led192 = 1253,
CustomDeviceChannel3Led193 = 1254,
CustomDeviceChannel3Led194 = 1255,
CustomDeviceChannel3Led195 = 1256,
CustomDeviceChannel3Led196 = 1257,
CustomDeviceChannel3Led197 = 1258,
CustomDeviceChannel3Led198 = 1259,
CustomDeviceChannel3Led199 = 1260,
CustomDeviceChannel3Led200 = 1261,
CustomDeviceChannel3Led201 = 1262,
CustomDeviceChannel3Led202 = 1263,
CustomDeviceChannel3Led203 = 1264,
CustomDeviceChannel3Led204 = 1265,
CustomDeviceChannel3Led205 = 1266,
CustomDeviceChannel3Led206 = 1267,
CustomDeviceChannel3Led207 = 1268,
CustomDeviceChannel3Led208 = 1269,
CustomDeviceChannel3Led209 = 1270,
CustomDeviceChannel3Led210 = 1271,
CustomDeviceChannel3Led211 = 1272,
CustomDeviceChannel3Led212 = 1273,
CustomDeviceChannel3Led213 = 1274,
CustomDeviceChannel3Led214 = 1275,
CustomDeviceChannel3Led215 = 1276,
CustomDeviceChannel3Led216 = 1277,
CustomDeviceChannel3Led217 = 1278,
CustomDeviceChannel3Led218 = 1279,
CustomDeviceChannel3Led219 = 1280,
CustomDeviceChannel3Led220 = 1281,
CustomDeviceChannel3Led221 = 1282,
CustomDeviceChannel3Led222 = 1283,
CustomDeviceChannel3Led223 = 1284,
CustomDeviceChannel3Led224 = 1285,
CustomDeviceChannel3Led225 = 1286,
CustomDeviceChannel3Led226 = 1287,
CustomDeviceChannel3Led227 = 1288,
CustomDeviceChannel3Led228 = 1289,
CustomDeviceChannel3Led229 = 1290,
CustomDeviceChannel3Led230 = 1291,
CustomDeviceChannel3Led231 = 1292,
CustomDeviceChannel3Led232 = 1293,
CustomDeviceChannel3Led233 = 1294,
CustomDeviceChannel3Led234 = 1295,
CustomDeviceChannel3Led235 = 1296,
CustomDeviceChannel3Led236 = 1297,
CustomDeviceChannel3Led237 = 1298,
CustomDeviceChannel3Led238 = 1299,
CustomDeviceChannel3Led239 = 1300,
CustomDeviceChannel3Led240 = 1301,
CustomDeviceChannel3Led241 = 1302,
CustomDeviceChannel3Led242 = 1303,
CustomDeviceChannel3Led243 = 1304,
CustomDeviceChannel3Led244 = 1305,
CustomDeviceChannel3Led245 = 1306,
CustomDeviceChannel3Led246 = 1307,
CustomDeviceChannel3Led247 = 1308,
CustomDeviceChannel3Led248 = 1309,
CustomDeviceChannel3Led249 = 1310,
CustomDeviceChannel3Led250 = 1311,
CustomDeviceChannel3Led251 = 1312,
CustomDeviceChannel3Led252 = 1313,
CustomDeviceChannel3Led253 = 1314,
CustomDeviceChannel3Led254 = 1315,
CustomDeviceChannel3Led255 = 1316,
CustomDeviceChannel3Led256 = 1317,
CustomDeviceChannel3Led257 = 1318,
CustomDeviceChannel3Led258 = 1319,
CustomDeviceChannel3Led259 = 1320,
CustomDeviceChannel3Led260 = 1321,
CustomDeviceChannel3Led261 = 1322,
CustomDeviceChannel3Led262 = 1323,
CustomDeviceChannel3Led263 = 1324,
CustomDeviceChannel3Led264 = 1325,
CustomDeviceChannel3Led265 = 1326,
CustomDeviceChannel3Led266 = 1327,
CustomDeviceChannel3Led267 = 1328,
CustomDeviceChannel3Led268 = 1329,
CustomDeviceChannel3Led269 = 1330,
CustomDeviceChannel3Led270 = 1331,
CustomDeviceChannel3Led271 = 1332,
CustomDeviceChannel3Led272 = 1333,
CustomDeviceChannel3Led273 = 1334,
CustomDeviceChannel3Led274 = 1335,
CustomDeviceChannel3Led275 = 1336,
CustomDeviceChannel3Led276 = 1337,
CustomDeviceChannel3Led277 = 1338,
CustomDeviceChannel3Led278 = 1339,
CustomDeviceChannel3Led279 = 1340,
CustomDeviceChannel3Led280 = 1341,
CustomDeviceChannel3Led281 = 1342,
CustomDeviceChannel3Led282 = 1343,
CustomDeviceChannel3Led283 = 1344,
CustomDeviceChannel3Led284 = 1345,
CustomDeviceChannel3Led285 = 1346,
CustomDeviceChannel3Led286 = 1347,
CustomDeviceChannel3Led287 = 1348,
CustomDeviceChannel3Led288 = 1349,
CustomDeviceChannel3Led289 = 1350,
CustomDeviceChannel3Led290 = 1351,
CustomDeviceChannel3Led291 = 1352,
CustomDeviceChannel3Led292 = 1353,
CustomDeviceChannel3Led293 = 1354,
CustomDeviceChannel3Led294 = 1355,
CustomDeviceChannel3Led295 = 1356,
CustomDeviceChannel3Led296 = 1357,
CustomDeviceChannel3Led297 = 1358,
CustomDeviceChannel3Led298 = 1359,
CustomDeviceChannel3Led299 = 1360,
CustomDeviceChannel3Led300 = 1361,
Mainboard1 = 1362,
Mainboard2 = 1363,
Mainboard3 = 1364,
Mainboard4 = 1365,
Mainboard5 = 1366,
Mainboard6 = 1367,
Mainboard7 = 1368,
Mainboard8 = 1369,
Mainboard9 = 1370,
Mainboard10 = 1371,
Mainboard11 = 1372,
Mainboard12 = 1373,
Mainboard13 = 1374,
Mainboard14 = 1375,
Mainboard15 = 1376,
Mainboard16 = 1377,
Mainboard17 = 1378,
Mainboard18 = 1379,
Mainboard19 = 1380,
Mainboard20 = 1381,
Mainboard21 = 1382,
Mainboard22 = 1383,
Mainboard23 = 1384,
Mainboard24 = 1385,
Mainboard25 = 1386,
Mainboard26 = 1387,
Mainboard27 = 1388,
Mainboard28 = 1389,
Mainboard29 = 1390,
Mainboard30 = 1391,
Mainboard31 = 1392,
Mainboard32 = 1393,
Mainboard33 = 1394,
Mainboard34 = 1395,
Mainboard35 = 1396,
Mainboard36 = 1397,
Mainboard37 = 1398,
Mainboard38 = 1399,
Mainboard39 = 1400,
Mainboard40 = 1401,
Mainboard41 = 1402,
Mainboard42 = 1403,
Mainboard43 = 1404,
Mainboard44 = 1405,
Mainboard45 = 1406,
Mainboard46 = 1407,
Mainboard47 = 1408,
Mainboard48 = 1409,
Mainboard49 = 1410,
Mainboard50 = 1411,
Mainboard51 = 1412,
Mainboard52 = 1413,
Mainboard53 = 1414,
Mainboard54 = 1415,
Mainboard55 = 1416,
Mainboard56 = 1417,
Mainboard57 = 1418,
Mainboard58 = 1419,
Mainboard59 = 1420,
Mainboard60 = 1421,
Mainboard61 = 1422,
Mainboard62 = 1423,
Mainboard63 = 1424,
Mainboard64 = 1425,
Mainboard65 = 1426,
Mainboard66 = 1427,
Mainboard67 = 1428,
Mainboard68 = 1429,
Mainboard69 = 1430,
Mainboard70 = 1431,
Mainboard71 = 1432,
Mainboard72 = 1433,
Mainboard73 = 1434,
Mainboard74 = 1435,
Mainboard75 = 1436,
Mainboard76 = 1437,
Mainboard77 = 1438,
Mainboard78 = 1439,
Mainboard79 = 1440,
Mainboard80 = 1441,
Mainboard81 = 1442,
Mainboard82 = 1443,
Mainboard83 = 1444,
Mainboard84 = 1445,
Mainboard85 = 1446,
Mainboard86 = 1447,
Mainboard87 = 1448,
Mainboard88 = 1449,
Mainboard89 = 1450,
Mainboard90 = 1451,
Mainboard91 = 1452,
Mainboard92 = 1453,
Mainboard93 = 1454,
Mainboard94 = 1455,
Mainboard95 = 1456,
Mainboard96 = 1457,
Mainboard97 = 1458,
Mainboard98 = 1459,
Mainboard99 = 1460,
Mainboard100 = 1461,
GPU1 = 1462,
GPU2 = 1463,
GPU3 = 1464,
GPU4 = 1465,
GPU5 = 1466,
GPU6 = 1467,
GPU7 = 1468,
GPU8 = 1469,
GPU9 = 1470,
GPU10 = 1471,
GPU11 = 1472,
GPU12 = 1473,
GPU13 = 1474,
GPU14 = 1475,
GPU15 = 1476,
GPU16 = 1477,
GPU17 = 1478,
GPU18 = 1479,
GPU19 = 1480,
GPU20 = 1481,
GPU21 = 1482,
GPU22 = 1483,
GPU23 = 1484,
GPU24 = 1485,
GPU25 = 1486,
GPU26 = 1487,
GPU27 = 1488,
GPU28 = 1489,
GPU29 = 1490,
GPU30 = 1491,
GPU31 = 1492,
GPU32 = 1493,
GPU33 = 1494,
GPU34 = 1495,
GPU35 = 1496,
GPU36 = 1497,
GPU37 = 1498,
GPU38 = 1499,
GPU39 = 1500,
GPU40 = 1501,
GPU41 = 1502,
GPU42 = 1503,
GPU43 = 1504,
GPU44 = 1505,
GPU45 = 1506,
GPU46 = 1507,
GPU47 = 1508,
GPU48 = 1509,
GPU49 = 1510,
GPU50 = 1511,
Lightbar20 = 1512,
Lightbar21 = 1513,
Lightbar22 = 1514,
Lightbar23 = 1515,
Lightbar24 = 1516,
Lightbar25 = 1517,
Lightbar26 = 1518,
Lightbar27 = 1519,
Lightbar28 = 1520,
Lightbar29 = 1521,
Lightbar30 = 1522,
Lightbar31 = 1523,
Lightbar32 = 1524,
Lightbar33 = 1525,
Lightbar34 = 1526,
Lightbar35 = 1527,
Lightbar36 = 1528,
Lightbar37 = 1529,
Lightbar38 = 1530,
Lightbar39 = 1531,
Lightbar40 = 1532,
Lightbar41 = 1533,
Lightbar42 = 1534,
Lightbar43 = 1535,
Lightbar44 = 1536,
Lightbar45 = 1537,
Lightbar46 = 1538,
Lightbar47 = 1539,
Lightbar48 = 1540,
Lightbar49 = 1541,
Lightbar50 = 1542,
Profile = 1543,
}
}

View File

@ -122,6 +122,15 @@ namespace RGB.NET.Devices.Corsair
Marshal.FreeHGlobal(ptr);
}
/// <inheritdoc />
public override void Dispose()
{
try { DeviceUpdateQueue?.Dispose(); }
catch { /* at least we tried */ }
base.Dispose();
}
#endregion
}
}

View File

@ -5,11 +5,11 @@ using RGB.NET.Core;
namespace RGB.NET.Devices.Corsair
{
/// <inheritdoc />
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
/// <summary>
/// Represents a corsair headset.
/// </summary>
public class CorsairHeadsetRGBDevice : CorsairRGBDevice<CorsairHeadsetRGBDeviceInfo>
public class CorsairHeadsetRGBDevice : CorsairRGBDevice<CorsairHeadsetRGBDeviceInfo>, IHeadset
{
#region Constructors

View File

@ -10,11 +10,11 @@ using RGB.NET.Devices.Corsair.Native;
namespace RGB.NET.Devices.Corsair
{
/// <inheritdoc />
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
/// <summary>
/// Represents a corsair headset stand.
/// </summary>
public class CorsairHeadsetStandRGBDevice : CorsairRGBDevice<CorsairHeadsetStandRGBDeviceInfo>
public class CorsairHeadsetStandRGBDevice : CorsairRGBDevice<CorsairHeadsetStandRGBDeviceInfo>, IHeadsetStand
{
#region Constructors

View File

@ -9,11 +9,11 @@ using RGB.NET.Devices.Corsair.Native;
namespace RGB.NET.Devices.Corsair
{
/// <inheritdoc />
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
/// <summary>
/// Represents a corsair keyboard.
/// </summary>
public class CorsairKeyboardRGBDevice : CorsairRGBDevice<CorsairKeyboardRGBDeviceInfo>
public class CorsairKeyboardRGBDevice : CorsairRGBDevice<CorsairKeyboardRGBDeviceInfo>, IKeyboard
{
#region Constructors

View File

@ -9,11 +9,11 @@ using RGB.NET.Devices.Corsair.Native;
namespace RGB.NET.Devices.Corsair
{
/// <inheritdoc />
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
/// <summary>
/// Represents a corsair memory.
/// </summary>
public class CorsairMemoryRGBDevice : CorsairRGBDevice<CorsairMemoryRGBDeviceInfo>
public class CorsairMemoryRGBDevice : CorsairRGBDevice<CorsairMemoryRGBDeviceInfo>, IDRAM
{
#region Constructors

View File

@ -6,11 +6,11 @@ using RGB.NET.Core;
namespace RGB.NET.Devices.Corsair
{
/// <inheritdoc />
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
/// <summary>
/// Represents a corsair mouse.
/// </summary>
public class CorsairMouseRGBDevice : CorsairRGBDevice<CorsairMouseRGBDeviceInfo>
public class CorsairMouseRGBDevice : CorsairRGBDevice<CorsairMouseRGBDeviceInfo>, IMouse
{
#region Constructors

View File

@ -10,11 +10,11 @@ using RGB.NET.Devices.Corsair.Native;
namespace RGB.NET.Devices.Corsair
{
/// <inheritdoc />
/// <inheritdoc cref="CorsairRGBDevice{TDeviceInfo}" />
/// <summary>
/// Represents a corsair mousepad.
/// </summary>
public class CorsairMousepadRGBDevice : CorsairRGBDevice<CorsairMousepadRGBDeviceInfo>
public class CorsairMousepadRGBDevice : CorsairRGBDevice<CorsairMousepadRGBDeviceInfo>, IMousepad
{
#region Constructors

View File

@ -56,7 +56,7 @@ namespace RGB.NET.Devices.Corsair.Native
_corsairGetLastErrorPointer = (CorsairGetLastErrorPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetLastError"), typeof(CorsairGetLastErrorPointer));
}
private static void UnloadCUESDK()
internal static void UnloadCUESDK()
{
if (_dllHandle == IntPtr.Zero) return;
@ -136,7 +136,7 @@ namespace RGB.NET.Devices.Corsair.Native
#endregion
// ReSharper disable EventExceptionNotDocumented
/// <summary>
/// CUE-SDK: set specified LEDs to some colors.
/// This function set LEDs colors in the buffer which is written to the devices via CorsairSetLedsColorsFlushBuffer or CorsairSetLedsColorsFlushBufferAsync.
@ -151,7 +151,7 @@ namespace RGB.NET.Devices.Corsair.Native
/// This function executes synchronously, if you are concerned about delays consider using CorsairSetLedsColorsFlushBufferAsync
/// </summary>
internal static bool CorsairSetLedsColorsFlushBuffer() => _corsairSetLedsColorsFlushBufferPointer();
/// <summary>
/// CUE-SDK: get current color for the list of requested LEDs.
/// The color should represent the actual state of the hardware LED, which could be a combination of SDK and/or CUE input.
@ -175,7 +175,7 @@ namespace RGB.NET.Devices.Corsair.Native
/// CUE-SDK: returns information about device at provided index.
/// </summary>
internal static IntPtr CorsairGetDeviceInfo(int deviceIndex) => _corsairGetDeviceInfoPointer(deviceIndex);
/// <summary>
/// CUE-SDK: provides list of keyboard or mousepad LEDs with their physical positions.
/// </summary>

View File

@ -14,8 +14,8 @@
<RootNamespace>RGB.NET.Devices.Corsair</RootNamespace>
<Description>Corsair-Device-Implementations of RGB.NET</Description>
<Summary>Corsair-Device-Implementations of RGB.NET, a C# (.NET) library for accessing various RGB-peripherals</Summary>
<Copyright>Copyright © Wyrez 2017</Copyright>
<PackageCopyright>Copyright © Wyrez 2017</PackageCopyright>
<Copyright>Copyright © Darth Affe 2020</Copyright>
<PackageCopyright>Copyright © Darth Affe 2020</PackageCopyright>
<PackageIconUrl>http://lib.arge.be/icon.png</PackageIconUrl>
<PackageProjectUrl>https://github.com/DarthAffe/RGB.NET</PackageProjectUrl>
<PackageLicenseUrl>https://raw.githubusercontent.com/DarthAffe/RGB.NET/master/LICENSE</PackageLicenseUrl>
@ -63,6 +63,6 @@
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
<PackageReference Include="System.ValueTuple" Version="4.4.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>
</Project>

View File

@ -116,7 +116,10 @@ namespace RGB.NET.Devices.DMX
/// <inheritdoc />
public void Dispose()
{ }
{
try { UpdateTrigger?.Dispose(); }
catch { /* at least we tried */ }
}
#endregion
}

View File

@ -8,7 +8,7 @@ namespace RGB.NET.Devices.DMX.E131
/// <summary>
/// Represents a E1.31-DXM-device.
/// </summary>
public class E131Device : AbstractRGBDevice<E131DeviceInfo>
public class E131Device : AbstractRGBDevice<E131DeviceInfo>, IUnknownDevice
{
#region Properties & Fields
@ -59,6 +59,15 @@ namespace RGB.NET.Devices.DMX.E131
/// <inheritdoc />
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate) => _updateQueue.SetData(ledsToUpdate.Where(x => x.Color.A > 0));
/// <inheritdoc />
public override void Dispose()
{
try { _updateQueue?.Dispose(); }
catch { /* at least we tried */ }
base.Dispose();
}
#endregion
}
}

View File

@ -14,8 +14,8 @@
<RootNamespace>RGB.NET.Devices.DMX</RootNamespace>
<Description>DMX-Device-Implementations of RGB.NET</Description>
<Summary>DMX-Device-Implementations of RGB.NET, a C# (.NET) library for accessing various RGB-peripherals</Summary>
<Copyright>Copyright © Wyrez 2017</Copyright>
<PackageCopyright>Copyright © Wyrez 2017</PackageCopyright>
<Copyright>Copyright © Darth Affe 2020</Copyright>
<PackageCopyright>Copyright © Darth Affe 2020</PackageCopyright>
<PackageIconUrl>http://lib.arge.be/icon.png</PackageIconUrl>
<PackageProjectUrl>https://github.com/DarthAffe/RGB.NET</PackageProjectUrl>
<PackageLicenseUrl>https://raw.githubusercontent.com/DarthAffe/RGB.NET/master/LICENSE</PackageLicenseUrl>
@ -63,6 +63,6 @@
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
<PackageReference Include="System.ValueTuple" Version="4.4.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>
</Project>

View File

@ -5,17 +5,22 @@ using RGB.NET.Core.Layout;
namespace RGB.NET.Devices.Debug
{
/// <inheritdoc />
/// <inheritdoc cref="AbstractRGBDevice{TDeviceInfo}" />
/// <summary>
/// Represents a debug device.
/// </summary>
public class DebugRGBDevice : AbstractRGBDevice<DebugRGBDeviceInfo>
public class DebugRGBDevice : AbstractRGBDevice<DebugRGBDeviceInfo>, IUnknownDevice
{
#region Properties & Fields
/// <inheritdoc />
public override DebugRGBDeviceInfo DeviceInfo { get; }
/// <summary>
/// Gets the path of the layout used to mock this <see cref="DebugRGBDevice"/>
/// </summary>
public string LayoutPath { get; }
private Func<Dictionary<LedId, Color>> _syncBackFunc;
private Action<IEnumerable<Led>> _updateLedsAction;
@ -27,6 +32,7 @@ namespace RGB.NET.Devices.Debug
/// </summary>
internal DebugRGBDevice(string layoutPath, Func<Dictionary<LedId, Color>> syncBackFunc = null, Action<IEnumerable<Led>> updateLedsAction = null)
{
this.LayoutPath = layoutPath;
this._syncBackFunc = syncBackFunc;
this._updateLedsAction = updateLedsAction;

View File

@ -14,8 +14,8 @@
<RootNamespace>RGB.NET.Devices.Debug</RootNamespace>
<Description>Debug-Device-Implementations of RGB.NET</Description>
<Summary>Debug-Device-Implementations of RGB.NET, a C# (.NET) library</Summary>
<Copyright>Copyright © Wyrez 2017</Copyright>
<PackageCopyright>Copyright © Wyrez 2017</PackageCopyright>
<Copyright>Copyright © Darth Affe 2020</Copyright>
<PackageCopyright>Copyright © Darth Affe 2020</PackageCopyright>
<PackageIconUrl>http://lib.arge.be/icon.png</PackageIconUrl>
<PackageProjectUrl>https://github.com/DarthAffe/RGB.NET</PackageProjectUrl>
<PackageLicenseUrl>https://raw.githubusercontent.com/DarthAffe/RGB.NET/master/LICENSE</PackageLicenseUrl>
@ -63,6 +63,6 @@
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
<PackageReference Include="System.ValueTuple" Version="4.4.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>
</Project>

View File

@ -70,6 +70,15 @@ namespace RGB.NET.Devices.Logitech
ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Logitech", $"{layoutPath}.xml"), layout, true);
}
/// <inheritdoc />
public override void Dispose()
{
try { UpdateQueue?.Dispose(); }
catch { /* at least we tried */ }
base.Dispose();
}
#endregion
}
}

View File

@ -18,9 +18,12 @@ namespace RGB.NET.Devices.Logitech.HID
{
("G910", RGBDeviceType.Keyboard, 0xC32B, 0, "DE", @"Keyboards\G910\UK"), //TODO DarthAffe 15.11.2017: Somehow detect the current layout
("G910v2", RGBDeviceType.Keyboard, 0xC335, 0, "DE", @"Keyboards\G910\UK"),
("G915", RGBDeviceType.Keyboard, 0xC541, 0, "DE", @"Keyboards\G915\UK"),
("G810", RGBDeviceType.Keyboard, 0xC337, 0, "DE", @"Keyboards\G810\UK"),
("G810", RGBDeviceType.Keyboard, 0xC331, 0, "DE", @"Keyboards\G810\UK"),
("G610", RGBDeviceType.Keyboard, 0xC333, 0, "DE", @"Keyboards\G610\UK"),
("G512", RGBDeviceType.Keyboard, 0xC33C, 0, "DE", @"Keyboards\G512\UK"),
("G512 SE", RGBDeviceType.Keyboard, 0xC342, 0, "DE", @"Keyboards\G512SE\UK"),
("G410", RGBDeviceType.Keyboard, 0xC330, 0, "DE", @"Keyboards\G410\UK"),
("G213", RGBDeviceType.Keyboard, 0xC336, 0, "DE", @"Keyboards\G213\UK"),
("Pro", RGBDeviceType.Keyboard, 0xC339, 0, "DE", @"Keyboards\Pro\UK"),
@ -56,6 +59,8 @@ namespace RGB.NET.Devices.Logitech.HID
("G303", RGBDeviceType.Mouse, 0xC080, 2, "default", @"Mice\G303"),
("G203", RGBDeviceType.Mouse, 0xC084, 1, "default", @"Mice\G203"),
("G Pro", RGBDeviceType.Mouse, 0xC085, 1, "default", @"Mice\GPro"),
("G Pro Wireless", RGBDeviceType.Mouse, 0xC088, 1, "default", @"Mice\GPro"),
("G Pro Hero", RGBDeviceType.Mouse, 0xC08C, 1, "default", @"Mice\GProHero"),
("G633", RGBDeviceType.Headset, 0x0A5C, 2, "default", @"Headsets\G633"),
("G933", RGBDeviceType.Headset, 0x0A5B, 2, "default", @"Headsets\G933"),
("G935", RGBDeviceType.Headset, 0x0A87, 2, "default", @"Headsets\G935"),

View File

@ -182,7 +182,17 @@ namespace RGB.NET.Devices.Logitech
public void ResetDevices() => _LogitechGSDK.LogiLedRestoreLighting();
/// <inheritdoc />
public void Dispose() => _LogitechGSDK.LogiLedRestoreLighting();
public void Dispose()
{
try { UpdateTrigger?.Dispose(); }
catch { /* at least we tried */ }
try { _LogitechGSDK.LogiLedRestoreLighting(); }
catch { /* at least we tried */ }
try { _LogitechGSDK.UnloadLogitechGSDK(); }
catch { /* at least we tried */ }
}
#endregion
}

View File

@ -55,7 +55,7 @@ namespace RGB.NET.Devices.Logitech.Native
_logiLedSetLightingForTargetZonePointer = (LogiLedSetLightingForTargetZonePointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "LogiLedSetLightingForTargetZone"), typeof(LogiLedSetLightingForTargetZonePointer));
}
private static void UnloadLogitechGSDK()
internal static void UnloadLogitechGSDK()
{
if (_dllHandle == IntPtr.Zero) return;

View File

@ -4,11 +4,11 @@ using RGB.NET.Core;
namespace RGB.NET.Devices.Logitech
{
/// <inheritdoc />
/// <inheritdoc cref="LogitechRGBDevice{TDeviceInfo}" />
/// <summary>
/// Represents a logitech per-device-lightable device.
/// </summary>
public class LogitechPerDeviceRGBDevice : LogitechRGBDevice<LogitechRGBDeviceInfo>
public class LogitechPerDeviceRGBDevice : LogitechRGBDevice<LogitechRGBDeviceInfo>, IUnknownDevice //TODO DarthAffe 18.04.2020: It's know which kind of device this is, but they would need to be separated
{
#region Constructors

View File

@ -4,11 +4,11 @@ using RGB.NET.Core;
namespace RGB.NET.Devices.Logitech
{
/// <inheritdoc />
/// <inheritdoc cref="LogitechRGBDevice{TDeviceInfo}" />
/// <summary>
/// Represents a logitech per-key-lightable device.
/// </summary>
public class LogitechPerKeyRGBDevice : LogitechRGBDevice<LogitechRGBDeviceInfo>
public class LogitechPerKeyRGBDevice : LogitechRGBDevice<LogitechRGBDeviceInfo>, IUnknownDevice //TODO DarthAffe 18.04.2020: It's know which kind of device this is, but they would need to be separated
{
#region Constructors

View File

@ -14,8 +14,8 @@
<RootNamespace>RGB.NET.Devices.Logitech</RootNamespace>
<Description>Logitech-Device-Implementations of RGB.NET</Description>
<Summary>Logitech-Device-Implementations of RGB.NET, a C# (.NET) library for accessing various RGB-peripherals</Summary>
<Copyright>Copyright © Wyrez 2017</Copyright>
<PackageCopyright>Copyright © Wyrez 2017</PackageCopyright>
<Copyright>Copyright © Darth Affe 2020</Copyright>
<PackageCopyright>Copyright © Darth Affe 2020</PackageCopyright>
<PackageIconUrl>http://lib.arge.be/icon.png</PackageIconUrl>
<PackageProjectUrl>https://github.com/DarthAffe/RGB.NET</PackageProjectUrl>
<PackageLicenseUrl>https://raw.githubusercontent.com/DarthAffe/RGB.NET/master/LICENSE</PackageLicenseUrl>
@ -60,10 +60,10 @@
<ItemGroup>
<ProjectReference Include="..\RGB.NET.Core\RGB.NET.Core.csproj" />
<PackageReference Include="HidSharp" Version="2.0.1" />
<PackageReference Include="HidSharp" Version="2.1.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
<PackageReference Include="System.ValueTuple" Version="4.4.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>
</Project>

View File

@ -4,11 +4,11 @@ using RGB.NET.Core;
namespace RGB.NET.Devices.Logitech
{
/// <inheritdoc />
/// <inheritdoc cref="LogitechRGBDevice{TDeviceInfo}" />
/// <summary>
/// Represents a logitech zone-lightable device.
/// </summary>
public class LogitechZoneRGBDevice : LogitechRGBDevice<LogitechRGBDeviceInfo>
public class LogitechZoneRGBDevice : LogitechRGBDevice<LogitechRGBDeviceInfo>, IUnknownDevice //TODO DarthAffe 18.04.2020: It's know which kind of device this is, but they would need to be separated
{
#region Constants

View File

@ -68,6 +68,15 @@ namespace RGB.NET.Devices.Msi
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate)
=> DeviceUpdateQueue.SetData(ledsToUpdate.Where(x => (x.Color.A > 0) && (x.CustomData is int)));
/// <inheritdoc />
public override void Dispose()
{
try { DeviceUpdateQueue?.Dispose(); }
catch { /* at least we tried */ }
base.Dispose();
}
#endregion
}
}

View File

@ -48,7 +48,7 @@ namespace RGB.NET.Devices.Msi
/// <param name="msiDeviceType">The internal type of the <see cref="IRGBDevice"/>.</param>
/// <param name="manufacturer">The manufacturer-name of the <see cref="IRGBDevice"/>.</param>
/// <param name="model">The model-name of the <see cref="IRGBDevice"/>.</param>
internal MsiRGBDeviceInfo(RGBDeviceType deviceType, string msiDeviceType, string manufacturer = "Msi", string model = "Generic Msi-Device")
internal MsiRGBDeviceInfo(RGBDeviceType deviceType, string msiDeviceType, string manufacturer = "MSI", string model = "Generic Msi-Device")
{
this.DeviceType = deviceType;
this.MsiDeviceType = msiDeviceType;

View File

@ -3,11 +3,11 @@ using RGB.NET.Devices.Msi.Native;
namespace RGB.NET.Devices.Msi
{
/// <inheritdoc />
/// <inheritdoc cref="MsiRGBDevice{TDeviceInfo}" />
/// <summary>
/// Represents MSI VGA adapters.
/// </summary>
public class MsiGraphicsCardRGBDevice : MsiRGBDevice<MsiRGBDeviceInfo>
public class MsiGraphicsCardRGBDevice : MsiRGBDevice<MsiRGBDeviceInfo>, IGraphicsCard
{
#region Constructors
@ -41,7 +41,7 @@ namespace RGB.NET.Devices.Msi
}
//TODO DarthAffe 07.10.2017: We don't know the model, how to save layouts and images?
ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\MSI\GraphicsCard\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null);
ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, $@"Layouts\MSI\GraphicsCard\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null);
}
/// <inheritdoc />

View File

@ -3,11 +3,11 @@ using RGB.NET.Devices.Msi.Native;
namespace RGB.NET.Devices.Msi
{
/// <inheritdoc />
/// <inheritdoc cref="MsiRGBDevice{TDeviceInfo}" />
/// <summary>
/// Represents a MSI mainboard.
/// </summary>
public class MsiMainboardRGBDevice : MsiRGBDevice<MsiRGBDeviceInfo>
public class MsiMainboardRGBDevice : MsiRGBDevice<MsiRGBDeviceInfo>, IMainboard
{
#region Constructors
@ -39,7 +39,7 @@ namespace RGB.NET.Devices.Msi
}
//TODO DarthAffe 07.10.2017: We don't know the model, how to save layouts and images?
ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\MSI\Mainboards\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null);
ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, $@"Layouts\MSI\Mainboards\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null);
}
/// <inheritdoc />

View File

@ -0,0 +1,54 @@
using RGB.NET.Core;
using RGB.NET.Devices.Msi.Native;
namespace RGB.NET.Devices.Msi
{
/// <inheritdoc />
/// <summary>
/// Represents a MSI mouse.
/// </summary>
public class MsiMouseRGBDevice : MsiRGBDevice<MsiRGBDeviceInfo>
{
#region Constructors
/// <inheritdoc />
/// <summary>
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Msi.MsiMouseRGBDevice" /> class.
/// </summary>
/// <param name="info">The specific information provided by MSI for the mouse.</param>
internal MsiMouseRGBDevice(MsiRGBDeviceInfo info)
: base(info)
{ }
#endregion
#region Methods
/// <inheritdoc />
protected override void InitializeLayout(int ledCount)
{
for (int i = 0; i < ledCount; i++)
{
//Hex3l: Should it be configurable in order to provide style access?
//Hex3l: Sets led style to "Steady" in order to have a solid color output therefore a controllable led color
//Hex3l: This is a string defined by the output of _MsiSDK.GetLedStyle, "Steady" should be always present
const string LED_STYLE = "Steady";
_MsiSDK.SetLedStyle(DeviceInfo.MsiDeviceType, i, LED_STYLE);
InitializeLed(LedId.Mouse1 + i, new Rectangle(i * 10, 0, 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 />
protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Mouse1;
/// <inheritdoc />
public override void SyncBack()
{ }
#endregion
}
}

Some files were not shown because too many files have changed in this diff Show More