diff --git a/Artemis/Artemis/Artemis.csproj b/Artemis/Artemis/Artemis.csproj index 5d58be4ea..00dba2b00 100644 --- a/Artemis/Artemis/Artemis.csproj +++ b/Artemis/Artemis/Artemis.csproj @@ -329,6 +329,8 @@ + + diff --git a/Artemis/Artemis/DeviceProviders/CoolerMaster/MasterkeysProL.cs b/Artemis/Artemis/DeviceProviders/CoolerMaster/MasterkeysProL.cs index e71fc43e3..6b83f28e8 100644 --- a/Artemis/Artemis/DeviceProviders/CoolerMaster/MasterkeysProL.cs +++ b/Artemis/Artemis/DeviceProviders/CoolerMaster/MasterkeysProL.cs @@ -72,6 +72,7 @@ namespace Artemis.DeviceProviders.CoolerMaster } // Send the matrix to the keyboard + CmSdk.SetControlDevice(DEVICE_INDEX.DEV_MKeys_L); CmSdk.SetAllLedColor(matrix); } } diff --git a/Artemis/Artemis/DeviceProviders/CoolerMaster/MasterkeysProS.cs b/Artemis/Artemis/DeviceProviders/CoolerMaster/MasterkeysProS.cs index a9275316e..22bf231e0 100644 --- a/Artemis/Artemis/DeviceProviders/CoolerMaster/MasterkeysProS.cs +++ b/Artemis/Artemis/DeviceProviders/CoolerMaster/MasterkeysProS.cs @@ -72,6 +72,7 @@ namespace Artemis.DeviceProviders.CoolerMaster } // Send the matrix to the keyboard + CmSdk.SetControlDevice(DEVICE_INDEX.DEV_MKeys_S); CmSdk.SetAllLedColor(matrix); } } diff --git a/Artemis/Artemis/DeviceProviders/CoolerMaster/MastermouseProL.cs b/Artemis/Artemis/DeviceProviders/CoolerMaster/MastermouseProL.cs new file mode 100644 index 000000000..284b970f9 --- /dev/null +++ b/Artemis/Artemis/DeviceProviders/CoolerMaster/MastermouseProL.cs @@ -0,0 +1,58 @@ +using System; +using System.Drawing; +using Artemis.DeviceProviders.CoolerMaster.Utilities; +using Ninject.Extensions.Logging; + +namespace Artemis.DeviceProviders.CoolerMaster +{ + public class MastermouseProL : DeviceProvider + { + public MastermouseProL(ILogger logger) + { + Logger = logger; + Type = DeviceType.Mouse; + } + + public ILogger Logger { get; } + + public override void UpdateDevice(Bitmap bitmap) + { + // Create an empty matrix + var matrix = new COLOR_MATRIX { KeyColor = new KEY_COLOR[6, 22] }; + + // Get colors from the bitmap's center X and on 2/5th, 3/5th and 4/5th Y + var x = bitmap.Width / 2; + var y = bitmap.Width / 5; + var led1Color = bitmap.GetPixel(x, y); + var led2Color = bitmap.GetPixel(x, y * 2); + var led3Color = bitmap.GetPixel(x, y * 3); + var led4Color = bitmap.GetPixel(x, y * 4); + matrix.KeyColor[0, 0] = new KEY_COLOR(led1Color.R, led1Color.G, led1Color.B); + matrix.KeyColor[0, 1] = new KEY_COLOR(led2Color.R, led2Color.G, led2Color.B); + matrix.KeyColor[0, 2] = new KEY_COLOR(led3Color.R, led3Color.G, led3Color.B); + matrix.KeyColor[0, 3] = new KEY_COLOR(led4Color.R, led4Color.G, led4Color.B); + + // Send the matrix to the mouse + CmSdk.SetControlDevice(DEVICE_INDEX.DEV_MMouse_L); + CmSdk.SetAllLedColor(matrix); + } + + public override bool TryEnable() + { + CmSdk.SetControlDevice(DEVICE_INDEX.DEV_MMouse_L); + + // Doesn't seem reliable but better than nothing I suppose + CanUse = CmSdk.IsDevicePlug(); + if (CanUse) + CmSdk.EnableLedControl(true); + + Logger.Debug("Attempted to enable Mastermouse Pro L. CanUse: {0}", CanUse); + return CanUse; + } + + public override void Disable() + { + throw new NotSupportedException("Can only disable a keyboard"); + } + } +} diff --git a/Artemis/Artemis/DeviceProviders/CoolerMaster/MastermouseProS.cs b/Artemis/Artemis/DeviceProviders/CoolerMaster/MastermouseProS.cs new file mode 100644 index 000000000..3d1fcafc7 --- /dev/null +++ b/Artemis/Artemis/DeviceProviders/CoolerMaster/MastermouseProS.cs @@ -0,0 +1,54 @@ +using System; +using System.Drawing; +using Artemis.DeviceProviders.CoolerMaster.Utilities; +using Ninject.Extensions.Logging; + +namespace Artemis.DeviceProviders.CoolerMaster +{ + public class MastermouseProS : DeviceProvider + { + public MastermouseProS(ILogger logger) + { + Logger = logger; + Type = DeviceType.Mouse; + } + + public ILogger Logger { get; } + + public override void UpdateDevice(Bitmap bitmap) + { + // Create an empty matrix + var matrix = new COLOR_MATRIX {KeyColor = new KEY_COLOR[6, 22]}; + + // Get colors from the bitmap's center X and on 1/3rd and 2/3rd Y + var x = bitmap.Width / 2; + var y = bitmap.Width / 3; + var led1Color = bitmap.GetPixel(x, y); + var led2Color = bitmap.GetPixel(x, y * 2); + matrix.KeyColor[0, 0] = new KEY_COLOR(led1Color.R, led1Color.G, led1Color.B); + matrix.KeyColor[0, 1] = new KEY_COLOR(led2Color.R, led2Color.G, led2Color.B); + + // Send the matrix to the mouse + CmSdk.SetControlDevice(DEVICE_INDEX.DEV_MMouse_S); + CmSdk.SetAllLedColor(matrix); + } + + public override bool TryEnable() + { + CmSdk.SetControlDevice(DEVICE_INDEX.DEV_MMouse_S); + + // Doesn't seem reliable but better than nothing I suppose + CanUse = CmSdk.IsDevicePlug(); + if (CanUse) + CmSdk.EnableLedControl(true); + + Logger.Debug("Attempted to enable Mastermouse Pro S. CanUse: {0}", CanUse); + return CanUse; + } + + public override void Disable() + { + throw new NotSupportedException("Can only disable a keyboard"); + } + } +} diff --git a/Artemis/Artemis/DeviceProviders/CoolerMaster/Utilities/CMSDK.cs b/Artemis/Artemis/DeviceProviders/CoolerMaster/Utilities/CMSDK.cs index 4283e412f..f9ffc25fa 100644 --- a/Artemis/Artemis/DeviceProviders/CoolerMaster/Utilities/CMSDK.cs +++ b/Artemis/Artemis/DeviceProviders/CoolerMaster/Utilities/CMSDK.cs @@ -28,7 +28,10 @@ namespace Artemis.DeviceProviders.CoolerMaster.Utilities DEV_MKeys_S = 1, DEV_MKeys_L_White = 2, DEV_MKeys_M_White = 3, - DEV_MMouse_L = 4 + DEV_MMouse_L = 4, + DEV_MMouse_S = 5, + DEV_MKeys_M = 6, + DEV_MKeys_S_White = 7 } //Enumeration of device layout @@ -53,6 +56,7 @@ namespace Artemis.DeviceProviders.CoolerMaster.Utilities /// /// [DllImport("lib\\SDKDLL ", CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.I1)] public static extern LAYOUT_KEYBOARD GetDeviceLayout(); /// @@ -60,6 +64,7 @@ namespace Artemis.DeviceProviders.CoolerMaster.Utilities /// /// [DllImport("lib\\SDKDLL ", CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.I1)] public static extern bool IsDevicePlug(); /// @@ -68,6 +73,7 @@ namespace Artemis.DeviceProviders.CoolerMaster.Utilities /// /// [DllImport("lib\\SDKDLL ", CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.I1)] public static extern bool EnableLedControl(bool bEnable); /// @@ -80,6 +86,7 @@ namespace Artemis.DeviceProviders.CoolerMaster.Utilities /// /// [DllImport("lib\\SDKDLL ", CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.I1)] public static extern bool SetLedColor(int iRow, int iColumn, byte r, byte g, byte b); /// @@ -88,6 +95,7 @@ namespace Artemis.DeviceProviders.CoolerMaster.Utilities /// /// [DllImport("lib\\SDKDLL ", CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.I1)] public static extern bool SetAllLedColor(COLOR_MATRIX colorMatrix); } -} \ No newline at end of file +} diff --git a/Artemis/Artemis/Managers/LoopManager.cs b/Artemis/Artemis/Managers/LoopManager.cs index 31b7300c8..598bfa3b1 100644 --- a/Artemis/Artemis/Managers/LoopManager.cs +++ b/Artemis/Artemis/Managers/LoopManager.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -62,9 +63,9 @@ namespace Artemis.Managers } catch (Exception e) { -#if DEBUG - throw e; -#endif + if (Debugger.IsAttached) + throw; + _logger.Warn(e, "Exception in render loop"); } } diff --git a/Artemis/Artemis/Profiles/Layers/Animations/PulseAnimation.cs b/Artemis/Artemis/Profiles/Layers/Animations/PulseAnimation.cs index bf78ce542..e660e607b 100644 --- a/Artemis/Artemis/Profiles/Layers/Animations/PulseAnimation.cs +++ b/Artemis/Artemis/Profiles/Layers/Animations/PulseAnimation.cs @@ -15,11 +15,12 @@ namespace Artemis.Profiles.Layers.Animations public void Update(LayerModel layerModel, bool updateAnimations) { + var animationSpeed = 3.1 - layerModel.Properties.AnimationSpeed; // TODO: Generic implementation // Reset animation progress if layer wasn't drawn for 100ms if (new TimeSpan(0, 0, 0, 0, 100) < DateTime.Now - layerModel.LastRender && updateAnimations || MustExpire(layerModel)) { - _opacityTweener = new Tweener(0, 1000, 1000, Ease.Quad.InOut, LerpFuncFloat); + _opacityTweener = new Tweener(0, 1000, animationSpeed * 1000, Ease.Quad.InOut, LerpFuncFloat); _increase = true; } @@ -29,7 +30,7 @@ namespace Artemis.Profiles.Layers.Animations if (!_opacityTweener.Running && _increase) { - _opacityTweener = new Tweener(1000, 0, 1000, Ease.Quad.InOut, LerpFuncFloat); + _opacityTweener = new Tweener(1000, 0, animationSpeed * 1000, Ease.Quad.InOut, LerpFuncFloat); _increase = false; } diff --git a/Artemis/Artemis/Profiles/Layers/Models/LayerKeybindModel.cs b/Artemis/Artemis/Profiles/Layers/Models/LayerKeybindModel.cs index fe69d9430..087e506ec 100644 --- a/Artemis/Artemis/Profiles/Layers/Models/LayerKeybindModel.cs +++ b/Artemis/Artemis/Profiles/Layers/Models/LayerKeybindModel.cs @@ -88,6 +88,7 @@ namespace Artemis.Profiles.Layers.Models switch (ToggleType) { case ToggleType.EnableHeldDown: + layerModel.RenderAllowed = false; downAction = () => layerModel.RenderAllowed = true; upAction = () => layerModel.RenderAllowed = false; break; diff --git a/Artemis/Artemis/Profiles/Layers/Models/LayerModel.cs b/Artemis/Artemis/Profiles/Layers/Models/LayerModel.cs index 8ae1736f8..014cde054 100644 --- a/Artemis/Artemis/Profiles/Layers/Models/LayerModel.cs +++ b/Artemis/Artemis/Profiles/Layers/Models/LayerModel.cs @@ -21,6 +21,7 @@ namespace Artemis.Profiles.Layers.Models { Children = new ChildItemCollection(this); TweenModel = new TweenModel(this); + RenderAllowed = true; var model = Properties as KeyboardPropertiesModel; if (model != null) @@ -284,6 +285,8 @@ namespace Artemis.Profiles.Layers.Models public void SetupKeybinds() { + RenderAllowed = true; + // Clean up old keybinds RemoveKeybinds(); @@ -315,7 +318,7 @@ namespace Artemis.Profiles.Layers.Models public string Name { get; set; } public int Order { get; set; } public bool Enabled { get; set; } - public bool RenderAllowed { get; set; } = true; + public bool RenderAllowed { get; set; } public bool Expanded { get; set; } public bool IsEvent { get; set; } public LayerPropertiesModel Properties { get; set; } diff --git a/Artemis/Artemis/Properties/AssemblyInfo.cs b/Artemis/Artemis/Properties/AssemblyInfo.cs index a5cb9bb47..44b0032cb 100644 --- a/Artemis/Artemis/Properties/AssemblyInfo.cs +++ b/Artemis/Artemis/Properties/AssemblyInfo.cs @@ -12,7 +12,7 @@ using System.Windows; [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("SpoinkyNL")] [assembly: AssemblyProduct("Artemis")] -[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyCopyright("Copyright © 2017")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -53,7 +53,7 @@ using System.Windows; // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.8.2.0")] -[assembly: AssemblyFileVersion("1.8.2.0")] +[assembly: AssemblyVersion("1.9.0.0")] +[assembly: AssemblyFileVersion("1.9.0.0")] [assembly: InternalsVisibleTo("Artemis.Explorables")] diff --git a/Artemis/Artemis/ViewModels/GeneralViewModel.cs b/Artemis/Artemis/ViewModels/GeneralViewModel.cs index c32531bf1..b19fe1aa6 100644 --- a/Artemis/Artemis/ViewModels/GeneralViewModel.cs +++ b/Artemis/Artemis/ViewModels/GeneralViewModel.cs @@ -14,7 +14,8 @@ namespace Artemis.ViewModels { DisplayName = "General"; _vms = moduleViewModels.Where(m => !m.ModuleModel.IsOverlay && !m.ModuleModel.IsBoundToProcess) - .OrderBy(m => m.DisplayName).ToList(); + .OrderByDescending(m => m.DisplayName == "General profile") + .ThenBy(m => m.DisplayName).ToList(); previewManager.PreviewViewModules.Clear(); previewManager.PreviewViewModules.AddRange(moduleViewModels.Where(m => m.UsesProfileEditor)); diff --git a/Artemis/Artemis/ViewModels/Profiles/LayerKeybindViewModel.cs b/Artemis/Artemis/ViewModels/Profiles/LayerKeybindViewModel.cs index 3f81ac17e..e756c111c 100644 --- a/Artemis/Artemis/ViewModels/Profiles/LayerKeybindViewModel.cs +++ b/Artemis/Artemis/ViewModels/Profiles/LayerKeybindViewModel.cs @@ -19,6 +19,7 @@ namespace Artemis.ViewModels.Profiles { _editorViewModel = editorViewModel; LayerKeybindModel = layerKeybindModel; + CanToggleType = !editorViewModel.ProposedLayer.IsEvent; PropertyChanged += MapViewToModel; editorViewModel.PropertyChanged += EditorViewModelOnPropertyChanged; diff --git a/Artemis/Artemis/lib/SDKDLL.dll b/Artemis/Artemis/lib/SDKDLL.dll index 279981433..a71619198 100644 Binary files a/Artemis/Artemis/lib/SDKDLL.dll and b/Artemis/Artemis/lib/SDKDLL.dll differ