diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..91953df
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,6 @@
+bin/
+obj/
+/packages/
+riderModule.iml
+/_ReSharper.Caches/
+.idea
\ No newline at end of file
diff --git a/Demo/Demo.csproj b/Demo/Demo.csproj
new file mode 100644
index 0000000..458fe26
--- /dev/null
+++ b/Demo/Demo.csproj
@@ -0,0 +1,12 @@
+
+
+
+ Exe
+ net5.0
+
+
+
+
+
+
+
diff --git a/Demo/Program.cs b/Demo/Program.cs
new file mode 100644
index 0000000..5f99995
--- /dev/null
+++ b/Demo/Program.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+using Illumilib;
+
+namespace Demo {
+ internal static class Program {
+
+ private static async Task Main(string[] args) {
+ await IllumilibLighting.Initialize();
+
+ Console.WriteLine("Setting all lights to blue");
+ IllumilibLighting.SetAllLighting(0, 0, 1);
+ Thread.Sleep(TimeSpan.FromSeconds(3));
+ IllumilibLighting.SetAllLighting(0, 0, 0);
+
+ Console.WriteLine("Going through the alphabet");
+ for (var i = 65; i <= 90; i++) {
+ var key = (KeyboardKeys) i;
+ IllumilibLighting.SetKeyLighting(key, 0, 1, 0);
+ Thread.Sleep(TimeSpan.FromSeconds(0.25F));
+ IllumilibLighting.SetKeyLighting(key, 0, 0, 0);
+ }
+ Thread.Sleep(TimeSpan.FromSeconds(1));
+
+ Console.WriteLine("Pulsing");
+ for (var i = 0; i < 500; i++) {
+ var value = (MathF.Sin(i / 50F * MathF.PI) + 1) / 2;
+ IllumilibLighting.SetAllLighting(value, 0, value);
+ Thread.Sleep(10);
+ }
+ IllumilibLighting.SetAllLighting(0, 0, 0);
+
+ Console.WriteLine("Setting all supported keys");
+ foreach (var key in Enum.GetValues()) {
+ IllumilibLighting.SetKeyLighting(key, 1, 0, 0);
+ Thread.Sleep(50);
+ }
+ Thread.Sleep(TimeSpan.FromSeconds(15));
+
+ Console.WriteLine("Done");
+ IllumilibLighting.Dispose();
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Illumilib.sln b/Illumilib.sln
new file mode 100644
index 0000000..62ca227
--- /dev/null
+++ b/Illumilib.sln
@@ -0,0 +1,22 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Illumilib", "Illumilib\Illumilib.csproj", "{A759A9B2-7E43-420C-B4C9-3E1BEA2DBD56}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo", "Demo\Demo.csproj", "{3FEF3BF9-D96E-42AF-A0B6-06B0D5523B6A}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {A759A9B2-7E43-420C-B4C9-3E1BEA2DBD56}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A759A9B2-7E43-420C-B4C9-3E1BEA2DBD56}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A759A9B2-7E43-420C-B4C9-3E1BEA2DBD56}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A759A9B2-7E43-420C-B4C9-3E1BEA2DBD56}.Release|Any CPU.Build.0 = Release|Any CPU
+ {3FEF3BF9-D96E-42AF-A0B6-06B0D5523B6A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {3FEF3BF9-D96E-42AF-A0B6-06B0D5523B6A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {3FEF3BF9-D96E-42AF-A0B6-06B0D5523B6A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {3FEF3BF9-D96E-42AF-A0B6-06B0D5523B6A}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+EndGlobal
diff --git a/Illumilib/Illumilib.csproj b/Illumilib/Illumilib.csproj
new file mode 100644
index 0000000..30a4e25
--- /dev/null
+++ b/Illumilib/Illumilib.csproj
@@ -0,0 +1,24 @@
+
+
+
+ netstandard2.0
+ true
+ Ellpeck
+ A simple keyboard and mouse lighting library with support for Razer and Logitech devices
+ lighting keyboard mouse lighting logitech lightsync razer chroma
+ https://github.com/Ellpeck/Illumilib
+ https://github.com/Ellpeck/Illumilib
+ MIT
+ 1.0.0
+
+
+
+
+ PreserveNewest
+
+
+
+
+
+
+
diff --git a/Illumilib/IllumilibLighting.cs b/Illumilib/IllumilibLighting.cs
new file mode 100644
index 0000000..d271a6f
--- /dev/null
+++ b/Illumilib/IllumilibLighting.cs
@@ -0,0 +1,91 @@
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using Illumilib.System;
+
+namespace Illumilib {
+ ///
+ /// The class that houses all Illumilib methods.
+ /// This class does not need to be instantiated.
+ ///
+ public static class IllumilibLighting {
+
+ private static List systems;
+
+ ///
+ /// Initializes Illumilib, starting all of the supported lighting systems.
+ /// Any lighting systems that are not supported, or for which devices are not present, will be ignored.
+ /// This function runs asynchronously.
+ ///
+ /// Thrown if Illumilib has already been initialized
+ public static async Task Initialize() {
+ if (systems != null)
+ throw new InvalidOperationException("Illumilib has already been initialized");
+ var ret = new List();
+ foreach (var system in new LightingSystem[] {new LogitechLighting(), new RazerLighting()}) {
+ if (await system.Initialize())
+ ret.Add(system);
+ }
+ systems = ret;
+ }
+
+ ///
+ /// Disposes Illumilib, disposing all of the underlying lighting systems
+ ///
+ public static void Dispose() {
+ ForEach(s => s.Dispose());
+ systems = null;
+ }
+
+ ///
+ /// Sets the lighting for all keyboards and mice to the given color
+ ///
+ /// The color's red value, between 0 and 1
+ /// The color's green value, between 0 and 1
+ /// The color's blue value, between 0 and 1
+ public static void SetAllLighting(float r, float g, float b) {
+ ForEach(s => s.SetAllLighting(r, g, b));
+ }
+
+ ///
+ /// Sets the lighting for all keyboards to the given color.
+ /// Note that, if Logitech is used, some keyboards do not support this method.
+ ///
+ /// The color's red value, between 0 and 1
+ /// The color's green value, between 0 and 1
+ /// The color's blue value, between 0 and 1
+ public static void SetKeyboardLighting(float r, float g, float b) {
+ ForEach(s => s.SetKeyboardLighting(r, g, b));
+ }
+
+ ///
+ /// Sets the lighting for all mice to the given color
+ ///
+ /// The color's red value, between 0 and 1
+ /// The color's green value, between 0 and 1
+ /// The color's blue value, between 0 and 1
+ public static void SetMouseLighting(float r, float g, float b) {
+ ForEach(s => s.SetMouseLighting(r, g, b));
+ }
+
+ ///
+ /// Sets the lighting for the specified to the given color.
+ /// Only a single key can be specified at a time.
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static void SetKeyLighting(KeyboardKeys key, float r, float g, float b) {
+ ForEach(s => s.SetKeyLighting(key, r, g, b));
+ }
+
+ private static void ForEach(Action action) {
+ if (systems == null)
+ throw new InvalidOperationException("Illumilib has not been initialized yet");
+ foreach (var system in systems)
+ action(system);
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Illumilib/KeyboardKeys.cs b/Illumilib/KeyboardKeys.cs
new file mode 100644
index 0000000..cb632f7
--- /dev/null
+++ b/Illumilib/KeyboardKeys.cs
@@ -0,0 +1,413 @@
+namespace Illumilib {
+ ///
+ /// Specifies key codes and modifiers
+ ///
+ public enum KeyboardKeys {
+
+ ///
+ /// The BACKSPACE key
+ ///
+ Back = 8,
+ ///
+ /// The TAB key
+ ///
+ Tab = 9,
+ ///
+ /// The ENTER key
+ ///
+ Enter = 13,
+ ///
+ /// The PAUSE key
+ ///
+ Pause = 19,
+ ///
+ /// The CAPS LOCK key
+ ///
+ CapsLock = 20,
+ ///
+ /// The ESC key
+ ///
+ Escape = 27,
+ ///
+ /// The SPACEBAR key
+ ///
+ Space = 32,
+ ///
+ /// The PAGE UP key
+ ///
+ PageUp = 33,
+ ///
+ /// The PAGE DOWN key
+ ///
+ PageDown = 34,
+ ///
+ /// The END key
+ ///
+ End = 35,
+ ///
+ /// The HOME key
+ ///
+ Home = 36,
+ ///
+ /// The LEFT ARROW key
+ ///
+ Left = 37,
+ ///
+ /// The UP ARROW key
+ ///
+ Up = 38,
+ ///
+ /// The RIGHT ARROW key
+ ///
+ Right = 39,
+ ///
+ /// The DOWN ARROW key
+ ///
+ Down = 40,
+ ///
+ /// The SELECT key
+ ///
+ Select = 41,
+ ///
+ /// The PRINT SCREEN key
+ ///
+ PrintScreen = 44,
+ ///
+ /// The INS key
+ ///
+ Insert = 45,
+ ///
+ /// The DEL key
+ ///
+ Delete = 46,
+ ///
+ /// The 0 key
+ ///
+ D0 = 48,
+ ///
+ /// The 1 key
+ ///
+ D1 = 49,
+ ///
+ /// The 2 key
+ ///
+ D2 = 50,
+ ///
+ /// The 3 key
+ ///
+ D3 = 51,
+ ///
+ /// The 4 key
+ ///
+ D4 = 52,
+ ///
+ /// The 5 key
+ ///
+ D5 = 53,
+ ///
+ /// The 6 key
+ ///
+ D6 = 54,
+ ///
+ /// The 7 key
+ ///
+ D7 = 55,
+ ///
+ /// The 8 key
+ ///
+ D8 = 56,
+ ///
+ /// The 9 key
+ ///
+ D9 = 57,
+ ///
+ /// The A key
+ ///
+ A = 65,
+ ///
+ /// The B key
+ ///
+ B = 66,
+ ///
+ /// The C key
+ ///
+ C = 67,
+ ///
+ /// The D key
+ ///
+ D = 68,
+ ///
+ /// The E key
+ ///
+ E = 69,
+ ///
+ /// The F key
+ ///
+ F = 70,
+ ///
+ /// The G key
+ ///
+ G = 71,
+ ///
+ /// The H key
+ ///
+ H = 72,
+ ///
+ /// The I key
+ ///
+ I = 73,
+ ///
+ /// The J key
+ ///
+ J = 74,
+ ///
+ /// The K key
+ ///
+ K = 75,
+ ///
+ /// The L key
+ ///
+ L = 76,
+ ///
+ /// The M key
+ ///
+ M = 77,
+ ///
+ /// The N key
+ ///
+ N = 78,
+ ///
+ /// The O key
+ ///
+ O = 79,
+ ///
+ /// The P key
+ ///
+ P = 80,
+ ///
+ /// The Q key
+ ///
+ Q = 81,
+ ///
+ /// The R key
+ ///
+ R = 82,
+ ///
+ /// The S key
+ ///
+ S = 83,
+ ///
+ /// The T key
+ ///
+ T = 84,
+ ///
+ /// The U key
+ ///
+ U = 85,
+ ///
+ /// The V key
+ ///
+ V = 86,
+ ///
+ /// The W key
+ ///
+ W = 87,
+ ///
+ /// The X key
+ ///
+ X = 88,
+ ///
+ /// The Y key
+ ///
+ Y = 89,
+ ///
+ /// The Z key
+ ///
+ Z = 90,
+ ///
+ /// The left Windows logo key (Microsoft Natural Keyboard)
+ ///
+ LWin = 91,
+ ///
+ /// The right Windows logo key (Microsoft Natural Keyboard)
+ ///
+ RWin = 92,
+ ///
+ /// The Application key (Microsoft Natural Keyboard)
+ ///
+ Apps = 93,
+ ///
+ /// The 0 key on the numeric keypad
+ ///
+ NumPad0 = 96,
+ ///
+ /// The 1 key on the numeric keypad
+ ///
+ NumPad1 = 97,
+ ///
+ /// The 2 key on the numeric keypad
+ ///
+ NumPad2 = 98,
+ ///
+ /// The 3 key on the numeric keypad
+ ///
+ NumPad3 = 99,
+ ///
+ /// The 4 key on the numeric keypad
+ ///
+ NumPad4 = 100,
+ ///
+ /// The 5 key on the numeric keypad
+ ///
+ NumPad5 = 101,
+ ///
+ /// The 6 key on the numeric keypad
+ ///
+ NumPad6 = 102,
+ ///
+ /// The 7 key on the numeric keypad
+ ///
+ NumPad7 = 103,
+ ///
+ /// The 8 key on the numeric keypad
+ ///
+ NumPad8 = 104,
+ ///
+ /// The 9 key on the numeric keypad
+ ///
+ NumPad9 = 105,
+ ///
+ /// The Multiply key
+ ///
+ Multiply = 106,
+ ///
+ /// The Add key
+ ///
+ Add = 107,
+ ///
+ /// The Subtract key
+ ///
+ Subtract = 109,
+ ///
+ /// The Decimal key
+ ///
+ Decimal = 110,
+ ///
+ /// The Divide key
+ ///
+ Divide = 111,
+ ///
+ /// The F1 key
+ ///
+ F1 = 112,
+ ///
+ /// The F2 key
+ ///
+ F2 = 113,
+ ///
+ /// The F3 key
+ ///
+ F3 = 114,
+ ///
+ /// The F4 key
+ ///
+ F4 = 115,
+ ///
+ /// The F5 key
+ ///
+ F5 = 116,
+ ///
+ /// The F6 key
+ ///
+ F6 = 117,
+ ///
+ /// The F7 key
+ ///
+ F7 = 118,
+ ///
+ /// The F8 key
+ ///
+ F8 = 119,
+ ///
+ /// The F9 key
+ ///
+ F9 = 120,
+ ///
+ /// The F10 key
+ ///
+ F10 = 121,
+ ///
+ /// The F11 key
+ ///
+ F11 = 122,
+ ///
+ /// The F12 key
+ ///
+ F12 = 123,
+ ///
+ /// The NUM LOCK key
+ ///
+ NumLock = 144,
+ ///
+ /// The SCROLL LOCK key
+ ///
+ Scroll = 145,
+ ///
+ /// The left SHIFT key
+ ///
+ LShiftKey = 160,
+ ///
+ /// The right SHIFT key
+ ///
+ RShiftKey = 161,
+ ///
+ /// The left CTRL key
+ ///
+ LControlKey = 162,
+ ///
+ /// The right CTRL key
+ ///
+ RControlKey = 163,
+ ///
+ /// The left ALT key
+ ///
+ LMenu = 164,
+ ///
+ /// The right ALT key
+ ///
+ RMenu = 165,
+ ///
+ /// The Oem Semicolon key
+ ///
+ OemSemicolon = 186,
+ ///
+ /// The Oem comma key
+ ///
+ OemComma = 188,
+ ///
+ /// The Oem Minus key
+ ///
+ OemMinus = 189,
+ ///
+ /// The Oem Period key
+ ///
+ OemPeriod = 190,
+ ///
+ /// The Oem tilde key
+ ///
+ OemTilde = 192,
+ ///
+ /// The Oem Open Brackets key
+ ///
+ OemOpenBrackets = 219,
+ ///
+ /// The Oem Close Brackets key
+ ///
+ OemCloseBrackets = 221,
+ ///
+ /// The Oem Backslash key
+ ///
+ OemBackslash = 226
+
+ }
+}
\ No newline at end of file
diff --git a/Illumilib/Lib/LogitechGsdk.cs b/Illumilib/Lib/LogitechGsdk.cs
new file mode 100644
index 0000000..59ee5ef
--- /dev/null
+++ b/Illumilib/Lib/LogitechGsdk.cs
@@ -0,0 +1,235 @@
+using System.Runtime.InteropServices;
+using System.Text;
+
+namespace Illumilib.Lib {
+ internal enum KeyboardNames {
+
+ Esc = 0x01,
+ F1 = 0x3b,
+ F2 = 0x3c,
+ F3 = 0x3d,
+ F4 = 0x3e,
+ F5 = 0x3f,
+ F6 = 0x40,
+ F7 = 0x41,
+ F8 = 0x42,
+ F9 = 0x43,
+ F10 = 0x44,
+ F11 = 0x57,
+ F12 = 0x58,
+ PrintScreen = 0x137,
+ ScrollLock = 0x46,
+ PauseBreak = 0x145,
+ Tilde = 0x29,
+ One = 0x02,
+ Two = 0x03,
+ Three = 0x04,
+ Four = 0x05,
+ Five = 0x06,
+ Six = 0x07,
+ Seven = 0x08,
+ Eight = 0x09,
+ Nine = 0x0A,
+ Zero = 0x0B,
+ Minus = 0x0C,
+ Equal = 0x0D,
+ Backspace = 0x0E,
+ Insert = 0x152,
+ Home = 0x147,
+ PageUp = 0x149,
+ NumLock = 0x45,
+ NumSlash = 0x135,
+ NumAsterisk = 0x37,
+ NumMinus = 0x4A,
+ Tab = 0x0F,
+ Q = 0x10,
+ W = 0x11,
+ E = 0x12,
+ R = 0x13,
+ T = 0x14,
+ Y = 0x15,
+ U = 0x16,
+ I = 0x17,
+ O = 0x18,
+ P = 0x19,
+ OpenBracket = 0x1A,
+ CloseBracket = 0x1B,
+ Backslash = 0x2B,
+ KeyboardDelete = 0x153,
+ End = 0x14F,
+ PageDown = 0x151,
+ NumSeven = 0x47,
+ NumEight = 0x48,
+ NumNine = 0x49,
+ NumPlus = 0x4E,
+ CapsLock = 0x3A,
+ A = 0x1E,
+ S = 0x1F,
+ D = 0x20,
+ F = 0x21,
+ G = 0x22,
+ H = 0x23,
+ J = 0x24,
+ K = 0x25,
+ L = 0x26,
+ Semicolon = 0x27,
+ Apostrophe = 0x28,
+ Enter = 0x1C,
+ NumFour = 0x4B,
+ NumFive = 0x4C,
+ NumSix = 0x4D,
+ LeftShift = 0x2A,
+ Z = 0x2C,
+ X = 0x2D,
+ C = 0x2E,
+ V = 0x2F,
+ B = 0x30,
+ N = 0x31,
+ M = 0x32,
+ Comma = 0x33,
+ Period = 0x34,
+ ForwardSlash = 0x35,
+ RightShift = 0x36,
+ ArrowUp = 0x148,
+ NumOne = 0x4F,
+ NumTwo = 0x50,
+ NumThree = 0x51,
+ NumEnter = 0x11C,
+ LeftControl = 0x1D,
+ LeftWindows = 0x15B,
+ LeftAlt = 0x38,
+ Space = 0x39,
+ RightAlt = 0x138,
+ RightWindows = 0x15C,
+ ApplicationSelect = 0x15D,
+ RightControl = 0x11D,
+ ArrowLeft = 0x14B,
+ ArrowDown = 0x150,
+ ArrowRight = 0x14D,
+ NumZero = 0x52,
+ NumPeriod = 0x53,
+ G1 = 0xFFF1,
+ G2 = 0xFFF2,
+ G3 = 0xFFF3,
+ G4 = 0xFFF4,
+ G5 = 0xFFF5,
+ G6 = 0xFFF6,
+ G7 = 0xFFF7,
+ G8 = 0xFFF8,
+ G9 = 0xFFF9,
+ GLogo = 0xFFFF1,
+ GBadge = 0xFFFF2
+
+ };
+
+ internal enum DeviceType {
+
+ Keyboard = 0x0,
+ Mouse = 0x3,
+ Mousemat = 0x4,
+ Headset = 0x8,
+ Speaker = 0xe
+
+ }
+
+ internal static class LogitechGsdk {
+
+ private const int LogiDevicetypeMonochromeOrd = 0;
+ private const int LogiDevicetypeRgbOrd = 1;
+ private const int LogiDevicetypePerkeyRgbOrd = 2;
+
+ public const int LogiDevicetypeMonochrome = (1 << LogiDevicetypeMonochromeOrd);
+ public const int LogiDevicetypeRgb = (1 << LogiDevicetypeRgbOrd);
+ public const int LogiDevicetypePerkeyRgb = (1 << LogiDevicetypePerkeyRgbOrd);
+ public const int LogiDevicetypeAll = (LogiDevicetypeMonochrome | LogiDevicetypeRgb | LogiDevicetypePerkeyRgb);
+
+ public const int LogiLedBitmapWidth = 21;
+ public const int LogiLedBitmapHeight = 6;
+ public const int LogiLedBitmapBytesPerKey = 4;
+
+ public const int LogiLedBitmapSize = LogiLedBitmapWidth * LogiLedBitmapHeight * LogiLedBitmapBytesPerKey;
+ public const int LogiLedDurationInfinite = 0;
+
+ [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
+ public static extern bool LogiLedInit();
+
+ [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
+ public static extern bool LogiLedInitWithName(string name);
+
+ [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
+ public static extern bool LogiLedGetConfigOptionNumber([MarshalAs(UnmanagedType.LPWStr)] string configPath, ref double defaultNumber);
+
+ [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
+ public static extern bool LogiLedGetConfigOptionBool([MarshalAs(UnmanagedType.LPWStr)] string configPath, ref bool defaultRed);
+
+ [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
+ public static extern bool LogiLedGetConfigOptionColor([MarshalAs(UnmanagedType.LPWStr)] string configPath, ref int defaultRed, ref int defaultGreen, ref int defaultBlue);
+
+ [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
+ public static extern bool LogiLedGetConfigOptionKeyInput([MarshalAs(UnmanagedType.LPWStr)] string configPath, StringBuilder buffer, int bufsize);
+
+ [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
+ public static extern bool LogiLedSetTargetDevice(int targetDevice);
+
+ [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
+ public static extern bool LogiLedGetSdkVersion(ref int majorNum, ref int minorNum, ref int buildNum);
+
+ [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
+ public static extern bool LogiLedSaveCurrentLighting();
+
+ [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
+ public static extern bool LogiLedSetLighting(int redPercentage, int greenPercentage, int bluePercentage);
+
+ [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
+ public static extern bool LogiLedRestoreLighting();
+
+ [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
+ public static extern bool LogiLedFlashLighting(int redPercentage, int greenPercentage, int bluePercentage, int milliSecondsDuration, int milliSecondsInterval);
+
+ [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
+ public static extern bool LogiLedPulseLighting(int redPercentage, int greenPercentage, int bluePercentage, int milliSecondsDuration, int milliSecondsInterval);
+
+ [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
+ public static extern bool LogiLedStopEffects();
+
+ [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
+ public static extern bool LogiLedExcludeKeysFromBitmap(KeyboardNames[] keyList, int listCount);
+
+ [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
+ public static extern bool LogiLedSetLightingFromBitmap(byte[] bitmap);
+
+ [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
+ public static extern bool LogiLedSetLightingForKeyWithScanCode(int keyCode, int redPercentage, int greenPercentage, int bluePercentage);
+
+ [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
+ public static extern bool LogiLedSetLightingForKeyWithHidCode(int keyCode, int redPercentage, int greenPercentage, int bluePercentage);
+
+ [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
+ public static extern bool LogiLedSetLightingForKeyWithQuartzCode(int keyCode, int redPercentage, int greenPercentage, int bluePercentage);
+
+ [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
+ public static extern bool LogiLedSetLightingForKeyWithKeyName(KeyboardNames keyCode, int redPercentage, int greenPercentage, int bluePercentage);
+
+ [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
+ public static extern bool LogiLedSaveLightingForKey(KeyboardNames keyName);
+
+ [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
+ public static extern bool LogiLedRestoreLightingForKey(KeyboardNames keyName);
+
+ [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
+ public static extern bool LogiLedFlashSingleKey(KeyboardNames keyName, int redPercentage, int greenPercentage, int bluePercentage, int msDuration, int msInterval);
+
+ [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
+ public static extern bool LogiLedPulseSingleKey(KeyboardNames keyName, int startRedPercentage, int startGreenPercentage, int startBluePercentage, int finishRedPercentage, int finishGreenPercentage, int finishBluePercentage, int msDuration, bool isInfinite);
+
+ [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
+ public static extern bool LogiLedStopEffectsOnKey(KeyboardNames keyName);
+
+ [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
+ public static extern bool LogiLedSetLightingForTargetZone(DeviceType deviceType, int zone, int redPercentage, int greenPercentage, int bluePercentage);
+
+ [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
+ public static extern void LogiLedShutdown();
+
+ }
+}
\ No newline at end of file
diff --git a/Illumilib/LogitechLedEnginesWrapper.dll b/Illumilib/LogitechLedEnginesWrapper.dll
new file mode 100644
index 0000000..52ff285
Binary files /dev/null and b/Illumilib/LogitechLedEnginesWrapper.dll differ
diff --git a/Illumilib/System/LightingSystem.cs b/Illumilib/System/LightingSystem.cs
new file mode 100644
index 0000000..735b079
--- /dev/null
+++ b/Illumilib/System/LightingSystem.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Threading.Tasks;
+
+namespace Illumilib.System {
+ internal abstract class LightingSystem : IDisposable {
+
+ public abstract Task Initialize();
+
+ public abstract void Dispose();
+
+ public abstract void SetAllLighting(float r, float g, float b);
+
+ public abstract void SetKeyboardLighting(float r, float g, float b);
+
+ public abstract void SetMouseLighting(float r, float g, float b);
+
+ public abstract void SetKeyLighting(KeyboardKeys key, float r, float g, float b);
+
+ }
+}
\ No newline at end of file
diff --git a/Illumilib/System/LogitechLighting.cs b/Illumilib/System/LogitechLighting.cs
new file mode 100644
index 0000000..cb791ef
--- /dev/null
+++ b/Illumilib/System/LogitechLighting.cs
@@ -0,0 +1,248 @@
+using System.Threading.Tasks;
+using Illumilib.Lib;
+
+namespace Illumilib.System {
+ internal class LogitechLighting : LightingSystem {
+
+ public override Task Initialize() {
+ try {
+ LogitechGsdk.LogiLedInit();
+ return Task.FromResult(true);
+ } catch {
+ return Task.FromResult(false);
+ }
+ }
+
+ public override void Dispose() {
+ LogitechGsdk.LogiLedShutdown();
+ }
+
+ public override void SetAllLighting(float r, float g, float b) {
+ LogitechGsdk.LogiLedSetLighting((int) (r * 100F), (int) (g * 100F), (int) (b * 100F));
+ }
+
+ public override void SetKeyboardLighting(float r, float g, float b) {
+ for (var i = 0; i <= 3; i++)
+ LogitechGsdk.LogiLedSetLightingForTargetZone(DeviceType.Keyboard, i, (int) (r * 100F), (int) (g * 100F), (int) (b * 100F));
+ }
+
+ public override void SetMouseLighting(float r, float g, float b) {
+ for (var i = 0; i <= 2; i++)
+ LogitechGsdk.LogiLedSetLightingForTargetZone(DeviceType.Mouse, i, (int) (r * 100F), (int) (g * 100F), (int) (b * 100F));
+ }
+
+ public override void SetKeyLighting(KeyboardKeys key, float r, float g, float b) {
+ LogitechGsdk.LogiLedSetLightingForKeyWithKeyName(ConvertKey(key), (int) (r * 100F), (int) (g * 100F), (int) (b * 100F));
+ }
+
+ private static KeyboardNames ConvertKey(KeyboardKeys key) {
+ switch (key) {
+ case KeyboardKeys.Back:
+ return KeyboardNames.Backspace;
+ case KeyboardKeys.Tab:
+ return KeyboardNames.Tab;
+ case KeyboardKeys.Enter:
+ return KeyboardNames.Enter;
+ case KeyboardKeys.Pause:
+ return KeyboardNames.PauseBreak;
+ case KeyboardKeys.CapsLock:
+ return KeyboardNames.CapsLock;
+ case KeyboardKeys.Escape:
+ return KeyboardNames.Esc;
+ case KeyboardKeys.Space:
+ return KeyboardNames.Space;
+ case KeyboardKeys.PageUp:
+ return KeyboardNames.PageUp;
+ case KeyboardKeys.PageDown:
+ return KeyboardNames.PageDown;
+ case KeyboardKeys.End:
+ return KeyboardNames.End;
+ case KeyboardKeys.Home:
+ return KeyboardNames.Home;
+ case KeyboardKeys.Left:
+ return KeyboardNames.ArrowLeft;
+ case KeyboardKeys.Up:
+ return KeyboardNames.ArrowUp;
+ case KeyboardKeys.Right:
+ return KeyboardNames.ArrowRight;
+ case KeyboardKeys.Down:
+ return KeyboardNames.ArrowDown;
+ case KeyboardKeys.Select:
+ return KeyboardNames.ApplicationSelect;
+ case KeyboardKeys.PrintScreen:
+ return KeyboardNames.PrintScreen;
+ case KeyboardKeys.Insert:
+ return KeyboardNames.Insert;
+ case KeyboardKeys.Delete:
+ return KeyboardNames.KeyboardDelete;
+ case KeyboardKeys.D0:
+ return KeyboardNames.Zero;
+ case KeyboardKeys.D1:
+ return KeyboardNames.One;
+ case KeyboardKeys.D2:
+ return KeyboardNames.Two;
+ case KeyboardKeys.D3:
+ return KeyboardNames.Three;
+ case KeyboardKeys.D4:
+ return KeyboardNames.Four;
+ case KeyboardKeys.D5:
+ return KeyboardNames.Five;
+ case KeyboardKeys.D6:
+ return KeyboardNames.Six;
+ case KeyboardKeys.D7:
+ return KeyboardNames.Seven;
+ case KeyboardKeys.D8:
+ return KeyboardNames.Eight;
+ case KeyboardKeys.D9:
+ return KeyboardNames.Nine;
+ case KeyboardKeys.A:
+ return KeyboardNames.A;
+ case KeyboardKeys.B:
+ return KeyboardNames.B;
+ case KeyboardKeys.C:
+ return KeyboardNames.C;
+ case KeyboardKeys.D:
+ return KeyboardNames.D;
+ case KeyboardKeys.E:
+ return KeyboardNames.E;
+ case KeyboardKeys.F:
+ return KeyboardNames.F;
+ case KeyboardKeys.G:
+ return KeyboardNames.G;
+ case KeyboardKeys.H:
+ return KeyboardNames.H;
+ case KeyboardKeys.I:
+ return KeyboardNames.I;
+ case KeyboardKeys.J:
+ return KeyboardNames.J;
+ case KeyboardKeys.K:
+ return KeyboardNames.K;
+ case KeyboardKeys.L:
+ return KeyboardNames.L;
+ case KeyboardKeys.M:
+ return KeyboardNames.M;
+ case KeyboardKeys.N:
+ return KeyboardNames.N;
+ case KeyboardKeys.O:
+ return KeyboardNames.O;
+ case KeyboardKeys.P:
+ return KeyboardNames.P;
+ case KeyboardKeys.Q:
+ return KeyboardNames.Q;
+ case KeyboardKeys.R:
+ return KeyboardNames.R;
+ case KeyboardKeys.S:
+ return KeyboardNames.S;
+ case KeyboardKeys.T:
+ return KeyboardNames.T;
+ case KeyboardKeys.U:
+ return KeyboardNames.U;
+ case KeyboardKeys.V:
+ return KeyboardNames.V;
+ case KeyboardKeys.W:
+ return KeyboardNames.W;
+ case KeyboardKeys.X:
+ return KeyboardNames.X;
+ case KeyboardKeys.Y:
+ return KeyboardNames.Y;
+ case KeyboardKeys.Z:
+ return KeyboardNames.Z;
+ case KeyboardKeys.LWin:
+ return KeyboardNames.LeftWindows;
+ case KeyboardKeys.RWin:
+ return KeyboardNames.RightWindows;
+ case KeyboardKeys.Apps:
+ return KeyboardNames.ApplicationSelect;
+ case KeyboardKeys.NumPad0:
+ return KeyboardNames.NumZero;
+ case KeyboardKeys.NumPad1:
+ return KeyboardNames.NumOne;
+ case KeyboardKeys.NumPad2:
+ return KeyboardNames.NumTwo;
+ case KeyboardKeys.NumPad3:
+ return KeyboardNames.NumThree;
+ case KeyboardKeys.NumPad4:
+ return KeyboardNames.NumFour;
+ case KeyboardKeys.NumPad5:
+ return KeyboardNames.NumFive;
+ case KeyboardKeys.NumPad6:
+ return KeyboardNames.NumSix;
+ case KeyboardKeys.NumPad7:
+ return KeyboardNames.NumSeven;
+ case KeyboardKeys.NumPad8:
+ return KeyboardNames.NumEight;
+ case KeyboardKeys.NumPad9:
+ return KeyboardNames.NumNine;
+ case KeyboardKeys.Multiply:
+ return KeyboardNames.NumAsterisk;
+ case KeyboardKeys.Add:
+ return KeyboardNames.NumPlus;
+ case KeyboardKeys.Subtract:
+ return KeyboardNames.NumMinus;
+ case KeyboardKeys.Decimal:
+ return KeyboardNames.NumPeriod;
+ case KeyboardKeys.Divide:
+ return KeyboardNames.NumSlash;
+ case KeyboardKeys.F1:
+ return KeyboardNames.F1;
+ case KeyboardKeys.F2:
+ return KeyboardNames.F2;
+ case KeyboardKeys.F3:
+ return KeyboardNames.F3;
+ case KeyboardKeys.F4:
+ return KeyboardNames.F4;
+ case KeyboardKeys.F5:
+ return KeyboardNames.F5;
+ case KeyboardKeys.F6:
+ return KeyboardNames.F6;
+ case KeyboardKeys.F7:
+ return KeyboardNames.F7;
+ case KeyboardKeys.F8:
+ return KeyboardNames.F8;
+ case KeyboardKeys.F9:
+ return KeyboardNames.F9;
+ case KeyboardKeys.F10:
+ return KeyboardNames.F10;
+ case KeyboardKeys.F11:
+ return KeyboardNames.F11;
+ case KeyboardKeys.F12:
+ return KeyboardNames.F12;
+ case KeyboardKeys.NumLock:
+ return KeyboardNames.NumLock;
+ case KeyboardKeys.Scroll:
+ return KeyboardNames.ScrollLock;
+ case KeyboardKeys.LShiftKey:
+ return KeyboardNames.LeftShift;
+ case KeyboardKeys.RShiftKey:
+ return KeyboardNames.RightShift;
+ case KeyboardKeys.LControlKey:
+ return KeyboardNames.LeftControl;
+ case KeyboardKeys.RControlKey:
+ return KeyboardNames.RightControl;
+ case KeyboardKeys.LMenu:
+ return KeyboardNames.LeftAlt;
+ case KeyboardKeys.RMenu:
+ return KeyboardNames.RightAlt;
+ case KeyboardKeys.OemSemicolon:
+ return KeyboardNames.Semicolon;
+ case KeyboardKeys.OemComma:
+ return KeyboardNames.Comma;
+ case KeyboardKeys.OemMinus:
+ return KeyboardNames.Minus;
+ case KeyboardKeys.OemPeriod:
+ return KeyboardNames.Period;
+ case KeyboardKeys.OemTilde:
+ return KeyboardNames.Tilde;
+ case KeyboardKeys.OemOpenBrackets:
+ return KeyboardNames.OpenBracket;
+ case KeyboardKeys.OemCloseBrackets:
+ return KeyboardNames.CloseBracket;
+ case KeyboardKeys.OemBackslash:
+ return KeyboardNames.Backslash;
+ default:
+ return 0;
+ }
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Illumilib/System/RazerLighting.cs b/Illumilib/System/RazerLighting.cs
new file mode 100644
index 0000000..50678d7
--- /dev/null
+++ b/Illumilib/System/RazerLighting.cs
@@ -0,0 +1,244 @@
+using System.Threading.Tasks;
+using Colore;
+using Colore.Data;
+using Colore.Effects.Keyboard;
+
+namespace Illumilib.System {
+ internal class RazerLighting : LightingSystem {
+
+ private static IChroma chroma;
+
+ public override async Task Initialize() {
+ try {
+ chroma = await ColoreProvider.CreateNativeAsync();
+ return true;
+ } catch {
+ return false;
+ }
+ }
+
+ public override void Dispose() {
+ chroma?.UninitializeAsync();
+ }
+
+ public override void SetAllLighting(float r, float g, float b) {
+ chroma?.SetAllAsync(new Color(r, g, b));
+ }
+
+ public override void SetKeyboardLighting(float r, float g, float b) {
+ chroma?.Keyboard.SetAllAsync(new Color(r, g, b));
+ }
+
+ public override void SetMouseLighting(float r, float g, float b) {
+ chroma?.Mouse.SetAllAsync(new Color(r, g, b));
+ }
+
+ public override void SetKeyLighting(KeyboardKeys key, float r, float g, float b) {
+ chroma.Keyboard?.SetKeyAsync(ConvertKey(key), new Color(r, g, b));
+ }
+
+ private static Key ConvertKey(KeyboardKeys key) {
+ switch (key) {
+ case KeyboardKeys.Back:
+ return Key.Backspace;
+ case KeyboardKeys.Tab:
+ return Key.Tab;
+ case KeyboardKeys.Enter:
+ return Key.Enter;
+ case KeyboardKeys.Pause:
+ return Key.Pause;
+ case KeyboardKeys.CapsLock:
+ return Key.CapsLock;
+ case KeyboardKeys.Escape:
+ return Key.Escape;
+ case KeyboardKeys.Space:
+ return Key.Space;
+ case KeyboardKeys.PageUp:
+ return Key.PageUp;
+ case KeyboardKeys.PageDown:
+ return Key.PageDown;
+ case KeyboardKeys.End:
+ return Key.End;
+ case KeyboardKeys.Home:
+ return Key.Home;
+ case KeyboardKeys.Left:
+ return Key.Left;
+ case KeyboardKeys.Up:
+ return Key.Up;
+ case KeyboardKeys.Right:
+ return Key.Right;
+ case KeyboardKeys.Down:
+ return Key.Down;
+ case KeyboardKeys.PrintScreen:
+ return Key.PrintScreen;
+ case KeyboardKeys.Insert:
+ return Key.Insert;
+ case KeyboardKeys.Delete:
+ return Key.Delete;
+ case KeyboardKeys.D0:
+ return Key.D0;
+ case KeyboardKeys.D1:
+ return Key.D1;
+ case KeyboardKeys.D2:
+ return Key.D2;
+ case KeyboardKeys.D3:
+ return Key.D3;
+ case KeyboardKeys.D4:
+ return Key.D4;
+ case KeyboardKeys.D5:
+ return Key.D5;
+ case KeyboardKeys.D6:
+ return Key.D6;
+ case KeyboardKeys.D7:
+ return Key.D7;
+ case KeyboardKeys.D8:
+ return Key.D8;
+ case KeyboardKeys.D9:
+ return Key.D9;
+ case KeyboardKeys.A:
+ return Key.A;
+ case KeyboardKeys.B:
+ return Key.B;
+ case KeyboardKeys.C:
+ return Key.C;
+ case KeyboardKeys.D:
+ return Key.D;
+ case KeyboardKeys.E:
+ return Key.E;
+ case KeyboardKeys.F:
+ return Key.F;
+ case KeyboardKeys.G:
+ return Key.G;
+ case KeyboardKeys.H:
+ return Key.H;
+ case KeyboardKeys.I:
+ return Key.I;
+ case KeyboardKeys.J:
+ return Key.J;
+ case KeyboardKeys.K:
+ return Key.K;
+ case KeyboardKeys.L:
+ return Key.L;
+ case KeyboardKeys.M:
+ return Key.M;
+ case KeyboardKeys.N:
+ return Key.N;
+ case KeyboardKeys.O:
+ return Key.O;
+ case KeyboardKeys.P:
+ return Key.P;
+ case KeyboardKeys.Q:
+ return Key.Q;
+ case KeyboardKeys.R:
+ return Key.R;
+ case KeyboardKeys.S:
+ return Key.S;
+ case KeyboardKeys.T:
+ return Key.T;
+ case KeyboardKeys.U:
+ return Key.U;
+ case KeyboardKeys.V:
+ return Key.V;
+ case KeyboardKeys.W:
+ return Key.W;
+ case KeyboardKeys.X:
+ return Key.X;
+ case KeyboardKeys.Y:
+ return Key.Y;
+ case KeyboardKeys.Z:
+ return Key.Z;
+ case KeyboardKeys.LWin:
+ return Key.LeftWindows;
+ case KeyboardKeys.NumPad0:
+ return Key.Num0;
+ case KeyboardKeys.NumPad1:
+ return Key.Num1;
+ case KeyboardKeys.NumPad2:
+ return Key.Num2;
+ case KeyboardKeys.NumPad3:
+ return Key.Num3;
+ case KeyboardKeys.NumPad4:
+ return Key.Num4;
+ case KeyboardKeys.NumPad5:
+ return Key.Num5;
+ case KeyboardKeys.NumPad6:
+ return Key.Num6;
+ case KeyboardKeys.NumPad7:
+ return Key.Num7;
+ case KeyboardKeys.NumPad8:
+ return Key.Num8;
+ case KeyboardKeys.NumPad9:
+ return Key.Num9;
+ case KeyboardKeys.Multiply:
+ return Key.NumMultiply;
+ case KeyboardKeys.Add:
+ return Key.NumAdd;
+ case KeyboardKeys.Subtract:
+ return Key.NumSubtract;
+ case KeyboardKeys.Decimal:
+ return Key.NumDecimal;
+ case KeyboardKeys.Divide:
+ return Key.NumDivide;
+ case KeyboardKeys.F1:
+ return Key.F1;
+ case KeyboardKeys.F2:
+ return Key.F2;
+ case KeyboardKeys.F3:
+ return Key.F3;
+ case KeyboardKeys.F4:
+ return Key.F4;
+ case KeyboardKeys.F5:
+ return Key.F5;
+ case KeyboardKeys.F6:
+ return Key.F6;
+ case KeyboardKeys.F7:
+ return Key.F7;
+ case KeyboardKeys.F8:
+ return Key.F8;
+ case KeyboardKeys.F9:
+ return Key.F9;
+ case KeyboardKeys.F10:
+ return Key.F10;
+ case KeyboardKeys.F11:
+ return Key.F11;
+ case KeyboardKeys.F12:
+ return Key.F12;
+ case KeyboardKeys.NumLock:
+ return Key.NumLock;
+ case KeyboardKeys.Scroll:
+ return Key.Scroll;
+ case KeyboardKeys.LShiftKey:
+ return Key.LeftShift;
+ case KeyboardKeys.RShiftKey:
+ return Key.RightShift;
+ case KeyboardKeys.LControlKey:
+ return Key.LeftControl;
+ case KeyboardKeys.RControlKey:
+ return Key.RightControl;
+ case KeyboardKeys.LMenu:
+ return Key.LeftAlt;
+ case KeyboardKeys.RMenu:
+ return Key.RightAlt;
+ case KeyboardKeys.OemSemicolon:
+ return Key.OemSemicolon;
+ case KeyboardKeys.OemComma:
+ return Key.OemComma;
+ case KeyboardKeys.OemMinus:
+ return Key.OemMinus;
+ case KeyboardKeys.OemPeriod:
+ return Key.OemPeriod;
+ case KeyboardKeys.OemTilde:
+ return Key.OemTilde;
+ case KeyboardKeys.OemOpenBrackets:
+ return Key.OemLeftBracket;
+ case KeyboardKeys.OemCloseBrackets:
+ return Key.OemRightBracket;
+ case KeyboardKeys.OemBackslash:
+ return Key.OemBackslash;
+ default:
+ return 0;
+ }
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/README.md b/README.md
index e1c7e88..5639dd8 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,2 @@
# Illumilib
-A keyboard lighting .NET library
+A simple keyboard and mouse lighting library with support for Razer and Logitech devices
\ No newline at end of file