Compare commits

..

No commits in common. "f640d05fa5356b3a40650247e999a65d51cf5085" and "e45344d211b2d13c756e0170c540f520baf5a570" have entirely different histories.

8 changed files with 59 additions and 59 deletions

View file

@ -14,49 +14,49 @@ namespace Demo {
}
Console.WriteLine("Setting all lights to blue");
IllumilibLighting.SetAllLighting(0, 0, 1);
IllumilibLighting.SetAllLighting(r: 0, g: 0, b: 1);
Thread.Sleep(TimeSpan.FromSeconds(3));
IllumilibLighting.SetAllLighting(0, 0, 0);
IllumilibLighting.SetAllLighting(r: 0, g: 0, b: 0);
Console.WriteLine("Setting specific positions");
IllumilibLighting.SetKeyboardLighting(6, 1, 1, 0, 1);
IllumilibLighting.SetKeyboardLighting(16, 5, 1, 0, 1);
IllumilibLighting.SetKeyboardLighting(x: 6, y: 1, r: 1, g: 0, b: 1);
IllumilibLighting.SetKeyboardLighting(x: 16, y: 5, r: 1, g: 0, b: 1);
Thread.Sleep(TimeSpan.FromSeconds(5));
IllumilibLighting.SetKeyboardLighting(0, 0, 0);
IllumilibLighting.SetKeyboardLighting(8, 2, 2, 2, 0, 1, 0);
IllumilibLighting.SetKeyboardLighting(r: 0, g: 0, b: 0);
IllumilibLighting.SetKeyboardLighting(x: 8, y: 2, width: 2, height: 2, r: 0, g: 1, b: 0);
Thread.Sleep(TimeSpan.FromSeconds(5));
IllumilibLighting.SetKeyboardLighting(0, 0, 0);
IllumilibLighting.SetKeyboardLighting(r: 0, g: 0, b: 0);
Console.WriteLine("Doing a fun effect");
for (var x = 0; x < IllumilibLighting.KeyboardWidth; x++) {
IllumilibLighting.SetKeyboardLighting(x, 0, 1, IllumilibLighting.KeyboardHeight, 0, 0, 1);
IllumilibLighting.SetKeyboardLighting(x: x, y: 0, width: 1, height: IllumilibLighting.KeyboardHeight, r: 0, g: 0, b: 1);
Thread.Sleep(TimeSpan.FromSeconds(0.25F));
}
for (var x = IllumilibLighting.KeyboardWidth - 1; x >= 0; x--) {
IllumilibLighting.SetKeyboardLighting(x, 0, 1, IllumilibLighting.KeyboardHeight, 0, 0, 0);
IllumilibLighting.SetKeyboardLighting(x: x, y: 0, width: 1, height: IllumilibLighting.KeyboardHeight, r: 0, g: 0, b: 0);
Thread.Sleep(TimeSpan.FromSeconds(0.25F));
}
Console.WriteLine("Going through the alphabet");
for (var i = 65; i <= 90; i++) {
var key = (KeyboardKeys) i;
IllumilibLighting.SetKeyboardLighting(key, 0, 1, 0);
IllumilibLighting.SetKeyboardLighting(key: key, r: 0, g: 1, b: 0);
Thread.Sleep(TimeSpan.FromSeconds(0.25F));
IllumilibLighting.SetKeyboardLighting(key, 0, 0, 0);
IllumilibLighting.SetKeyboardLighting(key: key, r: 0, g: 0, b: 0);
}
Thread.Sleep(TimeSpan.FromSeconds(1));
Console.WriteLine("Pulsing");
for (var i = 0; i < 500; i++) {
var value = (MathF.Sin(i / 50F * MathF.PI) + 1) / 2;
IllumilibLighting.SetAllLighting(value, 0, value);
IllumilibLighting.SetAllLighting(r: value, g: 0, b: value);
Thread.Sleep(10);
}
IllumilibLighting.SetAllLighting(0, 0, 0);
IllumilibLighting.SetAllLighting(r: 0, g: 0, b: 0);
Console.WriteLine("Setting all supported keys");
foreach (var key in Enum.GetValues<KeyboardKeys>()) {
IllumilibLighting.SetKeyboardLighting(key, 1, 0, 0);
IllumilibLighting.SetKeyboardLighting(key: key, r: 1, g: 0, b: 0);
Thread.Sleep(50);
}
Thread.Sleep(TimeSpan.FromSeconds(15));

View file

@ -11,7 +11,7 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageIcon>Logo.png</PackageIcon>
<VersionPrefix>1.2.5</VersionPrefix>
<VersionPrefix>1.2.4</VersionPrefix>
<NoWarn>NU1701</NoWarn>
</PropertyGroup>

View file

@ -22,7 +22,7 @@ namespace Illumilib {
/// <summary>
/// A property that returns whether Illumilib is currently initialized
/// </summary>
public static bool Initialized => IllumilibLighting.systems != null;
public static bool Initialized => systems != null;
/// <summary>
/// Initializes Illumilib, starting all of the supported lighting systems.
@ -31,25 +31,25 @@ namespace Illumilib {
/// <returns>Whether at least one lighting system was successfully initialized</returns>
/// <exception cref="InvalidOperationException">Thrown if Illumilib has already been <see cref="Initialized"/></exception>
public static bool Initialize() {
if (IllumilibLighting.Initialized)
if (Initialized)
throw new InvalidOperationException("Illumilib has already been initialized");
IllumilibLighting.systems = new Dictionary<LightingType, LightingSystem>();
systems = new Dictionary<LightingType, LightingSystem>();
foreach (var system in new LightingSystem[] {new LogitechLighting(), new RazerLighting(), new CorsairLighting()}) {
if (system.Initialize())
IllumilibLighting.systems.Add(system.Type, system);
systems.Add(system.Type, system);
}
return IllumilibLighting.systems.Count > 0;
return systems.Count > 0;
}
/// <summary>
/// Disposes Illumilib, disposing all of the underlying lighting systems
/// </summary>
public static void Dispose() {
if (!IllumilibLighting.Initialized)
if (!Initialized)
return;
foreach (var system in IllumilibLighting.systems.Values)
foreach (var system in systems.Values)
system.Dispose();
IllumilibLighting.systems = null;
systems = null;
}
/// <summary>
@ -58,8 +58,8 @@ namespace Illumilib {
/// <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) {
IllumilibLighting.EnsureInitialized();
return IllumilibLighting.systems.ContainsKey(type);
EnsureInitialized();
return systems.ContainsKey(type);
}
/// <summary>
@ -69,8 +69,8 @@ namespace Illumilib {
/// <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>
public static void SetAllLighting(float r, float g, float b) {
IllumilibLighting.EnsureInitialized();
foreach (var system in IllumilibLighting.systems.Values)
EnsureInitialized();
foreach (var system in systems.Values)
system.SetAllLighting(r, g, b);
}
@ -81,8 +81,8 @@ namespace Illumilib {
/// <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>
public static void SetKeyboardLighting(float r, float g, float b) {
IllumilibLighting.EnsureInitialized();
foreach (var system in IllumilibLighting.systems.Values)
EnsureInitialized();
foreach (var system in systems.Values)
system.SetKeyboardLighting(r, g, b);
}
@ -97,12 +97,12 @@ namespace Illumilib {
/// <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>
public static void SetKeyboardLighting(int x, int y, float r, float g, float b) {
IllumilibLighting.EnsureInitialized();
if (x < 0 || x >= IllumilibLighting.KeyboardWidth)
EnsureInitialized();
if (x < 0 || x >= KeyboardWidth)
throw new ArgumentOutOfRangeException(nameof(x));
if (y < 0 || y >= IllumilibLighting.KeyboardHeight)
if (y < 0 || y >= KeyboardHeight)
throw new ArgumentOutOfRangeException(nameof(y));
foreach (var system in IllumilibLighting.systems.Values)
foreach (var system in systems.Values)
system.SetKeyboardLighting(x, y, r, g, b);
}
@ -120,12 +120,12 @@ namespace Illumilib {
/// <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>
public static void SetKeyboardLighting(int x, int y, int width, int height, float r, float g, float b) {
IllumilibLighting.EnsureInitialized();
if (x < 0 || x + width > IllumilibLighting.KeyboardWidth)
EnsureInitialized();
if (x < 0 || x + width > KeyboardWidth)
throw new ArgumentOutOfRangeException(nameof(x));
if (y < 0 || y + height > IllumilibLighting.KeyboardHeight)
if (y < 0 || y + height > KeyboardHeight)
throw new ArgumentOutOfRangeException(nameof(y));
foreach (var system in IllumilibLighting.systems.Values)
foreach (var system in systems.Values)
system.SetKeyboardLighting(x, y, width, height, r, g, b);
}
@ -138,8 +138,8 @@ namespace Illumilib {
/// <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>
public static void SetKeyboardLighting(KeyboardKeys key, float r, float g, float b) {
IllumilibLighting.EnsureInitialized();
foreach (var system in IllumilibLighting.systems.Values)
EnsureInitialized();
foreach (var system in systems.Values)
system.SetKeyboardLighting(key, r, g, b);
}
@ -150,13 +150,13 @@ namespace Illumilib {
/// <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>
public static void SetMouseLighting(float r, float g, float b) {
IllumilibLighting.EnsureInitialized();
foreach (var system in IllumilibLighting.systems.Values)
EnsureInitialized();
foreach (var system in systems.Values)
system.SetMouseLighting(r, g, b);
}
private static void EnsureInitialized() {
if (!IllumilibLighting.Initialized)
if (!Initialized)
throw new InvalidOperationException("Illumilib has not been initialized yet");
}

View file

@ -138,16 +138,16 @@ namespace Illumilib.Lib {
private const int LogiDevicetypeRgbOrd = 1;
private const int LogiDevicetypePerkeyRgbOrd = 2;
public const int LogiDevicetypeMonochrome = 1 << LogitechGsdk.LogiDevicetypeMonochromeOrd;
public const int LogiDevicetypeRgb = 1 << LogitechGsdk.LogiDevicetypeRgbOrd;
public const int LogiDevicetypePerkeyRgb = 1 << LogitechGsdk.LogiDevicetypePerkeyRgbOrd;
public const int LogiDevicetypeAll = LogitechGsdk.LogiDevicetypeMonochrome | LogitechGsdk.LogiDevicetypeRgb | LogitechGsdk.LogiDevicetypePerkeyRgb;
public const int LogiDevicetypeMonochrome = (1 << LogiDevicetypeMonochromeOrd);
public const int LogiDevicetypeRgb = (1 << LogiDevicetypeRgbOrd);
public const int LogiDevicetypePerkeyRgb = (1 << LogiDevicetypePerkeyRgbOrd);
public const int LogiDevicetypeAll = (LogiDevicetypeMonochrome | LogiDevicetypeRgb | LogiDevicetypePerkeyRgb);
public const int LogiLedBitmapWidth = 21;
public const int LogiLedBitmapHeight = 6;
public const int LogiLedBitmapBytesPerKey = 4;
public const int LogiLedBitmapSize = LogitechGsdk.LogiLedBitmapWidth * LogitechGsdk.LogiLedBitmapHeight * LogitechGsdk.LogiLedBitmapBytesPerKey;
public const int LogiLedBitmapSize = LogiLedBitmapWidth * LogiLedBitmapHeight * LogiLedBitmapBytesPerKey;
public const int LogiLedDurationInfinite = 0;
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]

View file

@ -75,7 +75,7 @@ namespace Illumilib.System {
}
public override void SetKeyboardLighting(KeyboardKeys key, float r, float g, float b) {
var id = CorsairLighting.ConvertKey(key);
var id = ConvertKey(key);
foreach (var device in this.devices) {
if (!device.IsKeyboard())
continue;
@ -344,12 +344,12 @@ namespace Illumilib.System {
public void SetAllColors(float r, float g, float b) {
foreach (var color in this.colors)
DeviceInfo.SetColor(color, r, g, b);
SetColor(color, r, g, b);
}
public bool SetColorForId(CorsairLedId id, float r, float g, float b) {
if (this.ledIdToColorIndex.TryGetValue(id, out var index)) {
DeviceInfo.SetColor(this.colors[index], r, g, b);
SetColor(this.colors[index], r, g, b);
return true;
}
return false;

View file

@ -52,7 +52,7 @@ namespace Illumilib.System {
public override void SetKeyboardLighting(KeyboardKeys key, float r, float g, float b) {
this.ClearBitmap();
LogitechGsdk.LogiLedSetLightingForKeyWithKeyName(LogitechLighting.ConvertKey(key), (int) (r * 100), (int) (g * 100), (int) (b * 100));
LogitechGsdk.LogiLedSetLightingForKeyWithKeyName(ConvertKey(key), (int) (r * 100), (int) (g * 100), (int) (b * 100));
}
public override void SetMouseLighting(float r, float g, float b) {

View file

@ -22,7 +22,7 @@ namespace Illumilib.System {
public override void Dispose() {
base.Dispose();
this.chroma?.UninitializeAsync();
this.chroma.UninitializeAsync();
this.effectOutdated = true;
}
@ -59,7 +59,7 @@ namespace Illumilib.System {
}
public override void SetKeyboardLighting(KeyboardKeys key, float r, float g, float b) {
this.chroma.Keyboard?.SetKeyAsync(RazerLighting.ConvertKey(key), new Color(r, g, b));
this.chroma.Keyboard?.SetKeyAsync(ConvertKey(key), new Color(r, g, b));
this.effectOutdated = true;
}