mirror of
https://github.com/Ellpeck/Illumilib.git
synced 2024-11-25 05:08:35 +01:00
Compare commits
No commits in common. "9a5391573b199878cd6f0851f9341bd0ea6d90cd" and "d073bac96342767b270065054c9a35bef5993a8b" have entirely different histories.
9a5391573b
...
d073bac963
8 changed files with 16 additions and 75 deletions
|
@ -8,11 +8,6 @@ namespace Demo {
|
||||||
private static void Main(string[] args) {
|
private static void Main(string[] args) {
|
||||||
IllumilibLighting.Initialize();
|
IllumilibLighting.Initialize();
|
||||||
|
|
||||||
foreach (var type in Enum.GetValues<LightingType>()) {
|
|
||||||
if (IllumilibLighting.IsEnabled(type))
|
|
||||||
Console.WriteLine($"{type} lighting is enabled");
|
|
||||||
}
|
|
||||||
|
|
||||||
Console.WriteLine("Setting all lights to blue");
|
Console.WriteLine("Setting all lights to blue");
|
||||||
IllumilibLighting.SetAllLighting(r: 0, g: 0, b: 1);
|
IllumilibLighting.SetAllLighting(r: 0, g: 0, b: 1);
|
||||||
Thread.Sleep(TimeSpan.FromSeconds(3));
|
Thread.Sleep(TimeSpan.FromSeconds(3));
|
||||||
|
|
|
@ -11,8 +11,7 @@
|
||||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||||
<PackageIcon>Logo.png</PackageIcon>
|
<PackageIcon>Logo.png</PackageIcon>
|
||||||
<VersionPrefix>1.2.3</VersionPrefix>
|
<VersionPrefix>1.2.2</VersionPrefix>
|
||||||
<NoWarn>NU1701</NoWarn>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -25,7 +24,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Colore" Version="6.0.0" />
|
<PackageReference Include="Colore" Version="6.0.0"/>
|
||||||
<PackageReference Include="CUESDK.NET" Version="3.0.361.2" />
|
<PackageReference Include="CUESDK.NET" Version="3.0.361.2"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace Illumilib {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const int KeyboardHeight = 6;
|
public const int KeyboardHeight = 6;
|
||||||
|
|
||||||
private static Dictionary<LightingType, LightingSystem> systems;
|
private static List<LightingSystem> systems;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A property that returns whether Illumilib is currently initialized
|
/// A property that returns whether Illumilib is currently initialized
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -33,10 +33,10 @@ namespace Illumilib {
|
||||||
public static bool Initialize() {
|
public static bool Initialize() {
|
||||||
if (Initialized)
|
if (Initialized)
|
||||||
throw new InvalidOperationException("Illumilib has already been initialized");
|
throw new InvalidOperationException("Illumilib has already been initialized");
|
||||||
systems = new Dictionary<LightingType, LightingSystem>();
|
systems = new List<LightingSystem>();
|
||||||
foreach (var system in new LightingSystem[] {new LogitechLighting(), new RazerLighting(), new CorsairLighting()}) {
|
foreach (var system in new LightingSystem[] {new LogitechLighting(), new RazerLighting(), new CorsairLighting()}) {
|
||||||
if (system.Initialize())
|
if (system.Initialize())
|
||||||
systems.Add(system.Type, system);
|
systems.Add(system);
|
||||||
}
|
}
|
||||||
return systems.Count > 0;
|
return systems.Count > 0;
|
||||||
}
|
}
|
||||||
|
@ -47,21 +47,10 @@ namespace Illumilib {
|
||||||
public static void Dispose() {
|
public static void Dispose() {
|
||||||
if (!Initialized)
|
if (!Initialized)
|
||||||
return;
|
return;
|
||||||
foreach (var system in systems.Values)
|
ForEach(s => s.Dispose());
|
||||||
system.Dispose();
|
|
||||||
systems = null;
|
systems = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns whether the given <see cref="LightingType"/> has been initialized successfully and is enabled.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="type">The <see cref="LightingType"/> to query.</param>
|
|
||||||
/// <returns>Whether the given <see cref="LightingType"/> has been initialized and is enabled.</returns>
|
|
||||||
public static bool IsEnabled(LightingType type) {
|
|
||||||
EnsureInitialized();
|
|
||||||
return systems.ContainsKey(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets the lighting for all keyboards and mice to the given color
|
/// Sets the lighting for all keyboards and mice to the given color
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -69,9 +58,7 @@ namespace Illumilib {
|
||||||
/// <param name="g">The color's green value, between 0 and 1</param>
|
/// <param name="g">The color's green value, between 0 and 1</param>
|
||||||
/// <param name="b">The color's blue value, between 0 and 1</param>
|
/// <param name="b">The color's blue value, between 0 and 1</param>
|
||||||
public static void SetAllLighting(float r, float g, float b) {
|
public static void SetAllLighting(float r, float g, float b) {
|
||||||
EnsureInitialized();
|
ForEach(s => s.SetAllLighting(r, g, b));
|
||||||
foreach (var system in systems.Values)
|
|
||||||
system.SetAllLighting(r, g, b);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -81,9 +68,7 @@ namespace Illumilib {
|
||||||
/// <param name="g">The color's green value, between 0 and 1</param>
|
/// <param name="g">The color's green value, between 0 and 1</param>
|
||||||
/// <param name="b">The color's blue value, between 0 and 1</param>
|
/// <param name="b">The color's blue value, between 0 and 1</param>
|
||||||
public static void SetKeyboardLighting(float r, float g, float b) {
|
public static void SetKeyboardLighting(float r, float g, float b) {
|
||||||
EnsureInitialized();
|
ForEach(s => s.SetKeyboardLighting(r, g, b));
|
||||||
foreach (var system in systems.Values)
|
|
||||||
system.SetKeyboardLighting(r, g, b);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -97,13 +82,11 @@ namespace Illumilib {
|
||||||
/// <param name="b">The color's blue value, between 0 and 1</param>
|
/// <param name="b">The color's blue value, between 0 and 1</param>
|
||||||
/// <exception cref="ArgumentOutOfRangeException">Thrown if the positions are out of range in relation to <see cref="KeyboardWidth"/> and <see cref="KeyboardHeight"/></exception>
|
/// <exception cref="ArgumentOutOfRangeException">Thrown if the positions are out of range in relation to <see cref="KeyboardWidth"/> and <see cref="KeyboardHeight"/></exception>
|
||||||
public static void SetKeyboardLighting(int x, int y, float r, float g, float b) {
|
public static void SetKeyboardLighting(int x, int y, float r, float g, float b) {
|
||||||
EnsureInitialized();
|
|
||||||
if (x < 0 || x >= KeyboardWidth)
|
if (x < 0 || x >= KeyboardWidth)
|
||||||
throw new ArgumentOutOfRangeException(nameof(x));
|
throw new ArgumentOutOfRangeException(nameof(x));
|
||||||
if (y < 0 || y >= KeyboardHeight)
|
if (y < 0 || y >= KeyboardHeight)
|
||||||
throw new ArgumentOutOfRangeException(nameof(y));
|
throw new ArgumentOutOfRangeException(nameof(y));
|
||||||
foreach (var system in systems.Values)
|
ForEach(s => s.SetKeyboardLighting(x, y, r, g, b));
|
||||||
system.SetKeyboardLighting(x, y, r, g, b);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -120,13 +103,11 @@ namespace Illumilib {
|
||||||
/// <param name="b">The color's blue value, between 0 and 1</param>
|
/// <param name="b">The color's blue value, between 0 and 1</param>
|
||||||
/// <exception cref="ArgumentOutOfRangeException">Thrown if the positions are out of range in relation to <see cref="KeyboardWidth"/> and <see cref="KeyboardHeight"/></exception>
|
/// <exception cref="ArgumentOutOfRangeException">Thrown if the positions are out of range in relation to <see cref="KeyboardWidth"/> and <see cref="KeyboardHeight"/></exception>
|
||||||
public static void SetKeyboardLighting(int x, int y, int width, int height, float r, float g, float b) {
|
public static void SetKeyboardLighting(int x, int y, int width, int height, float r, float g, float b) {
|
||||||
EnsureInitialized();
|
|
||||||
if (x < 0 || x + width > KeyboardWidth)
|
if (x < 0 || x + width > KeyboardWidth)
|
||||||
throw new ArgumentOutOfRangeException(nameof(x));
|
throw new ArgumentOutOfRangeException(nameof(x));
|
||||||
if (y < 0 || y + height > KeyboardHeight)
|
if (y < 0 || y + height > KeyboardHeight)
|
||||||
throw new ArgumentOutOfRangeException(nameof(y));
|
throw new ArgumentOutOfRangeException(nameof(y));
|
||||||
foreach (var system in systems.Values)
|
ForEach(s => s.SetKeyboardLighting(x, y, width, height, r, g, b));
|
||||||
system.SetKeyboardLighting(x, y, width, height, r, g, b);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -138,9 +119,7 @@ namespace Illumilib {
|
||||||
/// <param name="g">The color's green value, between 0 and 1</param>
|
/// <param name="g">The color's green value, between 0 and 1</param>
|
||||||
/// <param name="b">The color's blue value, between 0 and 1</param>
|
/// <param name="b">The color's blue value, between 0 and 1</param>
|
||||||
public static void SetKeyboardLighting(KeyboardKeys key, float r, float g, float b) {
|
public static void SetKeyboardLighting(KeyboardKeys key, float r, float g, float b) {
|
||||||
EnsureInitialized();
|
ForEach(s => s.SetKeyboardLighting(key, r, g, b));
|
||||||
foreach (var system in systems.Values)
|
|
||||||
system.SetKeyboardLighting(key, r, g, b);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -150,14 +129,14 @@ namespace Illumilib {
|
||||||
/// <param name="g">The color's green value, between 0 and 1</param>
|
/// <param name="g">The color's green value, between 0 and 1</param>
|
||||||
/// <param name="b">The color's blue value, between 0 and 1</param>
|
/// <param name="b">The color's blue value, between 0 and 1</param>
|
||||||
public static void SetMouseLighting(float r, float g, float b) {
|
public static void SetMouseLighting(float r, float g, float b) {
|
||||||
EnsureInitialized();
|
ForEach(s => s.SetMouseLighting(r, g, b));
|
||||||
foreach (var system in systems.Values)
|
|
||||||
system.SetMouseLighting(r, g, b);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void EnsureInitialized() {
|
private static void ForEach(Action<LightingSystem> action) {
|
||||||
if (!Initialized)
|
if (!Initialized)
|
||||||
throw new InvalidOperationException("Illumilib has not been initialized yet");
|
throw new InvalidOperationException("Illumilib has not been initialized yet");
|
||||||
|
foreach (var system in systems)
|
||||||
|
action(system);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
using Illumilib.System;
|
|
||||||
|
|
||||||
namespace Illumilib {
|
|
||||||
/// <summary>
|
|
||||||
/// An enumeration of possible lighting engines that Illumilib currently supports.
|
|
||||||
/// To query whether a lighting type is available, see <see cref="IllumilibLighting.IsEnabled"/>.
|
|
||||||
/// </summary>
|
|
||||||
public enum LightingType {
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The logitech lighting type, controlled by <see cref="LogitechLighting"/>.
|
|
||||||
/// </summary>
|
|
||||||
Logitech,
|
|
||||||
/// <summary>
|
|
||||||
/// The corsair lighting type, controlled by <see cref="CorsairLighting"/>.
|
|
||||||
/// </summary>
|
|
||||||
Corsair,
|
|
||||||
/// <summary>
|
|
||||||
/// The razer lighting type, controlled by <see cref="RazerLighting"/>.
|
|
||||||
/// </summary>
|
|
||||||
Razer
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -5,8 +5,6 @@ using Corsair.CUE.SDK;
|
||||||
namespace Illumilib.System {
|
namespace Illumilib.System {
|
||||||
internal class CorsairLighting : LightingSystem {
|
internal class CorsairLighting : LightingSystem {
|
||||||
|
|
||||||
public override LightingType Type => LightingType.Corsair;
|
|
||||||
|
|
||||||
private DeviceInfo[] devices;
|
private DeviceInfo[] devices;
|
||||||
|
|
||||||
public override bool Initialize() {
|
public override bool Initialize() {
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
namespace Illumilib.System {
|
namespace Illumilib.System {
|
||||||
internal abstract class LightingSystem : IDisposable {
|
internal abstract class LightingSystem : IDisposable {
|
||||||
|
|
||||||
public abstract LightingType Type { get; }
|
|
||||||
|
|
||||||
public abstract bool Initialize();
|
public abstract bool Initialize();
|
||||||
|
|
||||||
public abstract void Dispose();
|
public abstract void Dispose();
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
namespace Illumilib.System {
|
namespace Illumilib.System {
|
||||||
internal class LogitechLighting : LightingSystem {
|
internal class LogitechLighting : LightingSystem {
|
||||||
|
|
||||||
public override LightingType Type => LightingType.Logitech;
|
|
||||||
|
|
||||||
private readonly byte[] bitmap = new byte[LogitechGsdk.LogiLedBitmapSize];
|
private readonly byte[] bitmap = new byte[LogitechGsdk.LogiLedBitmapSize];
|
||||||
private bool bitmapDirty;
|
private bool bitmapDirty;
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,6 @@ using Colore.Effects.Keyboard;
|
||||||
namespace Illumilib.System {
|
namespace Illumilib.System {
|
||||||
internal class RazerLighting : LightingSystem {
|
internal class RazerLighting : LightingSystem {
|
||||||
|
|
||||||
public override LightingType Type => LightingType.Razer;
|
|
||||||
|
|
||||||
private IChroma chroma;
|
private IChroma chroma;
|
||||||
private CustomKeyboardEffect effect = new CustomKeyboardEffect(Color.Black);
|
private CustomKeyboardEffect effect = new CustomKeyboardEffect(Color.Black);
|
||||||
private bool effectOutdated;
|
private bool effectOutdated;
|
||||||
|
|
Loading…
Reference in a new issue