mirror of
https://github.com/DarthAffe/CUE.NET.git
synced 2026-11-10 20:46:24 +00:00
Merged PR #49
This commit is contained in:
commit
8ab40180b3
20 files changed
+554
-10
No files matched your search
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using CUE.NET;
|
||||
@@ -10,6 +12,8 @@ using CUE.NET.Devices.Keyboard;
|
||||
using CUE.NET.Devices.Keyboard.Enums;
|
||||
using CUE.NET.Devices.Keyboard.Extensions;
|
||||
using CUE.NET.Devices.Keyboard.Keys;
|
||||
using CUE.NET.Devices.Mousemat;
|
||||
using CUE.NET.Devices.Mousemat.Enums;
|
||||
using CUE.NET.Exceptions;
|
||||
using CUE.NET.Gradients;
|
||||
using CUE.NET.Profiles;
|
||||
@@ -18,6 +22,8 @@ namespace SimpleDevTest
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
private static readonly Random Rand = new Random();
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Press any key to exit ...");
|
||||
@@ -70,6 +76,40 @@ namespace SimpleDevTest
|
||||
spotGroup.Rectangle = spot;
|
||||
};
|
||||
|
||||
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
|
||||
//foreach (var mousematLed in mousemat.Leds)
|
||||
// mousematLed.Color = GetRandomRainbowColor();
|
||||
|
||||
//mousemat.Updating += (sender, eventArgs) =>
|
||||
//{
|
||||
// foreach (var mousematLed in mousemat.Leds)
|
||||
// {
|
||||
// mousematLed.Color = ShiftColor(mousematLed.Color, 20);
|
||||
// }
|
||||
//};
|
||||
|
||||
//keyboard.Brush = new SolidColorBrush(Color.Black);
|
||||
//IKeyGroup group = new RectangleKeyGroup(keyboard, CorsairKeyboardKeyId.F1, CorsairKeyboardKeyId.RightShift);
|
||||
//group.Brush = new LinearGradientBrush(new RainbowGradient());
|
||||
@@ -350,5 +390,66 @@ namespace SimpleDevTest
|
||||
}
|
||||
return p2;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Comes up with a 'pure' psuedo-random color
|
||||
/// </summary>
|
||||
/// <returns>The color</returns>
|
||||
public static Color GetRandomRainbowColor()
|
||||
{
|
||||
List<int> colors = new List<int>();
|
||||
for (int i = 0; i < 3; i++)
|
||||
colors.Add(Rand.Next(0, 256));
|
||||
|
||||
int highest = colors.Max();
|
||||
int lowest = colors.Min();
|
||||
colors[colors.FindIndex(c => c == highest)] = 255;
|
||||
colors[colors.FindIndex(c => c == lowest)] = 0;
|
||||
|
||||
Color returnColor = Color.FromArgb(255, colors[0], colors[1], colors[2]);
|
||||
|
||||
return returnColor;
|
||||
}
|
||||
public static Color ShiftColor(Color c, int shiftAmount)
|
||||
{
|
||||
int newRed = c.R;
|
||||
int newGreen = c.G;
|
||||
int newBlue = c.B;
|
||||
|
||||
// Red to purple
|
||||
if (c.R == 255 && c.B < 255 && c.G == 0)
|
||||
newBlue = newBlue + shiftAmount;
|
||||
// Purple to blue
|
||||
else if (c.B == 255 && c.R > 0)
|
||||
newRed = newRed - shiftAmount;
|
||||
// Blue to light-blue
|
||||
else if (c.B == 255 && c.G < 255)
|
||||
newGreen = newGreen + shiftAmount;
|
||||
// Light-blue to green
|
||||
else if (c.G == 255 && c.B > 0)
|
||||
newBlue = newBlue - shiftAmount;
|
||||
// Green to yellow
|
||||
else if (c.G == 255 && c.R < 255)
|
||||
newRed = newRed + shiftAmount;
|
||||
// Yellow to red
|
||||
else if (c.R == 255 && c.G > 0)
|
||||
newGreen = newGreen - shiftAmount;
|
||||
|
||||
newRed = BringIntInColorRange(newRed);
|
||||
newGreen = BringIntInColorRange(newGreen);
|
||||
newBlue = BringIntInColorRange(newBlue);
|
||||
|
||||
return Color.FromArgb(c.A, newRed, newGreen, newBlue);
|
||||
}
|
||||
|
||||
private static int BringIntInColorRange(int i)
|
||||
{
|
||||
if (i < 0)
|
||||
return 0;
|
||||
if (i > 255)
|
||||
return 255;
|
||||
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -63,8 +63,8 @@
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>xcopy "$(SolutionDir)libs\x64\CUESDK_2013.dll" "$(TargetDir)x64\" /y
|
||||
xcopy "$(SolutionDir)libs\x86\CUESDK_2013.dll" "$(TargetDir)x86\" /y</PostBuildEvent>
|
||||
<PostBuildEvent>xcopy "$(SolutionDir)libs\x64\CUESDK_2015.dll" "$(TargetDir)x64\" /y
|
||||
xcopy "$(SolutionDir)libs\x86\CUESDK_2015.dll" "$(TargetDir)x86\" /y</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
||||
Reference in new issue
Block a user