mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2025-12-13 01:58:30 +00:00
Merge branch 'Development' into SDK/Corsair
This commit is contained in:
commit
75d748b5fe
@ -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.
|
||||
|
||||
@ -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>
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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>
|
||||
|
||||
@ -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>
|
||||
|
||||
8
RGB.NET.Core/Devices/TypeInterfaces/ICooler.cs
Normal file
8
RGB.NET.Core/Devices/TypeInterfaces/ICooler.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace RGB.NET.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a cooler-device
|
||||
/// </summary>
|
||||
public interface ICooler : IRGBDevice
|
||||
{ }
|
||||
}
|
||||
8
RGB.NET.Core/Devices/TypeInterfaces/IDRAM.cs
Normal file
8
RGB.NET.Core/Devices/TypeInterfaces/IDRAM.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace RGB.NET.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a DRAM-device
|
||||
/// </summary>
|
||||
public interface IDRAM : IRGBDevice
|
||||
{ }
|
||||
}
|
||||
8
RGB.NET.Core/Devices/TypeInterfaces/IFan.cs
Normal file
8
RGB.NET.Core/Devices/TypeInterfaces/IFan.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace RGB.NET.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// represents a fan-device
|
||||
/// </summary>
|
||||
public interface IFan : IRGBDevice
|
||||
{ }
|
||||
}
|
||||
8
RGB.NET.Core/Devices/TypeInterfaces/IGraphicsCard.cs
Normal file
8
RGB.NET.Core/Devices/TypeInterfaces/IGraphicsCard.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace RGB.NET.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a graphics-card-device
|
||||
/// </summary>
|
||||
public interface IGraphicsCard : IRGBDevice
|
||||
{ }
|
||||
}
|
||||
8
RGB.NET.Core/Devices/TypeInterfaces/IHeadset.cs
Normal file
8
RGB.NET.Core/Devices/TypeInterfaces/IHeadset.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace RGB.NET.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a headset-device
|
||||
/// </summary>
|
||||
public interface IHeadset : IRGBDevice
|
||||
{ }
|
||||
}
|
||||
8
RGB.NET.Core/Devices/TypeInterfaces/IHeadsetStand.cs
Normal file
8
RGB.NET.Core/Devices/TypeInterfaces/IHeadsetStand.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace RGB.NET.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a headset-stand-device
|
||||
/// </summary>
|
||||
public interface IHeadsetStand : IRGBDevice
|
||||
{ }
|
||||
}
|
||||
8
RGB.NET.Core/Devices/TypeInterfaces/IKeyboard.cs
Normal file
8
RGB.NET.Core/Devices/TypeInterfaces/IKeyboard.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace RGB.NET.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a keyboard-device
|
||||
/// </summary>
|
||||
public interface IKeyboard : IRGBDevice
|
||||
{ }
|
||||
}
|
||||
8
RGB.NET.Core/Devices/TypeInterfaces/IKeypad.cs
Normal file
8
RGB.NET.Core/Devices/TypeInterfaces/IKeypad.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace RGB.NET.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a keypad-device
|
||||
/// </summary>
|
||||
public interface IKeypad : IRGBDevice
|
||||
{ }
|
||||
}
|
||||
8
RGB.NET.Core/Devices/TypeInterfaces/ILedMatrix.cs
Normal file
8
RGB.NET.Core/Devices/TypeInterfaces/ILedMatrix.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace RGB.NET.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a led-matrix-device
|
||||
/// </summary>
|
||||
public interface ILedMatrix : IRGBDevice
|
||||
{ }
|
||||
}
|
||||
8
RGB.NET.Core/Devices/TypeInterfaces/ILedStripe.cs
Normal file
8
RGB.NET.Core/Devices/TypeInterfaces/ILedStripe.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace RGB.NET.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a led-stripe-device
|
||||
/// </summary>
|
||||
public interface ILedStripe : IRGBDevice
|
||||
{ }
|
||||
}
|
||||
8
RGB.NET.Core/Devices/TypeInterfaces/IMainboard.cs
Normal file
8
RGB.NET.Core/Devices/TypeInterfaces/IMainboard.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace RGB.NET.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a mainboard-device
|
||||
/// </summary>
|
||||
public interface IMainboard : IRGBDevice
|
||||
{ }
|
||||
}
|
||||
8
RGB.NET.Core/Devices/TypeInterfaces/IMouse.cs
Normal file
8
RGB.NET.Core/Devices/TypeInterfaces/IMouse.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace RGB.NET.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a mouse-device
|
||||
/// </summary>
|
||||
public interface IMouse : IRGBDevice
|
||||
{ }
|
||||
}
|
||||
8
RGB.NET.Core/Devices/TypeInterfaces/IMousepad.cs
Normal file
8
RGB.NET.Core/Devices/TypeInterfaces/IMousepad.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace RGB.NET.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a mousepad-device
|
||||
/// </summary>
|
||||
public interface IMousepad : IRGBDevice
|
||||
{ }
|
||||
}
|
||||
8
RGB.NET.Core/Devices/TypeInterfaces/ISpeaker.cs
Normal file
8
RGB.NET.Core/Devices/TypeInterfaces/ISpeaker.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace RGB.NET.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a speaker-device
|
||||
/// </summary>
|
||||
public interface ISpeaker : IRGBDevice
|
||||
{ }
|
||||
}
|
||||
8
RGB.NET.Core/Devices/TypeInterfaces/IUnknownDevice.cs
Normal file
8
RGB.NET.Core/Devices/TypeInterfaces/IUnknownDevice.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace RGB.NET.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a device with unkown or not specified type.
|
||||
/// </summary>
|
||||
public interface IUnknownDevice : IRGBDevice
|
||||
{ }
|
||||
}
|
||||
30
RGB.NET.Core/Extensions/ColorExtensions.cs
Normal file
30
RGB.NET.Core/Extensions/ColorExtensions.cs
Normal 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
|
||||
}
|
||||
}
|
||||
@ -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()
|
||||
|
||||
@ -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"/>.
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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>
|
||||
@ -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>
|
||||
|
||||
@ -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"/>.
|
||||
|
||||
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -144,6 +144,9 @@ namespace RGB.NET.Core
|
||||
UpdateFrequency = UpdateRateHardLimit;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Dispose() => Stop();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,7 +100,8 @@ namespace RGB.NET.Core
|
||||
_currentDataSet = null;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
/// <inheritdoc />
|
||||
public virtual void Dispose()
|
||||
{
|
||||
_updateTrigger.Starting -= OnStartup;
|
||||
_updateTrigger.Update -= OnUpdate;
|
||||
|
||||
@ -106,6 +106,9 @@ namespace RGB.NET.Core
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Dispose() => Stop();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,7 +129,7 @@ namespace RGB.NET.Decorators.Brush
|
||||
else
|
||||
{
|
||||
if ((++_repetitionCount >= Repetitions) && (Repetitions > 0))
|
||||
Detach<IBrush, FlashDecorator>();
|
||||
Detach();
|
||||
_currentPhaseValue = Attack;
|
||||
_currentPhase = ADSRPhase.Attack;
|
||||
}
|
||||
|
||||
@ -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>
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
25
RGB.NET.Devices.Asus/Enum/AsusDeviceType.cs
Normal file
25
RGB.NET.Devices.Asus/Enum/AsusDeviceType.cs
Normal 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
|
||||
}
|
||||
}
|
||||
160
RGB.NET.Devices.Asus/Enum/AsusLedId.cs
Normal file
160
RGB.NET.Devices.Asus/Enum/AsusLedId.cs
Normal 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,
|
||||
}
|
||||
}
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
161
RGB.NET.Devices.Asus/Keyboard/AsusKeyboardLedMapping.cs
Normal file
161
RGB.NET.Devices.Asus/Keyboard/AsusKeyboardLedMapping.cs
Normal 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 },
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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>
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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>
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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));
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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>
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -73,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";
|
||||
@ -93,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";
|
||||
@ -105,7 +118,7 @@ namespace RGB.NET.Devices.Corsair
|
||||
return "QL Fan";
|
||||
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(deviceType), deviceType, null);
|
||||
throw new ArgumentOutOfRangeException(nameof(channelDeviceInfo.type), channelDeviceInfo.type, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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>
|
||||
|
||||
@ -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>
|
||||
@ -116,7 +116,10 @@ namespace RGB.NET.Devices.DMX
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{ }
|
||||
{
|
||||
try { UpdateTrigger?.Dispose(); }
|
||||
catch { /* at least we tried */ }
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@ -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>
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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>
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@ -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"),
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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>
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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 />
|
||||
|
||||
@ -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 />
|
||||
|
||||
54
RGB.NET.Devices.Msi/Mouse/MsiMouseRGBDevice.cs
Normal file
54
RGB.NET.Devices.Msi/Mouse/MsiMouseRGBDevice.cs
Normal 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
|
||||
}
|
||||
}
|
||||
@ -118,7 +118,7 @@ namespace RGB.NET.Devices.Msi
|
||||
if (deviceType.Equals("MSI_MB"))
|
||||
{
|
||||
MsiDeviceUpdateQueue updateQueue = new MsiDeviceUpdateQueue(UpdateTrigger, deviceType);
|
||||
IMsiRGBDevice motherboard = new MsiMainboardRGBDevice(new MsiRGBDeviceInfo(RGBDeviceType.Mainboard, deviceType, "Msi", "Motherboard"));
|
||||
IMsiRGBDevice motherboard = new MsiMainboardRGBDevice(new MsiRGBDeviceInfo(RGBDeviceType.Mainboard, deviceType, "MSI", "Motherboard"));
|
||||
motherboard.Initialize(updateQueue, ledCount);
|
||||
devices.Add(motherboard);
|
||||
}
|
||||
@ -128,10 +128,20 @@ namespace RGB.NET.Devices.Msi
|
||||
//Hex3l: The led name is the name of the card (e.g. NVIDIA GeForce RTX 2080 Ti) we could provide it in device info.
|
||||
|
||||
MsiDeviceUpdateQueue updateQueue = new MsiDeviceUpdateQueue(UpdateTrigger, deviceType);
|
||||
IMsiRGBDevice graphicscard = new MsiGraphicsCardRGBDevice(new MsiRGBDeviceInfo(RGBDeviceType.GraphicsCard, deviceType, "Msi", "GraphicsCard"));
|
||||
IMsiRGBDevice graphicscard = new MsiGraphicsCardRGBDevice(new MsiRGBDeviceInfo(RGBDeviceType.GraphicsCard, deviceType, "MSI", "GraphicsCard"));
|
||||
graphicscard.Initialize(updateQueue, ledCount);
|
||||
devices.Add(graphicscard);
|
||||
}
|
||||
else if (deviceType.Equals("MSI_MOUSE"))
|
||||
{
|
||||
//Hex3l: Every led under MSI_MOUSE should be a different mouse. Handling all the mouses together seems a good way to avoid overlapping of leds
|
||||
//Hex3l: The led name is the name of the mouse (e.g. msi CLUTCH GM11) we could provide it in device info.
|
||||
|
||||
MsiDeviceUpdateQueue updateQueue = new MsiDeviceUpdateQueue(UpdateTrigger, deviceType);
|
||||
IMsiRGBDevice mouses = new MsiMouseRGBDevice(new MsiRGBDeviceInfo(RGBDeviceType.Mouse, deviceType, "MSI", "Mouse"));
|
||||
mouses.Initialize(updateQueue, ledCount);
|
||||
devices.Add(mouses);
|
||||
}
|
||||
|
||||
//TODO DarthAffe 22.02.2020: Add other devices
|
||||
}
|
||||
@ -163,7 +173,13 @@ namespace RGB.NET.Devices.Msi
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{ }
|
||||
{
|
||||
try { UpdateTrigger?.Dispose(); }
|
||||
catch { /* at least we tried */ }
|
||||
|
||||
try { _MsiSDK.UnloadMsiSDK(); }
|
||||
catch { /* at least we tried */ }
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ namespace RGB.NET.Devices.Msi.Native
|
||||
_getErrorMessagePointer = (GetErrorMessagePointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "MLAPI_GetErrorMessage"), typeof(GetErrorMessagePointer));
|
||||
}
|
||||
|
||||
private static void UnloadMsiSDK()
|
||||
internal static void UnloadMsiSDK()
|
||||
{
|
||||
if (_dllHandle == IntPtr.Zero) return;
|
||||
|
||||
|
||||
@ -14,8 +14,8 @@
|
||||
<RootNamespace>RGB.NET.Devices.Msi</RootNamespace>
|
||||
<Description>Msi-Device-Implementations of RGB.NET</Description>
|
||||
<Summary>Msi-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>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user