diff --git a/Artemis/Artemis/Artemis.csproj b/Artemis/Artemis/Artemis.csproj index cf29b0eae..73d25903c 100644 --- a/Artemis/Artemis/Artemis.csproj +++ b/Artemis/Artemis/Artemis.csproj @@ -230,8 +230,7 @@ - - + diff --git a/Artemis/Artemis/KeyboardProviders/Corsair/K70.cs b/Artemis/Artemis/KeyboardProviders/Corsair/CorsairRGB.cs similarity index 79% rename from Artemis/Artemis/KeyboardProviders/Corsair/K70.cs rename to Artemis/Artemis/KeyboardProviders/Corsair/CorsairRGB.cs index bc9dbe10a..1fcc074a9 100644 --- a/Artemis/Artemis/KeyboardProviders/Corsair/K70.cs +++ b/Artemis/Artemis/KeyboardProviders/Corsair/CorsairRGB.cs @@ -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); diff --git a/Artemis/Artemis/KeyboardProviders/Corsair/K95.cs b/Artemis/Artemis/KeyboardProviders/Corsair/K95.cs deleted file mode 100644 index 0f75e574c..000000000 --- a/Artemis/Artemis/KeyboardProviders/Corsair/K95.cs +++ /dev/null @@ -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; - } - - /// - /// Enables the SDK and sets updatemode to manual as well as the color of the background to black. - /// - 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(); - } - - /// - /// 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. - /// - /// - 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); - } - } -} \ No newline at end of file diff --git a/Artemis/Artemis/KeyboardProviders/ProviderHelper.cs b/Artemis/Artemis/KeyboardProviders/ProviderHelper.cs index 01cdba72c..0e5483490 100644 --- a/Artemis/Artemis/KeyboardProviders/ProviderHelper.cs +++ b/Artemis/Artemis/KeyboardProviders/ProviderHelper.cs @@ -12,8 +12,7 @@ namespace Artemis.KeyboardProviders return new List { new Orion(), - new K70(), - new K95(), + new CorsairRGB(), new BlackWidow() }; }