diff --git a/Artemis/Artemis/Artemis base layout.png b/Artemis/Artemis/Artemis base layout.png new file mode 100644 index 000000000..62a7a4972 Binary files /dev/null and b/Artemis/Artemis/Artemis base layout.png differ diff --git a/Artemis/Artemis/Artemis.csproj b/Artemis/Artemis/Artemis.csproj index a12a530c9..349c3cfcd 100644 --- a/Artemis/Artemis/Artemis.csproj +++ b/Artemis/Artemis/Artemis.csproj @@ -368,6 +368,8 @@ TheDivisionView.xaml + + True diff --git a/Artemis/Artemis/KeyboardProviders/Corsair/CorsairRGB.cs b/Artemis/Artemis/KeyboardProviders/Corsair/CorsairRGB.cs index 5e0bf0fb8..0a95d6ff5 100644 --- a/Artemis/Artemis/KeyboardProviders/Corsair/CorsairRGB.cs +++ b/Artemis/Artemis/KeyboardProviders/Corsair/CorsairRGB.cs @@ -24,7 +24,6 @@ namespace Artemis.KeyboardProviders.Corsair "Please check your cables and/or drivers (could be outdated) and that Corsair Utility Engine is running.\n" + "In CUE, make sure \"Enable SDK\" is checked under Settings > Program.\n\n" + "If needed, you can select a different keyboard in Artemis under settings."; - KeyboardRegions = new List(); } public override bool CanEnable() @@ -74,40 +73,29 @@ namespace Artemis.KeyboardProviders.Corsair /*CUE is already initialized*/ } _keyboard = CueSDK.KeyboardSDK; - switch (_keyboard.DeviceInfo.Model) + if (_keyboard.DeviceInfo.Model == "K95 RGB") { - case "K95 RGB": - Height = 7; - Width = 25; - PreviewSettings = new PreviewSettings(626, 175, new Thickness(0, -15, 0, 0), Resources.k95); - KeyboardRegions.Add(new KeyboardRegion("TopRow", new Point(0, 1), new Point(20, 1))); - KeyboardRegions.Add(new KeyboardRegion("NumPad", new Point(21, 2), new Point(25, 7))); - KeyboardRegions.Add(new KeyboardRegion("QWER", new Point(5, 3), new Point(8, 3))); - break; - case "K70 RGB": - Height = 7; - Width = 21; - PreviewSettings = new PreviewSettings(626, 175, new Thickness(0, -15, 0, 0), Resources.k70); - KeyboardRegions.Add(new KeyboardRegion("TopRow", new Point(0, 1), new Point(18, 1))); - KeyboardRegions.Add(new KeyboardRegion("NumPad", new Point(17, 2), new Point(21, 7))); - KeyboardRegions.Add(new KeyboardRegion("QWER", new Point(2, 3), new Point(5, 3))); - break; - case "K65 RGB": - Height = 7; - Width = 18; - PreviewSettings = new PreviewSettings(626, 175, new Thickness(0, -15, 0, 0), Resources.k65); - KeyboardRegions.Add(new KeyboardRegion("TopRow", new Point(0, 1), new Point(18, 1))); - KeyboardRegions.Add(new KeyboardRegion("NumPad", new Point(17, 2), new Point(20, 7))); - KeyboardRegions.Add(new KeyboardRegion("QWER", new Point(2, 3), new Point(5, 3))); - break; - case "STRAFE RGB": - Height = 6; - Width = 22; - PreviewSettings = new PreviewSettings(626, 175, new Thickness(0, -15, 0, 0), Resources.strafe); - KeyboardRegions.Add(new KeyboardRegion("TopRow", new Point(0, 1), new Point(18, 1))); - KeyboardRegions.Add(new KeyboardRegion("NumPad", new Point(18, 2), new Point(22, 7))); - KeyboardRegions.Add(new KeyboardRegion("QWER", new Point(1, 3), new Point(4, 3))); - break; + Height = 7; + Width = 25; + PreviewSettings = new PreviewSettings(626, 175, new Thickness(0, -15, 0, 0), Resources.k95); + } + else if (_keyboard.DeviceInfo.Model == "K70 RGB") + { + Height = 7; + Width = 21; + PreviewSettings = new PreviewSettings(626, 195, new Thickness(0, -25, 0, 0), Resources.k70); + } + else if (_keyboard.DeviceInfo.Model == "K65 RGB") + { + Height = 7; + Width = 18; + PreviewSettings = new PreviewSettings(610, 240, new Thickness(0, -30, 0, 0), Resources.k65); + } + else if (_keyboard.DeviceInfo.Model == "STRAFE RGB") + { + Height = 6; + Width = 22; + PreviewSettings = new PreviewSettings(620, 215, new Thickness(0, -15, 0, 0), Resources.strafe); } } diff --git a/Artemis/Artemis/KeyboardProviders/KeyboardProvider.cs b/Artemis/Artemis/KeyboardProviders/KeyboardProvider.cs index 7917fa75c..71c0d028e 100644 --- a/Artemis/Artemis/KeyboardProviders/KeyboardProvider.cs +++ b/Artemis/Artemis/KeyboardProviders/KeyboardProvider.cs @@ -12,8 +12,6 @@ namespace Artemis.KeyboardProviders public int Width { get; set; } public string CantEnableText { get; set; } - public List KeyboardRegions { get; set; } - public PreviewSettings PreviewSettings { get; set; } public abstract bool CanEnable(); diff --git a/Artemis/Artemis/KeyboardProviders/Logitech/Orion.cs b/Artemis/Artemis/KeyboardProviders/Logitech/Orion.cs index c46fd652d..e66c9d8e1 100644 --- a/Artemis/Artemis/KeyboardProviders/Logitech/Orion.cs +++ b/Artemis/Artemis/KeyboardProviders/Logitech/Orion.cs @@ -21,12 +21,6 @@ namespace Artemis.KeyboardProviders.Logitech Height = 6; Width = 21; PreviewSettings = new PreviewSettings(540, 154, new Thickness(25, -80, 0, 0), Resources.g910); - KeyboardRegions = new List - { - new KeyboardRegion("TopRow", new Point(0, 0), new Point(18, 0)), - new KeyboardRegion("NumPad", new Point(17, 1), new Point(21, 6)), - new KeyboardRegion("QWER", new Point(2, 2), new Point(5, 2)) - }; } public override bool CanEnable() diff --git a/Artemis/Artemis/KeyboardProviders/Razer/BlackWidow.cs b/Artemis/Artemis/KeyboardProviders/Razer/BlackWidow.cs index 908f83fdb..52a930dfd 100644 --- a/Artemis/Artemis/KeyboardProviders/Razer/BlackWidow.cs +++ b/Artemis/Artemis/KeyboardProviders/Razer/BlackWidow.cs @@ -32,10 +32,6 @@ namespace Artemis.KeyboardProviders.Razer Chroma.Instance.Initialize(); Height = Constants.MaxRows; Width = Constants.MaxColumns; - - KeyboardRegions.Add(new KeyboardRegion("TopRow", new Point(0, 0), new Point(19, 0))); - KeyboardRegions.Add(new KeyboardRegion("NumPad", new Point(20, 1), new Point(23, 6))); - KeyboardRegions.Add(new KeyboardRegion("QWER", new Point(2, 2), new Point(5, 2))); } public override void Disable() diff --git a/Artemis/Artemis/Managers/EffectManager.cs b/Artemis/Artemis/Managers/EffectManager.cs index 88aa9c52e..d564cdf6c 100644 --- a/Artemis/Artemis/Managers/EffectManager.cs +++ b/Artemis/Artemis/Managers/EffectManager.cs @@ -94,13 +94,20 @@ namespace Artemis.Managers _keyboardManager.EnableLastKeyboard(); // If still null, no last keyboard, so stop. if (_keyboardManager.ActiveKeyboard == null) + { + _logger.Debug("Cancelling effect change, no LastKeyboard"); return; + } // Game models are only used if they are enabled var gameModel = effectModel as GameModel; if (gameModel != null) if (!gameModel.Enabled) + { + _logger.Debug("Cancelling effect change, provided game not enabled"); return; + } + var wasNull = false; if (ActiveEffect == null) @@ -116,13 +123,6 @@ namespace Artemis.Managers ActiveEffect = effectModel; ActiveEffect.Enable(); - - if (ActiveEffect is GameModel || ActiveEffect is ProfilePreviewModel) - return; - - // Non-game effects are stored as the new LastEffect. - General.Default.LastEffect = ActiveEffect?.Name; - General.Default.Save(); } if (loopManager != null && !loopManager.Running) @@ -132,6 +132,13 @@ namespace Artemis.Managers } _logger.Debug("Changed active effect to: {0}", effectModel.Name); + + if (ActiveEffect is GameModel || ActiveEffect is ProfilePreviewModel) + return; + + // Non-game effects are stored as the new LastEffect. + General.Default.LastEffect = ActiveEffect?.Name; + General.Default.Save(); } diff --git a/Artemis/Artemis/Managers/LoopManager.cs b/Artemis/Artemis/Managers/LoopManager.cs index 1e8d21312..a2ed94f53 100644 --- a/Artemis/Artemis/Managers/LoopManager.cs +++ b/Artemis/Artemis/Managers/LoopManager.cs @@ -135,14 +135,16 @@ namespace Artemis.Managers if (bitmap == null) return; - // Fill the bitmap's background with blackness to avoid trailing colors on some keyboards - using (var g = Graphics.FromImage(bitmap)) + // Fill the bitmap's background with black to avoid trailing colors on some keyboards + var fixedBmp = new Bitmap(bitmap.Width, bitmap.Height); + using (var g = Graphics.FromImage(fixedBmp)) { - var preFix = (Bitmap)bitmap.Clone(); g.Clear(Color.Black); - g.DrawImage(preFix, 0, 0); + g.DrawImage(bitmap, 0, 0); } + bitmap = fixedBmp; + // If it exists, send bitmap to the device _keyboardManager.ActiveKeyboard?.DrawBitmap(bitmap); diff --git a/Artemis/Artemis/Managers/MainManager.cs b/Artemis/Artemis/Managers/MainManager.cs index 256c347bd..9afa9e00e 100644 --- a/Artemis/Artemis/Managers/MainManager.cs +++ b/Artemis/Artemis/Managers/MainManager.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Threading; using Artemis.Events; using Artemis.Models; -using Artemis.Services; +using Artemis.Modules.Effects.ProfilePreview; using Artemis.Utilities.GameState; using Artemis.Utilities.Keyboard; using Artemis.Utilities.LogitechDll; @@ -126,20 +126,31 @@ namespace Artemis.Managers if (EffectManager.ActiveEffect != null) EffectManager.DisableInactiveGame(); + if (EffectManager.ActiveEffect is ProfilePreviewModel) + return; + // If the currently active effect is a no longer running game, get rid of it. var activeGame = EffectManager.ActiveEffect as GameModel; if (activeGame != null) + { if (!runningProcesses.Any(p => p.ProcessName == activeGame.ProcessName && p.HasExited == false)) + { + _logger.Info("Disabling game: {0}", activeGame.Name); EffectManager.DisableGame(activeGame); + } + } // Look for running games, stopping on the first one that's found. var newGame = EffectManager.EnabledGames - .FirstOrDefault( - g => runningProcesses.Any(p => p.ProcessName == g.ProcessName && p.HasExited == false)); + .FirstOrDefault(g => runningProcesses + .Any(p => p.ProcessName == g.ProcessName && p.HasExited == false)); // If it's not already enabled, do so. if (newGame != null && EffectManager.ActiveEffect != newGame) - EffectManager.ChangeEffect(newGame); + { + _logger.Info("Detected and enabling game: {0}", newGame.Name); + EffectManager.ChangeEffect(newGame, LoopManager); + } Thread.Sleep(1000); } diff --git a/Artemis/Artemis/Models/GameModel.cs b/Artemis/Artemis/Models/GameModel.cs index ab209277e..e0569a0a5 100644 --- a/Artemis/Artemis/Models/GameModel.cs +++ b/Artemis/Artemis/Models/GameModel.cs @@ -1,14 +1,16 @@ using Artemis.Managers; using Artemis.Models.Interfaces; using Artemis.Models.Profiles; +using Artemis.Modules.Games.RocketLeague; namespace Artemis.Models { public abstract class GameModel : EffectModel { - protected GameModel(MainManager mainManager, GameSettings settings) : base(mainManager) + protected GameModel(MainManager mainManager, GameSettings settings, IGameDataModel gameDataModel) : base(mainManager) { Settings = settings; + GameDataModel = gameDataModel; } public GameSettings Settings { get; set; } diff --git a/Artemis/Artemis/Models/Profiles/LayerDynamicPropertiesModel.cs b/Artemis/Artemis/Models/Profiles/LayerDynamicPropertiesModel.cs index c6bd07882..0ffd2bd86 100644 --- a/Artemis/Artemis/Models/Profiles/LayerDynamicPropertiesModel.cs +++ b/Artemis/Artemis/Models/Profiles/LayerDynamicPropertiesModel.cs @@ -60,7 +60,7 @@ namespace Artemis.Models.Profiles layerProp.SetValue(props, opacity); } else - layerProp.SetValue(props, (int) (percentage*(int) userProp.GetValue(userProps, null))); + layerProp.SetValue(props, percentage*(double) userProp.GetValue(userProps, null)); } private void ApplyProp(LayerPropertiesModel props, LayerPropertiesModel userProps, IGameDataModel data) diff --git a/Artemis/Artemis/Models/Profiles/LayerPropertiesModel.cs b/Artemis/Artemis/Models/Profiles/LayerPropertiesModel.cs index 4427cb7e5..745997fa1 100644 --- a/Artemis/Artemis/Models/Profiles/LayerPropertiesModel.cs +++ b/Artemis/Artemis/Models/Profiles/LayerPropertiesModel.cs @@ -11,10 +11,10 @@ namespace Artemis.Models.Profiles [XmlInclude(typeof(MatrixTransform))] public class LayerPropertiesModel { - public int X { get; set; } - public int Y { get; set; } - public int Width { get; set; } - public int Height { get; set; } + public double X { get; set; } + public double Y { get; set; } + public double Width { get; set; } + public double Height { get; set; } public double Opacity { get; set; } public bool ContainedBrush { get; set; } public LayerAnimation Animation { get; set; } diff --git a/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeModel.cs b/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeModel.cs index bae1671bc..128ffb205 100644 --- a/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeModel.cs +++ b/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeModel.cs @@ -8,7 +8,7 @@ namespace Artemis.Modules.Games.CounterStrike { public class CounterStrikeModel : GameModel { - public CounterStrikeModel(MainManager mainManager, CounterStrikeSettings settings) : base(mainManager, settings) + public CounterStrikeModel(MainManager mainManager, CounterStrikeSettings settings) : base(mainManager, settings, new CounterStrikeDataModel()) { Name = "CounterStrike"; ProcessName = "csgo"; @@ -29,7 +29,6 @@ namespace Artemis.Modules.Games.CounterStrike { Initialized = false; - GameDataModel = new CounterStrikeDataModel(); MainManager.GameStateWebServer.GameDataReceived += HandleGameData; Initialized = true; diff --git a/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeView.xaml b/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeView.xaml index 4e521d966..ac9c61744 100644 --- a/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeView.xaml +++ b/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeView.xaml @@ -3,8 +3,6 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" - xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls" xmlns:cal="http://www.caliburnproject.org" mc:Ignorable="d" d:DesignHeight="476.986" d:DesignWidth="538.772"> @@ -20,8 +18,8 @@ - +