1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Changed keyboard height and width to adjust dynamically

This commit is contained in:
Logan Saso 2016-01-22 06:56:13 -08:00
parent 50a681d9e9
commit ec5c4d82e8
2 changed files with 59 additions and 59 deletions

View File

@ -1,22 +1,22 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14 # Visual Studio 14
VisualStudioVersion = 14.0.23107.0 VisualStudioVersion = 14.0.24720.0
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Artemis", "Artemis\Artemis.csproj", "{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Artemis", "Artemis\Artemis.csproj", "{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Debug|Any CPU.Build.0 = Debug|Any CPU {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Release|Any CPU.ActiveCfg = Release|Any CPU {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Release|Any CPU.Build.0 = Release|Any CPU {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View File

@ -1,60 +1,60 @@
using System.Drawing; using System.Drawing;
using CUE.NET; using CUE.NET;
using CUE.NET.Devices.Generic.Enums; using CUE.NET.Devices.Generic.Enums;
using CUE.NET.Devices.Keyboard; using CUE.NET.Devices.Keyboard;
using CUE.NET.Brushes; using CUE.NET.Brushes;
using CUE.NET.Devices.Keyboard.Keys; using CUE.NET.Devices.Keyboard.Keys;
namespace Artemis.KeyboardProviders.Corsair namespace Artemis.KeyboardProviders.Corsair
{ {
internal class K95 : KeyboardProvider internal class K95 : KeyboardProvider
{ {
private CorsairKeyboard _keyboard; private CorsairKeyboard _keyboard;
public K95() public K95()
{ {
Name = "Corsair Gaming K95 RGB"; Name = "Corsair Gaming K95 RGB";
} }
/// <summary> /// <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> /// </summary>
public override void Enable() public override void Enable()
{ {
try try
{ {
CueSDK.Initialize(); CueSDK.Initialize();
} }
catch (CUE.NET.Exceptions.WrapperException){/*CUE is already initialized*/} catch (CUE.NET.Exceptions.WrapperException){/*CUE is already initialized*/}
_keyboard = CueSDK.KeyboardSDK; _keyboard = CueSDK.KeyboardSDK;
_keyboard.UpdateMode = UpdateMode.Manual; _keyboard.UpdateMode = UpdateMode.Manual;
_keyboard.Brush = new SolidColorBrush(Color.Black); _keyboard.Brush = new SolidColorBrush(Color.Black);
_keyboard.Update(); _keyboard.Update();
} }
public override void Disable() public override void Disable()
{ {
} }
/// <summary> /// <summary>
/// Properly resizes any size bitmap to the keyboard by creating a rectangle whose size is dependent on the bitmap size. /// 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. /// Does not reset the color each time. Uncomment line 48 for collor reset.
/// </summary> /// </summary>
/// <param name="bitmap"></param> /// <param name="bitmap"></param>
public override void DrawBitmap(Bitmap bitmap) public override void DrawBitmap(Bitmap bitmap)
{ {
RectangleF[,] ledRectangles = new RectangleF[bitmap.Width, bitmap.Height]; RectangleF[,] ledRectangles = new RectangleF[bitmap.Width, bitmap.Height];
RectangleKeyGroup[,] ledGroups = new RectangleKeyGroup[bitmap.Width, bitmap.Height]; RectangleKeyGroup[,] ledGroups = new RectangleKeyGroup[bitmap.Width, bitmap.Height];
//_keyboard.Brush = new SolidColorBrush(Color.Black); //_keyboard.Brush = new SolidColorBrush(Color.Black);
for (var x = 0 ; x < bitmap.Width; x++) for (var x = 0 ; x < bitmap.Width; x++)
{ {
for (var y = 0; y < bitmap.Height; y++) for (var y = 0; y < bitmap.Height; y++)
{ {
ledRectangles[x, y] = new RectangleF(_keyboard.KeyboardRectangle.X * (x*(485F / bitmap.Width / _keyboard.KeyboardRectangle.X)), _keyboard.KeyboardRectangle.Y*(y*(133F / bitmap.Height / _keyboard.KeyboardRectangle.Y)), 485F / bitmap.Width, 133F / bitmap.Height); 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)) }; ledGroups[x, y] = new RectangleKeyGroup(_keyboard, ledRectangles[x, y], 0.1f) { Brush = new SolidColorBrush(bitmap.GetPixel(x, y)) };
} }
} }
_keyboard.Update(true); _keyboard.Update(true);
} }
} }
} }