mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
merged Corsair providers
This commit is contained in:
commit
1ba2db0bba
@ -2,6 +2,8 @@
|
||||
using CUE.NET;
|
||||
using CUE.NET.Devices.Generic.Enums;
|
||||
using CUE.NET.Devices.Keyboard;
|
||||
using CUE.NET.Brushes;
|
||||
using CUE.NET.Devices.Keyboard.Keys;
|
||||
|
||||
namespace Artemis.KeyboardProviders.Corsair
|
||||
{
|
||||
@ -13,29 +15,55 @@ namespace Artemis.KeyboardProviders.Corsair
|
||||
{
|
||||
Name = "Corsair Gaming K70 RGB";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enables the SDK and sets updatemode to manual as well as the color of the background to black.
|
||||
/// </summary>
|
||||
public override void Enable()
|
||||
{
|
||||
try
|
||||
{
|
||||
CueSDK.Initialize();
|
||||
}
|
||||
catch (CUE.NET.Exceptions.WrapperException) {/*CUE is already initialized*/}
|
||||
_keyboard = CueSDK.KeyboardSDK;
|
||||
Height = (int)_keyboard.KeyboardRectangle.Height;
|
||||
Width = (int)_keyboard.KeyboardRectangle.Width;
|
||||
|
||||
_keyboard.UpdateMode = UpdateMode.Manual;
|
||||
_keyboard.Brush = new SolidColorBrush(Color.Black);
|
||||
_keyboard.Update(true);
|
||||
}
|
||||
|
||||
public override void Disable()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Properly resizes any size bitmap to the keyboard by creating a rectangle whose size is dependent on the bitmap size.
|
||||
/// Does not reset the color each time. Uncomment line 48 for collor reset.
|
||||
/// </summary>
|
||||
/// <param name="bitmap"></param>
|
||||
public override void DrawBitmap(Bitmap bitmap)
|
||||
{
|
||||
// TODO: Resize bitmap to keyboard's size
|
||||
//if (bitmap.Width > width || bitmap.Height > height)
|
||||
// bitmap = ResizeImage(bitmap, width, height);
|
||||
|
||||
// One way of doing this, not sure at all if it's any good
|
||||
for (var y = 0; y < bitmap.Height - 1; y++)
|
||||
for (var x = 0; x < bitmap.Width - 1; x++)
|
||||
_keyboard[new PointF(x, y)].Led.Color = bitmap.GetPixel(x, y);
|
||||
|
||||
_keyboard.Update(true);
|
||||
RectangleF[,] ledRectangles = new RectangleF[bitmap.Width, bitmap.Height];
|
||||
RectangleKeyGroup[,] ledGroups = new RectangleKeyGroup[bitmap.Width, bitmap.Height];
|
||||
//_keyboard.Brush = new SolidColorBrush(Color.Black);
|
||||
for (var x = 0; x < bitmap.Width; x++)
|
||||
{
|
||||
for (var y = 0; y < bitmap.Height; y++)
|
||||
{
|
||||
ledRectangles[x, y] = new RectangleF(_keyboard.KeyboardRectangle.X * (x * (_keyboard.KeyboardRectangle.Width / bitmap.Width / _keyboard.KeyboardRectangle.X)), _keyboard.KeyboardRectangle.Y * (y * (_keyboard.KeyboardRectangle.Height / bitmap.Height / _keyboard.KeyboardRectangle.Y)), _keyboard.KeyboardRectangle.Width / bitmap.Width, _keyboard.KeyboardRectangle.Height / bitmap.Height);
|
||||
ledGroups[x, y] = new RectangleKeyGroup(_keyboard, ledRectangles[x, y], 0.01f) { Brush = new SolidColorBrush(bitmap.GetPixel(x, y)) };
|
||||
}
|
||||
}
|
||||
_keyboard.Update();
|
||||
for (var x = 0; x < bitmap.Width; x++)
|
||||
{
|
||||
for (var y = 0; y < bitmap.Height; y++)
|
||||
{
|
||||
_keyboard.DetachKeyGroup(ledGroups[x, y]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,10 +1,9 @@
|
||||
using System.Drawing;
|
||||
using CUE.NET;
|
||||
using CUE.NET.Brushes;
|
||||
using CUE.NET.Devices.Generic.Enums;
|
||||
using CUE.NET.Devices.Keyboard;
|
||||
using CUE.NET.Brushes;
|
||||
using CUE.NET.Devices.Keyboard.Keys;
|
||||
using CUE.NET.Exceptions;
|
||||
|
||||
namespace Artemis.KeyboardProviders.Corsair
|
||||
{
|
||||
@ -18,7 +17,7 @@ namespace Artemis.KeyboardProviders.Corsair
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enables the SDK and sets updatemode to manual as well as the color of the background to black.
|
||||
/// Enables the SDK and sets updatemode to manual as well as the color of the background to black.
|
||||
/// </summary>
|
||||
public override void Enable()
|
||||
{
|
||||
@ -26,17 +25,14 @@ namespace Artemis.KeyboardProviders.Corsair
|
||||
{
|
||||
CueSDK.Initialize();
|
||||
}
|
||||
catch (WrapperException)
|
||||
{
|
||||
/*CUE is already initialized*/
|
||||
}
|
||||
catch (CUE.NET.Exceptions.WrapperException){/*CUE is already initialized*/}
|
||||
_keyboard = CueSDK.KeyboardSDK;
|
||||
Height = (int) _keyboard.KeyboardRectangle.Height;
|
||||
Width = (int) _keyboard.KeyboardRectangle.Width;
|
||||
Height = (int)_keyboard.KeyboardRectangle.Height;
|
||||
Width = (int)_keyboard.KeyboardRectangle.Width;
|
||||
|
||||
_keyboard.UpdateMode = UpdateMode.Manual;
|
||||
_keyboard.Brush = new SolidColorBrush(Color.Black);
|
||||
_keyboard.Update();
|
||||
_keyboard.Update(true);
|
||||
}
|
||||
|
||||
public override void Disable()
|
||||
@ -44,35 +40,31 @@ namespace Artemis.KeyboardProviders.Corsair
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Properly resizes any size bitmap to the keyboard by creating a rectangle whose size is dependent on the bitmap
|
||||
/// size.
|
||||
/// Does not reset the color each time. Uncomment line 48 for collor reset.
|
||||
/// Properly resizes any size bitmap to the keyboard by creating a rectangle whose size is dependent on the bitmap size.
|
||||
/// Does not reset the color each time. Uncomment line 48 for collor reset.
|
||||
/// </summary>
|
||||
/// <param name="bitmap"></param>
|
||||
public override void DrawBitmap(Bitmap bitmap)
|
||||
{
|
||||
var ledRectangles = new RectangleF[bitmap.Width, bitmap.Height];
|
||||
var ledGroups = new RectangleKeyGroup[bitmap.Width, bitmap.Height];
|
||||
{
|
||||
RectangleF[,] ledRectangles = new RectangleF[bitmap.Width, bitmap.Height];
|
||||
RectangleKeyGroup[,] ledGroups = new RectangleKeyGroup[bitmap.Width, bitmap.Height];
|
||||
//_keyboard.Brush = new SolidColorBrush(Color.Black);
|
||||
for (var x = 0 ; x < bitmap.Width; x++)
|
||||
{
|
||||
for (var y = 0; y < bitmap.Height; y++)
|
||||
{
|
||||
ledRectangles[x, y] = new RectangleF(_keyboard.KeyboardRectangle.X * (x*(_keyboard.KeyboardRectangle.Width / bitmap.Width / _keyboard.KeyboardRectangle.X)), _keyboard.KeyboardRectangle.Y*(y*(_keyboard.KeyboardRectangle.Height / bitmap.Height / _keyboard.KeyboardRectangle.Y)), _keyboard.KeyboardRectangle.Width / bitmap.Width, _keyboard.KeyboardRectangle.Height / bitmap.Height);
|
||||
ledGroups[x, y] = new RectangleKeyGroup(_keyboard, ledRectangles[x, y], 0.01f) { Brush = new SolidColorBrush(bitmap.GetPixel(x, y)) };
|
||||
}
|
||||
}
|
||||
_keyboard.Update();
|
||||
for (var x = 0; x < bitmap.Width; x++)
|
||||
{
|
||||
for (var y = 0; y < bitmap.Height; y++)
|
||||
{
|
||||
ledRectangles[x, y] =
|
||||
new RectangleF(
|
||||
_keyboard.KeyboardRectangle.X*
|
||||
(x*(_keyboard.KeyboardRectangle.Width/bitmap.Width/_keyboard.KeyboardRectangle.X)),
|
||||
_keyboard.KeyboardRectangle.Y*
|
||||
(y*(_keyboard.KeyboardRectangle.Height/bitmap.Height/_keyboard.KeyboardRectangle.Y)),
|
||||
_keyboard.KeyboardRectangle.Width/bitmap.Width,
|
||||
_keyboard.KeyboardRectangle.Height/bitmap.Height);
|
||||
ledGroups[x, y] = new RectangleKeyGroup(_keyboard, ledRectangles[x, y], 0.1f)
|
||||
{
|
||||
Brush = new SolidColorBrush(bitmap.GetPixel(x, y))
|
||||
};
|
||||
_keyboard.DetachKeyGroup(ledGroups[x, y]);
|
||||
}
|
||||
}
|
||||
_keyboard.Update(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user