diff --git a/Artemis/Artemis/Artemis.csproj b/Artemis/Artemis/Artemis.csproj index 7c1a95602..5ccd4da7e 100644 --- a/Artemis/Artemis/Artemis.csproj +++ b/Artemis/Artemis/Artemis.csproj @@ -232,6 +232,7 @@ + diff --git a/Artemis/Artemis/KeyboardProviders/Corsair/CorsairRGB.cs b/Artemis/Artemis/KeyboardProviders/Corsair/CorsairRGB.cs index 6aa6b53d0..0cd59e3bc 100644 --- a/Artemis/Artemis/KeyboardProviders/Corsair/CorsairRGB.cs +++ b/Artemis/Artemis/KeyboardProviders/Corsair/CorsairRGB.cs @@ -1,4 +1,5 @@ -using System.Drawing; +using System.Collections.Generic; +using System.Drawing; using System.Threading; using Artemis.Utilities; using CUE.NET; @@ -18,6 +19,7 @@ namespace Artemis.KeyboardProviders.Corsair 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."; + KeyboardRegions = new List(); } public override bool CanEnable() @@ -71,13 +73,16 @@ namespace Artemis.KeyboardProviders.Corsair case "K95 RGB": Height = 7; Width = 24; + KeyboardRegions.Add(new KeyboardRegion("TopRow", new Point(1, 0), new Point(1, 20))); break; case "K70 RGB": Height = 7; Width = 21; + KeyboardRegions.Add(new KeyboardRegion("TopRow", new Point(1, 0), new Point(1, 16))); break; case "Strafe RGB": Height = 7; + KeyboardRegions.Add(new KeyboardRegion("TopRow", new Point(1, 0), new Point(1, 16))); Width = 22; break; } diff --git a/Artemis/Artemis/KeyboardProviders/KeyboardProvider.cs b/Artemis/Artemis/KeyboardProviders/KeyboardProvider.cs index 460c1ab09..b2ed485ea 100644 --- a/Artemis/Artemis/KeyboardProviders/KeyboardProvider.cs +++ b/Artemis/Artemis/KeyboardProviders/KeyboardProvider.cs @@ -1,4 +1,5 @@ -using System.Drawing; +using System.Collections.Generic; +using System.Drawing; namespace Artemis.KeyboardProviders { @@ -9,6 +10,8 @@ namespace Artemis.KeyboardProviders public int Width { get; set; } public string CantEnableText { get; set; } + public List KeyboardRegions { get; set; } + public abstract bool CanEnable(); public abstract void Enable(); public abstract void Disable(); diff --git a/Artemis/Artemis/KeyboardProviders/KeyboardRegion.cs b/Artemis/Artemis/KeyboardProviders/KeyboardRegion.cs new file mode 100644 index 000000000..c72f0e92d --- /dev/null +++ b/Artemis/Artemis/KeyboardProviders/KeyboardRegion.cs @@ -0,0 +1,18 @@ +using System.Drawing; + +namespace Artemis.KeyboardProviders +{ + public class KeyboardRegion + { + public string RegionName { get; set; } + public Point TopLeft { get; set; } + public Point BottomRight { get; set; } + + public KeyboardRegion(string regionName, Point topLeft, Point bottomRight) + { + RegionName = regionName; + TopLeft = topLeft; + BottomRight = bottomRight; + } + } +} \ No newline at end of file diff --git a/Artemis/Artemis/KeyboardProviders/Logitech/Orion.cs b/Artemis/Artemis/KeyboardProviders/Logitech/Orion.cs index c6cf2f2bc..5b0ced665 100644 --- a/Artemis/Artemis/KeyboardProviders/Logitech/Orion.cs +++ b/Artemis/Artemis/KeyboardProviders/Logitech/Orion.cs @@ -1,4 +1,5 @@ -using System.Drawing; +using System.Collections.Generic; +using System.Drawing; using System.Threading; using Artemis.KeyboardProviders.Logitech.Utilities; @@ -14,6 +15,7 @@ namespace Artemis.KeyboardProviders.Logitech "If needed, you can select a different keyboard in Artemis under settings."; Height = 6; Width = 21; + KeyboardRegions = new List {new KeyboardRegion("TopRow", new Point(0, 0), new Point(0, 16))}; } public override bool CanEnable() diff --git a/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeModel.cs b/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeModel.cs index 2c8ae0461..f593815f1 100644 --- a/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeModel.cs +++ b/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeModel.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Drawing; using System.Drawing.Drawing2D; using System.Linq; +using Artemis.KeyboardProviders; using Artemis.KeyboardProviders.Corsair; using Artemis.KeyboardProviders.Logitech; using Artemis.Models; @@ -16,7 +17,7 @@ namespace Artemis.Modules.Games.CounterStrike { public class CounterStrikeModel : GameModel { - private int _ammoWidth; + private KeyboardRegion _topRow; public CounterStrikeModel(MainModel mainModel, CounterStrikeSettings settings) : base(mainModel) { @@ -47,23 +48,12 @@ namespace Artemis.Modules.Games.CounterStrike public override void Enable() { // Some keyboards have a different baseline, Corsair F-keys start at row 1 - int baseLine; - if (MainModel.ActiveKeyboard is CorsairRGB) - { - baseLine = 1; - _ammoWidth = 19; - } - else - { - baseLine = 0; - _ammoWidth = 16; - } - - AmmoRect = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, baseLine, new List(), + _topRow = MainModel.ActiveKeyboard.KeyboardRegions.First(r => r.RegionName == "TopRow"); + AmmoRect = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, _topRow.TopLeft.X, new List(), LinearGradientMode.Horizontal) {Height = Scale, ContainedBrush = false}; - TeamRect = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, baseLine + 1, new List(), + TeamRect = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, _topRow.TopLeft.X + 1, new List(), LinearGradientMode.Horizontal) {Height = MainModel.ActiveKeyboard.Height*Scale - Scale}; - EventRect = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, baseLine + 1, new List(), + EventRect = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, _topRow.TopLeft.X + 1, new List(), LinearGradientMode.Horizontal) {Height = MainModel.ActiveKeyboard.Height*Scale - Scale}; MainModel.GameStateWebServer.GameDataReceived += HandleGameData; } @@ -162,7 +152,7 @@ namespace Artemis.Modules.Games.CounterStrike return; var ammoPercentage = (int) Math.Ceiling(100.00/maxAmmo)*ammo; - AmmoRect.Width = (int) Math.Floor(_ammoWidth / 100.00*ammoPercentage)*Scale; + AmmoRect.Width = (int) Math.Floor(_topRow.BottomRight.Y / 100.00*ammoPercentage)*Scale; AmmoRect.Colors = new List { ColorHelpers.ToDrawingColor(Settings.AmmoMainColor),