diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 00000000..01b0d7fe
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,17 @@
+[*]
+insert_final_newline = true
+trim_trailing_whitespace = true
+indent_style = space
+indent_size = 4
+
+[*.{cs,ps1,xml}]
+charset = utf-8
+
+[*.sln]
+indent_style = tab
+
+[*.{csproj,yml,nuspec},packages.config]
+indent_size = 2
+
+[*.md]
+trim_trailing_whitespace = false
diff --git a/Corale.Colore.Tests/Corale.Colore.Tests.csproj b/Corale.Colore.Tests/Corale.Colore.Tests.csproj
index 36064152..4fdb5f87 100644
--- a/Corale.Colore.Tests/Corale.Colore.Tests.csproj
+++ b/Corale.Colore.Tests/Corale.Colore.Tests.csproj
@@ -73,6 +73,7 @@
..\packages\NUnit.2.6.4\lib\nunit.framework.dll
+
diff --git a/Corale.Colore.Tests/Core/ColorTests.cs b/Corale.Colore.Tests/Core/ColorTests.cs
index 7b9a7516..6c93e75d 100644
--- a/Corale.Colore.Tests/Core/ColorTests.cs
+++ b/Corale.Colore.Tests/Core/ColorTests.cs
@@ -34,70 +34,111 @@ namespace Corale.Colore.Tests.Core
using NUnit.Framework;
+ using SystemColor = System.Drawing.Color;
+ using WpfColor = System.Windows.Media.Color;
+
[TestFixture]
public class ColorTests
{
[Test]
public void ShouldConstructCorrectly()
{
- Assert.AreEqual(new Color(0x00123456).Value, 0x00123456);
+ Assert.AreEqual(new Color(0x78123456).Value, 0x78123456);
}
[Test]
public void ShouldConstructFromColor()
{
- var c = new Color(0x00123456);
+ var c = new Color(0x78123456);
Assert.AreEqual(new Color(c), c);
}
[Test]
public void ShouldConvertRgbBytesCorrectly()
{
- const uint V = 0x00FFFFFF;
- const byte R = 255;
- const byte G = 255;
- const byte B = 255;
- var c = new Color(R, G, B);
+ const uint V = 0x8056F5C8;
+ const byte R = 200;
+ const byte G = 245;
+ const byte B = 86;
+ const byte A = 128;
+ var c = new Color(R, G, B, A);
Assert.AreEqual(c.Value, V);
Assert.AreEqual(c.R, R);
Assert.AreEqual(c.G, G);
Assert.AreEqual(c.B, B);
+ Assert.AreEqual(c.A, A);
}
[Test]
public void ShouldConvertRgbDoublesCorrectly()
{
- const uint V = 0x00FFFFFF;
- const double R = 1.0;
- const double G = 1.0;
- const double B = 1.0;
- const byte Expected = 255;
- var c = new Color(R, G, B);
+ const uint V = 0x7F3D89CC;
+ const double R = 0.8;
+ const double G = 0.54;
+ const double B = 0.24;
+ const double A = 0.5;
+ const byte ExpectedR = (byte)(R * 255);
+ const byte ExpectedG = (byte)(G * 255);
+ const byte ExpectedB = (byte)(B * 255);
+ const byte ExpectedA = (byte)(A * 255);
+ var c = new Color(R, G, B, A);
Assert.AreEqual(c.Value, V);
- Assert.AreEqual(c.R, Expected);
- Assert.AreEqual(c.G, Expected);
- Assert.AreEqual(c.B, Expected);
+ Assert.AreEqual(c.R, ExpectedR);
+ Assert.AreEqual(c.G, ExpectedG);
+ Assert.AreEqual(c.B, ExpectedB);
+ Assert.AreEqual(c.A, ExpectedA);
}
[Test]
public void ShouldConvertRgbFloatsCorrectly()
{
- const uint V = 0x00FFFFFF;
- const float R = 1.0f;
- const float G = 1.0f;
- const float B = 1.0f;
- const byte Expected = 255;
- var c = new Color(R, G, B);
+ const uint V = 0xD8E533CC;
+ const float R = 0.8f;
+ const float G = 0.2f;
+ const float B = 0.9f;
+ const float A = 0.85f;
+ const byte ExpectedR = (byte)(R * 255);
+ const byte ExpectedG = (byte)(G * 255);
+ const byte ExpectedB = (byte)(B * 255);
+ const byte ExpectedA = (byte)(A * 255);
+ var c = new Color(R, G, B, A);
Assert.AreEqual(c.Value, V);
- Assert.AreEqual(c.R, Expected);
- Assert.AreEqual(c.G, Expected);
- Assert.AreEqual(c.B, Expected);
+ Assert.AreEqual(c.R, ExpectedR);
+ Assert.AreEqual(c.G, ExpectedG);
+ Assert.AreEqual(c.B, ExpectedB);
+ Assert.AreEqual(c.A, ExpectedA);
+ }
+
+ [Test]
+ public void ShouldConstructFromArgb()
+ {
+ var expected = new Color(0x12345678);
+ var actual = Color.FromArgb(0x12785634);
+
+ Assert.AreEqual(expected.Value, actual.Value);
+ Assert.AreEqual(expected.R, actual.R);
+ Assert.AreEqual(expected.G, actual.G);
+ Assert.AreEqual(expected.B, actual.B);
+ Assert.AreEqual(expected.A, actual.A);
}
[Test]
- public void ShouldDefaultToBlackColor()
+ public void ShouldConstructFromRgb()
{
- Assert.AreEqual(new Color(), Color.Black);
+ var expected = new Color(0xFF123456);
+ var actual = Color.FromRgb(0x563412);
+
+ Assert.AreEqual(expected.Value, actual.Value);
+ Assert.AreEqual(expected.R, actual.R);
+ Assert.AreEqual(expected.G, actual.G);
+ Assert.AreEqual(expected.B, actual.B);
+ Assert.AreEqual(expected.A, actual.A);
+ }
+
+ [Test]
+ public void ShouldDefaultToEmptyColor()
+ {
+ Assert.AreEqual(new Color().Value, 0);
}
[Test]
@@ -114,7 +155,7 @@ public void ShouldEqualIdenticalColor()
public void ShouldEqualIdenticalUint()
{
var a = new Color(255, 0, 255);
- const uint B = 0x00FF00FF;
+ const uint B = 0xFFFF00FF;
Assert.AreEqual(a, B);
Assert.True(a == B);
Assert.False(a != B);
@@ -206,46 +247,143 @@ public void UintShouldNotEqualDifferentColor()
}
[Test]
- public void ShouldConstructFromSystemColor()
+ public void ShouldConvertFromSystemColor()
{
- var source = System.Drawing.Color.FromArgb(5, 10, 15);
- var coloreColor = new Color(source);
+ var source = SystemColor.FromArgb(5, 10, 15, 20);
+ var coloreColor = Color.FromSystemColor(source);
Assert.AreEqual(source.R, coloreColor.R);
Assert.AreEqual(source.G, coloreColor.G);
Assert.AreEqual(source.B, coloreColor.B);
+ Assert.AreEqual(source.A, coloreColor.A);
}
[Test]
- public void ShouldConvertToSystemColor()
+ public void ShouldExplicitCastToSystemColor()
{
- var coloreColor = new Color(1, 2, 4);
- var systemColor = (System.Drawing.Color)coloreColor;
+ var coloreColor = new Color(1, 2, 4, 8);
+ var systemColor = (SystemColor)coloreColor;
Assert.AreEqual(coloreColor.R, systemColor.R);
Assert.AreEqual(coloreColor.G, systemColor.G);
Assert.AreEqual(coloreColor.B, systemColor.B);
+ Assert.AreEqual(coloreColor.A, systemColor.A);
}
[Test]
- public void ShouldConvertFromSystemColor()
+ public void ShouldExplicitCastFromSystemColor()
{
- var systemColor = System.Drawing.Color.FromArgb(5, 10, 15);
+ var systemColor = SystemColor.FromArgb(5, 10, 15, 20);
var coloreColor = (Color)systemColor;
Assert.AreEqual(systemColor.R, coloreColor.R);
Assert.AreEqual(systemColor.G, coloreColor.G);
Assert.AreEqual(systemColor.B, coloreColor.B);
+ Assert.AreEqual(systemColor.A, coloreColor.A);
+ }
+
+ [Test]
+ public void ShouldImplicitCastToSystemColor()
+ {
+ var coloreColor = new Color(1, 2, 4, 8);
+ SystemColor systemColor = coloreColor;
+
+ Assert.AreEqual(coloreColor.R, systemColor.R);
+ Assert.AreEqual(coloreColor.G, systemColor.G);
+ Assert.AreEqual(coloreColor.B, systemColor.B);
+ Assert.AreEqual(coloreColor.A, systemColor.A);
+ }
+
+ [Test]
+ public void ShouldImplicitCastFromSystemColor()
+ {
+ var systemColor = SystemColor.FromArgb(5, 10, 15, 20);
+ Color coloreColor = systemColor;
+
+ Assert.AreEqual(systemColor.R, coloreColor.R);
+ Assert.AreEqual(systemColor.G, coloreColor.G);
+ Assert.AreEqual(systemColor.B, coloreColor.B);
+ Assert.AreEqual(systemColor.A, coloreColor.A);
}
[Test]
public void ShouldEqualSystemColorUsingOverload()
{
- var coloreColor = new Color(1, 2, 3);
- var systemColor = System.Drawing.Color.FromArgb(1, 2, 3);
+ var coloreColor = new Color(1, 2, 3, 8);
+ var systemColor = SystemColor.FromArgb(8, 1, 2, 3);
Assert.True(coloreColor.Equals(systemColor));
Assert.AreEqual(coloreColor, systemColor);
}
+
+ [Test]
+ public void ShouldConvertFromWpfColor()
+ {
+ var wpfColor = WpfColor.FromArgb(5, 10, 15, 20);
+ var coloreColor = Color.FromWpfColor(wpfColor);
+
+ Assert.AreEqual(wpfColor.R, coloreColor.R);
+ Assert.AreEqual(wpfColor.G, coloreColor.G);
+ Assert.AreEqual(wpfColor.B, coloreColor.B);
+ Assert.AreEqual(wpfColor.A, coloreColor.A);
+ }
+
+ [Test]
+ public void ShouldExplicitCastToWpfColor()
+ {
+ var coloreColor = new Color(1, 2, 4, 8);
+ var wpfColor = (WpfColor)coloreColor;
+
+ Assert.AreEqual(coloreColor.R, wpfColor.R);
+ Assert.AreEqual(coloreColor.G, wpfColor.G);
+ Assert.AreEqual(coloreColor.B, wpfColor.B);
+ Assert.AreEqual(coloreColor.A, wpfColor.A);
+ }
+
+ [Test]
+ public void ShouldExplicitCastFromWpfColor()
+ {
+ var wpfColor = WpfColor.FromArgb(5, 10, 15, 20);
+ var coloreColor = (Color)wpfColor;
+
+ Assert.AreEqual(wpfColor.R, coloreColor.R);
+ Assert.AreEqual(wpfColor.G, coloreColor.G);
+ Assert.AreEqual(wpfColor.B, coloreColor.B);
+ Assert.AreEqual(wpfColor.A, coloreColor.A);
+ }
+
+ [Test]
+ public void ShouldImplicitCastToWpfColor()
+ {
+ var coloreColor = new Color(1, 2, 4, 8);
+ WpfColor wpfColor = coloreColor;
+
+ Assert.AreEqual(coloreColor.R, wpfColor.R);
+ Assert.AreEqual(coloreColor.G, wpfColor.G);
+ Assert.AreEqual(coloreColor.B, wpfColor.B);
+ Assert.AreEqual(coloreColor.A, wpfColor.A);
+ }
+
+ [Test]
+ public void ShouldImplicitCastFromWpfColor()
+ {
+ var wpfColor = WpfColor.FromArgb(5, 10, 15, 20);
+ Color coloreColor = wpfColor;
+
+ Assert.AreEqual(wpfColor.R, coloreColor.R);
+ Assert.AreEqual(wpfColor.G, coloreColor.G);
+ Assert.AreEqual(wpfColor.B, coloreColor.B);
+ Assert.AreEqual(wpfColor.A, coloreColor.A);
+ }
+
+ [Test]
+ public void ShouldEqualWpfColorUsingOverload()
+ {
+ var coloreColor = new Color(1, 2, 3, 8);
+ var wpfColor = WpfColor.FromArgb(8, 1, 2, 3);
+
+ Assert.True(coloreColor.Equals(wpfColor));
+ Assert.AreEqual(coloreColor, wpfColor);
+ }
}
}
diff --git a/Corale.Colore/Corale.Colore.csproj b/Corale.Colore/Corale.Colore.csproj
index 2f61c801..aac6c676 100644
--- a/Corale.Colore/Corale.Colore.csproj
+++ b/Corale.Colore/Corale.Colore.csproj
@@ -79,6 +79,7 @@
..\packages\log4net.2.0.3\lib\net35-full\log4net.dll
True
+
@@ -91,21 +92,8 @@
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -146,6 +134,8 @@
+
+
@@ -169,6 +159,7 @@
+
@@ -176,6 +167,7 @@
+
diff --git a/Corale.Colore/Corale.Colore.nuspec b/Corale.Colore/Corale.Colore.nuspec
index 9074b257..8d0348e2 100644
--- a/Corale.Colore/Corale.Colore.nuspec
+++ b/Corale.Colore/Corale.Colore.nuspec
@@ -7,7 +7,7 @@
$author$
Adam Hellberg, Brandon Scott
https://github.com/CoraleStudios/Colore/blob/master/LICENSE
- https://github.com/Corale/Colore
+ https://github.com/CoraleStudios/Colore
false
$description$
Copyright (c) 2015 by Adam Hellberg and Brandon Scott.
diff --git a/Corale.Colore/Core/Chroma.cs b/Corale.Colore/Core/Chroma.cs
index a34e4f9b..539d80b1 100644
--- a/Corale.Colore/Core/Chroma.cs
+++ b/Corale.Colore/Core/Chroma.cs
@@ -52,6 +52,11 @@ public sealed class Chroma : IChroma
///
private static readonly ILog Log = LogManager.GetLogger(typeof(Chroma));
+ ///
+ /// Mutex lock for thread-safe init calls.
+ ///
+ private static readonly object InitLock = new object();
+
///
/// Holds the application-wide instance of the interface.
///
@@ -72,11 +77,7 @@ public sealed class Chroma : IChroma
///
private Chroma()
{
- Log.Info("Chroma is initializing.");
- Log.Debug("Calling SDK Init function");
- NativeWrapper.Init();
- Log.Debug("Resetting _registeredHandle");
- _registeredHandle = IntPtr.Zero;
+ Initialize();
}
///
@@ -87,8 +88,7 @@ private Chroma()
///
~Chroma()
{
- Unregister();
- NativeWrapper.UnInit();
+ Uninitialize();
}
///
@@ -129,7 +129,10 @@ public static IChroma Instance
{
get
{
- return _instance ?? (_instance = new Chroma());
+ lock (InitLock)
+ {
+ return _instance ?? (_instance = new Chroma());
+ }
}
}
@@ -194,15 +197,10 @@ public IKeypad Keypad
}
///
- /// Gets a value indicating whether the Chroma main class has been initialized or not.
+ /// Gets a value indicating whether the Chroma
+ /// SDK has been initialized or not.
///
- internal static bool Initialized
- {
- get
- {
- return _instance != null;
- }
- }
+ public bool Initialized { get; private set; }
///
/// Checks if the Chroma SDK is available on this system.
@@ -238,9 +236,16 @@ public static bool IsSdkAvailable()
if (key != null)
{
var value = key.GetValue("Enable");
- var bytes = value as byte[];
- regEnabled = bytes != null && bytes[0] == 1;
+ if (value is int)
+ regEnabled = (int)value == 1;
+ else
+ {
+ regEnabled = true;
+ Log.Warn(
+ "Chroma SDK has changed registry setting format. Please update Colore to latest version.");
+ Log.DebugFormat("New Enabled type: {0}", value.GetType());
+ }
}
else
regEnabled = false;
@@ -264,6 +269,57 @@ public static bool IsSdkAvailable()
return dllValid && regEnabled;
}
+ ///
+ /// Initializes the SDK if it hasn't already.
+ ///
+ ///
+ /// Manual manipulation of the SDK state is
+ /// not supported by the CoraleStudios team and may
+ /// result in undefined behaviour. Usage of this method is
+ /// at your own risk.
+ ///
+ public void Initialize()
+ {
+ if (Initialized)
+ return;
+
+ Log.Info("Chroma is initializing.");
+ Log.Debug("Calling SDK Init function");
+ NativeWrapper.Init();
+ Initialized = true;
+ Log.Debug("Resetting _registeredHandle");
+ _registeredHandle = IntPtr.Zero;
+ }
+
+ ///
+ /// Uninitializes the SDK if it has been initialized.
+ ///
+ ///
+ /// Manual manipulation of the SDK state is
+ /// not supported by the CoraleStudios team and may
+ /// result in undefined behaviour. Usage of this method is
+ /// at your own risk. Usage of SDK functions while
+ /// the SDK is in an uninitialized state is highly
+ /// advised against and WILL result in catastrophic
+ /// failure. YOU HAVE BEEN WARNED.
+ ///
+ public void Uninitialize()
+ {
+ if (!Initialized)
+ return;
+
+ ((Device)Keyboard).DeleteCurrentEffect();
+ ((Device)Mouse).DeleteCurrentEffect();
+ ((Device)Keypad).DeleteCurrentEffect();
+ ((Device)Mousepad).DeleteCurrentEffect();
+ ((Device)Headset).DeleteCurrentEffect();
+
+ Unregister();
+ NativeWrapper.UnInit();
+
+ Initialized = false;
+ }
+
///
/// Queries the SDK for information regarding a specific device.
///
@@ -404,10 +460,9 @@ public void SetAll(Color color)
///
/// For internal use by singleton accessors in device interface implementations.
///
- internal static void Initialize()
+ internal static void InitInstance()
{
- if (!Initialized)
- _instance = new Chroma();
+ Instance.Initialize();
}
///
diff --git a/Corale.Colore/Core/IMousepad.Obsoletes.cs b/Corale.Colore/Core/Color.Defines.cs
similarity index 58%
rename from Corale.Colore/Core/IMousepad.Obsoletes.cs
rename to Corale.Colore/Core/Color.Defines.cs
index 1a35502b..980b7d18 100644
--- a/Corale.Colore/Core/IMousepad.Obsoletes.cs
+++ b/Corale.Colore/Core/Color.Defines.cs
@@ -1,5 +1,5 @@
// ---------------------------------------------------------------------------------------
-//
+//
// Copyright © 2015 by Adam Hellberg and Brandon Scott.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
@@ -30,55 +30,71 @@
namespace Corale.Colore.Core
{
- using System;
-
using Corale.Colore.Annotations;
- using Corale.Colore.Razer.Mousepad.Effects;
///
- /// Interface for mouse pad functionality.
+ /// Represents an RGB color.
///
- public partial interface IMousepad
+ public partial struct Color
{
///
- /// Sets a breathing effect on the mouse pad.
+ /// Black color.
+ ///
+ [PublicAPI]
+ public static readonly Color Black = new Color(0, 0, 0);
+
+ ///
+ /// (Dark) blue color.
+ ///
+ [PublicAPI]
+ public static readonly Color Blue = new Color(0, 0, 255);
+
+ ///
+ /// (Neon/bright) green color.
+ ///
+ [PublicAPI]
+ public static readonly Color Green = new Color(0, 255, 0);
+
+ ///
+ /// Hot pink color.
+ ///
+ [PublicAPI]
+ public static readonly Color HotPink = new Color(255, 105, 180);
+
+ ///
+ /// Orange color.
+ ///
+ [PublicAPI]
+ public static readonly Color Orange = FromRgb(0xFFA500);
+
+ ///
+ /// Pink color.
///
- /// An instance of the struct.
- [Obsolete("Set is deprecated, please use SetBreathing(Breathing).", false)]
[PublicAPI]
- void Set(Breathing effect);
+ public static readonly Color Pink = new Color(255, 0, 255);
///
- /// Sets a static color effect on the mouse pad.
+ /// Purple color.
///
- /// An instance of the struct.
- [Obsolete("Set is deprecated, please use SetStatic(Static).", false)]
[PublicAPI]
- void Set(Static effect);
+ public static readonly Color Purple = FromRgb(0x800080);
///
- /// Sets a wave effect on the mouse pad.
+ /// Red color.
///
- /// An instance of the struct.
- [Obsolete("Set is deprecated, please use SetWave(Wave).", false)]
[PublicAPI]
- void Set(Wave effect);
+ public static readonly Color Red = new Color(255, 0, 0);
///
- /// Sets a custom effect on the mouse pad.
+ /// White color.
///
- /// An instance of the struct.
- [Obsolete("Set is deprecated, please use SetCustom(Custom).", false)]
[PublicAPI]
- void Set(Custom effect);
+ public static readonly Color White = new Color(255, 255, 255);
///
- /// Sets an effect without any parameters.
- /// Currently, this only works for the effect.
+ /// Yellow color.
///
- /// Effect options.
- [Obsolete("Set is deprecated, please use SetEffect(Effect).", false)]
[PublicAPI]
- void Set(Effect effect);
+ public static readonly Color Yellow = new Color(255, 255, 0);
}
}
diff --git a/Corale.Colore/Core/Color.cs b/Corale.Colore/Core/Color.cs
index 0ed64626..0aa89ac6 100644
--- a/Corale.Colore/Core/Color.cs
+++ b/Corale.Colore/Core/Color.cs
@@ -33,62 +33,17 @@ namespace Corale.Colore.Core
using System;
using System.Runtime.InteropServices;
+ using Corale.Colore.Annotations;
+
+ using SystemColor = System.Drawing.Color;
+ using WpfColor = System.Windows.Media.Color;
+
///
/// Represents an RGB color.
///
[StructLayout(LayoutKind.Sequential, Size = sizeof(uint))]
- public struct Color : IEquatable, IEquatable, IEquatable
+ public partial struct Color : IEquatable, IEquatable, IEquatable, IEquatable
{
- ///
- /// Black color.
- ///
- public static readonly Color Black = new Color(0, 0, 0);
-
- ///
- /// (Dark) blue color.
- ///
- public static readonly Color Blue = new Color(0, 0, 255);
-
- ///
- /// (Neon/bright) green color.
- ///
- public static readonly Color Green = new Color(0, 255, 0);
-
- ///
- /// Hot pink color.
- ///
- public static readonly Color HotPink = new Color(255, 105, 180);
-
- ///
- /// Orange color.
- ///
- public static readonly Color Orange = new Color(0xFFA500);
-
- ///
- /// Pink color.
- ///
- public static readonly Color Pink = new Color(255, 0, 255);
-
- ///
- /// Purple color.
- ///
- public static readonly Color Purple = new Color(0x800080);
-
- ///
- /// Red color.
- ///
- public static readonly Color Red = new Color(255, 0, 0);
-
- ///
- /// White color.
- ///
- public static readonly Color White = new Color(255, 255, 255);
-
- ///
- /// Yellow color.
- ///
- public static readonly Color Yellow = new Color(255, 255, 0);
-
///
/// Internal color value.
///
@@ -99,9 +54,11 @@ public struct Color : IEquatable, IEquatable, IEquatable
/// Initializes a new instance of the struct using an integer
- /// color value in the format 0xAABBGGRR.
+ /// color value in the format 0xAABBGGRR. Where the alpha component ranges
+ /// from 0x00 (fully transparent) to 0xFF (fully opaque).
///
/// Value to create the color from.
+ [PublicAPI]
public Color(uint value)
{
_value = value;
@@ -116,7 +73,8 @@ public Color(uint value)
/// The green component.
/// The blue component.
/// The alpha component (0 = fully opaque).
- public Color(byte red, byte green, byte blue, byte alpha = 0)
+ [PublicAPI]
+ public Color(byte red, byte green, byte blue, byte alpha = 255)
: this(red + ((uint)green << 8) + ((uint)blue << 16) + ((uint)alpha << 24))
{
}
@@ -133,7 +91,8 @@ public Color(byte red, byte green, byte blue, byte alpha = 0)
///
/// Each parameter value must be between 0.0f and 1.0f (inclusive).
///
- public Color(float red, float green, float blue, float alpha = 0.0f)
+ [PublicAPI]
+ public Color(float red, float green, float blue, float alpha = 1.0f)
: this((byte)(red * 255), (byte)(green * 255), (byte)(blue * 255), (byte)(alpha * 255))
{
}
@@ -149,24 +108,16 @@ public Color(float red, float green, float blue, float alpha = 0.0f)
///
/// Each parameter value must be between 0.0 and 1.0 (inclusive).
///
- public Color(double red, double green, double blue, double alpha = 0.0)
+ [PublicAPI]
+ public Color(double red, double green, double blue, double alpha = 1.0)
: this((byte)(red * 255), (byte)(green * 255), (byte)(blue * 255), (byte)(alpha * 255))
{
}
- ///
- /// Initializes a new instance of the struct using
- /// a struct as the source.
- ///
- /// An instance of the struct.
- public Color(System.Drawing.Color source)
- : this(source.R, source.G, source.B, source.A)
- {
- }
-
///
/// Gets the alpha component of the color as a byte.
///
+ [PublicAPI]
public byte A
{
get
@@ -178,6 +129,7 @@ public byte A
///
/// Gets the blue component of the color as a byte.
///
+ [PublicAPI]
public byte B
{
get
@@ -189,6 +141,7 @@ public byte B
///
/// Gets the green component of the color as a byte.
///
+ [PublicAPI]
public byte G
{
get
@@ -200,6 +153,7 @@ public byte G
///
/// Gets the red component of the color as a byte.
///
+ [PublicAPI]
public byte R
{
get
@@ -210,8 +164,9 @@ public byte R
///
/// Gets the unsigned integer representing
- /// the color. On the form 0x00BBGGRR.
+ /// the color. On the form 0xAABBGGRR.
///
+ [PublicAPI]
public uint Value
{
get
@@ -225,14 +180,15 @@ public uint Value
///
/// The to convert.
/// A representing the value of the argument.
- /// The returned has a format of 0x00BBGGRR.
+ /// The returned has a format of 0xAABBGGRR.
public static implicit operator uint(Color color)
{
return color._value;
}
///
- /// Converts to an instance of the struct.
+ /// Converts a uint in the format of 0xAABBGGRR
+ /// to a new instance of the struct.
///
/// The to convert, on the form 0x00BBGGRR.
/// An instance of representing the color value of .
@@ -249,13 +205,9 @@ public static implicit operator Color(uint value)
/// An instance of representing the
/// value of the argument.
///
- ///
- /// This is an explicit cast since casting a struct to
- /// is explicit.
- ///
- public static explicit operator System.Drawing.Color(Color color)
+ public static implicit operator SystemColor(Color color)
{
- return System.Drawing.Color.FromArgb(color.A, color.R, color.G, color.B);
+ return SystemColor.FromArgb(color.A, color.R, color.G, color.B);
}
///
@@ -265,13 +217,34 @@ public static explicit operator System.Drawing.Color(Color color)
///
/// An instance of representing the value of the argument.
///
- ///
- /// This is an explicit cast since the alpha component of the
- /// struct is discarded.
- ///
- public static explicit operator Color(System.Drawing.Color color)
+ public static implicit operator Color(SystemColor color)
{
- return new Color(color.R, color.G, color.B, color.A);
+ return FromSystemColor(color);
+ }
+
+ ///
+ /// Converts a struct to a struct.
+ ///
+ /// The to convert.
+ ///
+ /// An instance of representing the
+ /// value of the argument.
+ ///
+ public static implicit operator WpfColor(Color color)
+ {
+ return WpfColor.FromArgb(color.A, color.R, color.G, color.B);
+ }
+
+ ///
+ /// Converts a struct to a struct.
+ ///
+ /// The to convert.
+ ///
+ /// An instance of representing the value of the argument.
+ ///
+ public static implicit operator Color(WpfColor color)
+ {
+ return FromWpfColor(color);
}
///
@@ -296,6 +269,57 @@ public static explicit operator Color(System.Drawing.Color color)
return !left.Equals(right);
}
+ ///
+ /// Creates a new from the source
+ /// .
+ ///
+ /// The source object to construct color from.
+ /// A new instance of the struct.
+ [PublicAPI]
+ public static Color FromSystemColor(SystemColor source)
+ {
+ return new Color(source.R, source.G, source.B, source.A);
+ }
+
+ ///
+ /// Creates a new from the source
+ /// .
+ ///
+ /// The source object to construct color from.
+ /// A new instance of the struct.
+ [PublicAPI]
+ public static Color FromWpfColor(WpfColor source)
+ {
+ return new Color(source.R, source.G, source.B, source.A);
+ }
+
+ ///
+ /// Creates a new from an ARGB integer value
+ /// in the format of 0xAARRGGBB where the alpha component
+ /// ranges from 0x00 (fully transparent) to 0xFF (fully opaque).
+ ///
+ /// The ARGB value to convert from.
+ /// A new instance of the struct.
+ [PublicAPI]
+ public static Color FromArgb(uint value)
+ {
+ var abgr = (value & 0xFF00FF00) | ((value & 0xFF0000) >> 16) | ((value & 0xFF) << 16);
+ return new Color(abgr);
+ }
+
+ ///
+ /// Creates a new from an RGB integer value
+ /// in the format of 0xRRGGBB.
+ ///
+ /// The RGB value to convert from.
+ /// A new instance of the struct.
+ [PublicAPI]
+ public static Color FromRgb(uint value)
+ {
+ var abgr = 0xFF000000 | ((value & 0xFF0000) >> 16) | (value & 0xFF00) | ((value & 0xFF) << 16);
+ return new Color(abgr);
+ }
+
///
/// Returns a value indicating whether this instance of
/// is equal to an .
@@ -313,8 +337,11 @@ public override bool Equals(object other)
if (other is uint)
return Equals((uint)other);
- if (other is System.Drawing.Color)
- return Equals((System.Drawing.Color)other);
+ if (other is SystemColor)
+ return Equals((SystemColor)other);
+
+ if (other is WpfColor)
+ return Equals((WpfColor)other);
return false;
}
@@ -327,7 +354,7 @@ public override bool Equals(object other)
/// true of the two are equal, false otherwise.
public bool Equals(Color other)
{
- return _value.Equals(other);
+ return _value.Equals(other._value);
}
///
@@ -349,12 +376,20 @@ public bool Equals(uint other)
/// true if the current object is equal to the parameter; otherwise, false.
///
/// An instance of to compare with this object.
- public bool Equals(System.Drawing.Color other)
+ public bool Equals(SystemColor other)
+ {
+ return R == other.R && G == other.G && B == other.B && A == other.A;
+ }
+
+ ///
+ /// Indicates whether the current object is equal to an instance of a
+ /// struct.
+ ///
+ /// An instance of to compare with this object.
+ /// true if the current object is equal to the parameter; otherwise, false.
+ public bool Equals(WpfColor other)
{
- // Do not require matching alpha values for now, as it seems Razer do
- // not properly support alpha yet.
- // TODO: Change this back when Razer implements alpha
- return R == other.R && G == other.G && B == other.B; // && A == other.A;
+ return R == other.R && G == other.G && B == other.B & A == other.A;
}
///
diff --git a/Corale.Colore/Core/Device.cs b/Corale.Colore/Core/Device.cs
index a463ea6b..33a14b87 100644
--- a/Corale.Colore/Core/Device.cs
+++ b/Corale.Colore/Core/Device.cs
@@ -35,7 +35,7 @@ namespace Corale.Colore.Core
///
/// Base class for devices, containing code common between all devices.
///
- public abstract partial class Device : IDevice
+ public abstract class Device : IDevice
{
///
/// Gets or sets the ID of the currently active effect.
@@ -62,14 +62,21 @@ public void Clear()
/// GUID to set.
public void SetGuid(Guid guid)
{
- if (CurrentEffectId != Guid.Empty)
- {
- NativeWrapper.DeleteEffect(CurrentEffectId);
- CurrentEffectId = Guid.Empty;
- }
-
+ DeleteCurrentEffect();
NativeWrapper.SetEffect(guid);
CurrentEffectId = guid;
}
+
+ ///
+ /// Deletes the currently set effect.
+ ///
+ internal void DeleteCurrentEffect()
+ {
+ if (CurrentEffectId == Guid.Empty)
+ return;
+
+ NativeWrapper.DeleteEffect(CurrentEffectId);
+ CurrentEffectId = Guid.Empty;
+ }
}
}
diff --git a/Corale.Colore/Core/GenericDevice.Obsoletes.cs b/Corale.Colore/Core/GenericDevice.Obsoletes.cs
deleted file mode 100644
index 0193b64e..00000000
--- a/Corale.Colore/Core/GenericDevice.Obsoletes.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-// ---------------------------------------------------------------------------------------
-//
-// Copyright © 2015 by Adam Hellberg and Brandon Scott.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy of
-// this software and associated documentation files (the "Software"), to deal in
-// the Software without restriction, including without limitation the rights to
-// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-// of the Software, and to permit persons to whom the Software is furnished to do
-// so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-// Disclaimer: Corale and/or Colore is in no way affiliated with Razer and/or any
-// of its employees and/or licensors. Corale, Adam Hellberg, and/or Brandon Scott
-// do not take responsibility for any harm caused, direct or indirect, to any
-// Razer peripherals via the use of Colore.
-//
-// "Razer" is a trademark of Razer USA Ltd.
-//
-// ---------------------------------------------------------------------------------------
-
-namespace Corale.Colore.Core
-{
- using System;
-
- using Corale.Colore.Razer;
-
- ///
- /// A generic device.
- ///
- public sealed partial class GenericDevice
- {
- ///
- /// Sets a parameter-less effect on this device.
- ///
- /// Effect to set.
- [Obsolete("Set is deprecated, please use SetEffect(Effect).", false)]
- public void Set(Effect effect)
- {
- SetEffect(effect, IntPtr.Zero);
- }
-
- ///
- /// Sets an effect on this device, taking a parameter.
- ///
- /// Effect to set.
- /// Effect-specific parameter to use.
- [Obsolete("Set is deprecated, please use SetEffect(Effect, IntPtr).", false)]
- public void Set(Effect effect, IntPtr param)
- {
- SetGuid(NativeWrapper.CreateEffect(DeviceId, effect, param));
- }
- }
-}
diff --git a/Corale.Colore/Core/GenericDevice.cs b/Corale.Colore/Core/GenericDevice.cs
index d16a428e..b726288c 100644
--- a/Corale.Colore/Core/GenericDevice.cs
+++ b/Corale.Colore/Core/GenericDevice.cs
@@ -42,7 +42,7 @@ namespace Corale.Colore.Core
///
/// A generic device.
///
- public sealed partial class GenericDevice : Device, IGenericDevice
+ public sealed class GenericDevice : Device, IGenericDevice
{
///
/// Logger instance for this class.
@@ -93,7 +93,7 @@ public Guid DeviceId
[PublicAPI]
public static IGenericDevice Get(Guid deviceId)
{
- Chroma.Initialize();
+ Chroma.InitInstance();
if (!Instances.ContainsKey(deviceId))
Instances[deviceId] = new GenericDevice(deviceId);
diff --git a/Corale.Colore/Core/Headset.Obsoletes.cs b/Corale.Colore/Core/Headset.Obsoletes.cs
deleted file mode 100644
index 715fba77..00000000
--- a/Corale.Colore/Core/Headset.Obsoletes.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-// ---------------------------------------------------------------------------------------
-//
-// Copyright © 2015 by Adam Hellberg and Brandon Scott.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy of
-// this software and associated documentation files (the "Software"), to deal in
-// the Software without restriction, including without limitation the rights to
-// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-// of the Software, and to permit persons to whom the Software is furnished to do
-// so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-// Disclaimer: Corale and/or Colore is in no way affiliated with Razer and/or any
-// of its employees and/or licensors. Corale, Adam Hellberg, and/or Brandon Scott
-// do not take responsibility for any harm caused, direct or indirect, to any
-// Razer peripherals via the use of Colore.
-//
-// "Razer" is a trademark of Razer USA Ltd.
-//
-// ---------------------------------------------------------------------------------------
-
-namespace Corale.Colore.Core
-{
- using System;
-
- using Corale.Colore.Razer.Headset.Effects;
-
- ///
- /// Class for interacting with Chroma Headsets.
- ///
- public sealed partial class Headset
- {
- ///
- /// Sets an effect on the headset that doesn't
- /// take any parameters, currently only valid
- /// for the effect.
- ///
- /// The type of effect to set.
- [Obsolete("Set is deprecated, please use SetEffect(Effect).", false)]
- public void Set(Effect effect)
- {
- SetEffect(effect);
- }
-
- ///
- /// Sets a new static effect on the headset.
- ///
- ///
- /// An instance of the struct
- /// describing the effect.
- ///
- [Obsolete("Set is deprecated, please use SetStatic(Static).", false)]
- public void Set(Static effect)
- {
- SetStatic(effect);
- }
-
- ///
- /// Sets a new breathing effect on the headset.
- ///
- ///
- /// An instance of the struct
- /// describing the effect.
- ///
- [Obsolete("Set is deprecated, please use SetBreathing(Breathing).", false)]
- public void Set(Breathing effect)
- {
- SetBreathing(effect);
- }
- }
-}
diff --git a/Corale.Colore/Core/Headset.cs b/Corale.Colore/Core/Headset.cs
index 3c71beea..f3bc927b 100644
--- a/Corale.Colore/Core/Headset.cs
+++ b/Corale.Colore/Core/Headset.cs
@@ -37,7 +37,7 @@ namespace Corale.Colore.Core
///
/// Class for interacting with Chroma Headsets.
///
- public sealed partial class Headset : Device, IHeadset
+ public sealed class Headset : Device, IHeadset
{
///
/// Loggers instance for this class.
@@ -55,7 +55,7 @@ public sealed partial class Headset : Device, IHeadset
private Headset()
{
Log.Info("Headset is initializing");
- Chroma.Initialize();
+ Chroma.InitInstance();
}
///
diff --git a/Corale.Colore/Core/IChroma.cs b/Corale.Colore/Core/IChroma.cs
index 2829c9c2..982a7629 100644
--- a/Corale.Colore/Core/IChroma.cs
+++ b/Corale.Colore/Core/IChroma.cs
@@ -110,6 +110,35 @@ public interface IChroma
[PublicAPI]
IKeypad Keypad { get; }
+ ///
+ /// Gets a value indicating whether the Chroma
+ /// SDK has been initialized or not.
+ ///
+ [PublicAPI]
+ bool Initialized { get; }
+
+ ///
+ /// Initializes the SDK if it hasn't already.
+ ///
+ ///
+ /// Manually modifying the SDK init state is untested
+ /// and may result in undefined behaviour, usage
+ /// is at your own risk.
+ ///
+ [PublicAPI]
+ void Initialize();
+
+ ///
+ /// Uninitializes the SDK if it has been initialized.
+ ///
+ ///
+ /// Manually modifying the SDK init state is untested
+ /// and may result in undefined behaviour, usage
+ /// is at your own risk.
+ ///
+ [PublicAPI]
+ void Uninitialize();
+
///
/// Queries the SDK for information regarding a specific device.
///
diff --git a/Corale.Colore/Core/IDevice.Obsoletes.cs b/Corale.Colore/Core/IDevice.Obsoletes.cs
deleted file mode 100644
index f21eea23..00000000
--- a/Corale.Colore/Core/IDevice.Obsoletes.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-// ---------------------------------------------------------------------------------------
-//
-// Copyright © 2015 by Adam Hellberg and Brandon Scott.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy of
-// this software and associated documentation files (the "Software"), to deal in
-// the Software without restriction, including without limitation the rights to
-// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-// of the Software, and to permit persons to whom the Software is furnished to do
-// so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-// Disclaimer: Corale and/or Colore is in no way affiliated with Razer and/or any
-// of its employees and/or licensors. Corale, Adam Hellberg, and/or Brandon Scott
-// do not take responsibility for any harm caused, direct or indirect, to any
-// Razer peripherals via the use of Colore.
-//
-// "Razer" is a trademark of Razer USA Ltd.
-//
-// ---------------------------------------------------------------------------------------
-
-namespace Corale.Colore.Core
-{
- using System;
- using Corale.Colore.Annotations;
-
- ///
- /// Interface for functionality common with all devices.
- ///
- public partial interface IDevice
- {
- ///
- /// Sets the color of all components on this device.
- ///
- /// Color to set.
- [Obsolete("Set is deprecated, please use SetAll(Color).", false)]
- [PublicAPI]
- void Set(Color color);
-
- ///
- /// Updates the device to use the effect pointed to by the specified GUID.
- ///
- /// GUID to set.
- [Obsolete("Set is deprecated, please use SetGuid(Guid).", false)]
- [PublicAPI]
- void Set(Guid guid);
- }
-}
diff --git a/Corale.Colore/Core/IDevice.cs b/Corale.Colore/Core/IDevice.cs
index af12eb8e..4d97e980 100644
--- a/Corale.Colore/Core/IDevice.cs
+++ b/Corale.Colore/Core/IDevice.cs
@@ -37,7 +37,7 @@ namespace Corale.Colore.Core
///
/// Interface for functionality common with all devices.
///
- public partial interface IDevice
+ public interface IDevice
{
///
/// Gets the ID of the currently active effect.
diff --git a/Corale.Colore/Core/IGenericDevice.cs b/Corale.Colore/Core/IGenericDevice.cs
index 2d032195..25f1eec8 100644
--- a/Corale.Colore/Core/IGenericDevice.cs
+++ b/Corale.Colore/Core/IGenericDevice.cs
@@ -32,22 +32,25 @@ namespace Corale.Colore.Core
{
using System;
+ using Corale.Colore.Annotations;
using Corale.Colore.Razer;
///
/// Interface for generic devices.
///
- public partial interface IGenericDevice : IDevice
+ public interface IGenericDevice : IDevice
{
///
/// Gets the of this device.
///
+ [PublicAPI]
Guid DeviceId { get; }
///
/// Sets a parameter-less effect on this device.
///
/// Effect to set.
+ [PublicAPI]
void SetEffect(Effect effect);
///
@@ -55,6 +58,7 @@ public partial interface IGenericDevice : IDevice
///
/// Effect to set.
/// Effect-specific parameter to use.
+ [PublicAPI]
void SetEffect(Effect effect, IntPtr param);
}
}
diff --git a/Corale.Colore/Core/IHeadset.Obsoletes.cs b/Corale.Colore/Core/IHeadset.Obsoletes.cs
deleted file mode 100644
index 27874af1..00000000
--- a/Corale.Colore/Core/IHeadset.Obsoletes.cs
+++ /dev/null
@@ -1,75 +0,0 @@
-// ---------------------------------------------------------------------------------------
-//
-// Copyright © 2015 by Adam Hellberg and Brandon Scott.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy of
-// this software and associated documentation files (the "Software"), to deal in
-// the Software without restriction, including without limitation the rights to
-// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-// of the Software, and to permit persons to whom the Software is furnished to do
-// so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-// Disclaimer: Corale and/or Colore is in no way affiliated with Razer and/or any
-// of its employees and/or licensors. Corale, Adam Hellberg, and/or Brandon Scott
-// do not take responsibility for any harm caused, direct or indirect, to any
-// Razer peripherals via the use of Colore.
-//
-// "Razer" is a trademark of Razer USA Ltd.
-//
-// ---------------------------------------------------------------------------------------
-
-namespace Corale.Colore.Core
-{
- using System;
-
- using Corale.Colore.Annotations;
- using Corale.Colore.Razer.Headset.Effects;
-
- ///
- /// Interface for headset functionality.
- ///
- public partial interface IHeadset
- {
- ///
- /// Sets an effect on the headset that doesn't
- /// take any parameters, currently only valid
- /// for the effect.
- ///
- /// The type of effect to set.
- [Obsolete("Set is deprecated, please use SetEffect(Effect).", false)]
- [PublicAPI]
- void Set(Effect effect);
-
- ///
- /// Sets a new static effect on the headset.
- ///
- ///
- /// An instance of the struct
- /// describing the effect.
- ///
- [Obsolete("Set is deprecated, please use SetStatic(Static).", false)]
- [PublicAPI]
- void Set(Static effect);
-
- ///
- /// Sets a new breathing effect on the headset.
- ///
- ///
- /// An instance of the struct
- /// describing the effect.
- ///
- [Obsolete("Set is deprecated, please use SetBreathing(Breathing).", false)]
- [PublicAPI]
- void Set(Breathing effect);
- }
-}
diff --git a/Corale.Colore/Core/IHeadset.cs b/Corale.Colore/Core/IHeadset.cs
index f89d4c7b..9ec39332 100644
--- a/Corale.Colore/Core/IHeadset.cs
+++ b/Corale.Colore/Core/IHeadset.cs
@@ -36,7 +36,7 @@ namespace Corale.Colore.Core
///
/// Interface for headset functionality.
///
- public partial interface IHeadset : IDevice
+ public interface IHeadset : IDevice
{
///
/// Sets an effect on the headset that doesn't
diff --git a/Corale.Colore/Core/IKeyboard.Obsoletes.cs b/Corale.Colore/Core/IKeyboard.Obsoletes.cs
deleted file mode 100644
index 921b1def..00000000
--- a/Corale.Colore/Core/IKeyboard.Obsoletes.cs
+++ /dev/null
@@ -1,182 +0,0 @@
-// ---------------------------------------------------------------------------------------
-//
-// Copyright © 2015 by Adam Hellberg and Brandon Scott.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy of
-// this software and associated documentation files (the "Software"), to deal in
-// the Software without restriction, including without limitation the rights to
-// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-// of the Software, and to permit persons to whom the Software is furnished to do
-// so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-// Disclaimer: Corale and/or Colore is in no way affiliated with Razer and/or any
-// of its employees and/or licensors. Corale, Adam Hellberg, and/or Brandon Scott
-// do not take responsibility for any harm caused, direct or indirect, to any
-// Razer peripherals via the use of Colore.
-//
-// "Razer" is a trademark of Razer USA Ltd.
-//
-// ---------------------------------------------------------------------------------------
-
-namespace Corale.Colore.Core
-{
- using System;
- using System.Collections.Generic;
- using Corale.Colore.Annotations;
- using Corale.Colore.Razer.Keyboard;
- using Corale.Colore.Razer.Keyboard.Effects;
-
- ///
- /// Interface for keyboard functionality.
- ///
- public partial interface IKeyboard
- {
- ///
- /// Sets a breathing effect on the keyboard.
- ///
- /// Effect options.
- [Obsolete("Set is deprecated, please use SetBreathing(Breathing).", false)]
- [PublicAPI]
- void Set(Breathing effect);
-
- ///
- /// Sets a breathing effect on the keyboard, fading between the
- /// two specified colors.
- ///
- /// Color to start from.
- /// Color to reach, before going back to .
- [Obsolete("Set is deprecated, please use SetBreathing(Color, Color).", false)]
- [PublicAPI]
- void Set(Color first, Color second);
-
- ///
- /// Sets a reactive effect on the keyboard with the specified
- /// color and duration.
- ///
- /// Color to emit on key press.
- /// How long to illuminate the key after being pressed.
- [Obsolete("Set is deprecated, please use SetReactive(Color, Duration).", false)]
- [PublicAPI]
- void Set(Color color, Duration duration);
-
- ///
- /// Sets a custom grid effect on the keyboard using
- /// a two dimensional array of color values.
- ///
- /// The grid of colors to use.
- ///
- /// The passed in arrays cannot have more than rows and
- /// not more than columns in any row.
- ///
- /// This will overwrite the internal
- /// struct in the class.
- ///
- [Obsolete("Set is deprecated, please use SetGrid(Color[][]).", false)]
- [PublicAPI]
- void Set(Color[][] colors);
-
- ///
- /// Sets a custom grid effect on the keyboard.
- ///
- /// Effect options.
- ///
- /// This will overwrite the current internal
- /// struct in the class.
- ///
- [Obsolete("Set is deprecated, please use SetCustom(Custom).", false)]
- [PublicAPI]
- void Set(Custom effect);
-
- ///
- /// Sets a wave effect on the keyboard in the specified direction.
- ///
- /// Direction of the wave.
- [Obsolete("Set is deprecated, please use SetWave(Direction).", false)]
- [PublicAPI]
- void Set(Direction direction);
-
- ///
- /// Sets an effect without any parameters.
- /// Currently, this only works for the and effects.
- ///
- /// Effect options.
- [Obsolete("Set is deprecated, please use SetEffect(Effect).", false)]
- [PublicAPI]
- void Set(Effect effect);
-
- ///
- /// Sets the color on a specific row and column on the keyboard grid.
- ///
- /// Row to set, between 1 and .
- /// Column to set, between 1 and .
- /// Color to set.
- /// Whether or not to clear the existing colors before setting this one.
- [Obsolete("Set is deprecated, please use SetPosition(Size, Size, Color, bool).", false)]
- [PublicAPI]
- void Set(Size row, Size column, Color color, bool clear = false);
-
- ///
- /// Sets the color of a specific key on the keyboard.
- ///
- /// Key to modify.
- /// Color to set.
- /// If true, the keyboard will first be cleared before setting the key.
- [Obsolete("Set is deprecated, please use SetKey(Key, Color, bool).", false)]
- [PublicAPI]
- void Set(Key key, Color color, bool clear = false);
-
- ///
- /// Sets the specified color on a set of keys.
- ///
- /// The to apply.
- /// First key to change.
- /// Additional keys that should also have the color applied.
- [Obsolete("Set is deprecated, please use SetKeys(Color, Key, Key[][]).", false)]
- [PublicAPI]
- void Set(Color color, Key key, params Key[] keys);
-
- ///
- /// Sets a color on a collection of keys.
- ///
- /// The keys which should have their color changed.
- /// The to apply.
- /// If true, the keyboard will first be cleared before setting the keys.
- [Obsolete("Set is deprecated, please use SetKeys(INumerable, Color, bool).", false)]
- [PublicAPI]
- void Set(IEnumerable keys, Color color, bool clear = false);
-
- ///
- /// Sets a reactive effect on the keyboard.
- ///
- /// Effect options.
- [Obsolete("Set is deprecated, please use SetReactive(Reactive).", false)]
- [PublicAPI]
- void Set(Reactive effect);
-
- ///
- /// Sets a static color on the keyboard.
- ///
- /// Effect options.
- [Obsolete("Set is deprecated, please use SetStatic(Static).", false)]
- [PublicAPI]
- void Set(Static effect);
-
- ///
- /// Sets a wave effect on the keyboard.
- ///
- /// Effect options.
- [Obsolete("Set is deprecated, please use SetWave(Wave).", false)]
- [PublicAPI]
- void Set(Wave effect);
- }
-}
diff --git a/Corale.Colore/Core/IKeyboard.cs b/Corale.Colore/Core/IKeyboard.cs
index 6149bd82..e6104126 100644
--- a/Corale.Colore/Core/IKeyboard.cs
+++ b/Corale.Colore/Core/IKeyboard.cs
@@ -39,7 +39,7 @@ namespace Corale.Colore.Core
///
/// Interface for keyboard functionality.
///
- public partial interface IKeyboard : IDevice
+ public interface IKeyboard : IDevice
{
///
/// Gets or sets the for a specific on the keyboard.
diff --git a/Corale.Colore/Core/IKeypad.Obsoletes.cs b/Corale.Colore/Core/IKeypad.Obsoletes.cs
deleted file mode 100644
index dab06ef8..00000000
--- a/Corale.Colore/Core/IKeypad.Obsoletes.cs
+++ /dev/null
@@ -1,92 +0,0 @@
-// ---------------------------------------------------------------------------------------
-//
-// Copyright © 2015 by Adam Hellberg and Brandon Scott.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy of
-// this software and associated documentation files (the "Software"), to deal in
-// the Software without restriction, including without limitation the rights to
-// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-// of the Software, and to permit persons to whom the Software is furnished to do
-// so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-// Disclaimer: Corale and/or Colore is in no way affiliated with Razer and/or any
-// of its employees and/or licensors. Corale, Adam Hellberg, and/or Brandon Scott
-// do not take responsibility for any harm caused, direct or indirect, to any
-// Razer peripherals via the use of Colore.
-//
-// "Razer" is a trademark of Razer USA Ltd.
-//
-// ---------------------------------------------------------------------------------------
-
-namespace Corale.Colore.Core
-{
- using System;
-
- using Corale.Colore.Annotations;
- using Corale.Colore.Razer.Keypad.Effects;
-
- ///
- /// Interface for keypad functions.
- ///
- public partial interface IKeypad
- {
- ///
- /// Sets a effect on the keypad.
- ///
- /// An instance of the struct.
- [Obsolete("Set is deprecated, please use SetBreathing(Breathing).", false)]
- [PublicAPI]
- void Set(Breathing effect);
-
- ///
- /// Sets a effect on the keypad.
- ///
- /// An instance of the struct.
- [Obsolete("Set is deprecated, please use SetCustom(Custom).", false)]
- [PublicAPI]
- void Set(Custom effect);
-
- ///
- /// Sets a effect on the keypad.
- ///
- /// An instance of the struct.
- [Obsolete("Set is deprecated, please use SetReactive(Reactive).", false)]
- [PublicAPI]
- void Set(Reactive effect);
-
- ///
- /// Sets a effect on the keypad.
- ///
- /// An instance of the struct.
- [Obsolete("Set is deprecated, please use SetStatic(Static).", false)]
- [PublicAPI]
- void Set(Static effect);
-
- ///
- /// Sets a effect on the keypad.
- ///
- /// An instance of the struct.
- [Obsolete("Set is deprecated, please use SetWave(Wave).", false)]
- [PublicAPI]
- void Set(Wave effect);
-
- ///
- /// Sets an effect without any parameters.
- /// Currently, this only works for the effect.
- ///
- /// Effect options.
- [Obsolete("Set is deprecated, please use SetEffect(Effect).", false)]
- [PublicAPI]
- void Set(Effect effect);
- }
-}
diff --git a/Corale.Colore/Core/IKeypad.cs b/Corale.Colore/Core/IKeypad.cs
index a5dd8124..283fa06e 100644
--- a/Corale.Colore/Core/IKeypad.cs
+++ b/Corale.Colore/Core/IKeypad.cs
@@ -37,7 +37,7 @@ namespace Corale.Colore.Core
///
/// Interface for keypad functions.
///
- public partial interface IKeypad : IDevice
+ public interface IKeypad : IDevice
{
///
/// Gets or sets a color at the specified position in the keypad's
diff --git a/Corale.Colore/Core/IMouse.Obsoletes.cs b/Corale.Colore/Core/IMouse.Obsoletes.cs
deleted file mode 100644
index aa8f9a50..00000000
--- a/Corale.Colore/Core/IMouse.Obsoletes.cs
+++ /dev/null
@@ -1,110 +0,0 @@
-// ---------------------------------------------------------------------------------------
-//
-// Copyright © 2015 by Adam Hellberg and Brandon Scott.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy of
-// this software and associated documentation files (the "Software"), to deal in
-// the Software without restriction, including without limitation the rights to
-// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-// of the Software, and to permit persons to whom the Software is furnished to do
-// so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-// Disclaimer: Corale and/or Colore is in no way affiliated with Razer and/or any
-// of its employees and/or licensors. Corale, Adam Hellberg, and/or Brandon Scott
-// do not take responsibility for any harm caused, direct or indirect, to any
-// Razer peripherals via the use of Colore.
-//
-// "Razer" is a trademark of Razer USA Ltd.
-//
-// ---------------------------------------------------------------------------------------
-
-namespace Corale.Colore.Core
-{
- using System;
-
- using Corale.Colore.Annotations;
- using Corale.Colore.Razer.Mouse;
- using Corale.Colore.Razer.Mouse.Effects;
-
- ///
- /// Interface for mouse functionality.
- ///
- public partial interface IMouse
- {
- ///
- /// Sets the color of a specific LED on the mouse.
- ///
- /// Which LED to modify.
- /// Color to set.
- [Obsolete("Set is deprecated, please use SetLed(Led, Color).", false)]
- [PublicAPI]
- void Set(Led led, Color color);
-
- ///
- /// Sets an effect without any parameters.
- /// Currently, this only works for the effect.
- ///
- /// Effect options.
- [Obsolete("Set is deprecated, please use SetEffect(Effect).", false)]
- [PublicAPI]
- void Set(Effect effect);
-
- ///
- /// Sets a breathing effect on the mouse.
- ///
- /// An instance of the effect.
- [Obsolete("Set is deprecated, please use SetBreathing(Breathing).", false)]
- [PublicAPI]
- void Set(Breathing effect);
-
- ///
- /// Sets a static color on the mouse.
- ///
- /// An instance of the effect.
- [Obsolete("Set is deprecated, please use SetStatic(Static).", false)]
- [PublicAPI]
- void Set(Static effect);
-
- ///
- /// Starts a blinking effect on the specified LED.
- ///
- /// An instance of the effect.
- [Obsolete("Set is deprecated, please use SetBlinking(Blinking).", false)]
- [PublicAPI]
- void Set(Blinking effect);
-
- ///
- /// Sets a reactive effect on the mouse.
- ///
- /// Effect options struct.
- [Obsolete("Set is deprecated, please use SetReactive(Reactive).", false)]
- [PublicAPI]
- void Set(Reactive effect);
-
- ///
- /// Sets a spectrum cycling effect on the mouse.
- ///
- /// Effect options struct.
- [Obsolete("Set is deprecated, please use SetSpectrumCycling(SpectrumCycling).", false)]
- [PublicAPI]
- void Set(SpectrumCycling effect);
-
- ///
- /// Sets a wave effect on the mouse.
- ///
- /// Effect options struct.
- [Obsolete("Set is deprecated, please use SetWave(Wave).", false)]
- [PublicAPI]
- void Set(Wave effect);
- }
-}
diff --git a/Corale.Colore/Core/IMouse.cs b/Corale.Colore/Core/IMouse.cs
index ecc0781c..de4091c0 100644
--- a/Corale.Colore/Core/IMouse.cs
+++ b/Corale.Colore/Core/IMouse.cs
@@ -37,15 +37,51 @@ namespace Corale.Colore.Core
///
/// Interface for mouse functionality.
///
- public partial interface IMouse : IDevice
+ public interface IMouse : IDevice
{
+ ///
+ /// Gets or sets the for a specific LED index on the mouse.
+ ///
+ /// The index to query, between 0 and (exclusive).
+ /// The at the specified index.
+ [PublicAPI]
+ Color this[int index] { get; set; }
+
+ ///
+ /// Gets or sets the for a specific on the mouse.
+ ///
+ /// The to query.
+ /// The currently set for the specified .
+ [PublicAPI]
+ Color this[Led led] { get; set; }
+
+ ///
+ /// Gets or sets the for a specific position
+ /// on the mouse's virtual grid.
+ ///
+ /// The row to query, between 0 and (exclusive).
+ /// The column to query, between 0 and (exclusive).
+ /// The at the specified position.
+ [PublicAPI]
+ Color this[int row, int column] { get; set; }
+
+ ///
+ /// Gets or sets the for a specified
+ /// on the mouse's virtual grid.
+ ///
+ /// The to query.
+ /// The currently set for the specified .
+ [PublicAPI]
+ Color this[GridLed led] { get; set; }
+
///
/// Sets the color of a specific LED on the mouse.
///
/// Which LED to modify.
/// Color to set.
+ /// If true, the mouse will first be cleared before setting the LED.
[PublicAPI]
- void SetLed(Led led, Color color);
+ void SetLed(Led led, Color color, bool clear = false);
///
/// Sets an effect without any parameters.
@@ -169,5 +205,12 @@ public partial interface IMouse : IDevice
/// An instance of the struct.
[PublicAPI]
void SetCustom(Custom effect);
+
+ ///
+ /// Sets a custom grid effect on the mouse.
+ ///
+ /// An instance of the struct.
+ [PublicAPI]
+ void SetGrid(CustomGrid effect);
}
}
diff --git a/Corale.Colore/Core/IMousepad.cs b/Corale.Colore/Core/IMousepad.cs
index 233876da..af4c80b8 100644
--- a/Corale.Colore/Core/IMousepad.cs
+++ b/Corale.Colore/Core/IMousepad.cs
@@ -36,8 +36,16 @@ namespace Corale.Colore.Core
///
/// Interface for mouse pad functionality.
///
- public partial interface IMousepad : IDevice
+ public interface IMousepad : IDevice
{
+ ///
+ /// Gets or sets a specific LED on the mouse pad.
+ ///
+ /// The index to access.
+ /// The current at the .
+ [PublicAPI]
+ Color this[int index] { get; set; }
+
///
/// Sets a breathing effect on the mouse pad.
///
diff --git a/Corale.Colore/Core/Keyboard.Obsoletes.cs b/Corale.Colore/Core/Keyboard.Obsoletes.cs
deleted file mode 100644
index 7cd29401..00000000
--- a/Corale.Colore/Core/Keyboard.Obsoletes.cs
+++ /dev/null
@@ -1,214 +0,0 @@
-// ---------------------------------------------------------------------------------------
-//
-// Copyright © 2015 by Adam Hellberg and Brandon Scott.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy of
-// this software and associated documentation files (the "Software"), to deal in
-// the Software without restriction, including without limitation the rights to
-// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-// of the Software, and to permit persons to whom the Software is furnished to do
-// so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-// Disclaimer: Corale and/or Colore is in no way affiliated with Razer and/or any
-// of its employees and/or licensors. Corale, Adam Hellberg, and/or Brandon Scott
-// do not take responsibility for any harm caused, direct or indirect, to any
-// Razer peripherals via the use of Colore.
-//
-// "Razer" is a trademark of Razer USA Ltd.
-//
-// ---------------------------------------------------------------------------------------
-
-namespace Corale.Colore.Core
-{
- using System;
- using System.Collections.Generic;
-
- using Corale.Colore.Razer.Keyboard;
- using Corale.Colore.Razer.Keyboard.Effects;
-
- ///
- /// Class for interacting with a Chroma keyboard.
- ///
- public sealed partial class Keyboard
- {
- ///
- /// Sets a breathing effect on the keyboard.
- ///
- /// Effect options.
- [Obsolete("Set is deprecated, please use SetBreathing(Breathing).", false)]
- public void Set(Breathing effect)
- {
- SetBreathing(effect);
- }
-
- ///
- /// Sets a breathing effect on the keyboard, fading between the
- /// two specified colors.
- ///
- /// Color to start from.
- /// Color to reach, before going back to .
- [Obsolete("Set is deprecated, please use SetBreathing(Color, Color).", false)]
- public void Set(Color first, Color second)
- {
- SetBreathing(new Breathing(first, second));
- }
-
- ///
- /// Sets a reactive effect on the keyboard with the specified
- /// color and duration.
- ///
- /// Color to emit on key press.
- /// How long to illuminate the key after being pressed.
- [Obsolete("Set is deprecated, please use SetReactive(Color, Duration).", false)]
- public void Set(Color color, Duration duration)
- {
- SetReactive(color, duration);
- }
-
- ///
- /// Sets a custom grid effect on the keyboard using
- /// a two dimensional array of color values.
- ///
- /// The grid of colors to use.
- ///
- /// The passed in arrays cannot have more than rows and
- /// not more than columns in any row.
- ///
- /// This will overwrite the internal
- /// struct in the class.
- ///
- [Obsolete("Set is deprecated, please use SetGrid(Color[][]).", false)]
- public void Set(Color[][] colors)
- {
- SetGrid(colors);
- }
-
- ///
- /// Sets a custom grid effect on the keyboard.
- ///
- /// Effect options.
- ///
- /// This will overwrite the current internal
- /// struct in the class.
- ///
- [Obsolete("Set is deprecated, please use SetCustom(Custom).", false)]
- public void Set(Custom effect)
- {
- SetCustom(effect);
- }
-
- ///
- /// Sets a wave effect on the keyboard in the specified direction.
- ///
- /// Direction of the wave.
- [Obsolete("Set is deprecated, please use SetWave(Direction).", false)]
- public void Set(Direction direction)
- {
- SetWave(direction);
- }
-
- ///
- /// Sets an effect without any parameters.
- /// Currently, this only works for the and effects.
- ///
- /// Effect options.
- [Obsolete("Set is deprecated, please use SetEffect(Effect).", false)]
- public void Set(Effect effect)
- {
- SetEffect(effect);
- }
-
- ///
- /// Sets the color on a specific row and column on the keyboard grid.
- ///
- /// Row to set, between 0 and (exclusive upper-bound).
- /// Column to set, between 0 and (exclusive upper-bound).
- /// Color to set.
- /// Whether or not to clear the existing colors before setting this one.
- /// Thrown if the row or column parameters are outside the valid ranges.
- [Obsolete("Set is deprecated, please use SetPosition(Size, Size, Color, bool).", false)]
- public void Set(Size row, Size column, Color color, bool clear = false)
- {
- SetPosition(row, column, color, clear);
- }
-
- ///
- /// Sets the color of a specific key on the keyboard.
- ///
- /// Key to modify.
- /// Color to set.
- /// If true, the keyboard will first be cleared before setting the key.
- [Obsolete("Set is deprecated, please use SetKey(Key, Color, bool).", false)]
- public void Set(Key key, Color color, bool clear = false)
- {
- SetKey(key, color, clear);
- }
-
- ///
- /// Sets the specified color on a set of keys.
- ///
- /// The to apply.
- /// First key to change.
- /// Additional keys that should also have the color applied.
- [Obsolete("Set is deprecated, please use SetKeys(Color, Key, Key[][]).", false)]
- public void Set(Color color, Key key, params Key[] keys)
- {
- SetKeys(color, key, keys);
- }
-
- ///
- /// Sets a color on a collection of keys.
- ///
- /// The keys which should have their color changed.
- /// The to apply.
- ///
- /// If true, the keyboard keys will be cleared before
- /// applying the new colors.
- ///
- [Obsolete("Set is deprecated, please use SetKeys(INumerable, Color, bool).", false)]
- public void Set(IEnumerable keys, Color color, bool clear = false)
- {
- SetKeys(keys, color, clear);
- }
-
- ///
- /// Sets a reactive effect on the keyboard.
- ///
- /// Effect options.
- [Obsolete("Set is deprecated, please use SetReactive(Reactive).", false)]
- public void Set(Reactive effect)
- {
- SetReactive(effect);
- }
-
- ///
- /// Sets a static color on the keyboard.
- ///
- /// Effect options.
- [Obsolete("Set is deprecated, please use SetStatic(Static).", false)]
- public void Set(Static effect)
- {
- SetStatic(effect);
- }
-
- ///
- /// Sets a wave effect on the keyboard.
- ///
- /// Effect options.
- [Obsolete("Set is deprecated, please use SetWave(Wave).", false)]
- public void Set(Wave effect)
- {
- SetWave(effect);
- }
- }
-}
diff --git a/Corale.Colore/Core/Keyboard.cs b/Corale.Colore/Core/Keyboard.cs
index 7a998b42..17d2906e 100644
--- a/Corale.Colore/Core/Keyboard.cs
+++ b/Corale.Colore/Core/Keyboard.cs
@@ -32,6 +32,7 @@ namespace Corale.Colore.Core
{
using System;
using System.Collections.Generic;
+ using System.Linq;
using Corale.Colore.Annotations;
using Corale.Colore.Razer.Keyboard;
@@ -43,13 +44,18 @@ namespace Corale.Colore.Core
/// Class for interacting with a Chroma keyboard.
///
[PublicAPI]
- public sealed partial class Keyboard : Device, IKeyboard
+ public sealed class Keyboard : Device, IKeyboard
{
///
/// Logger instance for this class.
///
private static readonly ILog Log = LogManager.GetLogger(typeof(Keyboard));
+ ///
+ /// Lock object for thread-safe init.
+ ///
+ private static readonly object InitLock = new object();
+
///
/// Holds the application-wide instance of the class.
///
@@ -67,7 +73,7 @@ private Keyboard()
{
Log.Info("Keyboard initializing...");
- Chroma.Initialize();
+ Chroma.InitInstance();
CurrentEffectId = Guid.Empty;
@@ -89,7 +95,10 @@ public static IKeyboard Instance
{
get
{
- return _instance ?? (_instance = new Keyboard());
+ lock (InitLock)
+ {
+ return _instance ?? (_instance = new Keyboard());
+ }
}
}
@@ -131,6 +140,41 @@ public Color this[Key key]
}
}
+ ///
+ /// Returns whether the specified key is safe to use.
+ ///
+ /// The to test.
+ /// true if the is safe, otherwise false.
+ ///
+ /// A "safe" key means one that will always be visible if lit up,
+ /// regardless of the physical layout of the keyboard.
+ ///
+ [PublicAPI]
+ public static bool IsKeySafe(Key key)
+ {
+ var attr =
+ typeof(Key).GetMember(key.ToString())[0].GetCustomAttributes(typeof(UnsafeKeyAttribute), false)
+ .FirstOrDefault();
+
+ return attr == null;
+ }
+
+ ///
+ /// Returns whether the specified position is safe to use.
+ ///
+ /// Row to query.
+ /// Column to query.
+ /// true if the position is safe, otherwise false.
+ ///
+ /// A "safe" positions means one that will always be visible of lit up,
+ /// regardless of the physical layout of the keyboard.
+ ///
+ [PublicAPI]
+ public static bool IsPositionSafe(Size row, Size column)
+ {
+ return !PositionData.UnsafePositions.Contains(((int)row << 8) | (int)column);
+ }
+
///
/// Returns whether a certain key has had a custom color set.
///
@@ -322,4 +366,4 @@ public void SetWave(Wave effect)
SetGuid(NativeWrapper.CreateKeyboardEffect(effect));
}
}
-}
\ No newline at end of file
+}
diff --git a/Corale.Colore/Core/Keypad.Obsoletes.cs b/Corale.Colore/Core/Keypad.Obsoletes.cs
deleted file mode 100644
index 4cb41aa7..00000000
--- a/Corale.Colore/Core/Keypad.Obsoletes.cs
+++ /dev/null
@@ -1,102 +0,0 @@
-// ---------------------------------------------------------------------------------------
-//
-// Copyright © 2015 by Adam Hellberg and Brandon Scott.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy of
-// this software and associated documentation files (the "Software"), to deal in
-// the Software without restriction, including without limitation the rights to
-// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-// of the Software, and to permit persons to whom the Software is furnished to do
-// so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-// Disclaimer: Corale and/or Colore is in no way affiliated with Razer and/or any
-// of its employees and/or licensors. Corale, Adam Hellberg, and/or Brandon Scott
-// do not take responsibility for any harm caused, direct or indirect, to any
-// Razer peripherals via the use of Colore.
-//
-// "Razer" is a trademark of Razer USA Ltd.
-//
-// ---------------------------------------------------------------------------------------
-
-namespace Corale.Colore.Core
-{
- using System;
- using Corale.Colore.Razer.Keypad.Effects;
-
- ///
- /// Class for interacting with a Chroma keypad.
- ///
- public sealed partial class Keypad
- {
- ///
- /// Sets an effect without any parameters.
- /// Currently, this only works for the effect.
- ///
- /// Effect options.
- [Obsolete("Set is deprecated, please use SetEffect(Effect).", false)]
- public void Set(Effect effect)
- {
- SetEffect(effect);
- }
-
- ///
- /// Sets a effect on the keypad.
- ///
- /// An instance of the struct.
- [Obsolete("Set is deprecated, please use SetBreathing(Breathing).", false)]
- public void Set(Breathing effect)
- {
- SetBreathing(effect);
- }
-
- ///
- /// Sets a effect on the keypad.
- ///
- /// An instance of the struct.
- [Obsolete("Set is deprecated, please use SetCustom(Custom).", false)]
- public void Set(Custom effect)
- {
- SetCustom(effect);
- }
-
- ///
- /// Sets a effect on the keypad.
- ///
- /// An instance of the struct.
- [Obsolete("Set is deprecated, please use SetReactive(Reactive).", false)]
- public void Set(Reactive effect)
- {
- SetReactive(effect);
- }
-
- ///
- /// Sets a effect on the keypad.
- ///
- /// An instance of the struct.
- [Obsolete("Set is deprecated, please use SetStatic(Static).", false)]
- public void Set(Static effect)
- {
- SetStatic(effect);
- }
-
- ///
- /// Sets a effect on the keypad.
- ///
- /// An instance of the struct.
- [Obsolete("Set is deprecated, please use SetWave(Wave).", false)]
- public void Set(Wave effect)
- {
- SetWave(effect);
- }
- }
-}
diff --git a/Corale.Colore/Core/Keypad.cs b/Corale.Colore/Core/Keypad.cs
index f6925e25..4c2b5cc7 100644
--- a/Corale.Colore/Core/Keypad.cs
+++ b/Corale.Colore/Core/Keypad.cs
@@ -38,13 +38,18 @@ namespace Corale.Colore.Core
///
/// Class for interacting with a Chroma keypad.
///
- public sealed partial class Keypad : Device, IKeypad
+ public sealed class Keypad : Device, IKeypad
{
///
/// Logger instance for this class.
///
private static readonly ILog Log = LogManager.GetLogger(typeof(Keypad));
+ ///
+ /// Lock object for thread-safe init.
+ ///
+ private static readonly object InitLock = new object();
+
///
/// Singleton instance of this class.
///
@@ -62,7 +67,7 @@ public sealed partial class Keypad : Device, IKeypad
private Keypad()
{
Log.Debug("Keypad is initializing");
- Chroma.Initialize();
+ Chroma.InitInstance();
_custom = Custom.Create();
}
@@ -74,7 +79,10 @@ public static IKeypad Instance
{
get
{
- return _instance ?? (_instance = new Keypad());
+ lock (InitLock)
+ {
+ return _instance ?? (_instance = new Keypad());
+ }
}
}
diff --git a/Corale.Colore/Core/Mouse.Obsoletes.cs b/Corale.Colore/Core/Mouse.Obsoletes.cs
deleted file mode 100644
index 4a64889f..00000000
--- a/Corale.Colore/Core/Mouse.Obsoletes.cs
+++ /dev/null
@@ -1,125 +0,0 @@
-// ---------------------------------------------------------------------------------------
-//
-// Copyright © 2015 by Adam Hellberg and Brandon Scott.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy of
-// this software and associated documentation files (the "Software"), to deal in
-// the Software without restriction, including without limitation the rights to
-// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-// of the Software, and to permit persons to whom the Software is furnished to do
-// so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-// Disclaimer: Corale and/or Colore is in no way affiliated with Razer and/or any
-// of its employees and/or licensors. Corale, Adam Hellberg, and/or Brandon Scott
-// do not take responsibility for any harm caused, direct or indirect, to any
-// Razer peripherals via the use of Colore.
-//
-// "Razer" is a trademark of Razer USA Ltd.
-//
-// ---------------------------------------------------------------------------------------
-
-namespace Corale.Colore.Core
-{
- using System;
-
- using Corale.Colore.Razer.Mouse;
- using Corale.Colore.Razer.Mouse.Effects;
-
- ///
- /// Class for interacting with a Chroma mouse.
- ///
- public sealed partial class Mouse
- {
- ///
- /// Sets the color of a specific LED on the mouse.
- ///
- /// Which LED to modify.
- /// Color to set.
- [Obsolete("Set is deprecated, please use SetLed(Led, Color).", false)]
- public void Set(Led led, Color color)
- {
- SetLed(led, color);
- }
-
- ///
- /// Sets an effect without any parameters.
- /// Currently, this only works for the effect.
- ///
- /// Effect options.
- [Obsolete("Set is deprecated, please use SetEffect(Effect).", false)]
- public void Set(Effect effect)
- {
- SetEffect(effect);
- }
-
- ///
- /// Sets a breathing effect on the mouse.
- ///
- /// An instance of the effect.
- [Obsolete("Set is deprecated, please use SetBreathing(Breathing).", false)]
- public void Set(Breathing effect)
- {
- SetBreathing(effect);
- }
-
- ///
- /// Sets a static color on the mouse.
- ///
- /// An instance of the effect.
- [Obsolete("Set is deprecated, please use SetStatic(Static).", false)]
- public void Set(Static effect)
- {
- SetStatic(effect);
- }
-
- ///
- /// Starts a blinking effect on the specified LED.
- ///
- /// An instance of the effect.
- [Obsolete("Set is deprecated, please use SetBlinking(Blinking).", false)]
- public void Set(Blinking effect)
- {
- SetBlinking(effect);
- }
-
- ///
- /// Sets a reactive effect on the mouse.
- ///
- /// Effect options struct.
- [Obsolete("Set is deprecated, please use SetReactive(Reactive).", false)]
- public void Set(Reactive effect)
- {
- SetReactive(effect);
- }
-
- ///
- /// Sets a spectrum cycling effect on the mouse.
- ///
- /// Effect options struct.
- [Obsolete("Set is deprecated, please use SetSpectrumCycling(SpectrumCycling).", false)]
- public void Set(SpectrumCycling effect)
- {
- SetSpectrumCycling(effect);
- }
-
- ///
- /// Sets a wave effect on the mouse.
- ///
- /// Effect options struct.
- [Obsolete("Set is deprecated, please use SetWave(Wave).", false)]
- public void Set(Wave effect)
- {
- SetWave(effect);
- }
- }
-}
diff --git a/Corale.Colore/Core/Mouse.cs b/Corale.Colore/Core/Mouse.cs
index 78d414d1..e3b3df11 100644
--- a/Corale.Colore/Core/Mouse.cs
+++ b/Corale.Colore/Core/Mouse.cs
@@ -40,13 +40,18 @@ namespace Corale.Colore.Core
/// Class for interacting with a Chroma mouse.
///
[PublicAPI]
- public sealed partial class Mouse : Device, IMouse
+ public sealed class Mouse : Device, IMouse
{
///
/// Logger instance for this class.
///
private static readonly ILog Log = LogManager.GetLogger(typeof(Mouse));
+ ///
+ /// Lock object for thread-safe init.
+ ///
+ private static readonly object InitLock = new object();
+
///
/// Holds the application-wide instance of the interface.
///
@@ -57,14 +62,20 @@ public sealed partial class Mouse : Device, IMouse
///
private Custom _custom;
+ ///
+ /// Internal instance of a struct.
+ ///
+ private CustomGrid _customGrid;
+
///
/// Prevents a default instance of the class from being created.
///
private Mouse()
{
Log.Info("Mouse is initializing");
- Chroma.Initialize();
+ Chroma.InitInstance();
_custom = Custom.Create();
+ _customGrid = CustomGrid.Create();
}
///
@@ -75,7 +86,89 @@ public static IMouse Instance
{
get
{
- return _instance ?? (_instance = new Mouse());
+ lock (InitLock)
+ {
+ return _instance ?? (_instance = new Mouse());
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the for a specific LED index on the mouse.
+ ///
+ /// The index to query, between 0 and (exclusive).
+ /// The at the specified index.
+ public Color this[int index]
+ {
+ get
+ {
+ return _custom[index];
+ }
+
+ set
+ {
+ _custom[index] = value;
+ SetCustom(_custom);
+ }
+ }
+
+ ///
+ /// Gets or sets the for a specific on the mouse.
+ ///
+ /// The to query.
+ /// The currently set for the specified .
+ public Color this[Led led]
+ {
+ get
+ {
+ return _custom[led];
+ }
+
+ set
+ {
+ _custom[led] = value;
+ SetCustom(_custom);
+ }
+ }
+
+ ///
+ /// Gets or sets the for a specific position
+ /// on the mouse's virtual grid.
+ ///
+ /// The row to query, between 0 and (exclusive).
+ /// The column to query, between 0 and (exclusive).
+ /// The at the specified position.
+ public Color this[int row, int column]
+ {
+ get
+ {
+ return _customGrid[row, column];
+ }
+
+ set
+ {
+ _customGrid[row, column] = value;
+ SetGrid(_customGrid);
+ }
+ }
+
+ ///
+ /// Gets or sets the for a specified
+ /// on the mouse's virtual grid.
+ ///
+ /// The to query.
+ /// The currently set for the specified .
+ public Color this[GridLed led]
+ {
+ get
+ {
+ return _customGrid[led];
+ }
+
+ set
+ {
+ _customGrid[led] = value;
+ SetGrid(_customGrid);
}
}
@@ -84,8 +177,18 @@ public static IMouse Instance
///
/// Which LED to modify.
/// Color to set.
- public void SetLed(Led led, Color color)
+ /// If true, the mouse will first be cleared before setting the LED.
+ public void SetLed(Led led, Color color, bool clear = false)
{
+ if (clear)
+ {
+ _custom.Clear();
+
+ // Clear the grid effect as well, this way the mouse
+ // will behave slightly more predictable for the caller.
+ _customGrid.Clear();
+ }
+
_custom[led] = color;
SetCustom(_custom);
}
@@ -242,8 +345,11 @@ public void SetWave(Direction direction)
/// Color to set.
public override void SetAll(Color color)
{
+ // We update both the Custom and CustomGrid effect to keep them both
+ // as synced as possible.
_custom.Set(color);
- SetCustom(_custom);
+ _customGrid.Set(color);
+ SetGrid(_customGrid);
}
///
@@ -254,5 +360,14 @@ public void SetCustom(Custom effect)
{
SetGuid(NativeWrapper.CreateMouseEffect(effect));
}
+
+ ///
+ /// Sets a custom grid effect on the mouse.
+ ///
+ /// An instance of the struct.
+ public void SetGrid(CustomGrid effect)
+ {
+ SetGuid(NativeWrapper.CreateMouseEffect(effect));
+ }
}
}
diff --git a/Corale.Colore/Core/Mousepad.Obsoletes.cs b/Corale.Colore/Core/Mousepad.Obsoletes.cs
deleted file mode 100644
index 13b15121..00000000
--- a/Corale.Colore/Core/Mousepad.Obsoletes.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-// ---------------------------------------------------------------------------------------
-//
-// Copyright © 2015 by Adam Hellberg and Brandon Scott.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy of
-// this software and associated documentation files (the "Software"), to deal in
-// the Software without restriction, including without limitation the rights to
-// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-// of the Software, and to permit persons to whom the Software is furnished to do
-// so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-// Disclaimer: Corale and/or Colore is in no way affiliated with Razer and/or any
-// of its employees and/or licensors. Corale, Adam Hellberg, and/or Brandon Scott
-// do not take responsibility for any harm caused, direct or indirect, to any
-// Razer peripherals via the use of Colore.
-//
-// "Razer" is a trademark of Razer USA Ltd.
-//
-// ---------------------------------------------------------------------------------------
-
-namespace Corale.Colore.Core
-{
- using System;
-
- using Corale.Colore.Razer.Mousepad.Effects;
-
- ///
- /// Class for interacting with a Chroma mouse pad.
- ///
- public sealed partial class Mousepad
- {
- ///
- /// Sets an effect without any parameters.
- /// Currently, this only works for the effect.
- ///
- /// Effect options.
- [Obsolete("Set is deprecated, please use SetEffect(Effect).", false)]
- public void Set(Effect effect)
- {
- SetGuid(NativeWrapper.CreateMousepadEffect(effect));
- }
-
- ///
- /// Sets a breathing effect on the mouse pad.
- ///
- /// An instance of the struct.
- [Obsolete("Set is deprecated, please use SetBreathing(Breathing).", false)]
- public void Set(Breathing effect)
- {
- SetGuid(NativeWrapper.CreateMousepadEffect(effect));
- }
-
- ///
- /// Sets a static color effect on the mouse pad.
- ///
- /// An instance of the struct.
- [Obsolete("Set is deprecated, please use SetStatic(Static).", false)]
- public void Set(Static effect)
- {
- SetGuid(NativeWrapper.CreateMousepadEffect(effect));
- }
-
- ///
- /// Sets a wave effect on the mouse pad.
- ///
- /// An instance of the struct.
- [Obsolete("Set is deprecated, please use SetWave(Wave).", false)]
- public void Set(Wave effect)
- {
- SetGuid(NativeWrapper.CreateMousepadEffect(effect));
- }
-
- ///
- /// Sets a custom effect on the mouse pad.
- ///
- /// An instance of the struct.
- [Obsolete("Set is deprecated, please use SetCustom(Custom).", false)]
- public void Set(Custom effect)
- {
- SetGuid(NativeWrapper.CreateMousepadEffect(effect));
- }
- }
-}
diff --git a/Corale.Colore/Core/Mousepad.cs b/Corale.Colore/Core/Mousepad.cs
index 9d0039ef..2ec1ba6e 100644
--- a/Corale.Colore/Core/Mousepad.cs
+++ b/Corale.Colore/Core/Mousepad.cs
@@ -37,13 +37,18 @@ namespace Corale.Colore.Core
///
/// Class for interacting with a Chroma mouse pad.
///
- public sealed partial class Mousepad : Device, IMousepad
+ public sealed class Mousepad : Device, IMousepad
{
///
/// Logger instance for this class.
///
private static readonly ILog Log = LogManager.GetLogger(typeof(Mousepad));
+ ///
+ /// Lock object for thread-safe init.
+ ///
+ private static readonly object InitLock = new object();
+
///
/// Singleton instance.
///
@@ -60,7 +65,7 @@ public sealed partial class Mousepad : Device, IMousepad
private Mousepad()
{
Log.Debug("Mousepad is initializing.");
- Chroma.Initialize();
+ Chroma.InitInstance();
_custom = Custom.Create();
}
@@ -71,7 +76,29 @@ public static IMousepad Instance
{
get
{
- return _instance ?? (_instance = new Mousepad());
+ lock (InitLock)
+ {
+ return _instance ?? (_instance = new Mousepad());
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets a specific LED on the mouse pad.
+ ///
+ /// The index to access.
+ /// The current at the .
+ public Color this[int index]
+ {
+ get
+ {
+ return _custom[index];
+ }
+
+ set
+ {
+ _custom[index] = value;
+ SetCustom(_custom);
}
}
diff --git a/Corale.Colore/Core/NativeWrapper.cs b/Corale.Colore/Core/NativeWrapper.cs
index 19da5f30..bb4d5155 100644
--- a/Corale.Colore/Core/NativeWrapper.cs
+++ b/Corale.Colore/Core/NativeWrapper.cs
@@ -35,7 +35,7 @@ namespace Corale.Colore.Core
using Corale.Colore.Razer;
using Corale.Colore.Razer.Keyboard.Effects;
-
+
using log4net;
///
@@ -47,7 +47,7 @@ internal static class NativeWrapper
/// Logger instance for this class.
///
private static readonly ILog Log = LogManager.GetLogger(typeof(NativeWrapper));
-
+
///
/// Creates an effect for a device.
///
@@ -182,6 +182,16 @@ internal static Guid CreateMouseEffect(Razer.Mouse.Effects.Custom effect)
return CreateMouseEffect(Razer.Mouse.Effects.Effect.Custom, effect);
}
+ ///
+ /// Creates a custom grid effect for the mouse.
+ ///
+ /// Effect options.
+ /// A for the created effect.
+ internal static Guid CreateMouseEffect(Razer.Mouse.Effects.CustomGrid effect)
+ {
+ return CreateMouseEffect(Razer.Mouse.Effects.Effect.CustomGrid, effect);
+ }
+
///
/// Creates a breathing effect for the mouse.
///
@@ -470,7 +480,7 @@ internal static void SetEffect(Guid guid)
var result = NativeMethods.SetEffect(guid);
if (result)
return;
-
+
if (result == Result.RzResourceDisabled || result == Result.RzAccessDenied)
Log.WarnFormat("Ambiguous {0} error thrown from call to native function SetEffect.", result);
else
diff --git a/Corale.Colore/EnvironmentHelper.cs b/Corale.Colore/EnvironmentHelper.cs
index 519a1a97..bec68bd4 100644
--- a/Corale.Colore/EnvironmentHelper.cs
+++ b/Corale.Colore/EnvironmentHelper.cs
@@ -38,13 +38,13 @@ namespace Corale.Colore
/// Helper to get the architecture of the OS.
/// Taken from here: http://stackoverflow.com/a/28866330/1104531
///
- public static class EnvironmentHelper
+ internal static class EnvironmentHelper
{
///
/// Determines whether the current system is 64-bit.
///
/// true if the system is 64-bit.
- public static bool Is64BitOperatingSystem()
+ internal static bool Is64BitOperatingSystem()
{
// Check if this process is natively an x64 process. If it is, it will only run on x64 environments, thus, the environment must be x64.
if (IntPtr.Size == 8)
diff --git a/Corale.Colore/Razer/DeviceType.cs b/Corale.Colore/Razer/DeviceType.cs
index 868ec9e5..0daacabd 100644
--- a/Corale.Colore/Razer/DeviceType.cs
+++ b/Corale.Colore/Razer/DeviceType.cs
@@ -30,6 +30,8 @@
namespace Corale.Colore.Razer
{
+ using Corale.Colore.Annotations;
+
///
/// Device types supported by the Chroma SDK.
///
@@ -38,26 +40,31 @@ public enum DeviceType
///
/// A keyboard device.
///
+ [PublicAPI]
Keyboard = 1,
///
/// A mouse device.
///
+ [PublicAPI]
Mouse,
///
/// A headset device.
///
+ [PublicAPI]
Headset,
///
/// A mouse pad.
///
+ [PublicAPI]
Mousepad,
///
/// A keypad.
///
+ [PublicAPI]
Keypad
}
}
diff --git a/Corale.Colore/Razer/Devices.cs b/Corale.Colore/Razer/Devices.cs
index 201553c0..87401f15 100644
--- a/Corale.Colore/Razer/Devices.cs
+++ b/Corale.Colore/Razer/Devices.cs
@@ -43,7 +43,7 @@ public static class Devices
/// Blackwidow Chroma edition.
///
[PublicAPI]
- public static readonly Guid BlackwidowChroma = new Guid(
+ public static readonly Guid Blackwidow = new Guid(
0x2ea1bb63,
0xca28,
0x428d,
@@ -60,7 +60,7 @@ public static class Devices
/// Deathadder Chroma edition.
///
[PublicAPI]
- public static readonly Guid DeathadderChroma = new Guid(
+ public static readonly Guid Deathadder = new Guid(
0xaec50d91,
0xb1f1,
0x452f,
@@ -77,7 +77,7 @@ public static class Devices
/// Kraken 7.1 Chroma edition.
///
[PublicAPI]
- public static readonly Guid Kraken71Chroma = new Guid(
+ public static readonly Guid Kraken71 = new Guid(
0xcd1e09a5,
0xd5e6,
0x4a6c,
@@ -94,7 +94,7 @@ public static class Devices
/// Firefly Chroma edition.
///
[PublicAPI]
- public static readonly Guid FireflyChroma = new Guid(
+ public static readonly Guid Firefly = new Guid(
0x80f95a94,
0x73d2,
0x48ca,
@@ -111,69 +111,103 @@ public static class Devices
/// Orbweaver Chroma edition.
///
[PublicAPI]
- public static readonly Guid OrbweaverChroma = new Guid(
- 0x9d24b0ab,
- 0x162,
+ public static readonly Guid Orbweaver = new Guid(
+ 0x9d24b0ab,
+ 0x162,
0x466c,
- 0x96,
+ 0x96,
0x40,
- 0x7a,
+ 0x7a,
0x92,
- 0x4a,
+ 0x4a,
0xa4,
- 0xd9,
+ 0xd9,
0xfd);
///
/// Tartarus Chroma edition.
///
[PublicAPI]
- public static readonly Guid TartarusChroma = new Guid(
+ public static readonly Guid Tartarus = new Guid(
0xf0545c,
- 0xe180,
+ 0xe180,
0x4ad1,
0x8e,
- 0x8a,
- 0x41,
- 0x90,
- 0x61,
+ 0x8a,
+ 0x41,
+ 0x90,
+ 0x61,
0xce,
- 0x50,
+ 0x50,
0x5e);
///
/// Mamba TE Chroma edition.
///
[PublicAPI]
- public static readonly Guid MambaTeChroma = new Guid(
+ public static readonly Guid MambaTe = new Guid(
0x7ec00450,
- 0xe0ee,
+ 0xe0ee,
0x4289,
- 0x89,
- 0xd5,
- 0xd,
- 0x87,
- 0x9c,
- 0x19,
- 0x6,
+ 0x89,
+ 0xd5,
+ 0xd,
+ 0x87,
+ 0x9c,
+ 0x19,
+ 0x6,
0x1a);
-
+
///
/// BlackWidow TE Chroma edition.
///
[PublicAPI]
- public static readonly Guid BlackwidowTeChroma = new Guid(
- 0xed1c1b82,
- 0xbfbe,
- 0x418f,
- 0xb4,
- 0x9d,
- 0xd0,
- 0x3f,
- 0x5,
- 0xb1,
- 0x49,
- 0xdf);
+ public static readonly Guid BlackwidowTe = new Guid(
+ 0xed1c1b82,
+ 0xbfbe,
+ 0x418f,
+ 0xb4,
+ 0x9d,
+ 0xd0,
+ 0x3f,
+ 0x5,
+ 0xb1,
+ 0x49,
+ 0xdf);
+
+ ///
+ /// Deathstalker Chroma edition.
+ ///
+ [PublicAPI]
+ public static readonly Guid Deathstalker = new Guid(
+ 0x18c5ad9b,
+ 0x4326,
+ 0x4828,
+ 0x92,
+ 0xc4,
+ 0x26,
+ 0x69,
+ 0xa6,
+ 0x6d,
+ 0x22,
+ 0x83);
+
+ ///
+ /// Diamondback Chroma edition.
+ ///
+ [PublicAPI]
+ public static readonly Guid Diamondback = new Guid(
+ 0xff8a5929,
+ 0x4512,
+ 0x4257,
+ 0x8d,
+ 0x59,
+ 0xc6,
+ 0x47,
+ 0xbf,
+ 0x99,
+ 0x35,
+ 0xd0);
///
/// Returns whether a specified is a valid device identifier.
@@ -183,9 +217,8 @@ public static class Devices
[PublicAPI]
public static bool IsValidId(Guid id)
{
- return id == BlackwidowChroma || id == DeathadderChroma || id == OrbweaverChroma || id == TartarusChroma ||
- id == MambaTeChroma || id == BlackwidowTeChroma || id == Kraken71Chroma
- || id == FireflyChroma;
+ return id == Blackwidow || id == Deathadder || id == Orbweaver || id == Tartarus || id == MambaTe
+ || id == BlackwidowTe || id == Kraken71 || id == Firefly || id == Deathstalker || id == Diamondback;
}
}
}
diff --git a/Corale.Colore/Razer/Headset/Effects/Breathing.cs b/Corale.Colore/Razer/Headset/Effects/Breathing.cs
index 8d1bffaf..bb268a91 100644
--- a/Corale.Colore/Razer/Headset/Effects/Breathing.cs
+++ b/Corale.Colore/Razer/Headset/Effects/Breathing.cs
@@ -42,7 +42,7 @@ public struct Breathing
/// The color of the effect.
///
[PublicAPI]
- public Color Color;
+ public readonly Color Color;
///
/// Initializes a new instance of the struct.
diff --git a/Corale.Colore/Razer/Headset/Effects/Static.cs b/Corale.Colore/Razer/Headset/Effects/Static.cs
index 7f5af076..a570b1a6 100644
--- a/Corale.Colore/Razer/Headset/Effects/Static.cs
+++ b/Corale.Colore/Razer/Headset/Effects/Static.cs
@@ -45,7 +45,7 @@ public struct Static
/// The of the effect.
///
[PublicAPI]
- public Color Color;
+ public readonly Color Color;
///
/// Initializes a new instance of the struct.
diff --git a/Corale.Colore/Razer/Keyboard/Effects/Breathing.cs b/Corale.Colore/Razer/Keyboard/Effects/Breathing.cs
index 47fe7b7b..681113a7 100644
--- a/Corale.Colore/Razer/Keyboard/Effects/Breathing.cs
+++ b/Corale.Colore/Razer/Keyboard/Effects/Breathing.cs
@@ -45,13 +45,13 @@ public struct Breathing
/// First color.
///
[PublicAPI]
- public Color First;
+ public readonly Color First;
///
/// Second color.
///
[PublicAPI]
- public Color Second;
+ public readonly Color Second;
///
/// Initializes a new instance of the struct.
diff --git a/Corale.Colore/Razer/Keyboard/Effects/Reactive.cs b/Corale.Colore/Razer/Keyboard/Effects/Reactive.cs
index a6529148..39b2d41e 100644
--- a/Corale.Colore/Razer/Keyboard/Effects/Reactive.cs
+++ b/Corale.Colore/Razer/Keyboard/Effects/Reactive.cs
@@ -45,13 +45,13 @@ public struct Reactive
/// The duration of the effect.
///
[PublicAPI]
- public Duration Duration;
+ public readonly Duration Duration;
///
/// Color of the effect.
///
[PublicAPI]
- public Color Color;
+ public readonly Color Color;
///
/// Initializes a new instance of the struct.
diff --git a/Corale.Colore/Razer/Keyboard/Effects/Static.cs b/Corale.Colore/Razer/Keyboard/Effects/Static.cs
index 83e8f3d9..6fa19837 100644
--- a/Corale.Colore/Razer/Keyboard/Effects/Static.cs
+++ b/Corale.Colore/Razer/Keyboard/Effects/Static.cs
@@ -45,7 +45,7 @@ public struct Static
/// Color of the effect.
///
[PublicAPI]
- public Color Color;
+ public readonly Color Color;
///
/// Initializes a new instance of the struct.
diff --git a/Corale.Colore/Razer/Keyboard/Effects/Wave.cs b/Corale.Colore/Razer/Keyboard/Effects/Wave.cs
index d6882c0a..dd2aaa9d 100644
--- a/Corale.Colore/Razer/Keyboard/Effects/Wave.cs
+++ b/Corale.Colore/Razer/Keyboard/Effects/Wave.cs
@@ -44,7 +44,7 @@ public struct Wave
/// Direction of wave effect.
///
[PublicAPI]
- public Direction Direction;
+ public readonly Direction Direction;
///
/// Initializes a new instance of the struct.
diff --git a/Corale.Colore/Razer/Keyboard/Key.cs b/Corale.Colore/Razer/Keyboard/Key.cs
index 6037c717..d594df06 100644
--- a/Corale.Colore/Razer/Keyboard/Key.cs
+++ b/Corale.Colore/Razer/Keyboard/Key.cs
@@ -119,61 +119,61 @@ public enum Key
/// 1 key.
///
[PublicAPI]
- One = 0x0102,
+ D1 = 0x0102,
///
/// 2 key.
///
[PublicAPI]
- Two = 0x0103,
+ D2 = 0x0103,
///
/// 3 key.
///
[PublicAPI]
- Three = 0x0104,
+ D3 = 0x0104,
///
/// 4 key.
///
[PublicAPI]
- Four = 0x0105,
+ D4 = 0x0105,
///
/// 5 key.
///
[PublicAPI]
- Five = 0x0106,
+ D5 = 0x0106,
///
/// 6 key.
///
[PublicAPI]
- Six = 0x0107,
+ D6 = 0x0107,
///
/// 7 key.
///
[PublicAPI]
- Seven = 0x0108,
+ D7 = 0x0108,
///
/// 8 key.
///
[PublicAPI]
- Eight = 0x0109,
+ D8 = 0x0109,
///
/// 9 key.
///
[PublicAPI]
- Nine = 0x010A,
+ D9 = 0x010A,
///
/// 0 key.
///
[PublicAPI]
- Zero = 0x010B,
+ D0 = 0x010B,
///
/// A key.
@@ -533,6 +533,7 @@ public enum Key
/// Enter key.
///
[PublicAPI]
+ [UnsafeKey]
Enter = 0x030E,
///
@@ -587,12 +588,14 @@ public enum Key
/// Left shift key.
///
[PublicAPI]
+ [UnsafeKey]
LeftShift = 0x0401,
///
/// Right shift key.
///
[PublicAPI]
+ [UnsafeKey]
RightShift = 0x040E,
///
@@ -629,115 +632,123 @@ public enum Key
/// Tilde (~) key. 半角/全角.
///
[PublicAPI]
- Oem1 = 0x0101,
+ OemTilde = 0x0101,
///
/// Minus (-) key.
///
[PublicAPI]
- Oem2 = 0x010C,
+ OemMinus = 0x010C,
///
/// Equal sign (=) key.
///
[PublicAPI]
- Oem3 = 0x010D,
+ OemEquals = 0x010D,
///
/// Left square bracket ([) key.
///
[PublicAPI]
- Oem4 = 0x020C,
+ OemLeftBracket = 0x020C,
///
/// Right square bracket (]) key.
///
[PublicAPI]
- Oem5 = 0x020D,
+ OemRightBracket = 0x020D,
///
/// Forwards slash (/) key.
///
[PublicAPI]
- Oem6 = 0x020E,
+ [UnsafeKey]
+ OemSlash = 0x020E,
///
/// Semi-colon (;) key.
///
[PublicAPI]
- Oem7 = 0x030B,
+ OemSemicolon = 0x030B,
///
/// Apostrophe (') key.
///
[PublicAPI]
- Oem8 = 0x030C,
+ OemApostrophe = 0x030C,
///
/// Comma (,) key.
///
[PublicAPI]
- Oem9 = 0x040A,
+ OemComma = 0x040A,
///
/// Period/full stop (.) key.
///
[PublicAPI]
- Oem10 = 0x040B,
+ OemPeriod = 0x040B,
///
/// Backslash (\) key.
///
[PublicAPI]
- Oem11 = 0x040C,
+ OemBackslash = 0x040C,
///
/// Pound sign (#) key.
///
[PublicAPI]
- Eur1 = 0x030D,
+ [UnsafeKey]
+ EurPound = 0x030D,
///
/// Backslash (\) key.
///
[PublicAPI]
- Eur2 = 0x0402,
+ [UnsafeKey]
+ EurBackslash = 0x0402,
///
/// Yen (¥) key.
///
[PublicAPI]
- Jpn1 = 0x0015,
+ [UnsafeKey]
+ JpnYen = 0x0015,
///
/// Forward slash (/) key.
///
[PublicAPI]
- Jpn2 = 0x040D,
+ [UnsafeKey]
+ JpnSlash = 0x040D,
///
/// 無変換 key.
///
[PublicAPI]
+ [UnsafeKey]
Jpn3 = 0x0504,
///
/// 変換 key.
///
[PublicAPI]
+ [UnsafeKey]
Jpn4 = 0x0509,
///
/// ひらがな/カタカナ key.
///
[PublicAPI]
+ [UnsafeKey]
Jpn5 = 0x050A,
///
/// Pipe character (|) key.
///
[PublicAPI]
- Kor1 = 0x0015,
+ KorPipe = 0x0015,
///
/// Unknown Korean key.
diff --git a/Corale.Colore/Core/Device.Obsoletes.cs b/Corale.Colore/Razer/Keyboard/PositionData.cs
similarity index 66%
rename from Corale.Colore/Core/Device.Obsoletes.cs
rename to Corale.Colore/Razer/Keyboard/PositionData.cs
index 7c2779ea..e89fd66f 100644
--- a/Corale.Colore/Core/Device.Obsoletes.cs
+++ b/Corale.Colore/Razer/Keyboard/PositionData.cs
@@ -1,5 +1,5 @@
// ---------------------------------------------------------------------------------------
-//
+//
// Copyright © 2015 by Adam Hellberg and Brandon Scott.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
@@ -28,33 +28,47 @@
//
// ---------------------------------------------------------------------------------------
-namespace Corale.Colore.Core
+namespace Corale.Colore.Razer.Keyboard
{
- using System;
+ using System.Collections.Generic;
///
- /// Base class for devices, containing code common between all devices.
+ /// Contains methods to determine if a grid positions is safe.
///
- public abstract partial class Device
+ public static class PositionData
{
///
- /// Sets the color of all components on this device.
+ /// Set of positions that are unsafe to use.
///
- /// Color to set.
- [Obsolete("Set is deprecated, please use SetAll(Effect).", false)]
- public void Set(Color color)
+ internal static readonly HashSet UnsafePositions = new HashSet
{
- SetAll(color);
- }
-
- ///
- /// Updates the device to use the effect pointed to by the specified GUID.
- ///
- /// GUID to set.
- [Obsolete("Set is deprecated, please use SetGuid(Guid).", false)]
- public void Set(Guid guid)
- {
- SetGuid(guid);
- }
+ 0x0000,
+ 0x0002,
+ 0x0012,
+ 0x0013,
+ 0x0014,
+ 0x0015,
+ 0x020E,
+ 0x030D,
+ 0x030E,
+ 0x030F,
+ 0x0310,
+ 0x0311,
+ 0x0315,
+ 0x0401,
+ 0x0402,
+ 0x040D,
+ 0x040E,
+ 0x040F,
+ 0x0411,
+ 0x0504,
+ 0x0505,
+ 0x0506,
+ 0x0508,
+ 0x0509,
+ 0x050A,
+ 0x0512,
+ 0x0515
+ };
}
}
diff --git a/Corale.Colore/Core/IGenericDevice.Obsoletes.cs b/Corale.Colore/Razer/Keyboard/UnsafeKeyAttribute.cs
similarity index 70%
rename from Corale.Colore/Core/IGenericDevice.Obsoletes.cs
rename to Corale.Colore/Razer/Keyboard/UnsafeKeyAttribute.cs
index 838a1e83..b474dc38 100644
--- a/Corale.Colore/Core/IGenericDevice.Obsoletes.cs
+++ b/Corale.Colore/Razer/Keyboard/UnsafeKeyAttribute.cs
@@ -1,5 +1,5 @@
// ---------------------------------------------------------------------------------------
-//
+//
// Copyright © 2015 by Adam Hellberg and Brandon Scott.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
@@ -28,31 +28,15 @@
//
// ---------------------------------------------------------------------------------------
-namespace Corale.Colore.Core
+namespace Corale.Colore.Razer.Keyboard
{
using System;
- using Corale.Colore.Annotations;
- using Corale.Colore.Razer;
-
///
- /// Interface for generic devices.
+ /// Marks a value as unsafe.
///
- public partial interface IGenericDevice
+ [AttributeUsage(AttributeTargets.Field)]
+ public class UnsafeKeyAttribute : Attribute
{
- ///
- /// Sets a parameter-less effect on this device.
- ///
- /// Effect to set.
- [PublicAPI]
- void Set(Effect effect);
-
- ///
- /// Sets an effect on this device, taking a parameter.
- ///
- /// Effect to set.
- /// Effect-specific parameter to use.
- [PublicAPI]
- void Set(Effect effect, IntPtr param);
}
}
diff --git a/Corale.Colore/Razer/Keypad/Effects/Breathing.cs b/Corale.Colore/Razer/Keypad/Effects/Breathing.cs
index 9e0d2495..1ed2185a 100644
--- a/Corale.Colore/Razer/Keypad/Effects/Breathing.cs
+++ b/Corale.Colore/Razer/Keypad/Effects/Breathing.cs
@@ -42,19 +42,19 @@ public struct Breathing
/// The type of breathing.
///
[UsedImplicitly]
- public BreathingType Type;
+ public readonly BreathingType Type;
///
/// Initial color.
///
[UsedImplicitly]
- public Color First;
+ public readonly Color First;
///
/// Second color.
///
[UsedImplicitly]
- public Color Second;
+ public readonly Color Second;
///
/// Initializes a new instance of the struct.
diff --git a/Corale.Colore/Razer/Keypad/Effects/Reactive.cs b/Corale.Colore/Razer/Keypad/Effects/Reactive.cs
index 1b59422b..5f72dd5d 100644
--- a/Corale.Colore/Razer/Keypad/Effects/Reactive.cs
+++ b/Corale.Colore/Razer/Keypad/Effects/Reactive.cs
@@ -32,6 +32,7 @@ namespace Corale.Colore.Razer.Keypad.Effects
{
using System.Runtime.InteropServices;
+ using Corale.Colore.Annotations;
using Corale.Colore.Core;
///
@@ -43,12 +44,14 @@ public struct Reactive
///
/// Duration of the effect.
///
- public Duration Duration;
+ [UsedImplicitly]
+ public readonly Duration Duration;
///
/// Reaction color.
///
- public Color Color;
+ [UsedImplicitly]
+ public readonly Color Color;
///
/// Initializes a new instance of the struct.
diff --git a/Corale.Colore/Razer/Keypad/Effects/Static.cs b/Corale.Colore/Razer/Keypad/Effects/Static.cs
index 8e8c1b2e..9f965e14 100644
--- a/Corale.Colore/Razer/Keypad/Effects/Static.cs
+++ b/Corale.Colore/Razer/Keypad/Effects/Static.cs
@@ -32,6 +32,7 @@ namespace Corale.Colore.Razer.Keypad.Effects
{
using System.Runtime.InteropServices;
+ using Corale.Colore.Annotations;
using Corale.Colore.Core;
///
@@ -43,7 +44,8 @@ public struct Static
///
/// Color to use.
///
- public Color Color;
+ [UsedImplicitly]
+ public readonly Color Color;
///
/// Initializes a new instance of the struct.
diff --git a/Corale.Colore/Razer/Keypad/Effects/Wave.cs b/Corale.Colore/Razer/Keypad/Effects/Wave.cs
index 1f0b8691..63b16e9f 100644
--- a/Corale.Colore/Razer/Keypad/Effects/Wave.cs
+++ b/Corale.Colore/Razer/Keypad/Effects/Wave.cs
@@ -32,6 +32,8 @@ namespace Corale.Colore.Razer.Keypad.Effects
{
using System.Runtime.InteropServices;
+ using Corale.Colore.Annotations;
+
///
/// Wave effect.
///
@@ -41,6 +43,7 @@ public struct Wave
///
/// Direction of the wave effect.
///
+ [UsedImplicitly]
public readonly Direction Direction;
///
diff --git a/Corale.Colore/Razer/Mouse/Constants.cs b/Corale.Colore/Razer/Mouse/Constants.cs
index 29f2543c..cc468177 100644
--- a/Corale.Colore/Razer/Mouse/Constants.cs
+++ b/Corale.Colore/Razer/Mouse/Constants.cs
@@ -39,5 +39,15 @@ public static class Constants
/// Maximum number of custom LEDs.
///
public const int MaxLeds = 30;
+
+ ///
+ /// Maximum number of LED rows.
+ ///
+ public const int MaxRows = 9;
+
+ ///
+ /// Maximum number of LED columns.
+ ///
+ public const int MaxColumns = 7;
}
}
diff --git a/Corale.Colore/Razer/Mouse/Effects/Blinking.cs b/Corale.Colore/Razer/Mouse/Effects/Blinking.cs
index 60104fbd..03b38941 100644
--- a/Corale.Colore/Razer/Mouse/Effects/Blinking.cs
+++ b/Corale.Colore/Razer/Mouse/Effects/Blinking.cs
@@ -30,25 +30,28 @@
namespace Corale.Colore.Razer.Mouse.Effects
{
+ using System.Runtime.InteropServices;
+
using Corale.Colore.Annotations;
using Corale.Colore.Core;
///
/// Mouse effect that causes a specified LED to blink.
///
+ [StructLayout(LayoutKind.Sequential)]
public struct Blinking
{
///
/// The LED on which to apply the effect.
///
[UsedImplicitly]
- public Led Led;
+ public readonly Led Led;
///
/// Color of the blinking effect.
///
[UsedImplicitly]
- public Color Color;
+ public readonly Color Color;
///
/// Initializes a new instance of the struct.
diff --git a/Corale.Colore/Razer/Mouse/Effects/Breathing.cs b/Corale.Colore/Razer/Mouse/Effects/Breathing.cs
index 5803a25f..d45c4753 100644
--- a/Corale.Colore/Razer/Mouse/Effects/Breathing.cs
+++ b/Corale.Colore/Razer/Mouse/Effects/Breathing.cs
@@ -45,25 +45,25 @@ public struct Breathing
/// The LED on which to apply the effect.
///
[UsedImplicitly]
- public Led Led;
+ public readonly Led Led;
///
/// The type of breathing effect.
///
[UsedImplicitly]
- public BreathingType Type;
+ public readonly BreathingType Type;
///
/// Initial effect color.
///
[UsedImplicitly]
- public Color First;
+ public readonly Color First;
///
/// Second color to breathe to.
///
[UsedImplicitly]
- public Color Second;
+ public readonly Color Second;
///
/// Initializes a new instance of the struct.
diff --git a/Corale.Colore/Razer/Mouse/Effects/Custom.cs b/Corale.Colore/Razer/Mouse/Effects/Custom.cs
index df6672b8..074b99d9 100644
--- a/Corale.Colore/Razer/Mouse/Effects/Custom.cs
+++ b/Corale.Colore/Razer/Mouse/Effects/Custom.cs
@@ -28,8 +28,6 @@
//
// ---------------------------------------------------------------------------------------
-#pragma warning disable 618
-
namespace Corale.Colore.Razer.Mouse.Effects
{
using System;
@@ -49,8 +47,7 @@ public struct Custom : IEquatable, IEquatable>
/// Colors for each LED.
///
[MarshalAs(UnmanagedType.ByValArray, SizeConst = Constants.MaxLeds)]
- [Obsolete("Accessing the Color array directly has been deprecated, please use the indexer instead.")]
- public readonly Color[] Colors;
+ private readonly Color[] _colors;
///
/// Initializes a new instance of the struct with
@@ -59,10 +56,10 @@ public struct Custom : IEquatable, IEquatable>
/// The color to set each LED to initially.
public Custom(Color color)
{
- Colors = new Color[Constants.MaxLeds];
+ _colors = new Color[Constants.MaxLeds];
- for (var i = 0; i < Colors.Length; i++)
- Colors[i] = color;
+ for (var i = 0; i < _colors.Length; i++)
+ _colors[i] = color;
}
///
@@ -80,10 +77,10 @@ public Custom(IList colors)
"colors");
}
- Colors = new Color[Constants.MaxLeds];
+ _colors = new Color[Constants.MaxLeds];
for (var index = 0; index < Constants.MaxLeds; index++)
- Colors[index] = colors[index];
+ _colors[index] = colors[index];
}
///
@@ -104,7 +101,7 @@ public Color this[int led]
"Attempted to access an LED that was out of range.");
}
- return Colors[led];
+ return _colors[led];
}
set
@@ -117,7 +114,7 @@ public Color this[int led]
"Attempted to access an LED that was out of range.");
}
- Colors[led] = value;
+ _colors[led] = value;
}
}
@@ -188,7 +185,7 @@ public static Custom Create()
public void Set(Color color)
{
for (var index = 0; index < Constants.MaxLeds; index++)
- Colors[index] = color;
+ _colors[index] = color;
}
///
@@ -209,7 +206,7 @@ public void Clear()
/// 2
public override int GetHashCode()
{
- return Colors != null ? Colors.GetHashCode() : 0;
+ return _colors != null ? _colors.GetHashCode() : 0;
}
///
diff --git a/Corale.Colore/Razer/Mouse/Effects/CustomGrid.cs b/Corale.Colore/Razer/Mouse/Effects/CustomGrid.cs
new file mode 100644
index 00000000..aa7a190e
--- /dev/null
+++ b/Corale.Colore/Razer/Mouse/Effects/CustomGrid.cs
@@ -0,0 +1,392 @@
+// ---------------------------------------------------------------------------------------
+//
+// Copyright © 2015 by Adam Hellberg and Brandon Scott.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy of
+// this software and associated documentation files (the "Software"), to deal in
+// the Software without restriction, including without limitation the rights to
+// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+// of the Software, and to permit persons to whom the Software is furnished to do
+// so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Disclaimer: Corale and/or Colore is in no way affiliated with Razer and/or any
+// of its employees and/or licensors. Corale, Adam Hellberg, and/or Brandon Scott
+// do not take responsibility for any harm caused, direct or indirect, to any
+// Razer peripherals via the use of Colore.
+//
+// "Razer" is a trademark of Razer USA Ltd.
+//
+// ---------------------------------------------------------------------------------------
+
+namespace Corale.Colore.Razer.Mouse.Effects
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Runtime.InteropServices;
+
+ using Corale.Colore.Annotations;
+ using Corale.Colore.Core;
+
+ ///
+ /// Custom grid effect for mouse LEDs.
+ ///
+ public struct CustomGrid : IEquatable, IEquatable
+ {
+ ///
+ /// Color definitions for each led on the mouse.
+ ///
+ ///
+ /// The array is 2-dimensional, with the first dimension
+ /// specifying the row for the led, and the second the column.
+ ///
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = Constants.MaxRows)]
+ private readonly Row[] _rows;
+
+ ///
+ /// Initializes a new instance of the struct.
+ ///
+ /// The colors to use.
+ /// Thrown if the colors array supplied is of an incorrect size.
+ public CustomGrid(Color[][] colors)
+ {
+ var rows = colors.GetLength(0);
+
+ if (rows != Constants.MaxRows)
+ {
+ throw new ArgumentException(
+ "Colors array has incorrect number of rows, should be " + Constants.MaxRows + ", received " + rows,
+ "colors");
+ }
+
+ _rows = new Row[Constants.MaxRows];
+
+ for (Size row = 0; row < Constants.MaxRows; row++)
+ {
+ var inRow = colors[row];
+ _rows[row] = new Row(inRow);
+ }
+ }
+
+ ///
+ /// Initializes a new instance of the struct
+ /// with every position set to a specific color.
+ ///
+ /// The to set each position to.
+ public CustomGrid(Color color)
+ {
+ _rows = new Row[Constants.MaxRows];
+
+ for (var row = 0; row < Constants.MaxRows; row++)
+ _rows[row] = new Row(color);
+ }
+
+ ///
+ /// Gets or sets cells in the .
+ ///
+ /// Row to access, zero indexed.
+ /// Column to access, zero indexed.
+ /// The at the specified position.
+ [PublicAPI]
+ public Color this[int row, int column]
+ {
+ get
+ {
+ if (row < 0 || row >= Constants.MaxRows)
+ throw new ArgumentOutOfRangeException("row", row, "Attempted to access a row that does not exist.");
+
+ return _rows[row][column];
+ }
+
+ set
+ {
+ if (row < 0 || row >= Constants.MaxRows)
+ throw new ArgumentOutOfRangeException("row", row, "Attempted to access a row that does not exist.");
+
+ _rows[row][column] = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the color for a specific LED in the .
+ ///
+ /// The to access.
+ /// The for the specified led.
+ [PublicAPI]
+ public Color this[GridLed led]
+ {
+ get
+ {
+ var row = (int)led >> 8;
+ var column = (int)led & 0xFF;
+ return this[row, column];
+ }
+
+ set
+ {
+ var row = (int)led >> 8;
+ var column = (int)led & 0xFF;
+ this[row, column] = value;
+ }
+ }
+
+ ///
+ /// Compares an instance of with
+ /// another object for equality.
+ ///
+ /// The left operand, an instance of .
+ /// The right operand, any type of object.
+ /// true if the two objects are equal, otherwise false.
+ public static bool operator ==(CustomGrid left, object right)
+ {
+ return left.Equals(right);
+ }
+
+ ///
+ /// Compares an instance of with
+ /// another object for inequality.
+ ///
+ /// The left operand, an instance of .
+ /// The right operand, any type of object.
+ /// true if the two objects are not equal, otherwise false.
+ public static bool operator !=(CustomGrid left, object right)
+ {
+ return !left.Equals(right);
+ }
+
+ ///
+ /// Creates a new empty struct.
+ ///
+ /// An instance of
+ /// filled with the color black.
+ [PublicAPI]
+ public static CustomGrid Create()
+ {
+ return new CustomGrid(Color.Black);
+ }
+
+ ///
+ /// Returns the hash code for this instance.
+ ///
+ ///
+ /// A 32-bit signed integer that is the hash code for this instance.
+ ///
+ public override int GetHashCode()
+ {
+ return _rows == null ? 0 : _rows.GetHashCode();
+ }
+
+ ///
+ /// Clears the colors from the grid, setting them to .
+ ///
+ [PublicAPI]
+ public void Clear()
+ {
+ Set(Color.Black);
+ }
+
+ ///
+ /// Indicates whether this instance and a specified object are equal.
+ ///
+ ///
+ /// true if and this instance are of compatible types
+ /// and represent the same value; otherwise, false.
+ ///
+ /// Another object to compare to.
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(obj, null))
+ return false;
+
+ if (obj is CustomGrid)
+ return Equals((CustomGrid)obj);
+
+ var arr = obj as Color[][];
+ return arr != null && Equals(arr);
+ }
+
+ ///
+ /// Indicates whether the current object is equal to another object of the same type.
+ ///
+ /// A to compare with this object.
+ ///
+ /// true if the current object is equal to the parameter;
+ /// otherwise, false.
+ ///
+ public bool Equals(CustomGrid other)
+ {
+ for (var row = 0; row < Constants.MaxRows; row++)
+ {
+ for (var col = 0; col < Constants.MaxColumns; col++)
+ {
+ if (this[row, col] != other[row, col])
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ ///
+ /// Indicates whether the current object is equal to an instance of
+ /// a 2-dimensional array of .
+ ///
+ ///
+ /// A 2-dimensional array of to compare with this object.
+ ///
+ ///
+ /// true if the object has the same
+ /// number of rows and columns, and contain matching colors; otherwise, false.
+ ///
+ public bool Equals(Color[][] other)
+ {
+ if (other == null || other.GetLength(0) != Constants.MaxRows)
+ return false;
+
+ for (var row = 0; row < Constants.MaxRows; row++)
+ {
+ if (other[row].Length != Constants.MaxColumns)
+ return false;
+
+ for (var col = 0; col < Constants.MaxColumns; col++)
+ {
+ if (this[row, col] != other[row][col])
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ ///
+ /// Sets the entire grid to a specific .
+ ///
+ /// The to apply.
+ [PublicAPI]
+ public void Set(Color color)
+ {
+ for (var row = 0; row < Constants.MaxRows; row++)
+ _rows[row].Set(color);
+ }
+
+ ///
+ /// Container struct holding color definitions for a single row in the custom grid.
+ ///
+ [StructLayout(LayoutKind.Sequential)]
+ private struct Row
+ {
+ ///
+ /// Color definitions for the columns of this row.
+ ///
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = Constants.MaxColumns)]
+ private readonly uint[] _columns;
+
+ ///
+ /// Initializes a new instance of the struct.
+ ///
+ /// Colors for this row.
+ internal Row(IList colors)
+ {
+ if (colors.Count != Constants.MaxColumns)
+ {
+ throw new ArgumentException(
+ "Incorrect color count, expected " + Constants.MaxColumns + " but received " + colors.Count,
+ "colors");
+ }
+
+ _columns = new uint[Constants.MaxColumns];
+
+ for (var col = 0; col < Constants.MaxColumns; col++)
+ _columns[col] = colors[col];
+ }
+
+ ///
+ /// Initializes a new instance of the struct
+ /// setting each column to a specific color.
+ ///
+ /// The to set each column to.
+ internal Row(Color color)
+ {
+ _columns = new uint[Constants.MaxColumns];
+
+ for (var col = 0; col < Constants.MaxColumns; col++)
+ _columns[col] = color;
+ }
+
+ ///
+ /// Gets or sets a column's .
+ ///
+ /// The column index to access (zero-index).
+ /// The at the specified column index.
+ internal Color this[int column]
+ {
+ get
+ {
+ if (column < 0 || column >= Constants.MaxColumns)
+ {
+ throw new ArgumentOutOfRangeException(
+ "column",
+ column,
+ "Attempted to access a column that does not exist.");
+ }
+
+ return _columns[column];
+ }
+
+ set
+ {
+ if (column < 0 || column >= Constants.MaxColumns)
+ {
+ throw new ArgumentOutOfRangeException(
+ "column",
+ column,
+ "Attempted to access a column that does not exist.");
+ }
+
+ _columns[column] = value;
+ }
+ }
+
+ ///
+ /// Converts an instance of the struct to an array of unsigned integers.
+ ///
+ /// The object to convert.
+ /// An array of unsigned integeres representing the colors of the row.
+ public static implicit operator uint[](Row row)
+ {
+ return row._columns;
+ }
+
+ ///
+ /// Returns the hash code for this instance.
+ ///
+ ///
+ /// A 32-bit signed integer that is the hash code for this instance.
+ ///
+ /// 2
+ public override int GetHashCode()
+ {
+ return _columns == null ? 0 : _columns.GetHashCode();
+ }
+
+ ///
+ /// Sets the entire row to a specific .
+ ///
+ /// The to apply.
+ public void Set(Color color)
+ {
+ for (var column = 0; column < Constants.MaxColumns; column++)
+ _columns[column] = color;
+ }
+ }
+ }
+}
diff --git a/Corale.Colore/Razer/Mouse/Effects/Effect.cs b/Corale.Colore/Razer/Mouse/Effects/Effect.cs
index 2e172e2d..e880f1eb 100644
--- a/Corale.Colore/Razer/Mouse/Effects/Effect.cs
+++ b/Corale.Colore/Razer/Mouse/Effects/Effect.cs
@@ -61,6 +61,12 @@ public enum Effect
[PublicAPI]
Custom,
+ ///
+ /// Custom grid effect.
+ ///
+ [PublicAPI]
+ CustomGrid,
+
///
/// Reactive effect.
///
diff --git a/Corale.Colore/Razer/Mouse/Effects/None.cs b/Corale.Colore/Razer/Mouse/Effects/None.cs
index 7b6943be..8b9df75a 100644
--- a/Corale.Colore/Razer/Mouse/Effects/None.cs
+++ b/Corale.Colore/Razer/Mouse/Effects/None.cs
@@ -32,6 +32,8 @@ namespace Corale.Colore.Razer.Mouse.Effects
{
using System.Runtime.InteropServices;
+ using Corale.Colore.Annotations;
+
///
/// No effect (resets the affected LEDs).
///
@@ -41,7 +43,8 @@ public struct None
///
/// The LED that should have its effects reset.
///
- public Led Led;
+ [UsedImplicitly]
+ public readonly Led Led;
///
/// Initializes a new instance of the struct.
diff --git a/Corale.Colore/Razer/Mouse/Effects/Reactive.cs b/Corale.Colore/Razer/Mouse/Effects/Reactive.cs
index 55da2841..10141122 100644
--- a/Corale.Colore/Razer/Mouse/Effects/Reactive.cs
+++ b/Corale.Colore/Razer/Mouse/Effects/Reactive.cs
@@ -45,19 +45,19 @@ public struct Reactive
/// The LED on which to apply the effect.
///
[UsedImplicitly]
- public Led Led;
+ public readonly Led Led;
///
/// Duration of the reaction.
///
[UsedImplicitly]
- public Duration Duration;
+ public readonly Duration Duration;
///
/// Reaction color.
///
[UsedImplicitly]
- public Color Color;
+ public readonly Color Color;
///
/// Initializes a new instance of the struct.
diff --git a/Corale.Colore/Razer/Mouse/Effects/SpectrumCycling.cs b/Corale.Colore/Razer/Mouse/Effects/SpectrumCycling.cs
index 2b42531a..62045744 100644
--- a/Corale.Colore/Razer/Mouse/Effects/SpectrumCycling.cs
+++ b/Corale.Colore/Razer/Mouse/Effects/SpectrumCycling.cs
@@ -41,7 +41,7 @@ public struct SpectrumCycling
/// The LED on which to apply the effect.
///
[UsedImplicitly]
- public Led Led;
+ public readonly Led Led;
///
/// Initializes a new instance of the struct.
diff --git a/Corale.Colore/Razer/Mouse/Effects/Static.cs b/Corale.Colore/Razer/Mouse/Effects/Static.cs
index 538413d9..d54fedc3 100644
--- a/Corale.Colore/Razer/Mouse/Effects/Static.cs
+++ b/Corale.Colore/Razer/Mouse/Effects/Static.cs
@@ -45,13 +45,13 @@ public struct Static
/// The LED on which to apply the color.
///
[UsedImplicitly]
- public Led Led;
+ public readonly Led Led;
///
/// The color to apply.
///
[UsedImplicitly]
- public Color Color;
+ public readonly Color Color;
///
/// Initializes a new instance of the struct.
diff --git a/Corale.Colore/Razer/Mouse/Effects/Wave.cs b/Corale.Colore/Razer/Mouse/Effects/Wave.cs
index 42360c56..77acc10b 100644
--- a/Corale.Colore/Razer/Mouse/Effects/Wave.cs
+++ b/Corale.Colore/Razer/Mouse/Effects/Wave.cs
@@ -41,7 +41,7 @@ public struct Wave
/// The direction of the wave effect.
///
[UsedImplicitly]
- public Direction Direction;
+ public readonly Direction Direction;
///
/// Initializes a new instance of the struct.
diff --git a/Corale.Colore/Razer/Mouse/GridLed.cs b/Corale.Colore/Razer/Mouse/GridLed.cs
new file mode 100644
index 00000000..dbbe2a14
--- /dev/null
+++ b/Corale.Colore/Razer/Mouse/GridLed.cs
@@ -0,0 +1,172 @@
+// ---------------------------------------------------------------------------------------
+//
+// Copyright © 2015 by Adam Hellberg and Brandon Scott.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy of
+// this software and associated documentation files (the "Software"), to deal in
+// the Software without restriction, including without limitation the rights to
+// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+// of the Software, and to permit persons to whom the Software is furnished to do
+// so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Disclaimer: Corale and/or Colore is in no way affiliated with Razer and/or any
+// of its employees and/or licensors. Corale, Adam Hellberg, and/or Brandon Scott
+// do not take responsibility for any harm caused, direct or indirect, to any
+// Razer peripherals via the use of Colore.
+//
+// "Razer" is a trademark of Razer USA Ltd.
+//
+// ---------------------------------------------------------------------------------------
+
+namespace Corale.Colore.Razer.Mouse
+{
+ using Corale.Colore.Annotations;
+
+ ///
+ /// LED definitions for the virtual grid.
+ ///
+ public enum GridLed
+ {
+ ///
+ /// The LED illuminating the scroll wheel.
+ ///
+ [PublicAPI]
+ ScrollWheel = 0x0203,
+
+ ///
+ /// The LED illuminating the logo present on the mouse.
+ ///
+ [PublicAPI]
+ Logo = 0x0703,
+
+ ///
+ /// The mouse backlight.
+ ///
+ [PublicAPI]
+ Backlight = 0x0403,
+
+ ///
+ /// First LED on left side.
+ ///
+ [PublicAPI]
+ LeftSide1 = 0x0100,
+
+ ///
+ /// Second LED on left side.
+ ///
+ [PublicAPI]
+ LeftSide2 = 0x0200,
+
+ ///
+ /// Third LED on left side.
+ ///
+ [PublicAPI]
+ LeftSide3 = 0x0300,
+
+ ///
+ /// Fourth LED on left side.
+ ///
+ [PublicAPI]
+ LeftSide4 = 0x0400,
+
+ ///
+ /// Fifth LED on left side.
+ ///
+ [PublicAPI]
+ LeftSide5 = 0x0500,
+
+ ///
+ /// Sixth LED on left side.
+ ///
+ [PublicAPI]
+ LeftSide6 = 0x0600,
+
+ ///
+ /// Seventh LED on left side.
+ ///
+ [PublicAPI]
+ LeftSide7 = 0x0700,
+
+ ///
+ /// First bottom LED.
+ ///
+ [PublicAPI]
+ Bottom1 = 0x0801,
+
+ ///
+ /// Second bottom LED.
+ ///
+ [PublicAPI]
+ Bottom2 = 0x0802,
+
+ ///
+ /// Third bottom LED.
+ ///
+ [PublicAPI]
+ Bottom3 = 0x0803,
+
+ ///
+ /// Fourth bottom LED.
+ ///
+ [PublicAPI]
+ Bottom4 = 0x0804,
+
+ ///
+ /// Fifth bottom LED.
+ ///
+ [PublicAPI]
+ Bottom5 = 0x0805,
+
+ ///
+ /// First LED on right side.
+ ///
+ [PublicAPI]
+ RightSide1 = 0x0106,
+
+ ///
+ /// Second LED on right side.
+ ///
+ [PublicAPI]
+ RightSide2 = 0x0206,
+
+ ///
+ /// Third LED on right side.
+ ///
+ [PublicAPI]
+ RightSide3 = 0x0306,
+
+ ///
+ /// Fourth LED on right side.
+ ///
+ [PublicAPI]
+ RightSide4 = 0x0406,
+
+ ///
+ /// Fifth LED on right side.
+ ///
+ [PublicAPI]
+ RightSide5 = 0x0506,
+
+ ///
+ /// Sixth LED on right side.
+ ///
+ [PublicAPI]
+ RightSide6 = 0x0606,
+
+ ///
+ /// Seventh LED on right side.
+ ///
+ [PublicAPI]
+ RightSide7 = 0x0706
+ }
+}
diff --git a/Corale.Colore/Razer/Mousepad/Effects/Custom.cs b/Corale.Colore/Razer/Mousepad/Effects/Custom.cs
index b9b15e4c..775534e0 100644
--- a/Corale.Colore/Razer/Mousepad/Effects/Custom.cs
+++ b/Corale.Colore/Razer/Mousepad/Effects/Custom.cs
@@ -28,8 +28,6 @@
//
// ---------------------------------------------------------------------------------------
-#pragma warning disable 618
-
namespace Corale.Colore.Razer.Mousepad.Effects
{
using System;
@@ -49,8 +47,7 @@ public struct Custom : IEquatable, IEquatable>
/// Colors for the LEDs.
///
[MarshalAs(UnmanagedType.ByValArray, SizeConst = Constants.MaxLeds)]
- [Obsolete("Accessing the Colors array directly has been deprecated, please use the indexer instead.")]
- public readonly Color[] Colors;
+ private readonly Color[] _colors;
///
/// Initializes a new instance of the struct with
@@ -59,10 +56,10 @@ public struct Custom : IEquatable, IEquatable>
/// The color to set every LED to initially.
public Custom(Color color)
{
- Colors = new Color[Constants.MaxLeds];
+ _colors = new Color[Constants.MaxLeds];
- for (var i = 0; i < Colors.Length; i++)
- Colors[i] = color;
+ for (var i = 0; i < _colors.Length; i++)
+ _colors[i] = color;
}
///
@@ -79,10 +76,10 @@ public Custom(IList colors)
"colors");
}
- Colors = new Color[Constants.MaxLeds];
+ _colors = new Color[Constants.MaxLeds];
- for (var i = 0; i < Colors.Length; i++)
- Colors[i] = colors[i];
+ for (var i = 0; i < _colors.Length; i++)
+ _colors[i] = colors[i];
}
///
@@ -103,7 +100,7 @@ public Color this[int led]
"Attempted to access an LED that was out of range.");
}
- return Colors[led];
+ return _colors[led];
}
set
@@ -116,7 +113,7 @@ public Color this[int led]
"Attempted to access an LED that was out of range.");
}
- Colors[led] = value;
+ _colors[led] = value;
}
}
@@ -163,7 +160,7 @@ public static Custom Create()
/// 2
public override int GetHashCode()
{
- return Colors != null ? Colors.GetHashCode() : 0;
+ return _colors != null ? _colors.GetHashCode() : 0;
}
///
@@ -174,7 +171,7 @@ public override int GetHashCode()
public void Set(Color color)
{
for (var i = 0; i < Constants.MaxLeds; i++)
- Colors[i] = color;
+ _colors[i] = color;
}
///
diff --git a/Corale.Colore/Razer/Mousepad/Effects/Static.cs b/Corale.Colore/Razer/Mousepad/Effects/Static.cs
index 9b1b5cf2..0f9c3f3e 100644
--- a/Corale.Colore/Razer/Mousepad/Effects/Static.cs
+++ b/Corale.Colore/Razer/Mousepad/Effects/Static.cs
@@ -45,7 +45,7 @@ public struct Static
/// The color to use.
///
[UsedImplicitly]
- public Color Color;
+ public readonly Color Color;
///
/// Initializes a new instance of the struct.
diff --git a/Corale.Colore/Razer/Mousepad/Effects/Wave.cs b/Corale.Colore/Razer/Mousepad/Effects/Wave.cs
index e57a98d0..50d28f82 100644
--- a/Corale.Colore/Razer/Mousepad/Effects/Wave.cs
+++ b/Corale.Colore/Razer/Mousepad/Effects/Wave.cs
@@ -32,6 +32,8 @@ namespace Corale.Colore.Razer.Mousepad.Effects
{
using System.Runtime.InteropServices;
+ using Corale.Colore.Annotations;
+
///
/// Wave effect for the mouse pad.
///
@@ -41,6 +43,7 @@ public struct Wave
///
/// Direction of the wave.
///
+ [UsedImplicitly]
public readonly Direction Direction;
///