mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Combined all corsair keyboards for easy use
This commit is contained in:
parent
bf9a30bea2
commit
4d5f60ac84
@ -230,8 +230,7 @@
|
|||||||
<Compile Include="Events\ToggleEnabled.cs" />
|
<Compile Include="Events\ToggleEnabled.cs" />
|
||||||
<Compile Include="Events\ChangeActiveEffect.cs" />
|
<Compile Include="Events\ChangeActiveEffect.cs" />
|
||||||
<Compile Include="Events\ChangeBitmap.cs" />
|
<Compile Include="Events\ChangeBitmap.cs" />
|
||||||
<Compile Include="KeyboardProviders\Corsair\K70.cs" />
|
<Compile Include="KeyboardProviders\Corsair\CorsairRGB.cs" />
|
||||||
<Compile Include="KeyboardProviders\Corsair\K95.cs" />
|
|
||||||
<Compile Include="KeyboardProviders\KeyboardProvider.cs" />
|
<Compile Include="KeyboardProviders\KeyboardProvider.cs" />
|
||||||
<Compile Include="KeyboardProviders\Logitech\Orion.cs" />
|
<Compile Include="KeyboardProviders\Logitech\Orion.cs" />
|
||||||
<Compile Include="KeyboardProviders\Logitech\Utilities\KeyboardNames.cs" />
|
<Compile Include="KeyboardProviders\Logitech\Utilities\KeyboardNames.cs" />
|
||||||
|
|||||||
@ -1,19 +1,20 @@
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using Artemis.Utilities;
|
using Artemis.Utilities;
|
||||||
using CUE.NET;
|
using CUE.NET;
|
||||||
|
using CUE.NET.Brushes;
|
||||||
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.Exceptions;
|
using CUE.NET.Exceptions;
|
||||||
|
|
||||||
namespace Artemis.KeyboardProviders.Corsair
|
namespace Artemis.KeyboardProviders.Corsair
|
||||||
{
|
{
|
||||||
internal class K70 : KeyboardProvider
|
internal class CorsairRGB : KeyboardProvider
|
||||||
{
|
{
|
||||||
private CorsairKeyboard _keyboard;
|
private CorsairKeyboard _keyboard;
|
||||||
|
|
||||||
public K70()
|
public CorsairRGB()
|
||||||
{
|
{
|
||||||
Name = "Corsair K70 RGB";
|
Name = "Corsair RGB Keyboards";
|
||||||
CantEnableText = "Couldn't connect to your Corsair keyboard.\n " +
|
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 " +
|
"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.";
|
"If needed, you can select a different keyboard in Artemis under settings.";
|
||||||
@ -54,8 +55,22 @@ namespace Artemis.KeyboardProviders.Corsair
|
|||||||
/*CUE is already initialized*/
|
/*CUE is already initialized*/
|
||||||
}
|
}
|
||||||
_keyboard = CueSDK.KeyboardSDK;
|
_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.UpdateMode = UpdateMode.Manual;
|
||||||
_keyboard.Update(true);
|
_keyboard.Update(true);
|
||||||
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -12,8 +12,7 @@ namespace Artemis.KeyboardProviders
|
|||||||
return new List<KeyboardProvider>
|
return new List<KeyboardProvider>
|
||||||
{
|
{
|
||||||
new Orion(),
|
new Orion(),
|
||||||
new K70(),
|
new CorsairRGB(),
|
||||||
new K95(),
|
|
||||||
new BlackWidow()
|
new BlackWidow()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user