1
0
mirror of https://github.com/DarthAffe/CUE.NET.git synced 2025-12-13 00:58:31 +00:00

Experimental Glaive support

This commit is contained in:
Daro 2017-09-29 16:48:14 +02:00
parent 220953bfe7
commit 372cc51477
6 changed files with 592 additions and 386 deletions

View File

@ -36,6 +36,9 @@
<DocumentationFile>bin\CUE.NET.XML</DocumentationFile> <DocumentationFile>bin\CUE.NET.XML</DocumentationFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="HidSharp, Version=1.5.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\HidSharp.1.5\lib\net35\HidSharp.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
@ -68,6 +71,7 @@
<Compile Include="Devices\Generic\EventArgs\UpdatingEventArgs.cs" /> <Compile Include="Devices\Generic\EventArgs\UpdatingEventArgs.cs" />
<Compile Include="Devices\Generic\LedUpateRequest.cs" /> <Compile Include="Devices\Generic\LedUpateRequest.cs" />
<Compile Include="Devices\Keyboard\Enums\BrushCalculationMode.cs" /> <Compile Include="Devices\Keyboard\Enums\BrushCalculationMode.cs" />
<Compile Include="Devices\Mouse\GlaiveMouse.cs" />
<Compile Include="Effects\AbstractLedGroupEffect.cs" /> <Compile Include="Effects\AbstractLedGroupEffect.cs" />
<Compile Include="Effects\AbstractBrushEffect.cs" /> <Compile Include="Effects\AbstractBrushEffect.cs" />
<Compile Include="Effects\AbstractEffectTarget.cs" /> <Compile Include="Effects\AbstractEffectTarget.cs" />
@ -132,7 +136,9 @@
<Compile Include="CueSDK.cs" /> <Compile Include="CueSDK.cs" />
<Compile Include="Devices\ICueDevice.cs" /> <Compile Include="Devices\ICueDevice.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup /> <ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildProjectDirectory)\CUE.NET.targets" /> <Import Project="$(MSBuildProjectDirectory)\CUE.NET.targets" />
</Project> </Project>

View File

@ -13,6 +13,7 @@ using CUE.NET.Devices.Mouse;
using CUE.NET.Devices.Mousemat; using CUE.NET.Devices.Mousemat;
using CUE.NET.Exceptions; using CUE.NET.Exceptions;
using CUE.NET.Native; using CUE.NET.Native;
using System;
namespace CUE.NET namespace CUE.NET
{ {
@ -79,6 +80,8 @@ namespace CUE.NET
/// </summary> /// </summary>
public static CorsairMouse MouseSDK { get; private set; } public static CorsairMouse MouseSDK { get; private set; }
public static GlaiveMouse GlaiveSDK { get; private set; }
/// <summary> /// <summary>
/// Gets the managed representation of a headset managed by the CUE-SDK. /// Gets the managed representation of a headset managed by the CUE-SDK.
/// Note that currently only one connected headset is supported. /// Note that currently only one connected headset is supported.
@ -197,7 +200,14 @@ namespace CUE.NET
device = KeyboardSDK = new CorsairKeyboard(new CorsairKeyboardDeviceInfo(nativeDeviceInfo)); device = KeyboardSDK = new CorsairKeyboard(new CorsairKeyboardDeviceInfo(nativeDeviceInfo));
break; break;
case CorsairDeviceType.Mouse: case CorsairDeviceType.Mouse:
device = MouseSDK = new CorsairMouse(new CorsairMouseDeviceInfo(nativeDeviceInfo)); if(info.Model.ToLower().Contains("glaive"))
{
device = GlaiveSDK = new GlaiveMouse(new CorsairMouseDeviceInfo(nativeDeviceInfo));
}
else
{
device = MouseSDK = new CorsairMouse(new CorsairMouseDeviceInfo(nativeDeviceInfo));
}
break; break;
case CorsairDeviceType.Headset: case CorsairDeviceType.Headset:
device = HeadsetSDK = new CorsairHeadset(new CorsairHeadsetDeviceInfo(nativeDeviceInfo)); device = HeadsetSDK = new CorsairHeadset(new CorsairHeadsetDeviceInfo(nativeDeviceInfo));

View File

@ -262,7 +262,7 @@ namespace CUE.NET.Devices.Generic
catch (Exception ex) { OnException(ex); } catch (Exception ex) { OnException(ex); }
} }
private void UpdateLeds(ICollection<LedUpateRequest> updateRequests) protected virtual void UpdateLeds(ICollection<LedUpateRequest> updateRequests)
{ {
updateRequests = updateRequests.Where(x => x.Color != CorsairColor.Transparent).ToList(); updateRequests = updateRequests.Where(x => x.Color != CorsairColor.Transparent).ToList();

View File

@ -0,0 +1,171 @@
using CUE.NET.Devices.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HidSharp;
using System.Drawing;
using CUE.NET.Devices.Generic.Enums;
using CUE.NET.Devices.Mouse.Enums;
using CUE.NET.Exceptions;
namespace CUE.NET.Devices.Mouse
{
public class GlaiveMouse : AbstractCueDevice
{
private const int vid = 0x1b1c;
private const int pid = 0x1b34;
private HidDevice dev;
private HidStream stream;
private Color bars;
private Color front;
private Color logo;
private bool initialized = false;
public CorsairMouseDeviceInfo MouseDeviceInfo { get; }
public GlaiveMouse(CorsairMouseDeviceInfo info) : base(info)
{
this.MouseDeviceInfo = info;
}
public static GlaiveMouse FromCorsairMouse(CorsairMouse mouse)
{
return new GlaiveMouse(mouse.MouseDeviceInfo);
}
public override void Initialize()
{
var loader = new HidDeviceLoader();
dev = loader.GetDeviceOrDefault(vid, pid);
if (!dev.TryOpen(out stream)) throw new Exception("Glaive mouse init error!");
initialized = true;
switch (MouseDeviceInfo.PhysicalLayout)
{
case CorsairPhysicalMouseLayout.Zones1:
InitializeLed(CorsairMouseLedId.B1, new RectangleF(0, 0, 1, 1));
break;
case CorsairPhysicalMouseLayout.Zones2:
InitializeLed(CorsairMouseLedId.B1, new RectangleF(0, 0, 1, 1));
InitializeLed(CorsairMouseLedId.B2, new RectangleF(1, 0, 1, 1));
break;
case CorsairPhysicalMouseLayout.Zones3:
InitializeLed(CorsairMouseLedId.B1, new RectangleF(0, 0, 1, 1));
InitializeLed(CorsairMouseLedId.B2, new RectangleF(1, 0, 1, 1));
InitializeLed(CorsairMouseLedId.B3, new RectangleF(2, 0, 1, 1));
break;
case CorsairPhysicalMouseLayout.Zones4:
InitializeLed(CorsairMouseLedId.B1, new RectangleF(0, 0, 1, 1));
InitializeLed(CorsairMouseLedId.B2, new RectangleF(1, 0, 1, 1));
InitializeLed(CorsairMouseLedId.B3, new RectangleF(2, 0, 1, 1));
InitializeLed(CorsairMouseLedId.B4, new RectangleF(3, 0, 1, 1));
break;
default:
throw new WrapperException($"Can't initial mouse with layout '{MouseDeviceInfo.PhysicalLayout}'");
}
base.Initialize();
}
protected override void UpdateLeds(ICollection<LedUpateRequest> updateRequests)
{
updateRequests = updateRequests.Where(x => x.Color != CorsairColor.Transparent).ToList();
OnLedsUpdating(updateRequests);
if (updateRequests.Any()) // CUE seems to crash if 'CorsairSetLedsColors' is called with a zero length array
{
//int structSize = Marshal.SizeOf(typeof(_CorsairLedColor));
//IntPtr ptr = Marshal.AllocHGlobal(structSize * updateRequests.Count);
//IntPtr addPtr = new IntPtr(ptr.ToInt64());
//foreach (LedUpateRequest ledUpdateRequest in updateRequests)
//{
// _CorsairLedColor color = new _CorsairLedColor
// {
// ledId = (int)ledUpdateRequest.LedId,
// r = ledUpdateRequest.Color.R,
// g = ledUpdateRequest.Color.G,
// b = ledUpdateRequest.Color.B
// };
// Marshal.StructureToPtr(color, addPtr, false);
// addPtr = new IntPtr(addPtr.ToInt64() + structSize);
//}
//_CUESDK.CorsairSetLedsColors(updateRequests.Count, ptr);
//Marshal.FreeHGlobal(ptr);
foreach (LedUpateRequest ledUpdateRequest in updateRequests)
{
switch(ledUpdateRequest.LedId)
{
case CorsairLedId.B1:
logo = Color.FromArgb(ledUpdateRequest.Color.R, ledUpdateRequest.Color.G, ledUpdateRequest.Color.B);
break;
case CorsairLedId.B2:
front = Color.FromArgb(ledUpdateRequest.Color.R, ledUpdateRequest.Color.G, ledUpdateRequest.Color.B);
break;
case CorsairLedId.B3:
bars = Color.FromArgb(ledUpdateRequest.Color.R, ledUpdateRequest.Color.G, ledUpdateRequest.Color.B);
break;
default:
break;
}
}
HidUpdate();
}
OnLedsUpdated(updateRequests);
}
private void HidUpdate()
{
if (initialized)
{
byte[] buff = new byte[65];
buff[1] = 7;
buff[2] = 34;
buff[3] = 4;
buff[4] = 1;
//dpi indicator (no idea why but this crap doesnt work)
buff[5] = 3;
//if (dpiIndicator == 1 || dpiIndicator == 2 || dpiIndicator == 4)
//buff[6] = 255;
//if (dpiIndicator >= 2)
buff[7] = 255;
//if (dpiIndicator == 2 || dpiIndicator == 5)
buff[8] = 255;
//bars rgb
buff[9] = 6;
buff[10] = bars.R;
buff[11] = bars.G;
buff[12] = bars.B;
//front rgb
buff[13] = 1;
buff[14] = front.R;
buff[15] = front.G;
buff[16] = front.B;
//logo rgb
buff[17] = 2;
buff[18] = logo.R;
buff[19] = logo.G;
buff[20] = logo.B;
stream.Write(buff);
}
else throw new Exception("not initialized");
}
}
}

View File

@ -13,6 +13,7 @@ using CUE.NET.Effects;
using CUE.NET.Exceptions; using CUE.NET.Exceptions;
using CUE.NET.Gradients; using CUE.NET.Gradients;
using CUE.NET.Groups; using CUE.NET.Groups;
using CUE.NET.Devices.Mouse;
namespace SimpleDevTest namespace SimpleDevTest
{ {
@ -22,389 +23,403 @@ namespace SimpleDevTest
public static void Main(string[] args) public static void Main(string[] args)
{ {
Console.WriteLine("Press any key to exit ..."); //Console.WriteLine("Press any key to exit ...");
Console.WriteLine(); //Console.WriteLine();
Task.Factory.StartNew( //Task.Factory.StartNew(
() => // () =>
{ // {
Console.ReadKey(); // Console.ReadKey();
Environment.Exit(0); // Environment.Exit(0);
}); // });
try //try
{ //{
bool test = CueSDK.IsSDKAvailable(); // bool test = CueSDK.IsSDKAvailable();
// Initialize CUE-SDK // // Initialize CUE-SDK
CueSDK.Initialize(); // CueSDK.Initialize();
Console.WriteLine("Initialized with " + CueSDK.LoadedArchitecture + "-SDK"); // Console.WriteLine("Initialized with " + CueSDK.LoadedArchitecture + "-SDK");
CueSDK.KeyboardSDK.Brush = (SolidColorBrush)Color.Black; // CueSDK.KeyboardSDK.Brush = (SolidColorBrush)Color.Black;
//CueSDK.KeyboardSDK[CorsairLedId.Z].Color = Color.Red; // //CueSDK.KeyboardSDK[CorsairLedId.Z].Color = Color.Red;
//CueSDK.KeyboardSDK[CorsairLedId.Z].IsLocked = true; // //CueSDK.KeyboardSDK[CorsairLedId.Z].IsLocked = true;
float thirdKeyboardWidth = CueSDK.KeyboardSDK.DeviceRectangle.Width / 3f; // float thirdKeyboardWidth = CueSDK.KeyboardSDK.DeviceRectangle.Width / 3f;
ILedGroup left = new RectangleLedGroup(CueSDK.KeyboardSDK, new RectangleF(CueSDK.KeyboardSDK.DeviceRectangle.X, CueSDK.KeyboardSDK.DeviceRectangle.Y, thirdKeyboardWidth, CueSDK.KeyboardSDK.DeviceRectangle.Height)); // ILedGroup left = new RectangleLedGroup(CueSDK.KeyboardSDK, new RectangleF(CueSDK.KeyboardSDK.DeviceRectangle.X, CueSDK.KeyboardSDK.DeviceRectangle.Y, thirdKeyboardWidth, CueSDK.KeyboardSDK.DeviceRectangle.Height));
ILedGroup mid = new RectangleLedGroup(CueSDK.KeyboardSDK, new RectangleF(CueSDK.KeyboardSDK.DeviceRectangle.X + thirdKeyboardWidth, CueSDK.KeyboardSDK.DeviceRectangle.Y, thirdKeyboardWidth, CueSDK.KeyboardSDK.DeviceRectangle.Height)); // ILedGroup mid = new RectangleLedGroup(CueSDK.KeyboardSDK, new RectangleF(CueSDK.KeyboardSDK.DeviceRectangle.X + thirdKeyboardWidth, CueSDK.KeyboardSDK.DeviceRectangle.Y, thirdKeyboardWidth, CueSDK.KeyboardSDK.DeviceRectangle.Height));
ILedGroup right = new RectangleLedGroup(CueSDK.KeyboardSDK, new RectangleF(CueSDK.KeyboardSDK.DeviceRectangle.X + thirdKeyboardWidth * 2, CueSDK.KeyboardSDK.DeviceRectangle.Y, thirdKeyboardWidth, CueSDK.KeyboardSDK.DeviceRectangle.Height)); // ILedGroup right = new RectangleLedGroup(CueSDK.KeyboardSDK, new RectangleF(CueSDK.KeyboardSDK.DeviceRectangle.X + thirdKeyboardWidth * 2, CueSDK.KeyboardSDK.DeviceRectangle.Y, thirdKeyboardWidth, CueSDK.KeyboardSDK.DeviceRectangle.Height));
//CueSDK.KeyboardSDK.Brush = new LinearGradientBrush(new LinearGradient(true, new GradientStop(0, Color.Blue), new GradientStop(0.5f, Color.Red))); // //CueSDK.KeyboardSDK.Brush = new LinearGradientBrush(new LinearGradient(true, new GradientStop(0, Color.Blue), new GradientStop(0.5f, Color.Red)));
left.Brush = new ConicalGradientBrush(new PointF(0.6f, 0.7f), new RainbowGradient(360, 0)); // left.Brush = new ConicalGradientBrush(new PointF(0.6f, 0.7f), new RainbowGradient(360, 0));
left.Brush.AddEffect(new MoveGradientEffect()); // left.Brush.AddEffect(new MoveGradientEffect());
mid.Brush = new ConicalGradientBrush(new PointF(0.5f, 0.3f), new RainbowGradient()); // mid.Brush = new ConicalGradientBrush(new PointF(0.5f, 0.3f), new RainbowGradient());
mid.Brush.AddEffect(new MoveGradientEffect()); // mid.Brush.AddEffect(new MoveGradientEffect());
right.Brush = new ConicalGradientBrush(new PointF(0.4f, 0.7f), new RainbowGradient(360, 0)); // right.Brush = new ConicalGradientBrush(new PointF(0.4f, 0.7f), new RainbowGradient(360, 0));
right.Brush.AddEffect(new MoveGradientEffect()); // right.Brush.AddEffect(new MoveGradientEffect());
//float halfKeyboardWidth = CueSDK.KeyboardSDK.DeviceRectangle.Width / 2f; // //float halfKeyboardWidth = CueSDK.KeyboardSDK.DeviceRectangle.Width / 2f;
//ILedGroup left = new RectangleLedGroup(CueSDK.KeyboardSDK, new RectangleF(CueSDK.KeyboardSDK.DeviceRectangle.X, CueSDK.KeyboardSDK.DeviceRectangle.Y, halfKeyboardWidth, CueSDK.KeyboardSDK.DeviceRectangle.Height)); // //ILedGroup left = new RectangleLedGroup(CueSDK.KeyboardSDK, new RectangleF(CueSDK.KeyboardSDK.DeviceRectangle.X, CueSDK.KeyboardSDK.DeviceRectangle.Y, halfKeyboardWidth, CueSDK.KeyboardSDK.DeviceRectangle.Height));
//ILedGroup right = new RectangleLedGroup(CueSDK.KeyboardSDK, new RectangleF(CueSDK.KeyboardSDK.DeviceRectangle.X + halfKeyboardWidth, CueSDK.KeyboardSDK.DeviceRectangle.Y, halfKeyboardWidth, CueSDK.KeyboardSDK.DeviceRectangle.Height)); // //ILedGroup right = new RectangleLedGroup(CueSDK.KeyboardSDK, new RectangleF(CueSDK.KeyboardSDK.DeviceRectangle.X + halfKeyboardWidth, CueSDK.KeyboardSDK.DeviceRectangle.Y, halfKeyboardWidth, CueSDK.KeyboardSDK.DeviceRectangle.Height));
////CueSDK.KeyboardSDK.Brush = new LinearGradientBrush(new LinearGradient(true, new GradientStop(0, Color.Blue), new GradientStop(0.5f, Color.Red))); // ////CueSDK.KeyboardSDK.Brush = new LinearGradientBrush(new LinearGradient(true, new GradientStop(0, Color.Blue), new GradientStop(0.5f, Color.Red)));
//left.Brush = new ConicalGradientBrush(new PointF(0.6f, 0.6f), new RainbowGradient(360, 0)); // //left.Brush = new ConicalGradientBrush(new PointF(0.6f, 0.6f), new RainbowGradient(360, 0));
//left.Brush.AddEffect(new MoveGradientEffect()); // //left.Brush.AddEffect(new MoveGradientEffect());
//right.Brush = new ConicalGradientBrush(new PointF(0.4f, 0.6f), new RainbowGradient()); // //right.Brush = new ConicalGradientBrush(new PointF(0.4f, 0.6f), new RainbowGradient());
//right.Brush.AddEffect(new MoveGradientEffect()); // //right.Brush.AddEffect(new MoveGradientEffect());
CueSDK.UpdateMode = UpdateMode.Continuous; // CueSDK.UpdateMode = UpdateMode.Continuous;
//IBrush rainbowBrush = new LinearGradientBrush(new RainbowGradient()); // //IBrush rainbowBrush = new LinearGradientBrush(new RainbowGradient());
//rainbowBrush.AddEffect(new FlashEffect { Attack = 5f, Sustain = 1f, Decay = 0, Release = 5f, Interval = 1f }); // //rainbowBrush.AddEffect(new FlashEffect { Attack = 5f, Sustain = 1f, Decay = 0, Release = 5f, Interval = 1f });
//rainbowBrush.AddEffect(new MoveRainbowEffect()); // //rainbowBrush.AddEffect(new MoveRainbowEffect());
//rainbowBrush.AddEffect(new RemoveRedEffect()); // //rainbowBrush.AddEffect(new RemoveRedEffect());
//foreach (ICueDevice device in CueSDK.InitializedDevices) // //foreach (ICueDevice device in CueSDK.InitializedDevices)
// AddTestBrush(device, rainbowBrush); // // AddTestBrush(device, rainbowBrush);
//// Get connected keyboard or throw exception if there is no light controllable keyboard connected // //// Get connected keyboard or throw exception if there is no light controllable keyboard connected
//CorsairKeyboard keyboard = CueSDK.KeyboardSDK; // //CorsairKeyboard keyboard = CueSDK.KeyboardSDK;
//if (keyboard == null) // //if (keyboard == null)
// throw new WrapperException("No keyboard found"); // // throw new WrapperException("No keyboard found");
//const float SPEED = 100f; // mm/sec // //const float SPEED = 100f; // mm/sec
//const float BRUSH_MODE_CHANGE_TIMER = 2f; // //const float BRUSH_MODE_CHANGE_TIMER = 2f;
//Random random = new Random(); // //Random random = new Random();
//keyboard.UpdateMode = UpdateMode.Continuous; // //keyboard.UpdateMode = UpdateMode.Continuous;
//keyboard.Brush = new SolidColorBrush(Color.Black); // //keyboard.Brush = new SolidColorBrush(Color.Black);
//RectangleF spot = new RectangleF(keyboard.DeviceRectangle.Width / 2f, keyboard.DeviceRectangle.Y / 2f, 160, 80); // //RectangleF spot = new RectangleF(keyboard.DeviceRectangle.Width / 2f, keyboard.DeviceRectangle.Y / 2f, 160, 80);
//PointF target = new PointF(spot.X, spot.Y); // //PointF target = new PointF(spot.X, spot.Y);
//RectangleLedGroup spotGroup = new RectangleLedGroup(keyboard, spot) { Brush = new LinearGradientBrush(new RainbowGradient()) }; // //RectangleLedGroup spotGroup = new RectangleLedGroup(keyboard, spot) { Brush = new LinearGradientBrush(new RainbowGradient()) };
//float brushModeTimer = BRUSH_MODE_CHANGE_TIMER; // //float brushModeTimer = BRUSH_MODE_CHANGE_TIMER;
//keyboard.Updating += (sender, eventArgs) => // //keyboard.Updating += (sender, eventArgs) =>
//{ // //{
// brushModeTimer -= eventArgs.DeltaTime; // // brushModeTimer -= eventArgs.DeltaTime;
// if (brushModeTimer <= 0) // // if (brushModeTimer <= 0)
// { // // {
// spotGroup.Brush.BrushCalculationMode = spotGroup.Brush.BrushCalculationMode == BrushCalculationMode.Relative // // spotGroup.Brush.BrushCalculationMode = spotGroup.Brush.BrushCalculationMode == BrushCalculationMode.Relative
// ? BrushCalculationMode.Absolute : BrushCalculationMode.Relative; // // ? BrushCalculationMode.Absolute : BrushCalculationMode.Relative;
// brushModeTimer = BRUSH_MODE_CHANGE_TIMER + brushModeTimer; // // brushModeTimer = BRUSH_MODE_CHANGE_TIMER + brushModeTimer;
// } // // }
// if (spot.Contains(target)) // // if (spot.Contains(target))
// target = new PointF((float)(keyboard.DeviceRectangle.X + (random.NextDouble() * keyboard.DeviceRectangle.Width)), // // target = new PointF((float)(keyboard.DeviceRectangle.X + (random.NextDouble() * keyboard.DeviceRectangle.Width)),
// (float)(keyboard.DeviceRectangle.Y + (random.NextDouble() * keyboard.DeviceRectangle.Height))); // // (float)(keyboard.DeviceRectangle.Y + (random.NextDouble() * keyboard.DeviceRectangle.Height)));
// else // // else
// spot.Location = Interpolate(spot.Location, target, eventArgs.DeltaTime * SPEED); // // spot.Location = Interpolate(spot.Location, target, eventArgs.DeltaTime * SPEED);
// spotGroup.Rectangle = spot; // // spotGroup.Rectangle = spot;
//}; // //};
//CorsairMousemat mousemat = CueSDK.MousematSDK; // //CorsairMousemat mousemat = CueSDK.MousematSDK;
//mousemat.UpdateMode = UpdateMode.Continuous; // //mousemat.UpdateMode = UpdateMode.Continuous;
//// Left // //// Left
//mousemat[CorsairMousematLedId.Zone1].Color = Color.Red; // //mousemat[CorsairMousematLedId.Zone1].Color = Color.Red;
//mousemat[CorsairMousematLedId.Zone2].Color = Color.Red; // //mousemat[CorsairMousematLedId.Zone2].Color = Color.Red;
//mousemat[CorsairMousematLedId.Zone3].Color = Color.Red; // //mousemat[CorsairMousematLedId.Zone3].Color = Color.Red;
//mousemat[CorsairMousematLedId.Zone4].Color = Color.Red; // //mousemat[CorsairMousematLedId.Zone4].Color = Color.Red;
//mousemat[CorsairMousematLedId.Zone5].Color = Color.Red; // //mousemat[CorsairMousematLedId.Zone5].Color = Color.Red;
//// Bottom // //// Bottom
//mousemat[CorsairMousematLedId.Zone6].Color = Color.LawnGreen; // //mousemat[CorsairMousematLedId.Zone6].Color = Color.LawnGreen;
//mousemat[CorsairMousematLedId.Zone7].Color = Color.LawnGreen; // //mousemat[CorsairMousematLedId.Zone7].Color = Color.LawnGreen;
//mousemat[CorsairMousematLedId.Zone8].Color = Color.LawnGreen; // //mousemat[CorsairMousematLedId.Zone8].Color = Color.LawnGreen;
//mousemat[CorsairMousematLedId.Zone9].Color = Color.LawnGreen; // //mousemat[CorsairMousematLedId.Zone9].Color = Color.LawnGreen;
//mousemat[CorsairMousematLedId.Zone10].Color = Color.LawnGreen; // //mousemat[CorsairMousematLedId.Zone10].Color = Color.LawnGreen;
//// Right // //// Right
//mousemat[CorsairMousematLedId.Zone11].Color = Color.Blue; // //mousemat[CorsairMousematLedId.Zone11].Color = Color.Blue;
//mousemat[CorsairMousematLedId.Zone12].Color = Color.Blue; // //mousemat[CorsairMousematLedId.Zone12].Color = Color.Blue;
//mousemat[CorsairMousematLedId.Zone13].Color = Color.Blue; // //mousemat[CorsairMousematLedId.Zone13].Color = Color.Blue;
//mousemat[CorsairMousematLedId.Zone14].Color = Color.Blue; // //mousemat[CorsairMousematLedId.Zone14].Color = Color.Blue;
//mousemat[CorsairMousematLedId.Zone15].Color = Color.Blue; // //mousemat[CorsairMousematLedId.Zone15].Color = Color.Blue;
// Random colors to show update rate // // Random colors to show update rate
//foreach (var mousematLed in mousemat.Leds) // //foreach (var mousematLed in mousemat.Leds)
// mousematLed.Color = GetRandomRainbowColor(); // // mousematLed.Color = GetRandomRainbowColor();
//mousemat.Updating += (sender, eventArgs) => // //mousemat.Updating += (sender, eventArgs) =>
//{ // //{
// foreach (var mousematLed in mousemat.Leds) // // foreach (var mousematLed in mousemat.Leds)
// { // // {
// mousematLed.Color = ShiftColor(mousematLed.Color, 20); // // mousematLed.Color = ShiftColor(mousematLed.Color, 20);
// } // // }
//}; // //};
//keyboard.Brush = new SolidColorBrush(Color.Black); // //keyboard.Brush = new SolidColorBrush(Color.Black);
//ILedGroup group = new RectangleLedGroup(keyboard, CorsairKeyboardKeyId.F1, CorsairKeyboardKeyId.RightShift); // //ILedGroup group = new RectangleLedGroup(keyboard, CorsairKeyboardKeyId.F1, CorsairKeyboardKeyId.RightShift);
//group.Brush = new LinearGradientBrush(new RainbowGradient()); // //group.Brush = new LinearGradientBrush(new RainbowGradient());
//bool tmp = false; // //bool tmp = false;
//while (true) // //while (true)
//{ // //{
// group.Brush.BrushCalculationMode = tmp ? BrushCalculationMode.Absolute : BrushCalculationMode.Relative; // // group.Brush.BrushCalculationMode = tmp ? BrushCalculationMode.Absolute : BrushCalculationMode.Relative;
// tmp = !tmp; // // tmp = !tmp;
// keyboard.Update(); // // keyboard.Update();
// Wait(1); // // Wait(1);
//} // //}
//keyboard.Brush = new SolidColorBrush(Color.Aqua); // //keyboard.Brush = new SolidColorBrush(Color.Aqua);
//keyboard.Update(); // //keyboard.Update();
//ILedGroup specialKeyGroup = new ListLedGroup(keyboard, CorsairKeyboardKeyId.Brightness, CorsairKeyboardKeyId.WinLock); // //ILedGroup specialKeyGroup = new ListLedGroup(keyboard, CorsairKeyboardKeyId.Brightness, CorsairKeyboardKeyId.WinLock);
//specialKeyGroup.Brush = new SolidColorBrush(Color.Aqua); // //specialKeyGroup.Brush = new SolidColorBrush(Color.Aqua);
//keyboard.Update(); // //keyboard.Update();
//// Replacing the specialKeyGroup with this won't work // //// Replacing the specialKeyGroup with this won't work
//keyboard[CorsairKeyboardKeyId.Brightness].Led.Color = Color.Aqua; // //keyboard[CorsairKeyboardKeyId.Brightness].Led.Color = Color.Aqua;
//keyboard[CorsairKeyboardKeyId.Brightness].Led.IsLocked = true; // //keyboard[CorsairKeyboardKeyId.Brightness].Led.IsLocked = true;
//keyboard[CorsairKeyboardKeyId.WinLock].Led.Color = Color.Aqua; // //keyboard[CorsairKeyboardKeyId.WinLock].Led.Color = Color.Aqua;
//keyboard[CorsairKeyboardKeyId.WinLock].Led.IsLocked = true; // //keyboard[CorsairKeyboardKeyId.WinLock].Led.IsLocked = true;
//keyboard.Update(); // //keyboard.Update();
//Wait(3); // //Wait(3);
//CueSDK.Reinitialize(); // //CueSDK.Reinitialize();
////keyboard.Brush = CueProfiles.LoadProfileByID()[null]; // ////keyboard.Brush = CueProfiles.LoadProfileByID()[null];
////keyboard.Update(); // ////keyboard.Update();
//Wait(3); // //Wait(3);
//// My Profile 'K95 RGB Default 2' is all black - this could lead to different behavior than cue has since transparent isn't black in CUE.NET // //// My Profile 'K95 RGB Default 2' is all black - this could lead to different behavior than cue has since transparent isn't black in CUE.NET
//// To swap a profile like CUE does we would need to black out the keyboard before // //// To swap a profile like CUE does we would need to black out the keyboard before
//// OR work with a key group containing all keys and leave the background black - this should be always the prefered solution // //// OR work with a key group containing all keys and leave the background black - this should be always the prefered solution
//keyboard.Brush = new SolidColorBrush(Color.Black); // //keyboard.Brush = new SolidColorBrush(Color.Black);
//keyboard.Update(); // //keyboard.Update();
////keyboard.Brush = CueProfiles.LoadProfileByID()["K95 RGB Default 2"]; // ////keyboard.Brush = CueProfiles.LoadProfileByID()["K95 RGB Default 2"];
////keyboard.Update(); // ////keyboard.Update();
//Wait(3); // //Wait(3);
//ListLedGroup ledGroup = new ListLedGroup(keyboard, keyboard['R'].KeyId); // //ListLedGroup ledGroup = new ListLedGroup(keyboard, keyboard['R'].KeyId);
//ledGroup.Brush = new SolidColorBrush(Color.White); // //ledGroup.Brush = new SolidColorBrush(Color.White);
//keyboard.Update(); // //keyboard.Update();
//Wait(2); // //Wait(2);
//ledGroup.RemoveKey(keyboard['R'].KeyId); // //ledGroup.RemoveKey(keyboard['R'].KeyId);
//keyboard['R'].Led.Color = Color.Black; // //keyboard['R'].Led.Color = Color.Black;
//ledGroup.AddKey(keyboard['T'].KeyId); // //ledGroup.AddKey(keyboard['T'].KeyId);
//keyboard.Update(); // //keyboard.Update();
//Wait(10); // //Wait(10);
//return; // //return;
// --------------------------------------------------------------------------- // // ---------------------------------------------------------------------------
// First we'll look at some basic coloring // // First we'll look at some basic coloring
//Console.WriteLine("Basic color-test ..."); // //Console.WriteLine("Basic color-test ...");
//// Ink all numbers on the keypad except the '5' purple, we want that to be gray // //// Ink all numbers on the keypad except the '5' purple, we want that to be gray
//ListLedGroup purpleGroup = new RectangleLedGroup(keyboard, CorsairKeyboardKeyId.Keypad7, CorsairKeyboardKeyId.Keypad3) // //ListLedGroup purpleGroup = new RectangleLedGroup(keyboard, CorsairKeyboardKeyId.Keypad7, CorsairKeyboardKeyId.Keypad3)
//{ Brush = new SolidColorBrush(Color.Purple) } // //{ Brush = new SolidColorBrush(Color.Purple) }
//.Exclude(CorsairKeyboardKeyId.Keypad5); // //.Exclude(CorsairKeyboardKeyId.Keypad5);
//keyboard[CorsairKeyboardKeyId.Keypad5].Led.Color = Color.Gray; // //keyboard[CorsairKeyboardKeyId.Keypad5].Led.Color = Color.Gray;
//// Ink the Keys 'r', 'g', 'b' in their respective color // //// Ink the Keys 'r', 'g', 'b' in their respective color
//// The char access fails for everything except letters (SDK doesn't return a valid keyId) // //// The char access fails for everything except letters (SDK doesn't return a valid keyId)
//keyboard['R'].Led.Color = Color.Red; // //keyboard['R'].Led.Color = Color.Red;
//keyboard[CorsairKeyboardKeyId.G].Led.Color = Color.Green; // //keyboard[CorsairKeyboardKeyId.G].Led.Color = Color.Green;
//keyboard['B'].Led.Color = Color.Blue; // //keyboard['B'].Led.Color = Color.Blue;
//// Lock the 'r', 'g', 'b' keys. We want them to stay like this forever (commented since it looks quite stupid later, but feel free tu uncomment this) // //// Lock the 'r', 'g', 'b' keys. We want them to stay like this forever (commented since it looks quite stupid later, but feel free tu uncomment this)
////keyboard['R'].Led.IsLocked = true; // ////keyboard['R'].Led.IsLocked = true;
////keyboard['G'].Led.IsLocked = true; // ////keyboard['G'].Led.IsLocked = true;
////keyboard['B'].Led.IsLocked = true; // ////keyboard['B'].Led.IsLocked = true;
//// Ink the letters of 'white' white // //// Ink the letters of 'white' white
//ListLedGroup whiteGroup = new ListLedGroup(keyboard, CorsairKeyboardKeyId.W, CorsairKeyboardKeyId.H, CorsairKeyboardKeyId.I, CorsairKeyboardKeyId.T, CorsairKeyboardKeyId.E) // //ListLedGroup whiteGroup = new ListLedGroup(keyboard, CorsairKeyboardKeyId.W, CorsairKeyboardKeyId.H, CorsairKeyboardKeyId.I, CorsairKeyboardKeyId.T, CorsairKeyboardKeyId.E)
//{ Brush = new SolidColorBrush(Color.White) }; // //{ Brush = new SolidColorBrush(Color.White) };
//// Ink the keys '1' to '0' yellow // //// Ink the keys '1' to '0' yellow
//RectangleLedGroup yellowGroup = new RectangleLedGroup(keyboard, CorsairKeyboardKeyId.D1, CorsairKeyboardKeyId.D0) // //RectangleLedGroup yellowGroup = new RectangleLedGroup(keyboard, CorsairKeyboardKeyId.D1, CorsairKeyboardKeyId.D0)
//{ Brush = new SolidColorBrush(Color.Yellow) }; // //{ Brush = new SolidColorBrush(Color.Yellow) };
//// Update the keyboard to show the configured colors, (your CUE settings defines the rest) // //// Update the keyboard to show the configured colors, (your CUE settings defines the rest)
//keyboard.Update(); // //keyboard.Update();
//Wait(3); // //Wait(3);
//// Remove all the groups we created above to clear the keyboard // //// Remove all the groups we created above to clear the keyboard
//purpleGroup.Detach(); // //purpleGroup.Detach();
//whiteGroup.Detach(); // //whiteGroup.Detach();
//yellowGroup.Detach(); // //yellowGroup.Detach();
//// --------------------------------------------------------------------------- // //// ---------------------------------------------------------------------------
//// Next we add a nice linear gradient brush over the keyboard and play around with the offset of one stop // //// Next we add a nice linear gradient brush over the keyboard and play around with the offset of one stop
//Console.WriteLine("gradient-brush-test"); // //Console.WriteLine("gradient-brush-test");
//// Create our gradient stop to play with // //// Create our gradient stop to play with
//GradientStop moveableStop = new GradientStop(0, Color.FromArgb(0, 255, 0)); // //GradientStop moveableStop = new GradientStop(0, Color.FromArgb(0, 255, 0));
//// Create a basic (by default horizontal) brush ... // //// Create a basic (by default horizontal) brush ...
//LinearGradientBrush linearBrush = new LinearGradientBrush(new LinearGradient(new GradientStop(0, Color.Blue), moveableStop, new GradientStop(1f, Color.White))); // //LinearGradientBrush linearBrush = new LinearGradientBrush(new LinearGradient(new GradientStop(0, Color.Blue), moveableStop, new GradientStop(1f, Color.White)));
//// ... and add it as the keyboard background // //// ... and add it as the keyboard background
//keyboard.Brush = linearBrush; // //keyboard.Brush = linearBrush;
//// Move the brush from left to right // //// Move the brush from left to right
//for (float offset = 0; offset <= 1f; offset += 0.02f) // //for (float offset = 0; offset <= 1f; offset += 0.02f)
//{ // //{
// moveableStop.Offset = offset; // // moveableStop.Offset = offset;
// keyboard.Update(); // // keyboard.Update();
// Thread.Sleep(100); // // Thread.Sleep(100);
//} // //}
//// And back to center // //// And back to center
//for (float offset = 1f; offset >= 0.5f; offset -= 0.02f) // //for (float offset = 1f; offset >= 0.5f; offset -= 0.02f)
//{ // //{
// moveableStop.Offset = offset; // // moveableStop.Offset = offset;
// keyboard.Update(); // // keyboard.Update();
// Thread.Sleep(100); // // Thread.Sleep(100);
//} // //}
//// "Rotate" the brush (this is of course not the best implementation for this but you see the point) // //// "Rotate" the brush (this is of course not the best implementation for this but you see the point)
//for (float rotateX = 0, rotateY = 0; rotateX <= 1f; rotateX += 0.02f, rotateY = 0.04f) // //for (float rotateX = 0, rotateY = 0; rotateX <= 1f; rotateX += 0.02f, rotateY = 0.04f)
//{ // //{
// if (rotateY > 1f) // // if (rotateY > 1f)
// rotateY = 1f - (rotateY - 1f); // // rotateY = 1f - (rotateY - 1f);
// linearBrush.StartPoint = new PointF(rotateX, rotateY); // // linearBrush.StartPoint = new PointF(rotateX, rotateY);
// linearBrush.EndPoint = new PointF(1f - rotateX, 1f - rotateY); // // linearBrush.EndPoint = new PointF(1f - rotateX, 1f - rotateY);
// keyboard.Update(); // // keyboard.Update();
// Thread.Sleep(100); // // Thread.Sleep(100);
//} // //}
//Wait(2); // //Wait(2);
//// --------------------------------------------------------------------------- // //// ---------------------------------------------------------------------------
//// Time for an even better brush: rainbow // //// Time for an even better brush: rainbow
//Console.WriteLine("rainbow-test"); // //Console.WriteLine("rainbow-test");
//// Create an simple horizontal rainbow containing two times the full spectrum // //// Create an simple horizontal rainbow containing two times the full spectrum
//RainbowGradient rainbowGradient = new RainbowGradient(0, 720); // //RainbowGradient rainbowGradient = new RainbowGradient(0, 720);
//// Add the rainbow to the keyboard and perform an initial update // //// Add the rainbow to the keyboard and perform an initial update
//keyboard.Brush = new LinearGradientBrush(rainbowGradient); // //keyboard.Brush = new LinearGradientBrush(rainbowGradient);
//keyboard.Update(); // //keyboard.Update();
//// Let the rainbow move around for 10 secs // //// Let the rainbow move around for 10 secs
//for (int i = 0; i < 100; i++) // //for (int i = 0; i < 100; i++)
//{ // //{
// rainbowGradient.StartHue += 10f; // // rainbowGradient.StartHue += 10f;
// rainbowGradient.EndHue += 10f; // // rainbowGradient.EndHue += 10f;
// keyboard.Update(); // // keyboard.Update();
// Thread.Sleep(100); // // Thread.Sleep(100);
//} // //}
//Wait(2); // //Wait(2);
// --------------------------------------------------------------------------- // // ---------------------------------------------------------------------------
// Now let us move some points random over the keyboard // // Now let us move some points random over the keyboard
// Something like this could become some sort of effect // // Something like this could become some sort of effect
// Initialize needed stuff // // Initialize needed stuff
// const float SPEED = 6f; // mm/tick // // const float SPEED = 6f; // mm/tick
//Random random = new Random(); // //Random random = new Random();
//// Flash whole keyboard three times to ... well ... just to make it happen // //// Flash whole keyboard three times to ... well ... just to make it happen
//for (int i = 0; i < 3; i++) // //for (int i = 0; i < 3; i++)
//{ // //{
// keyboard.Brush = new SolidColorBrush(Color.Aquamarine); // // keyboard.Brush = new SolidColorBrush(Color.Aquamarine);
// keyboard.Update(); // // keyboard.Update();
// Thread.Sleep(160); // // Thread.Sleep(160);
// keyboard.Brush = new SolidColorBrush(Color.Black); // // keyboard.Brush = new SolidColorBrush(Color.Black);
// keyboard.Update(); // // keyboard.Update();
// Thread.Sleep(200); // // Thread.Sleep(200);
//} // //}
//// Set keyboard 'background' to black with low alpha (this will add a nice "fade" effect instead of just clearing the keyboard every frame) // //// Set keyboard 'background' to black with low alpha (this will add a nice "fade" effect instead of just clearing the keyboard every frame)
//keyboard.Brush = new SolidColorBrush(Color.FromArgb(25, 0, 0, 0)); // //keyboard.Brush = new SolidColorBrush(Color.FromArgb(25, 0, 0, 0));
//// Define how many points we have // //// Define how many points we have
//const int NUM_POINTS = 6; // //const int NUM_POINTS = 6;
//// The points we want to draw (rectangle since circles are too hard to calculate :p) // //// The points we want to draw (rectangle since circles are too hard to calculate :p)
//RectangleF[] points = new RectangleF[NUM_POINTS]; // //RectangleF[] points = new RectangleF[NUM_POINTS];
//// KeyGroups which represents our point on the keyboard // //// KeyGroups which represents our point on the keyboard
//RectangleLedGroup[] pointGroups = new RectangleLedGroup[NUM_POINTS]; // //RectangleLedGroup[] pointGroups = new RectangleLedGroup[NUM_POINTS];
//// Target of our movement // //// Target of our movement
//PointF[] targets = new PointF[NUM_POINTS]; // //PointF[] targets = new PointF[NUM_POINTS];
//// Initialize all the stuff // //// Initialize all the stuff
//for (int i = 0; i < NUM_POINTS; i++) // //for (int i = 0; i < NUM_POINTS; i++)
//{ // //{
// // Spawn our point in the top-left corner (right over G1 or on ESC depending on your keyboard) // // // Spawn our point in the top-left corner (right over G1 or on ESC depending on your keyboard)
// points[i] = new RectangleF(keyboard.KeyboardRectangle.X, keyboard.KeyboardRectangle.Y, 60, 60); // // points[i] = new RectangleF(keyboard.KeyboardRectangle.X, keyboard.KeyboardRectangle.Y, 60, 60);
// pointGroups[i] = new RectangleLedGroup(keyboard, points[i], 0.1f) { Brush = new SolidColorBrush(Color.White) }; // // pointGroups[i] = new RectangleLedGroup(keyboard, points[i], 0.1f) { Brush = new SolidColorBrush(Color.White) };
// targets[i] = new PointF(points[i].X, points[i].Y); // // targets[i] = new PointF(points[i].X, points[i].Y);
//} // //}
//// We set colors manually since white points are kinda boring (notice, that we use alpha values) // //// We set colors manually since white points are kinda boring (notice, that we use alpha values)
//pointGroups[0].Brush = new RadialGradientBrush(new LinearGradient(new GradientStop(0, Color.FromArgb(127, 255, 0, 0)), new GradientStop(0.5f, Color.FromArgb(127, 255, 0, 0)), new GradientStop(1, Color.FromArgb(0, 255, 0, 0)))); // //pointGroups[0].Brush = new RadialGradientBrush(new LinearGradient(new GradientStop(0, Color.FromArgb(127, 255, 0, 0)), new GradientStop(0.5f, Color.FromArgb(127, 255, 0, 0)), new GradientStop(1, Color.FromArgb(0, 255, 0, 0))));
//pointGroups[1].Brush = new RadialGradientBrush(new LinearGradient(new GradientStop(0, Color.FromArgb(127, 0, 255, 0)), new GradientStop(0.5f, Color.FromArgb(127, 0, 255, 0)), new GradientStop(1, Color.FromArgb(0, 0, 255, 0)))); // //pointGroups[1].Brush = new RadialGradientBrush(new LinearGradient(new GradientStop(0, Color.FromArgb(127, 0, 255, 0)), new GradientStop(0.5f, Color.FromArgb(127, 0, 255, 0)), new GradientStop(1, Color.FromArgb(0, 0, 255, 0))));
//pointGroups[2].Brush = new RadialGradientBrush(new LinearGradient(new GradientStop(0, Color.FromArgb(127, 0, 0, 255)), new GradientStop(0.5f, Color.FromArgb(127, 0, 0, 255)), new GradientStop(1, Color.FromArgb(0, 0, 0, 255)))); // //pointGroups[2].Brush = new RadialGradientBrush(new LinearGradient(new GradientStop(0, Color.FromArgb(127, 0, 0, 255)), new GradientStop(0.5f, Color.FromArgb(127, 0, 0, 255)), new GradientStop(1, Color.FromArgb(0, 0, 0, 255))));
//pointGroups[3].Brush = new RadialGradientBrush(new LinearGradient(new GradientStop(0, Color.FromArgb(127, 255, 0, 255)), new GradientStop(0.5f, Color.FromArgb(127, 255, 0, 255)), new GradientStop(1, Color.FromArgb(0, 255, 0, 255)))); // //pointGroups[3].Brush = new RadialGradientBrush(new LinearGradient(new GradientStop(0, Color.FromArgb(127, 255, 0, 255)), new GradientStop(0.5f, Color.FromArgb(127, 255, 0, 255)), new GradientStop(1, Color.FromArgb(0, 255, 0, 255))));
//pointGroups[4].Brush = new RadialGradientBrush(new LinearGradient(new GradientStop(0, Color.FromArgb(127, 255, 255, 0)), new GradientStop(0.5f, Color.FromArgb(127, 255, 255, 0)), new GradientStop(1, Color.FromArgb(0, 255, 255, 0)))); // //pointGroups[4].Brush = new RadialGradientBrush(new LinearGradient(new GradientStop(0, Color.FromArgb(127, 255, 255, 0)), new GradientStop(0.5f, Color.FromArgb(127, 255, 255, 0)), new GradientStop(1, Color.FromArgb(0, 255, 255, 0))));
//pointGroups[5].Brush = new RadialGradientBrush(new LinearGradient(new GradientStop(0, Color.FromArgb(127, 0, 255, 255)), new GradientStop(0.5f, Color.FromArgb(127, 0, 255, 255)), new GradientStop(1, Color.FromArgb(0, 0, 255, 255)))); // //pointGroups[5].Brush = new RadialGradientBrush(new LinearGradient(new GradientStop(0, Color.FromArgb(127, 0, 255, 255)), new GradientStop(0.5f, Color.FromArgb(127, 0, 255, 255)), new GradientStop(1, Color.FromArgb(0, 0, 255, 255))));
//while (true) // //while (true)
//{ // //{
// // Calculate all the points // // // Calculate all the points
// for (int i = 0; i < NUM_POINTS; i++) // // for (int i = 0; i < NUM_POINTS; i++)
// { // // {
// // Choose new target if we arrived // // // Choose new target if we arrived
// if (points[i].Contains(targets[i])) // // if (points[i].Contains(targets[i]))
// targets[i] = new PointF((float)(keyboard.KeyboardRectangle.X + (random.NextDouble() * keyboard.KeyboardRectangle.Width)), // // targets[i] = new PointF((float)(keyboard.KeyboardRectangle.X + (random.NextDouble() * keyboard.KeyboardRectangle.Width)),
// (float)(keyboard.KeyboardRectangle.Y + (random.NextDouble() * keyboard.KeyboardRectangle.Height))); // // (float)(keyboard.KeyboardRectangle.Y + (random.NextDouble() * keyboard.KeyboardRectangle.Height)));
// else // // else
// // Calculate movement // // // Calculate movement
// points[i].Location = Interpolate(points[i].Location, targets[i], SPEED); // It would be better to calculate from the center of our rectangle but the easy way is enough here // // points[i].Location = Interpolate(points[i].Location, targets[i], SPEED); // It would be better to calculate from the center of our rectangle but the easy way is enough here
// // Move our rectangle to the new position // // // Move our rectangle to the new position
// pointGroups[i].Rectangle = points[i]; // // pointGroups[i].Rectangle = points[i];
// } // // }
// // Update changed leds // // // Update changed leds
// keyboard.Update(); // // keyboard.Update();
// // 20 updates per sec should be enought for this // // // 20 updates per sec should be enought for this
// Thread.Sleep(50); // // Thread.Sleep(50);
//} // //}
} //}
catch (CUEException ex) //catch (CUEException ex)
{ //{
Console.WriteLine("CUE Exception! ErrorCode: " + Enum.GetName(typeof(CorsairError), ex.Error)); // Console.WriteLine("CUE Exception! ErrorCode: " + Enum.GetName(typeof(CorsairError), ex.Error));
} //}
catch (WrapperException ex) //catch (WrapperException ex)
{ //{
Console.WriteLine("Wrapper Exception! Message:" + ex.Message); // Console.WriteLine("Wrapper Exception! Message:" + ex.Message);
} //}
catch (Exception ex) //catch (Exception ex)
{ //{
Console.WriteLine("Exception! Message:" + ex.Message); // Console.WriteLine("Exception! Message:" + ex.Message);
} //}
while (true) //while (true)
Thread.Sleep(1000); // Don't exit after exception // Thread.Sleep(1000); // Don't exit after exception
CueSDK.Initialize();
GlaiveMouse mouse = CueSDK.GlaiveSDK;
//mouse.Initialize();
mouse[CorsairLedId.B1].Color = Color.Red;
mouse[CorsairLedId.B2].Color = Color.Green;
mouse[CorsairLedId.B3].Color = Color.Blue;
mouse.Update();
Console.ReadLine();
} }
private static void AddTestBrush(ICueDevice device, IBrush brush) private static void AddTestBrush(ICueDevice device, IBrush brush)

4
packages.config Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="HidSharp" version="1.5" targetFramework="net45" />
</packages>