mirror of
https://github.com/Ellpeck/Illumilib.git
synced 2024-11-23 12:18:36 +01:00
initial release
This commit is contained in:
parent
6a43191dbc
commit
f70f6d7ffa
13 changed files with 1362 additions and 1 deletions
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
bin/
|
||||
obj/
|
||||
/packages/
|
||||
riderModule.iml
|
||||
/_ReSharper.Caches/
|
||||
.idea
|
12
Demo/Demo.csproj
Normal file
12
Demo/Demo.csproj
Normal file
|
@ -0,0 +1,12 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Illumilib\Illumilib.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
46
Demo/Program.cs
Normal file
46
Demo/Program.cs
Normal file
|
@ -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<KeyboardKeys>()) {
|
||||
IllumilibLighting.SetKeyLighting(key, 1, 0, 0);
|
||||
Thread.Sleep(50);
|
||||
}
|
||||
Thread.Sleep(TimeSpan.FromSeconds(15));
|
||||
|
||||
Console.WriteLine("Done");
|
||||
IllumilibLighting.Dispose();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
22
Illumilib.sln
Normal file
22
Illumilib.sln
Normal file
|
@ -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
|
24
Illumilib/Illumilib.csproj
Normal file
24
Illumilib/Illumilib.csproj
Normal file
|
@ -0,0 +1,24 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<Authors>Ellpeck</Authors>
|
||||
<Description>A simple keyboard and mouse lighting library with support for Razer and Logitech devices</Description>
|
||||
<PackageTags>lighting keyboard mouse lighting logitech lightsync razer chroma</PackageTags>
|
||||
<PackageProjectUrl>https://github.com/Ellpeck/Illumilib</PackageProjectUrl>
|
||||
<RepositoryUrl>https://github.com/Ellpeck/Illumilib</RepositoryUrl>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<VersionPrefix>1.0.0</VersionPrefix>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="LogitechLedEnginesWrapper.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Colore" Version="6.0.0"/>
|
||||
</ItemGroup>
|
||||
</Project>
|
91
Illumilib/IllumilibLighting.cs
Normal file
91
Illumilib/IllumilibLighting.cs
Normal file
|
@ -0,0 +1,91 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Illumilib.System;
|
||||
|
||||
namespace Illumilib {
|
||||
/// <summary>
|
||||
/// The class that houses all Illumilib methods.
|
||||
/// This class does not need to be instantiated.
|
||||
/// </summary>
|
||||
public static class IllumilibLighting {
|
||||
|
||||
private static List<LightingSystem> systems;
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <exception cref="InvalidOperationException">Thrown if Illumilib has already been initialized</exception>
|
||||
public static async Task Initialize() {
|
||||
if (systems != null)
|
||||
throw new InvalidOperationException("Illumilib has already been initialized");
|
||||
var ret = new List<LightingSystem>();
|
||||
foreach (var system in new LightingSystem[] {new LogitechLighting(), new RazerLighting()}) {
|
||||
if (await system.Initialize())
|
||||
ret.Add(system);
|
||||
}
|
||||
systems = ret;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disposes Illumilib, disposing all of the underlying lighting systems
|
||||
/// </summary>
|
||||
public static void Dispose() {
|
||||
ForEach(s => s.Dispose());
|
||||
systems = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the lighting for all keyboards and mice to the given color
|
||||
/// </summary>
|
||||
/// <param name="r">The color's red value, between 0 and 1</param>
|
||||
/// <param name="g">The color's green value, between 0 and 1</param>
|
||||
/// <param name="b">The color's blue value, between 0 and 1</param>
|
||||
public static void SetAllLighting(float r, float g, float b) {
|
||||
ForEach(s => s.SetAllLighting(r, g, b));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the lighting for all keyboards to the given color.
|
||||
/// Note that, if Logitech is used, some keyboards do not support this method.
|
||||
/// </summary>
|
||||
/// <param name="r">The color's red value, between 0 and 1</param>
|
||||
/// <param name="g">The color's green value, between 0 and 1</param>
|
||||
/// <param name="b">The color's blue value, between 0 and 1</param>
|
||||
public static void SetKeyboardLighting(float r, float g, float b) {
|
||||
ForEach(s => s.SetKeyboardLighting(r, g, b));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the lighting for all mice to the given color
|
||||
/// </summary>
|
||||
/// <param name="r">The color's red value, between 0 and 1</param>
|
||||
/// <param name="g">The color's green value, between 0 and 1</param>
|
||||
/// <param name="b">The color's blue value, between 0 and 1</param>
|
||||
public static void SetMouseLighting(float r, float g, float b) {
|
||||
ForEach(s => s.SetMouseLighting(r, g, b));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the lighting for the specified <see cref="KeyboardKeys"/> to the given color.
|
||||
/// Only a single key can be specified at a time.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="r"></param>
|
||||
/// <param name="g"></param>
|
||||
/// <param name="b"></param>
|
||||
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<LightingSystem> action) {
|
||||
if (systems == null)
|
||||
throw new InvalidOperationException("Illumilib has not been initialized yet");
|
||||
foreach (var system in systems)
|
||||
action(system);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
413
Illumilib/KeyboardKeys.cs
Normal file
413
Illumilib/KeyboardKeys.cs
Normal file
|
@ -0,0 +1,413 @@
|
|||
namespace Illumilib {
|
||||
/// <summary>
|
||||
/// Specifies key codes and modifiers
|
||||
/// </summary>
|
||||
public enum KeyboardKeys {
|
||||
|
||||
/// <summary>
|
||||
/// The BACKSPACE key
|
||||
/// </summary>
|
||||
Back = 8,
|
||||
/// <summary>
|
||||
/// The TAB key
|
||||
/// </summary>
|
||||
Tab = 9,
|
||||
/// <summary>
|
||||
/// The ENTER key
|
||||
/// </summary>
|
||||
Enter = 13,
|
||||
/// <summary>
|
||||
/// The PAUSE key
|
||||
/// </summary>
|
||||
Pause = 19,
|
||||
/// <summary>
|
||||
/// The CAPS LOCK key
|
||||
/// </summary>
|
||||
CapsLock = 20,
|
||||
/// <summary>
|
||||
/// The ESC key
|
||||
/// </summary>
|
||||
Escape = 27,
|
||||
/// <summary>
|
||||
/// The SPACEBAR key
|
||||
/// </summary>
|
||||
Space = 32,
|
||||
/// <summary>
|
||||
/// The PAGE UP key
|
||||
/// </summary>
|
||||
PageUp = 33,
|
||||
/// <summary>
|
||||
/// The PAGE DOWN key
|
||||
/// </summary>
|
||||
PageDown = 34,
|
||||
/// <summary>
|
||||
/// The END key
|
||||
/// </summary>
|
||||
End = 35,
|
||||
/// <summary>
|
||||
/// The HOME key
|
||||
/// </summary>
|
||||
Home = 36,
|
||||
/// <summary>
|
||||
/// The LEFT ARROW key
|
||||
/// </summary>
|
||||
Left = 37,
|
||||
/// <summary>
|
||||
/// The UP ARROW key
|
||||
/// </summary>
|
||||
Up = 38,
|
||||
/// <summary>
|
||||
/// The RIGHT ARROW key
|
||||
/// </summary>
|
||||
Right = 39,
|
||||
/// <summary>
|
||||
/// The DOWN ARROW key
|
||||
/// </summary>
|
||||
Down = 40,
|
||||
/// <summary>
|
||||
/// The SELECT key
|
||||
/// </summary>
|
||||
Select = 41,
|
||||
/// <summary>
|
||||
/// The PRINT SCREEN key
|
||||
/// </summary>
|
||||
PrintScreen = 44,
|
||||
/// <summary>
|
||||
/// The INS key
|
||||
/// </summary>
|
||||
Insert = 45,
|
||||
/// <summary>
|
||||
/// The DEL key
|
||||
/// </summary>
|
||||
Delete = 46,
|
||||
/// <summary>
|
||||
/// The 0 key
|
||||
/// </summary>
|
||||
D0 = 48,
|
||||
/// <summary>
|
||||
/// The 1 key
|
||||
/// </summary>
|
||||
D1 = 49,
|
||||
/// <summary>
|
||||
/// The 2 key
|
||||
/// </summary>
|
||||
D2 = 50,
|
||||
/// <summary>
|
||||
/// The 3 key
|
||||
/// </summary>
|
||||
D3 = 51,
|
||||
/// <summary>
|
||||
/// The 4 key
|
||||
/// </summary>
|
||||
D4 = 52,
|
||||
/// <summary>
|
||||
/// The 5 key
|
||||
/// </summary>
|
||||
D5 = 53,
|
||||
/// <summary>
|
||||
/// The 6 key
|
||||
/// </summary>
|
||||
D6 = 54,
|
||||
/// <summary>
|
||||
/// The 7 key
|
||||
/// </summary>
|
||||
D7 = 55,
|
||||
/// <summary>
|
||||
/// The 8 key
|
||||
/// </summary>
|
||||
D8 = 56,
|
||||
/// <summary>
|
||||
/// The 9 key
|
||||
/// </summary>
|
||||
D9 = 57,
|
||||
/// <summary>
|
||||
/// The A key
|
||||
/// </summary>
|
||||
A = 65,
|
||||
/// <summary>
|
||||
/// The B key
|
||||
/// </summary>
|
||||
B = 66,
|
||||
/// <summary>
|
||||
/// The C key
|
||||
/// </summary>
|
||||
C = 67,
|
||||
/// <summary>
|
||||
/// The D key
|
||||
/// </summary>
|
||||
D = 68,
|
||||
/// <summary>
|
||||
/// The E key
|
||||
/// </summary>
|
||||
E = 69,
|
||||
/// <summary>
|
||||
/// The F key
|
||||
/// </summary>
|
||||
F = 70,
|
||||
/// <summary>
|
||||
/// The G key
|
||||
/// </summary>
|
||||
G = 71,
|
||||
/// <summary>
|
||||
/// The H key
|
||||
/// </summary>
|
||||
H = 72,
|
||||
/// <summary>
|
||||
/// The I key
|
||||
/// </summary>
|
||||
I = 73,
|
||||
/// <summary>
|
||||
/// The J key
|
||||
/// </summary>
|
||||
J = 74,
|
||||
/// <summary>
|
||||
/// The K key
|
||||
/// </summary>
|
||||
K = 75,
|
||||
/// <summary>
|
||||
/// The L key
|
||||
/// </summary>
|
||||
L = 76,
|
||||
/// <summary>
|
||||
/// The M key
|
||||
/// </summary>
|
||||
M = 77,
|
||||
/// <summary>
|
||||
/// The N key
|
||||
/// </summary>
|
||||
N = 78,
|
||||
/// <summary>
|
||||
/// The O key
|
||||
/// </summary>
|
||||
O = 79,
|
||||
/// <summary>
|
||||
/// The P key
|
||||
/// </summary>
|
||||
P = 80,
|
||||
/// <summary>
|
||||
/// The Q key
|
||||
/// </summary>
|
||||
Q = 81,
|
||||
/// <summary>
|
||||
/// The R key
|
||||
/// </summary>
|
||||
R = 82,
|
||||
/// <summary>
|
||||
/// The S key
|
||||
/// </summary>
|
||||
S = 83,
|
||||
/// <summary>
|
||||
/// The T key
|
||||
/// </summary>
|
||||
T = 84,
|
||||
/// <summary>
|
||||
/// The U key
|
||||
/// </summary>
|
||||
U = 85,
|
||||
/// <summary>
|
||||
/// The V key
|
||||
/// </summary>
|
||||
V = 86,
|
||||
/// <summary>
|
||||
/// The W key
|
||||
/// </summary>
|
||||
W = 87,
|
||||
/// <summary>
|
||||
/// The X key
|
||||
/// </summary>
|
||||
X = 88,
|
||||
/// <summary>
|
||||
/// The Y key
|
||||
/// </summary>
|
||||
Y = 89,
|
||||
/// <summary>
|
||||
/// The Z key
|
||||
/// </summary>
|
||||
Z = 90,
|
||||
/// <summary>
|
||||
/// The left Windows logo key (Microsoft Natural Keyboard)
|
||||
/// </summary>
|
||||
LWin = 91,
|
||||
/// <summary>
|
||||
/// The right Windows logo key (Microsoft Natural Keyboard)
|
||||
/// </summary>
|
||||
RWin = 92,
|
||||
/// <summary>
|
||||
/// The Application key (Microsoft Natural Keyboard)
|
||||
/// </summary>
|
||||
Apps = 93,
|
||||
/// <summary>
|
||||
/// The 0 key on the numeric keypad
|
||||
/// </summary>
|
||||
NumPad0 = 96,
|
||||
/// <summary>
|
||||
/// The 1 key on the numeric keypad
|
||||
/// </summary>
|
||||
NumPad1 = 97,
|
||||
/// <summary>
|
||||
/// The 2 key on the numeric keypad
|
||||
/// </summary>
|
||||
NumPad2 = 98,
|
||||
/// <summary>
|
||||
/// The 3 key on the numeric keypad
|
||||
/// </summary>
|
||||
NumPad3 = 99,
|
||||
/// <summary>
|
||||
/// The 4 key on the numeric keypad
|
||||
/// </summary>
|
||||
NumPad4 = 100,
|
||||
/// <summary>
|
||||
/// The 5 key on the numeric keypad
|
||||
/// </summary>
|
||||
NumPad5 = 101,
|
||||
/// <summary>
|
||||
/// The 6 key on the numeric keypad
|
||||
/// </summary>
|
||||
NumPad6 = 102,
|
||||
/// <summary>
|
||||
/// The 7 key on the numeric keypad
|
||||
/// </summary>
|
||||
NumPad7 = 103,
|
||||
/// <summary>
|
||||
/// The 8 key on the numeric keypad
|
||||
/// </summary>
|
||||
NumPad8 = 104,
|
||||
/// <summary>
|
||||
/// The 9 key on the numeric keypad
|
||||
/// </summary>
|
||||
NumPad9 = 105,
|
||||
/// <summary>
|
||||
/// The Multiply key
|
||||
/// </summary>
|
||||
Multiply = 106,
|
||||
/// <summary>
|
||||
/// The Add key
|
||||
/// </summary>
|
||||
Add = 107,
|
||||
/// <summary>
|
||||
/// The Subtract key
|
||||
/// </summary>
|
||||
Subtract = 109,
|
||||
/// <summary>
|
||||
/// The Decimal key
|
||||
/// </summary>
|
||||
Decimal = 110,
|
||||
/// <summary>
|
||||
/// The Divide key
|
||||
/// </summary>
|
||||
Divide = 111,
|
||||
/// <summary>
|
||||
/// The F1 key
|
||||
/// </summary>
|
||||
F1 = 112,
|
||||
/// <summary>
|
||||
/// The F2 key
|
||||
/// </summary>
|
||||
F2 = 113,
|
||||
/// <summary>
|
||||
/// The F3 key
|
||||
/// </summary>
|
||||
F3 = 114,
|
||||
/// <summary>
|
||||
/// The F4 key
|
||||
/// </summary>
|
||||
F4 = 115,
|
||||
/// <summary>
|
||||
/// The F5 key
|
||||
/// </summary>
|
||||
F5 = 116,
|
||||
/// <summary>
|
||||
/// The F6 key
|
||||
/// </summary>
|
||||
F6 = 117,
|
||||
/// <summary>
|
||||
/// The F7 key
|
||||
/// </summary>
|
||||
F7 = 118,
|
||||
/// <summary>
|
||||
/// The F8 key
|
||||
/// </summary>
|
||||
F8 = 119,
|
||||
/// <summary>
|
||||
/// The F9 key
|
||||
/// </summary>
|
||||
F9 = 120,
|
||||
/// <summary>
|
||||
/// The F10 key
|
||||
/// </summary>
|
||||
F10 = 121,
|
||||
/// <summary>
|
||||
/// The F11 key
|
||||
/// </summary>
|
||||
F11 = 122,
|
||||
/// <summary>
|
||||
/// The F12 key
|
||||
/// </summary>
|
||||
F12 = 123,
|
||||
/// <summary>
|
||||
/// The NUM LOCK key
|
||||
/// </summary>
|
||||
NumLock = 144,
|
||||
/// <summary>
|
||||
/// The SCROLL LOCK key
|
||||
/// </summary>
|
||||
Scroll = 145,
|
||||
/// <summary>
|
||||
/// The left SHIFT key
|
||||
/// </summary>
|
||||
LShiftKey = 160,
|
||||
/// <summary>
|
||||
/// The right SHIFT key
|
||||
/// </summary>
|
||||
RShiftKey = 161,
|
||||
/// <summary>
|
||||
/// The left CTRL key
|
||||
/// </summary>
|
||||
LControlKey = 162,
|
||||
/// <summary>
|
||||
/// The right CTRL key
|
||||
/// </summary>
|
||||
RControlKey = 163,
|
||||
/// <summary>
|
||||
/// The left ALT key
|
||||
/// </summary>
|
||||
LMenu = 164,
|
||||
/// <summary>
|
||||
/// The right ALT key
|
||||
/// </summary>
|
||||
RMenu = 165,
|
||||
/// <summary>
|
||||
/// The Oem Semicolon key
|
||||
/// </summary>
|
||||
OemSemicolon = 186,
|
||||
/// <summary>
|
||||
/// The Oem comma key
|
||||
/// </summary>
|
||||
OemComma = 188,
|
||||
/// <summary>
|
||||
/// The Oem Minus key
|
||||
/// </summary>
|
||||
OemMinus = 189,
|
||||
/// <summary>
|
||||
/// The Oem Period key
|
||||
/// </summary>
|
||||
OemPeriod = 190,
|
||||
/// <summary>
|
||||
/// The Oem tilde key
|
||||
/// </summary>
|
||||
OemTilde = 192,
|
||||
/// <summary>
|
||||
/// The Oem Open Brackets key
|
||||
/// </summary>
|
||||
OemOpenBrackets = 219,
|
||||
/// <summary>
|
||||
/// The Oem Close Brackets key
|
||||
/// </summary>
|
||||
OemCloseBrackets = 221,
|
||||
/// <summary>
|
||||
/// The Oem Backslash key
|
||||
/// </summary>
|
||||
OemBackslash = 226
|
||||
|
||||
}
|
||||
}
|
235
Illumilib/Lib/LogitechGsdk.cs
Normal file
235
Illumilib/Lib/LogitechGsdk.cs
Normal file
|
@ -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();
|
||||
|
||||
}
|
||||
}
|
BIN
Illumilib/LogitechLedEnginesWrapper.dll
Normal file
BIN
Illumilib/LogitechLedEnginesWrapper.dll
Normal file
Binary file not shown.
20
Illumilib/System/LightingSystem.cs
Normal file
20
Illumilib/System/LightingSystem.cs
Normal file
|
@ -0,0 +1,20 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Illumilib.System {
|
||||
internal abstract class LightingSystem : IDisposable {
|
||||
|
||||
public abstract Task<bool> 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);
|
||||
|
||||
}
|
||||
}
|
248
Illumilib/System/LogitechLighting.cs
Normal file
248
Illumilib/System/LogitechLighting.cs
Normal file
|
@ -0,0 +1,248 @@
|
|||
using System.Threading.Tasks;
|
||||
using Illumilib.Lib;
|
||||
|
||||
namespace Illumilib.System {
|
||||
internal class LogitechLighting : LightingSystem {
|
||||
|
||||
public override Task<bool> 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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
244
Illumilib/System/RazerLighting.cs
Normal file
244
Illumilib/System/RazerLighting.cs
Normal file
|
@ -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<bool> 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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,2 +1,2 @@
|
|||
# Illumilib
|
||||
A keyboard lighting .NET library
|
||||
A simple keyboard and mouse lighting library with support for Razer and Logitech devices
|
Loading…
Reference in a new issue