1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-12 21:38:38 +00:00
This commit is contained in:
SpoinkyNL 2016-02-21 22:46:12 +01:00
commit b9e63dd0d2
4 changed files with 22 additions and 103 deletions

View File

@ -230,8 +230,7 @@
<Compile Include="Events\ToggleEnabled.cs" />
<Compile Include="Events\ChangeActiveEffect.cs" />
<Compile Include="Events\ChangeBitmap.cs" />
<Compile Include="KeyboardProviders\Corsair\K70.cs" />
<Compile Include="KeyboardProviders\Corsair\K95.cs" />
<Compile Include="KeyboardProviders\Corsair\CorsairRGB.cs" />
<Compile Include="KeyboardProviders\KeyboardProvider.cs" />
<Compile Include="KeyboardProviders\Logitech\Orion.cs" />
<Compile Include="KeyboardProviders\Logitech\Utilities\KeyboardNames.cs" />

View File

@ -1,19 +1,20 @@
using System.Drawing;
using Artemis.Utilities;
using CUE.NET;
using CUE.NET.Brushes;
using CUE.NET.Devices.Generic.Enums;
using CUE.NET.Devices.Keyboard;
using CUE.NET.Exceptions;
namespace Artemis.KeyboardProviders.Corsair
{
internal class K70 : KeyboardProvider
internal class CorsairRGB : KeyboardProvider
{
private CorsairKeyboard _keyboard;
public K70()
public CorsairRGB()
{
Name = "Corsair K70 RGB";
Name = "Corsair RGB Keyboards";
CantEnableText = "Couldn't connect to your Corsair keyboard.\n " +
"Please check your cables and/or drivers (could be outdated) and that Corsair Utility Engine is running.\n\n " +
"If needed, you can select a different keyboard in Artemis under settings.";
@ -54,8 +55,22 @@ namespace Artemis.KeyboardProviders.Corsair
/*CUE is already initialized*/
}
_keyboard = CueSDK.KeyboardSDK;
Height = 7; //(int) _keyboard.KeyboardRectangle.Height;
Width = 21; //(int) _keyboard.KeyboardRectangle.Width;
switch (_keyboard.DeviceInfo.Model)
{
case "K95 RGB":
Height = 7;
Width = 24;
break;
case "K70 RGB":
Height = 7;
Width = 21;
break;
case "Strafe RGB":
Height = 7;
Width = 22;
break;
}
// _keyboard.UpdateMode = UpdateMode.Manual;
_keyboard.Update(true);

View File

@ -1,94 +0,0 @@
using System.Drawing;
using Artemis.Utilities;
using CUE.NET;
using CUE.NET.Devices.Generic.Enums;
using CUE.NET.Devices.Keyboard;
using CUE.NET.Exceptions;
namespace Artemis.KeyboardProviders.Corsair
{
internal class K95 : KeyboardProvider
{
private CorsairKeyboard _keyboard;
public K95()
{
Name = "Corsair K95 RGB";
CantEnableText = "Couldn't connect to your Corsair keyboard.\n " +
"Please check your cables and/or drivers (could be outdated) and that Corsair Utility Engine is running.\n\n " +
"If needed, you can select a different keyboard in Artemis under settings.";
}
public override bool CanEnable()
{
try
{
CueSDK.Initialize();
}
catch (CUEException e)
{
if (e.Error == CorsairError.ServerNotFound)
return false;
throw;
}
catch (WrapperException)
{
CueSDK.Reinitialize();
return true;
}
return true;
}
/// <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 (WrapperException)
{
/*CUE is already initialized*/
}
_keyboard = CueSDK.KeyboardSDK;
Height = 7; //(int) _keyboard.KeyboardRectangle.Height;
Width = 24; //(int) _keyboard.KeyboardRectangle.Width;
// _keyboard.UpdateMode = UpdateMode.Manual;
_keyboard.Update(true);
}
public override void Disable()
{
CueSDK.Reinitialize();
}
/// <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)
{
using (
var resized = ImageUtilities.ResizeImage(bitmap,
(int) _keyboard.KeyboardRectangle.Width,
(int) _keyboard.KeyboardRectangle.Height)
)
{
foreach (var item in _keyboard.Keys)
{
var ledColor = resized.GetPixel((int) item.KeyRectangle.X, (int) item.KeyRectangle.Y);
if (ledColor == Color.FromArgb(0, 0, 0, 0))
ledColor = Color.Black;
item.Led.Color = ledColor;
}
}
_keyboard.Update(true);
}
}
}

View File

@ -12,8 +12,7 @@ namespace Artemis.KeyboardProviders
return new List<KeyboardProvider>
{
new Orion(),
new K70(),
new K95(),
new CorsairRGB(),
new BlackWidow()
};
}