From 7fc2a6e03f11b26e7c465138e84d974a7bbf593a Mon Sep 17 00:00:00 2001 From: SpoinkyNL Date: Tue, 23 Feb 2016 07:37:00 +0100 Subject: [PATCH 1/3] One more CS:GO fix --- Artemis/Artemis/Artemis.csproj | 1 + .../KeyboardProviders/Corsair/CorsairRGB.cs | 7 +++++- .../KeyboardProviders/KeyboardProvider.cs | 5 +++- .../KeyboardProviders/KeyboardRegion.cs | 18 ++++++++++++++ .../KeyboardProviders/Logitech/Orion.cs | 4 +++- .../Games/CounterStrike/CounterStrikeModel.cs | 24 ++++++------------- 6 files changed, 39 insertions(+), 20 deletions(-) create mode 100644 Artemis/Artemis/KeyboardProviders/KeyboardRegion.cs 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), From dcedb546996ba1e7fe1967b925c4a9bbf531816b Mon Sep 17 00:00:00 2001 From: Robert Beekman Date: Tue, 23 Feb 2016 07:53:16 +0100 Subject: [PATCH 2/3] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 2bb7d44e1..86a5c9962 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,10 @@ Artemis adds support for several games to a range of RGB keyboards. Besides game-support there are also a few effects for when you're not gaming. +**Download**: https://github.com/SpoinkyNL/Artemis/releases + +**FAQ**: https://github.com/SpoinkyNL/Artemis/releases/tag/1.0.0 + Some of it's basic features: * Support for multiple keyboards planned. From 61a3a64b2a451d7ddb4d3b7d2e57dcb08bb791e4 Mon Sep 17 00:00:00 2001 From: Robert Beekman Date: Tue, 23 Feb 2016 07:53:41 +0100 Subject: [PATCH 3/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 86a5c9962..34dd4cb22 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Besides game-support there are also a few effects for when you're not gaming. **Download**: https://github.com/SpoinkyNL/Artemis/releases -**FAQ**: https://github.com/SpoinkyNL/Artemis/releases/tag/1.0.0 +**FAQ**: https://github.com/SpoinkyNL/Artemis/wiki/Frequently-Asked-Questions-(FAQ) Some of it's basic features: