mirror of
https://github.com/Ellpeck/Illumilib.git
synced 2024-11-25 13:18:34 +01:00
Compare commits
3 commits
e45344d211
...
f640d05fa5
Author | SHA1 | Date | |
---|---|---|---|
f640d05fa5 | |||
942dc47e94 | |||
8f742b1eeb |
8 changed files with 59 additions and 59 deletions
|
@ -14,49 +14,49 @@ namespace Demo {
|
|||
}
|
||||
|
||||
Console.WriteLine("Setting all lights to blue");
|
||||
IllumilibLighting.SetAllLighting(r: 0, g: 0, b: 1);
|
||||
IllumilibLighting.SetAllLighting(0, 0, 1);
|
||||
Thread.Sleep(TimeSpan.FromSeconds(3));
|
||||
IllumilibLighting.SetAllLighting(r: 0, g: 0, b: 0);
|
||||
IllumilibLighting.SetAllLighting(0, 0, 0);
|
||||
|
||||
Console.WriteLine("Setting specific positions");
|
||||
IllumilibLighting.SetKeyboardLighting(x: 6, y: 1, r: 1, g: 0, b: 1);
|
||||
IllumilibLighting.SetKeyboardLighting(x: 16, y: 5, r: 1, g: 0, b: 1);
|
||||
IllumilibLighting.SetKeyboardLighting(6, 1, 1, 0, 1);
|
||||
IllumilibLighting.SetKeyboardLighting(16, 5, 1, 0, 1);
|
||||
Thread.Sleep(TimeSpan.FromSeconds(5));
|
||||
IllumilibLighting.SetKeyboardLighting(r: 0, g: 0, b: 0);
|
||||
IllumilibLighting.SetKeyboardLighting(x: 8, y: 2, width: 2, height: 2, r: 0, g: 1, b: 0);
|
||||
IllumilibLighting.SetKeyboardLighting(0, 0, 0);
|
||||
IllumilibLighting.SetKeyboardLighting(8, 2, 2, 2, 0, 1, 0);
|
||||
Thread.Sleep(TimeSpan.FromSeconds(5));
|
||||
IllumilibLighting.SetKeyboardLighting(r: 0, g: 0, b: 0);
|
||||
IllumilibLighting.SetKeyboardLighting(0, 0, 0);
|
||||
|
||||
Console.WriteLine("Doing a fun effect");
|
||||
for (var x = 0; x < IllumilibLighting.KeyboardWidth; x++) {
|
||||
IllumilibLighting.SetKeyboardLighting(x: x, y: 0, width: 1, height: IllumilibLighting.KeyboardHeight, r: 0, g: 0, b: 1);
|
||||
IllumilibLighting.SetKeyboardLighting(x, 0, 1, IllumilibLighting.KeyboardHeight, 0, 0, 1);
|
||||
Thread.Sleep(TimeSpan.FromSeconds(0.25F));
|
||||
}
|
||||
for (var x = IllumilibLighting.KeyboardWidth - 1; x >= 0; x--) {
|
||||
IllumilibLighting.SetKeyboardLighting(x: x, y: 0, width: 1, height: IllumilibLighting.KeyboardHeight, r: 0, g: 0, b: 0);
|
||||
IllumilibLighting.SetKeyboardLighting(x, 0, 1, IllumilibLighting.KeyboardHeight, 0, 0, 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: key, r: 0, g: 1, b: 0);
|
||||
IllumilibLighting.SetKeyboardLighting(key, 0, 1, 0);
|
||||
Thread.Sleep(TimeSpan.FromSeconds(0.25F));
|
||||
IllumilibLighting.SetKeyboardLighting(key: key, r: 0, g: 0, b: 0);
|
||||
IllumilibLighting.SetKeyboardLighting(key, 0, 0, 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(r: value, g: 0, b: value);
|
||||
IllumilibLighting.SetAllLighting(value, 0, value);
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
IllumilibLighting.SetAllLighting(r: 0, g: 0, b: 0);
|
||||
IllumilibLighting.SetAllLighting(0, 0, 0);
|
||||
|
||||
Console.WriteLine("Setting all supported keys");
|
||||
foreach (var key in Enum.GetValues<KeyboardKeys>()) {
|
||||
IllumilibLighting.SetKeyboardLighting(key: key, r: 1, g: 0, b: 0);
|
||||
IllumilibLighting.SetKeyboardLighting(key, 1, 0, 0);
|
||||
Thread.Sleep(50);
|
||||
}
|
||||
Thread.Sleep(TimeSpan.FromSeconds(15));
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||
<PackageIcon>Logo.png</PackageIcon>
|
||||
<VersionPrefix>1.2.4</VersionPrefix>
|
||||
<VersionPrefix>1.2.5</VersionPrefix>
|
||||
<NoWarn>NU1701</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace Illumilib {
|
|||
/// <summary>
|
||||
/// A property that returns whether Illumilib is currently initialized
|
||||
/// </summary>
|
||||
public static bool Initialized => systems != null;
|
||||
public static bool Initialized => IllumilibLighting.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 (Initialized)
|
||||
if (IllumilibLighting.Initialized)
|
||||
throw new InvalidOperationException("Illumilib has already been initialized");
|
||||
systems = new Dictionary<LightingType, LightingSystem>();
|
||||
IllumilibLighting.systems = new Dictionary<LightingType, LightingSystem>();
|
||||
foreach (var system in new LightingSystem[] {new LogitechLighting(), new RazerLighting(), new CorsairLighting()}) {
|
||||
if (system.Initialize())
|
||||
systems.Add(system.Type, system);
|
||||
IllumilibLighting.systems.Add(system.Type, system);
|
||||
}
|
||||
return systems.Count > 0;
|
||||
return IllumilibLighting.systems.Count > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disposes Illumilib, disposing all of the underlying lighting systems
|
||||
/// </summary>
|
||||
public static void Dispose() {
|
||||
if (!Initialized)
|
||||
if (!IllumilibLighting.Initialized)
|
||||
return;
|
||||
foreach (var system in systems.Values)
|
||||
foreach (var system in IllumilibLighting.systems.Values)
|
||||
system.Dispose();
|
||||
systems = null;
|
||||
IllumilibLighting.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) {
|
||||
EnsureInitialized();
|
||||
return systems.ContainsKey(type);
|
||||
IllumilibLighting.EnsureInitialized();
|
||||
return IllumilibLighting.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) {
|
||||
EnsureInitialized();
|
||||
foreach (var system in systems.Values)
|
||||
IllumilibLighting.EnsureInitialized();
|
||||
foreach (var system in IllumilibLighting.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) {
|
||||
EnsureInitialized();
|
||||
foreach (var system in systems.Values)
|
||||
IllumilibLighting.EnsureInitialized();
|
||||
foreach (var system in IllumilibLighting.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) {
|
||||
EnsureInitialized();
|
||||
if (x < 0 || x >= KeyboardWidth)
|
||||
IllumilibLighting.EnsureInitialized();
|
||||
if (x < 0 || x >= IllumilibLighting.KeyboardWidth)
|
||||
throw new ArgumentOutOfRangeException(nameof(x));
|
||||
if (y < 0 || y >= KeyboardHeight)
|
||||
if (y < 0 || y >= IllumilibLighting.KeyboardHeight)
|
||||
throw new ArgumentOutOfRangeException(nameof(y));
|
||||
foreach (var system in systems.Values)
|
||||
foreach (var system in IllumilibLighting.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) {
|
||||
EnsureInitialized();
|
||||
if (x < 0 || x + width > KeyboardWidth)
|
||||
IllumilibLighting.EnsureInitialized();
|
||||
if (x < 0 || x + width > IllumilibLighting.KeyboardWidth)
|
||||
throw new ArgumentOutOfRangeException(nameof(x));
|
||||
if (y < 0 || y + height > KeyboardHeight)
|
||||
if (y < 0 || y + height > IllumilibLighting.KeyboardHeight)
|
||||
throw new ArgumentOutOfRangeException(nameof(y));
|
||||
foreach (var system in systems.Values)
|
||||
foreach (var system in IllumilibLighting.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) {
|
||||
EnsureInitialized();
|
||||
foreach (var system in systems.Values)
|
||||
IllumilibLighting.EnsureInitialized();
|
||||
foreach (var system in IllumilibLighting.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) {
|
||||
EnsureInitialized();
|
||||
foreach (var system in systems.Values)
|
||||
IllumilibLighting.EnsureInitialized();
|
||||
foreach (var system in IllumilibLighting.systems.Values)
|
||||
system.SetMouseLighting(r, g, b);
|
||||
}
|
||||
|
||||
private static void EnsureInitialized() {
|
||||
if (!Initialized)
|
||||
if (!IllumilibLighting.Initialized)
|
||||
throw new InvalidOperationException("Illumilib has not been initialized yet");
|
||||
}
|
||||
|
||||
|
|
|
@ -138,16 +138,16 @@ namespace Illumilib.Lib {
|
|||
private const int LogiDevicetypeRgbOrd = 1;
|
||||
private const int LogiDevicetypePerkeyRgbOrd = 2;
|
||||
|
||||
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 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 LogiLedBitmapWidth = 21;
|
||||
public const int LogiLedBitmapHeight = 6;
|
||||
public const int LogiLedBitmapBytesPerKey = 4;
|
||||
|
||||
public const int LogiLedBitmapSize = LogiLedBitmapWidth * LogiLedBitmapHeight * LogiLedBitmapBytesPerKey;
|
||||
public const int LogiLedBitmapSize = LogitechGsdk.LogiLedBitmapWidth * LogitechGsdk.LogiLedBitmapHeight * LogitechGsdk.LogiLedBitmapBytesPerKey;
|
||||
public const int LogiLedDurationInfinite = 0;
|
||||
|
||||
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
|
||||
|
|
|
@ -75,7 +75,7 @@ namespace Illumilib.System {
|
|||
}
|
||||
|
||||
public override void SetKeyboardLighting(KeyboardKeys key, float r, float g, float b) {
|
||||
var id = ConvertKey(key);
|
||||
var id = CorsairLighting.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)
|
||||
SetColor(color, r, g, b);
|
||||
DeviceInfo.SetColor(color, r, g, b);
|
||||
}
|
||||
|
||||
public bool SetColorForId(CorsairLedId id, float r, float g, float b) {
|
||||
if (this.ledIdToColorIndex.TryGetValue(id, out var index)) {
|
||||
SetColor(this.colors[index], r, g, b);
|
||||
DeviceInfo.SetColor(this.colors[index], r, g, b);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace Illumilib.System {
|
|||
|
||||
public override void SetKeyboardLighting(KeyboardKeys key, float r, float g, float b) {
|
||||
this.ClearBitmap();
|
||||
LogitechGsdk.LogiLedSetLightingForKeyWithKeyName(ConvertKey(key), (int) (r * 100), (int) (g * 100), (int) (b * 100));
|
||||
LogitechGsdk.LogiLedSetLightingForKeyWithKeyName(LogitechLighting.ConvertKey(key), (int) (r * 100), (int) (g * 100), (int) (b * 100));
|
||||
}
|
||||
|
||||
public override void SetMouseLighting(float r, float g, float b) {
|
||||
|
|
|
@ -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(ConvertKey(key), new Color(r, g, b));
|
||||
this.chroma.Keyboard?.SetKeyAsync(RazerLighting.ConvertKey(key), new Color(r, g, b));
|
||||
this.effectOutdated = true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue