mirror of
https://github.com/DarthAffe/CUE.NET.git
synced 2025-12-13 00:58:31 +00:00
Added small test
This commit is contained in:
parent
b392ceb6e4
commit
16c297611e
@ -6,11 +6,9 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using CUE.NET;
|
using CUE.NET;
|
||||||
using CUE.NET.Brushes;
|
using CUE.NET.Brushes;
|
||||||
|
using CUE.NET.Devices;
|
||||||
using CUE.NET.Devices.Generic.Enums;
|
using CUE.NET.Devices.Generic.Enums;
|
||||||
using CUE.NET.Devices.Keyboard;
|
using CUE.NET.Effects;
|
||||||
using CUE.NET.Devices.Keyboard.Enums;
|
|
||||||
using CUE.NET.Devices.Mousemat;
|
|
||||||
using CUE.NET.Devices.Mousemat.Enums;
|
|
||||||
using CUE.NET.Exceptions;
|
using CUE.NET.Exceptions;
|
||||||
using CUE.NET.Gradients;
|
using CUE.NET.Gradients;
|
||||||
using CUE.NET.Groups;
|
using CUE.NET.Groups;
|
||||||
@ -38,62 +36,72 @@ namespace SimpleDevTest
|
|||||||
CueSDK.Initialize();
|
CueSDK.Initialize();
|
||||||
Console.WriteLine("Initialized with " + CueSDK.LoadedArchitecture + "-SDK");
|
Console.WriteLine("Initialized with " + CueSDK.LoadedArchitecture + "-SDK");
|
||||||
|
|
||||||
// Get connected keyboard or throw exception if there is no light controllable keyboard connected
|
IBrush rainbowBrush = new LinearGradientBrush(new RainbowGradient());
|
||||||
CorsairKeyboard keyboard = CueSDK.KeyboardSDK;
|
rainbowBrush.AddEffect(new FlashEffect());
|
||||||
if (keyboard == null)
|
|
||||||
throw new WrapperException("No keyboard found");
|
|
||||||
|
|
||||||
const float SPEED = 100f; // mm/sec
|
AddTestBrush(CueSDK.KeyboardSDK, rainbowBrush);
|
||||||
const float BRUSH_MODE_CHANGE_TIMER = 2f;
|
AddTestBrush(CueSDK.MouseSDK, rainbowBrush);
|
||||||
Random random = new Random();
|
AddTestBrush(CueSDK.HeadsetSDK, rainbowBrush);
|
||||||
|
AddTestBrush(CueSDK.MousematSDK, rainbowBrush);
|
||||||
|
|
||||||
keyboard.UpdateMode = UpdateMode.Continuous;
|
Wait(10);
|
||||||
keyboard.Brush = new SolidColorBrush(Color.Black);
|
|
||||||
|
|
||||||
RectangleF spot = new RectangleF(keyboard.DeviceRectangle.Width / 2f, keyboard.DeviceRectangle.Y / 2f, 160, 80);
|
//// Get connected keyboard or throw exception if there is no light controllable keyboard connected
|
||||||
PointF target = new PointF(spot.X, spot.Y);
|
//CorsairKeyboard keyboard = CueSDK.KeyboardSDK;
|
||||||
RectangleLedGroup spotGroup = new RectangleLedGroup(keyboard, spot) { Brush = new LinearGradientBrush(new RainbowGradient()) };
|
//if (keyboard == null)
|
||||||
|
// throw new WrapperException("No keyboard found");
|
||||||
|
|
||||||
float brushModeTimer = BRUSH_MODE_CHANGE_TIMER;
|
//const float SPEED = 100f; // mm/sec
|
||||||
keyboard.Updating += (sender, eventArgs) =>
|
//const float BRUSH_MODE_CHANGE_TIMER = 2f;
|
||||||
{
|
//Random random = new Random();
|
||||||
brushModeTimer -= eventArgs.DeltaTime;
|
|
||||||
if (brushModeTimer <= 0)
|
|
||||||
{
|
|
||||||
spotGroup.Brush.BrushCalculationMode = spotGroup.Brush.BrushCalculationMode == BrushCalculationMode.Relative
|
|
||||||
? BrushCalculationMode.Absolute : BrushCalculationMode.Relative;
|
|
||||||
brushModeTimer = BRUSH_MODE_CHANGE_TIMER + brushModeTimer;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (spot.Contains(target))
|
//keyboard.UpdateMode = UpdateMode.Continuous;
|
||||||
target = new PointF((float)(keyboard.DeviceRectangle.X + (random.NextDouble() * keyboard.DeviceRectangle.Width)),
|
//keyboard.Brush = new SolidColorBrush(Color.Black);
|
||||||
(float)(keyboard.DeviceRectangle.Y + (random.NextDouble() * keyboard.DeviceRectangle.Height)));
|
|
||||||
else
|
|
||||||
spot.Location = Interpolate(spot.Location, target, eventArgs.DeltaTime * SPEED);
|
|
||||||
spotGroup.Rectangle = spot;
|
|
||||||
};
|
|
||||||
|
|
||||||
CorsairMousemat mousemat = CueSDK.MousematSDK;
|
//RectangleF spot = new RectangleF(keyboard.DeviceRectangle.Width / 2f, keyboard.DeviceRectangle.Y / 2f, 160, 80);
|
||||||
mousemat.UpdateMode = UpdateMode.Continuous;
|
//PointF target = new PointF(spot.X, spot.Y);
|
||||||
|
//RectangleLedGroup spotGroup = new RectangleLedGroup(keyboard, spot) { Brush = new LinearGradientBrush(new RainbowGradient()) };
|
||||||
|
|
||||||
// Left
|
//float brushModeTimer = BRUSH_MODE_CHANGE_TIMER;
|
||||||
mousemat[CorsairMousematLedId.Zone1].Color = Color.Red;
|
//keyboard.Updating += (sender, eventArgs) =>
|
||||||
mousemat[CorsairMousematLedId.Zone2].Color = Color.Red;
|
//{
|
||||||
mousemat[CorsairMousematLedId.Zone3].Color = Color.Red;
|
// brushModeTimer -= eventArgs.DeltaTime;
|
||||||
mousemat[CorsairMousematLedId.Zone4].Color = Color.Red;
|
// if (brushModeTimer <= 0)
|
||||||
mousemat[CorsairMousematLedId.Zone5].Color = Color.Red;
|
// {
|
||||||
// Bottom
|
// spotGroup.Brush.BrushCalculationMode = spotGroup.Brush.BrushCalculationMode == BrushCalculationMode.Relative
|
||||||
mousemat[CorsairMousematLedId.Zone6].Color = Color.LawnGreen;
|
// ? BrushCalculationMode.Absolute : BrushCalculationMode.Relative;
|
||||||
mousemat[CorsairMousematLedId.Zone7].Color = Color.LawnGreen;
|
// brushModeTimer = BRUSH_MODE_CHANGE_TIMER + brushModeTimer;
|
||||||
mousemat[CorsairMousematLedId.Zone8].Color = Color.LawnGreen;
|
// }
|
||||||
mousemat[CorsairMousematLedId.Zone9].Color = Color.LawnGreen;
|
|
||||||
mousemat[CorsairMousematLedId.Zone10].Color = Color.LawnGreen;
|
// if (spot.Contains(target))
|
||||||
// Right
|
// target = new PointF((float)(keyboard.DeviceRectangle.X + (random.NextDouble() * keyboard.DeviceRectangle.Width)),
|
||||||
mousemat[CorsairMousematLedId.Zone11].Color = Color.Blue;
|
// (float)(keyboard.DeviceRectangle.Y + (random.NextDouble() * keyboard.DeviceRectangle.Height)));
|
||||||
mousemat[CorsairMousematLedId.Zone12].Color = Color.Blue;
|
// else
|
||||||
mousemat[CorsairMousematLedId.Zone13].Color = Color.Blue;
|
// spot.Location = Interpolate(spot.Location, target, eventArgs.DeltaTime * SPEED);
|
||||||
mousemat[CorsairMousematLedId.Zone14].Color = Color.Blue;
|
// spotGroup.Rectangle = spot;
|
||||||
mousemat[CorsairMousematLedId.Zone15].Color = Color.Blue;
|
//};
|
||||||
|
|
||||||
|
//CorsairMousemat mousemat = CueSDK.MousematSDK;
|
||||||
|
//mousemat.UpdateMode = UpdateMode.Continuous;
|
||||||
|
|
||||||
|
//// Left
|
||||||
|
//mousemat[CorsairMousematLedId.Zone1].Color = Color.Red;
|
||||||
|
//mousemat[CorsairMousematLedId.Zone2].Color = Color.Red;
|
||||||
|
//mousemat[CorsairMousematLedId.Zone3].Color = Color.Red;
|
||||||
|
//mousemat[CorsairMousematLedId.Zone4].Color = Color.Red;
|
||||||
|
//mousemat[CorsairMousematLedId.Zone5].Color = Color.Red;
|
||||||
|
//// Bottom
|
||||||
|
//mousemat[CorsairMousematLedId.Zone6].Color = Color.LawnGreen;
|
||||||
|
//mousemat[CorsairMousematLedId.Zone7].Color = Color.LawnGreen;
|
||||||
|
//mousemat[CorsairMousematLedId.Zone8].Color = Color.LawnGreen;
|
||||||
|
//mousemat[CorsairMousematLedId.Zone9].Color = Color.LawnGreen;
|
||||||
|
//mousemat[CorsairMousematLedId.Zone10].Color = Color.LawnGreen;
|
||||||
|
//// Right
|
||||||
|
//mousemat[CorsairMousematLedId.Zone11].Color = Color.Blue;
|
||||||
|
//mousemat[CorsairMousematLedId.Zone12].Color = Color.Blue;
|
||||||
|
//mousemat[CorsairMousematLedId.Zone13].Color = Color.Blue;
|
||||||
|
//mousemat[CorsairMousematLedId.Zone14].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)
|
||||||
@ -366,6 +374,16 @@ namespace SimpleDevTest
|
|||||||
Thread.Sleep(1000); // Don't exit after exception
|
Thread.Sleep(1000); // Don't exit after exception
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void AddTestBrush(ICueDevice device, IBrush brush)
|
||||||
|
{
|
||||||
|
if (device == null) return;
|
||||||
|
|
||||||
|
device.UpdateMode = UpdateMode.Continuous;
|
||||||
|
device.Brush = (SolidColorBrush)Color.Black;
|
||||||
|
ILedGroup leds = new ListLedGroup(device, device);
|
||||||
|
leds.Brush = brush;
|
||||||
|
}
|
||||||
|
|
||||||
private static void Wait(int sec)
|
private static void Wait(int sec)
|
||||||
{
|
{
|
||||||
for (int i = sec; i > 0; i--)
|
for (int i = sec; i > 0; i--)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user