1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Cleaned up ProfileEditorViewModel, added expirimental Overwatch DLL

This commit is contained in:
SpoinkyNL 2016-05-27 23:44:30 +02:00
parent d9ad83d73e
commit c80c87dce7
49 changed files with 3118 additions and 1428 deletions

View File

@ -5,6 +5,8 @@ VisualStudioVersion = 14.0.25123.0
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Artemis", "Artemis\Artemis.csproj", "{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Artemis", "Artemis\Artemis.csproj", "{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Razer2Artemis", "Razer2Artemis\Razer2Artemis.vcxproj", "{39711909-C1D5-46CE-A9EA-2D561692EA47}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
CD_ROM|Any CPU = CD_ROM|Any CPU CD_ROM|Any CPU = CD_ROM|Any CPU
@ -54,6 +56,34 @@ Global
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.SingleImage|x64.Build.0 = Release|x64 {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.SingleImage|x64.Build.0 = Release|x64
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.SingleImage|x86.ActiveCfg = Release|x86 {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.SingleImage|x86.ActiveCfg = Release|x86
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.SingleImage|x86.Build.0 = Release|x86 {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.SingleImage|x86.Build.0 = Release|x86
{39711909-C1D5-46CE-A9EA-2D561692EA47}.CD_ROM|Any CPU.ActiveCfg = Release|x64
{39711909-C1D5-46CE-A9EA-2D561692EA47}.CD_ROM|Any CPU.Build.0 = Release|x64
{39711909-C1D5-46CE-A9EA-2D561692EA47}.CD_ROM|x64.ActiveCfg = Release|x64
{39711909-C1D5-46CE-A9EA-2D561692EA47}.CD_ROM|x64.Build.0 = Release|x64
{39711909-C1D5-46CE-A9EA-2D561692EA47}.CD_ROM|x86.ActiveCfg = Release|Win32
{39711909-C1D5-46CE-A9EA-2D561692EA47}.CD_ROM|x86.Build.0 = Release|Win32
{39711909-C1D5-46CE-A9EA-2D561692EA47}.Debug|Any CPU.ActiveCfg = Debug|Win32
{39711909-C1D5-46CE-A9EA-2D561692EA47}.Debug|x64.ActiveCfg = Debug|x64
{39711909-C1D5-46CE-A9EA-2D561692EA47}.Debug|x64.Build.0 = Debug|x64
{39711909-C1D5-46CE-A9EA-2D561692EA47}.Debug|x86.ActiveCfg = Debug|Win32
{39711909-C1D5-46CE-A9EA-2D561692EA47}.Debug|x86.Build.0 = Debug|Win32
{39711909-C1D5-46CE-A9EA-2D561692EA47}.DVD-5|Any CPU.ActiveCfg = Release|x64
{39711909-C1D5-46CE-A9EA-2D561692EA47}.DVD-5|Any CPU.Build.0 = Release|x64
{39711909-C1D5-46CE-A9EA-2D561692EA47}.DVD-5|x64.ActiveCfg = Debug|x64
{39711909-C1D5-46CE-A9EA-2D561692EA47}.DVD-5|x64.Build.0 = Debug|x64
{39711909-C1D5-46CE-A9EA-2D561692EA47}.DVD-5|x86.ActiveCfg = Debug|Win32
{39711909-C1D5-46CE-A9EA-2D561692EA47}.DVD-5|x86.Build.0 = Debug|Win32
{39711909-C1D5-46CE-A9EA-2D561692EA47}.Release|Any CPU.ActiveCfg = Release|Win32
{39711909-C1D5-46CE-A9EA-2D561692EA47}.Release|x64.ActiveCfg = Release|x64
{39711909-C1D5-46CE-A9EA-2D561692EA47}.Release|x64.Build.0 = Release|x64
{39711909-C1D5-46CE-A9EA-2D561692EA47}.Release|x86.ActiveCfg = Release|Win32
{39711909-C1D5-46CE-A9EA-2D561692EA47}.Release|x86.Build.0 = Release|Win32
{39711909-C1D5-46CE-A9EA-2D561692EA47}.SingleImage|Any CPU.ActiveCfg = Release|x64
{39711909-C1D5-46CE-A9EA-2D561692EA47}.SingleImage|Any CPU.Build.0 = Release|x64
{39711909-C1D5-46CE-A9EA-2D561692EA47}.SingleImage|x64.ActiveCfg = Release|x64
{39711909-C1D5-46CE-A9EA-2D561692EA47}.SingleImage|x64.Build.0 = Release|x64
{39711909-C1D5-46CE-A9EA-2D561692EA47}.SingleImage|x86.ActiveCfg = Release|Win32
{39711909-C1D5-46CE-A9EA-2D561692EA47}.SingleImage|x86.Build.0 = Release|Win32
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Security.Principal;
using System.Windows; using System.Windows;
using System.Windows.Threading; using System.Windows.Threading;
using Artemis.Utilities; using Artemis.Utilities;
@ -14,12 +15,20 @@ namespace Artemis
{ {
public App() public App()
{ {
if (!GeneralHelpers.IsRunAsAdministrator()) if (!IsRunAsAdministrator())
GeneralHelpers.RunAsAdministrator(); GeneralHelpers.RunAsAdministrator();
InitializeComponent(); InitializeComponent();
} }
private static bool IsRunAsAdministrator()
{
var wi = WindowsIdentity.GetCurrent();
var wp = new WindowsPrincipal(wi);
return wp.IsInRole(WindowsBuiltInRole.Administrator);
}
public bool DoHandle { get; set; } public bool DoHandle { get; set; }
private void Application_Startup(object sender, StartupEventArgs e) private void Application_Startup(object sender, StartupEventArgs e)

View File

@ -464,17 +464,18 @@
<Compile Include="Modules\Games\Dota2\Dota2ViewModel.cs" /> <Compile Include="Modules\Games\Dota2\Dota2ViewModel.cs" />
<Compile Include="Modules\Games\RocketLeague\RocketLeagueViewModel.cs" /> <Compile Include="Modules\Games\RocketLeague\RocketLeagueViewModel.cs" />
<Compile Include="Modules\Games\Witcher3\Witcher3ViewModel.cs" /> <Compile Include="Modules\Games\Witcher3\Witcher3ViewModel.cs" />
<Compile Include="ViewModels\LayerEditor\Properties\KeyboardPropertiesViewModel.cs" /> <Compile Include="ViewModels\Profiles\ProfileViewModel.cs" />
<Compile Include="ViewModels\LayerEditor\LayerConditionViewModel.cs" /> <Compile Include="ViewModels\Profiles\Properties\KeyboardPropertiesViewModel.cs" />
<Compile Include="ViewModels\LayerEditor\LayerDynamicPropertiesViewModel.cs" /> <Compile Include="ViewModels\Profiles\LayerConditionViewModel.cs" />
<Compile Include="ViewModels\LayerEditor\LayerEditorViewModel.cs" /> <Compile Include="ViewModels\Profiles\LayerDynamicPropertiesViewModel.cs" />
<Compile Include="ViewModels\LayerEditor\Properties\LayerPropertiesViewModel.cs" /> <Compile Include="ViewModels\Profiles\LayerEditorViewModel.cs" />
<Compile Include="ViewModels\LayerEditor\Properties\HeadsetPropertiesViewModel.cs" /> <Compile Include="ViewModels\Profiles\Properties\LayerPropertiesViewModel.cs" />
<Compile Include="ViewModels\LayerEditor\Properties\FolderPropertiesViewModel.cs" /> <Compile Include="ViewModels\Profiles\Properties\HeadsetPropertiesViewModel.cs" />
<Compile Include="ViewModels\LayerEditor\Properties\MousePropertiesViewModel.cs" /> <Compile Include="ViewModels\Profiles\Properties\FolderPropertiesViewModel.cs" />
<Compile Include="ViewModels\Profiles\Properties\MousePropertiesViewModel.cs" />
<Compile Include="ViewModels\OverlaysViewModel.cs" /> <Compile Include="ViewModels\OverlaysViewModel.cs" />
<Compile Include="Modules\Overlays\VolumeDisplay\VolumeDisplayViewModel.cs" /> <Compile Include="Modules\Overlays\VolumeDisplay\VolumeDisplayViewModel.cs" />
<Compile Include="ViewModels\ProfileEditorViewModel.cs" /> <Compile Include="ViewModels\Profiles\ProfileEditorViewModel.cs" />
<Compile Include="ViewModels\ShellViewModel.cs" /> <Compile Include="ViewModels\ShellViewModel.cs" />
<Compile Include="ViewModels\SystemTrayViewModel.cs" /> <Compile Include="ViewModels\SystemTrayViewModel.cs" />
<Compile Include="ViewModels\WelcomeViewModel.cs" /> <Compile Include="ViewModels\WelcomeViewModel.cs" />
@ -508,25 +509,25 @@
<Compile Include="Modules\Games\Witcher3\Witcher3View.xaml.cs"> <Compile Include="Modules\Games\Witcher3\Witcher3View.xaml.cs">
<DependentUpon>Witcher3View.xaml</DependentUpon> <DependentUpon>Witcher3View.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Views\LayerEditor\Properties\FolderPropertiesView.xaml.cs"> <Compile Include="Views\Profiles\Properties\FolderPropertiesView.xaml.cs">
<DependentUpon>FolderPropertiesView.xaml</DependentUpon> <DependentUpon>FolderPropertiesView.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Views\LayerEditor\Properties\HeadsetPropertiesView.xaml.cs"> <Compile Include="Views\Profiles\Properties\HeadsetPropertiesView.xaml.cs">
<DependentUpon>HeadsetPropertiesView.xaml</DependentUpon> <DependentUpon>HeadsetPropertiesView.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Views\LayerEditor\Properties\KeyboardPropertiesView.xaml.cs"> <Compile Include="Views\Profiles\Properties\KeyboardPropertiesView.xaml.cs">
<DependentUpon>KeyboardPropertiesView.xaml</DependentUpon> <DependentUpon>KeyboardPropertiesView.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Views\LayerEditor\LayerConditionView.xaml.cs"> <Compile Include="Views\Profiles\LayerConditionView.xaml.cs">
<DependentUpon>LayerConditionView.xaml</DependentUpon> <DependentUpon>LayerConditionView.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Views\LayerEditor\LayerDynamicPropertiesView.xaml.cs"> <Compile Include="Views\Profiles\LayerDynamicPropertiesView.xaml.cs">
<DependentUpon>LayerDynamicPropertiesView.xaml</DependentUpon> <DependentUpon>LayerDynamicPropertiesView.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Views\LayerEditor\LayerEditorView.xaml.cs"> <Compile Include="Views\Profiles\LayerEditorView.xaml.cs">
<DependentUpon>LayerEditorView.xaml</DependentUpon> <DependentUpon>LayerEditorView.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Views\LayerEditor\Properties\MousePropertiesView.xaml.cs"> <Compile Include="Views\Profiles\Properties\MousePropertiesView.xaml.cs">
<DependentUpon>MousePropertiesView.xaml</DependentUpon> <DependentUpon>MousePropertiesView.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Views\OverlaysView.xaml.cs"> <Compile Include="Views\OverlaysView.xaml.cs">
@ -535,7 +536,7 @@
<Compile Include="Modules\Overlays\VolumeDisplay\VolumeDisplayView.xaml.cs"> <Compile Include="Modules\Overlays\VolumeDisplay\VolumeDisplayView.xaml.cs">
<DependentUpon>VolumeDisplayView.xaml</DependentUpon> <DependentUpon>VolumeDisplayView.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Views\ProfileEditorView.xaml.cs"> <Compile Include="Views\Profiles\ProfileEditorView.xaml.cs">
<DependentUpon>ProfileEditorView.xaml</DependentUpon> <DependentUpon>ProfileEditorView.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Views\ShellView.xaml.cs"> <Compile Include="Views\ShellView.xaml.cs">
@ -696,31 +697,31 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Views\LayerEditor\Properties\FolderPropertiesView.xaml"> <Page Include="Views\Profiles\Properties\FolderPropertiesView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Views\LayerEditor\Properties\HeadsetPropertiesView.xaml"> <Page Include="Views\Profiles\Properties\HeadsetPropertiesView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Views\LayerEditor\Properties\KeyboardPropertiesView.xaml"> <Page Include="Views\Profiles\Properties\KeyboardPropertiesView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Views\LayerEditor\LayerConditionView.xaml"> <Page Include="Views\Profiles\LayerConditionView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Views\LayerEditor\LayerDynamicPropertiesView.xaml"> <Page Include="Views\Profiles\LayerDynamicPropertiesView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Views\LayerEditor\LayerEditorView.xaml"> <Page Include="Views\Profiles\LayerEditorView.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
<Page Include="Views\LayerEditor\Properties\MousePropertiesView.xaml"> <Page Include="Views\Profiles\Properties\MousePropertiesView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
@ -732,7 +733,7 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Views\ProfileEditorView.xaml"> <Page Include="Views\Profiles\ProfileEditorView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>

View File

@ -1,6 +1,7 @@
using Artemis.Managers; using Artemis.Managers;
using Artemis.Models; using Artemis.Models;
using Artemis.ViewModels; using Artemis.ViewModels;
using Artemis.ViewModels.Profiles;
using Caliburn.Micro; using Caliburn.Micro;
namespace Artemis.InjectionFactories namespace Artemis.InjectionFactories

View File

@ -20,6 +20,8 @@ namespace Artemis.InjectionModules
{ {
public override void Load() public override void Load()
{ {
#region Modules
// Effects // Effects
Bind<EffectViewModel>().To<AudioVisualizerViewModel>().InSingletonScope(); Bind<EffectViewModel>().To<AudioVisualizerViewModel>().InSingletonScope();
Bind<EffectViewModel>().To<DebugEffectViewModel>().InSingletonScope(); Bind<EffectViewModel>().To<DebugEffectViewModel>().InSingletonScope();
@ -36,7 +38,10 @@ namespace Artemis.InjectionModules
// Overlays // Overlays
Bind<OverlayViewModel>().To<VolumeDisplayViewModel>().InSingletonScope(); Bind<OverlayViewModel>().To<VolumeDisplayViewModel>().InSingletonScope();
// Device Providers #endregion
#region Devices
// Keyboards // Keyboards
Bind<DeviceProvider>().To<CorsairRGB>().InSingletonScope(); Bind<DeviceProvider>().To<CorsairRGB>().InSingletonScope();
Bind<DeviceProvider>().To<Orion>().InSingletonScope(); Bind<DeviceProvider>().To<Orion>().InSingletonScope();
@ -45,6 +50,8 @@ namespace Artemis.InjectionModules
Bind<DeviceProvider>().To<CorsairMice>().InSingletonScope(); Bind<DeviceProvider>().To<CorsairMice>().InSingletonScope();
// Headsets // Headsets
Bind<DeviceProvider>().To<CorsairHeadsets>().InSingletonScope(); Bind<DeviceProvider>().To<CorsairHeadsets>().InSingletonScope();
#endregion
} }
} }
} }

View File

@ -3,6 +3,7 @@ using Artemis.Modules.Effects.ProfilePreview;
using Artemis.Services; using Artemis.Services;
using Artemis.ViewModels; using Artemis.ViewModels;
using Artemis.ViewModels.Abstract; using Artemis.ViewModels.Abstract;
using Artemis.ViewModels.Profiles;
using Caliburn.Micro; using Caliburn.Micro;
using Ninject.Extensions.Factory; using Ninject.Extensions.Factory;
using Ninject.Modules; using Ninject.Modules;
@ -16,6 +17,7 @@ namespace Artemis.InjectionModules
// ViewModels // ViewModels
Bind<IScreen>().To<ShellViewModel>().InSingletonScope(); Bind<IScreen>().To<ShellViewModel>().InSingletonScope();
Bind<IProfileEditorViewModelFactory>().ToFactory(); Bind<IProfileEditorViewModelFactory>().ToFactory();
Bind<ProfileViewModel>().ToSelf();
Bind<BaseViewModel>().To<WelcomeViewModel>().InSingletonScope(); Bind<BaseViewModel>().To<WelcomeViewModel>().InSingletonScope();
Bind<BaseViewModel>().To<EffectsViewModel>().InSingletonScope(); Bind<BaseViewModel>().To<EffectsViewModel>().InSingletonScope();

View File

@ -3,6 +3,7 @@ using System.Linq;
using System.Timers; using System.Timers;
using Artemis.Models; using Artemis.Models;
using Artemis.Modules.Effects.ProfilePreview; using Artemis.Modules.Effects.ProfilePreview;
using Artemis.Settings;
using Artemis.ViewModels.Abstract; using Artemis.ViewModels.Abstract;
using Ninject.Extensions.Logging; using Ninject.Extensions.Logging;
@ -10,13 +11,14 @@ namespace Artemis.Managers
{ {
public class ProfileManager public class ProfileManager
{ {
private readonly EffectManager _effectManager;
private readonly DeviceManager _deviceManager; private readonly DeviceManager _deviceManager;
private readonly LoopManager _loopManager; private readonly EffectManager _effectManager;
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly LoopManager _loopManager;
private EffectModel _prePreviewEffect; private EffectModel _prePreviewEffect;
public ProfileManager(ILogger logger, EffectManager effectManager, DeviceManager deviceManager, LoopManager loopManager) public ProfileManager(ILogger logger, EffectManager effectManager, DeviceManager deviceManager,
LoopManager loopManager)
{ {
_logger = logger; _logger = logger;
_effectManager = effectManager; _effectManager = effectManager;
@ -41,7 +43,8 @@ namespace Artemis.Managers
/// <param name="e"></param> /// <param name="e"></param>
private void SetupProfilePreview(object sender, ElapsedEventArgs e) private void SetupProfilePreview(object sender, ElapsedEventArgs e)
{ {
if (_deviceManager.ActiveKeyboard == null ||_deviceManager.ChangingKeyboard || ProfilePreviewModel == null) if (string.IsNullOrEmpty(General.Default.LastKeyboard) || _deviceManager.ChangingKeyboard ||
ProfilePreviewModel == null)
return; return;
var activePreview = GameViewModels.FirstOrDefault(vm => vm.IsActive); var activePreview = GameViewModels.FirstOrDefault(vm => vm.IsActive);
@ -73,7 +76,7 @@ namespace Artemis.Managers
// LoopManager might be running, this method won't do any harm in that case. // LoopManager might be running, this method won't do any harm in that case.
_loopManager.Start(); _loopManager.Start();
if (!ReferenceEquals(ProfilePreviewModel.SelectedProfile, activePreview.ProfileEditor.SelectedProfile)) if (!ReferenceEquals(ProfilePreviewModel.SelectedProfile, activePreview.ProfileEditor.SelectedProfile))
ProfilePreviewModel.SelectedProfile = activePreview.ProfileEditor.SelectedProfile; ProfilePreviewModel.SelectedProfile = activePreview.ProfileEditor.SelectedProfile;
} }

View File

@ -101,7 +101,7 @@ namespace Artemis.Models.Profiles
else else
appliedProperties = Properties.Brush.Dispatcher.Invoke(() => GeneralHelpers.Clone(Properties)); appliedProperties = Properties.Brush.Dispatcher.Invoke(() => GeneralHelpers.Clone(Properties));
// TODO: Animations // TODO: Mouse/headset animations
// Update animations on layer types that support them // Update animations on layer types that support them
//if (LayerType != LayerType.Folder && updateAnimations) //if (LayerType != LayerType.Folder && updateAnimations)
//{ //{

View File

@ -154,6 +154,10 @@ namespace Artemis.Models.Profiles
return layers; return layers;
} }
/// <summary>
/// Looks at all the layers wthin the profile and makes sure they are within boundaries of the given rectangle
/// </summary>
/// <param name="keyboardRectangle"></param>
public void FixBoundaries(Rect keyboardRectangle) public void FixBoundaries(Rect keyboardRectangle)
{ {
foreach (var layer in GetLayers(false)) foreach (var layer in GetLayers(false))

View File

@ -36,6 +36,8 @@ namespace Artemis.Modules.Effects.ProfilePreview
public override Bitmap GenerateBitmap() public override Bitmap GenerateBitmap()
{ {
if (MainManager.DeviceManager.ActiveKeyboard == null)
return null;
var bitmap = MainManager.DeviceManager.ActiveKeyboard.KeyboardBitmap(4); var bitmap = MainManager.DeviceManager.ActiveKeyboard.KeyboardBitmap(4);
if (SelectedProfile == null) if (SelectedProfile == null)

View File

@ -38,22 +38,6 @@ namespace Artemis.Utilities
Environment.Exit(0); Environment.Exit(0);
} }
public static bool IsRunAsAdministrator()
{
var wi = WindowsIdentity.GetCurrent();
var wp = new WindowsPrincipal(wi);
return wp.IsInRole(WindowsBuiltInRole.Administrator);
}
public static void CopyProperties(object dest, object src)
{
foreach (PropertyDescriptor item in TypeDescriptor.GetProperties(src))
{
item.SetValue(dest, item.GetValue(src));
}
}
/// <summary> /// <summary>
/// Perform a deep Copy of the object. /// Perform a deep Copy of the object.
/// </summary> /// </summary>
@ -87,7 +71,6 @@ namespace Artemis.Utilities
} }
public static List<PropertyCollection> GenerateTypeMap(object o) => GenerateTypeMap(o.GetType().GetProperties()); public static List<PropertyCollection> GenerateTypeMap(object o) => GenerateTypeMap(o.GetType().GetProperties());
public static List<PropertyCollection> GenerateTypeMap<T>() => GenerateTypeMap(typeof(T).GetProperties());
private static List<PropertyCollection> GenerateTypeMap(IEnumerable<PropertyInfo> getProperties, private static List<PropertyCollection> GenerateTypeMap(IEnumerable<PropertyInfo> getProperties,
string path = "") string path = "")

View File

@ -37,30 +37,6 @@ namespace Artemis.Utilities
return result; return result;
} }
public static Bitmap BitmapSourceToBitmap(BitmapSource srs)
{
var width = srs.PixelWidth;
var height = srs.PixelHeight;
var stride = width*((srs.Format.BitsPerPixel + 7)/8);
var ptr = IntPtr.Zero;
try
{
ptr = Marshal.AllocHGlobal(height*stride);
srs.CopyPixels(new Int32Rect(0, 0, width, height), ptr, height*stride, stride);
using (var btm = new Bitmap(width, height, stride, PixelFormat.Format1bppIndexed, ptr))
{
// Clone the bitmap so that we can dispose it and
// release the unmanaged memory at ptr
return new Bitmap(btm);
}
}
finally
{
if (ptr != IntPtr.Zero)
Marshal.FreeHGlobal(ptr);
}
}
public static BitmapImage BitmapToBitmapImage(Bitmap b) public static BitmapImage BitmapToBitmapImage(Bitmap b)
{ {
if (b == null) if (b == null)

View File

@ -6,6 +6,7 @@ using Artemis.Managers;
using Artemis.Models; using Artemis.Models;
using Artemis.Modules.Effects.ProfilePreview; using Artemis.Modules.Effects.ProfilePreview;
using Artemis.Services; using Artemis.Services;
using Artemis.ViewModels.Profiles;
using Caliburn.Micro; using Caliburn.Micro;
using Ninject; using Ninject;
using Ninject.Extensions.Logging; using Ninject.Extensions.Logging;
@ -103,13 +104,13 @@ namespace Artemis.ViewModels.Abstract
protected override void OnActivate() protected override void OnActivate()
{ {
base.OnActivate(); base.OnActivate();
ProfileEditor.PreviewTimer.Start(); ProfileEditor.ProfileViewModel.Activate();
} }
protected override void OnDeactivate(bool close) protected override void OnDeactivate(bool close)
{ {
base.OnDeactivate(close); base.OnDeactivate(close);
ProfileEditor.PreviewTimer.Stop(); ProfileEditor.ProfileViewModel.Deactivate();
} }
} }

View File

@ -1,236 +1,236 @@
using System.ComponentModel; using System.ComponentModel;
using System.Linq; using System.Linq;
using Artemis.Models.Profiles; using Artemis.Models.Profiles;
using Artemis.Utilities; using Artemis.Utilities;
using Caliburn.Micro; using Caliburn.Micro;
namespace Artemis.ViewModels.LayerEditor namespace Artemis.ViewModels.Profiles
{ {
public sealed class LayerConditionViewModel : Screen public sealed class LayerConditionViewModel : Screen
{ {
private readonly NamedOperator[] _boolOperators = private readonly NamedOperator[] _boolOperators =
{ {
new NamedOperator("True", "== True"), new NamedOperator("True", "== True"),
new NamedOperator("False", "== False") new NamedOperator("False", "== False")
}; };
private readonly LayerEditorViewModel _conditionModel; private readonly LayerEditorViewModel _conditionModel;
private readonly NamedOperator[] _int32Operators = private readonly NamedOperator[] _int32Operators =
{ {
new NamedOperator("Lower than", "<"), new NamedOperator("Lower than", "<"),
new NamedOperator("Lower or equal to", "<="), new NamedOperator("Lower or equal to", "<="),
new NamedOperator("Higher than", ">"), new NamedOperator("Higher than", ">"),
new NamedOperator("Higher or equal to", ">="), new NamedOperator("Higher or equal to", ">="),
new NamedOperator("Equal to", "=="), new NamedOperator("Equal to", "=="),
new NamedOperator("Not equal to", "!=") new NamedOperator("Not equal to", "!=")
}; };
private readonly NamedOperator[] _operators = private readonly NamedOperator[] _operators =
{ {
new NamedOperator("Equal to", "=="), new NamedOperator("Equal to", "=="),
new NamedOperator("Not equal to", "!=") new NamedOperator("Not equal to", "!=")
}; };
private bool _enumValueIsVisible; private bool _enumValueIsVisible;
private bool _preselecting; private bool _preselecting;
private GeneralHelpers.PropertyCollection _selectedDataModelProp; private GeneralHelpers.PropertyCollection _selectedDataModelProp;
private string _selectedEnum; private string _selectedEnum;
private NamedOperator _selectedOperator; private NamedOperator _selectedOperator;
private string _userValue; private string _userValue;
private bool _userValueIsVisible; private bool _userValueIsVisible;
public LayerConditionViewModel(LayerEditorViewModel conditionModel, LayerConditionModel layerConditionModel, public LayerConditionViewModel(LayerEditorViewModel conditionModel, LayerConditionModel layerConditionModel,
BindableCollection<GeneralHelpers.PropertyCollection> dataModelProps) BindableCollection<GeneralHelpers.PropertyCollection> dataModelProps)
{ {
_conditionModel = conditionModel; _conditionModel = conditionModel;
_preselecting = false; _preselecting = false;
LayerConditionModel = layerConditionModel; LayerConditionModel = layerConditionModel;
DataModelProps = dataModelProps; DataModelProps = dataModelProps;
Operators = new BindableCollection<NamedOperator>(); Operators = new BindableCollection<NamedOperator>();
Enums = new BindableCollection<string>(); Enums = new BindableCollection<string>();
PropertyChanged += UpdateModel; PropertyChanged += UpdateModel;
PropertyChanged += UpdateForm; PropertyChanged += UpdateForm;
PreSelect(); PreSelect();
} }
public LayerConditionModel LayerConditionModel { get; set; } public LayerConditionModel LayerConditionModel { get; set; }
public BindableCollection<GeneralHelpers.PropertyCollection> DataModelProps { get; set; } public BindableCollection<GeneralHelpers.PropertyCollection> DataModelProps { get; set; }
public BindableCollection<NamedOperator> Operators { get; set; } public BindableCollection<NamedOperator> Operators { get; set; }
public BindableCollection<string> Enums { get; set; } public BindableCollection<string> Enums { get; set; }
public string UserValue public string UserValue
{ {
get { return _userValue; } get { return _userValue; }
set set
{ {
if (value == _userValue) return; if (value == _userValue) return;
_userValue = value; _userValue = value;
NotifyOfPropertyChange(() => UserValue); NotifyOfPropertyChange(() => UserValue);
} }
} }
public GeneralHelpers.PropertyCollection SelectedDataModelProp public GeneralHelpers.PropertyCollection SelectedDataModelProp
{ {
get { return _selectedDataModelProp; } get { return _selectedDataModelProp; }
set set
{ {
if (value.Equals(_selectedDataModelProp)) return; if (value.Equals(_selectedDataModelProp)) return;
_selectedDataModelProp = value; _selectedDataModelProp = value;
NotifyOfPropertyChange(() => SelectedDataModelProp); NotifyOfPropertyChange(() => SelectedDataModelProp);
} }
} }
public bool UserValueIsVisible public bool UserValueIsVisible
{ {
get { return _userValueIsVisible; } get { return _userValueIsVisible; }
set set
{ {
if (value == _userValueIsVisible) return; if (value == _userValueIsVisible) return;
_userValueIsVisible = value; _userValueIsVisible = value;
NotifyOfPropertyChange(() => UserValueIsVisible); NotifyOfPropertyChange(() => UserValueIsVisible);
} }
} }
public bool EnumValueIsVisible public bool EnumValueIsVisible
{ {
get { return _enumValueIsVisible; } get { return _enumValueIsVisible; }
set set
{ {
if (value == _enumValueIsVisible) return; if (value == _enumValueIsVisible) return;
_enumValueIsVisible = value; _enumValueIsVisible = value;
NotifyOfPropertyChange(() => EnumValueIsVisible); NotifyOfPropertyChange(() => EnumValueIsVisible);
} }
} }
public NamedOperator SelectedOperator public NamedOperator SelectedOperator
{ {
get { return _selectedOperator; } get { return _selectedOperator; }
set set
{ {
if (value.Equals(_selectedOperator)) return; if (value.Equals(_selectedOperator)) return;
_selectedOperator = value; _selectedOperator = value;
NotifyOfPropertyChange(() => SelectedOperator); NotifyOfPropertyChange(() => SelectedOperator);
} }
} }
public string SelectedEnum public string SelectedEnum
{ {
get { return _selectedEnum; } get { return _selectedEnum; }
set set
{ {
if (value == _selectedEnum) return; if (value == _selectedEnum) return;
_selectedEnum = value; _selectedEnum = value;
NotifyOfPropertyChange(() => SelectedEnum); NotifyOfPropertyChange(() => SelectedEnum);
} }
} }
/// <summary> /// <summary>
/// Handles updating the form to match the selected data model property /// Handles updating the form to match the selected data model property
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void UpdateForm(object sender, PropertyChangedEventArgs e) private void UpdateForm(object sender, PropertyChangedEventArgs e)
{ {
if (e.PropertyName != "SelectedDataModelProp") if (e.PropertyName != "SelectedDataModelProp")
return; return;
Operators.Clear(); Operators.Clear();
UserValueIsVisible = false; UserValueIsVisible = false;
EnumValueIsVisible = false; EnumValueIsVisible = false;
switch (SelectedDataModelProp.Type) switch (SelectedDataModelProp.Type)
{ {
case "Int32": case "Int32":
Operators.AddRange(_int32Operators); Operators.AddRange(_int32Operators);
UserValueIsVisible = true; UserValueIsVisible = true;
break; break;
case "Boolean": case "Boolean":
Operators.AddRange(_boolOperators); Operators.AddRange(_boolOperators);
break; break;
default: default:
Operators.AddRange(_operators); Operators.AddRange(_operators);
UserValueIsVisible = true; UserValueIsVisible = true;
break; break;
} }
// Setup Enum selection if needed // Setup Enum selection if needed
if (SelectedDataModelProp.EnumValues != null) if (SelectedDataModelProp.EnumValues != null)
{ {
Enums.AddRange(SelectedDataModelProp.EnumValues); Enums.AddRange(SelectedDataModelProp.EnumValues);
EnumValueIsVisible = true; EnumValueIsVisible = true;
} }
SelectedOperator = Operators.First(); SelectedOperator = Operators.First();
} }
/// <summary> /// <summary>
/// Handles saving user input to the model /// Handles saving user input to the model
/// TODO: Data validation? /// TODO: Data validation?
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void UpdateModel(object sender, PropertyChangedEventArgs e) private void UpdateModel(object sender, PropertyChangedEventArgs e)
{ {
// Don't mess with model during preselect // Don't mess with model during preselect
if (_preselecting) if (_preselecting)
return; return;
// Only care about these fields // Only care about these fields
if (e.PropertyName != "UserValue" && if (e.PropertyName != "UserValue" &&
e.PropertyName != "SelectedOperator" && e.PropertyName != "SelectedOperator" &&
e.PropertyName != "SelectedDataModelProp" && e.PropertyName != "SelectedDataModelProp" &&
e.PropertyName != "SelectedEnum") e.PropertyName != "SelectedEnum")
return; return;
LayerConditionModel.Field = SelectedDataModelProp.Path; LayerConditionModel.Field = SelectedDataModelProp.Path;
LayerConditionModel.Operator = SelectedOperator.Value; LayerConditionModel.Operator = SelectedOperator.Value;
LayerConditionModel.Type = SelectedDataModelProp.Type; LayerConditionModel.Type = SelectedDataModelProp.Type;
LayerConditionModel.Value = SelectedDataModelProp.Type == "Enum" ? SelectedEnum : UserValue; LayerConditionModel.Value = SelectedDataModelProp.Type == "Enum" ? SelectedEnum : UserValue;
} }
/// <summary> /// <summary>
/// Setup the current UI elements to show the backing model /// Setup the current UI elements to show the backing model
/// </summary> /// </summary>
private void PreSelect() private void PreSelect()
{ {
_preselecting = true; _preselecting = true;
SelectedDataModelProp = DataModelProps.FirstOrDefault(m => m.Path == LayerConditionModel.Field); SelectedDataModelProp = DataModelProps.FirstOrDefault(m => m.Path == LayerConditionModel.Field);
SelectedOperator = Operators.FirstOrDefault(o => o.Value == LayerConditionModel.Operator); SelectedOperator = Operators.FirstOrDefault(o => o.Value == LayerConditionModel.Operator);
LayerConditionModel.Type = SelectedDataModelProp.Type; LayerConditionModel.Type = SelectedDataModelProp.Type;
if (LayerConditionModel.Type =="Enum") if (LayerConditionModel.Type =="Enum")
SelectedEnum = LayerConditionModel.Value; SelectedEnum = LayerConditionModel.Value;
else else
UserValue = LayerConditionModel.Value; UserValue = LayerConditionModel.Value;
_preselecting = false; _preselecting = false;
} }
/// <summary> /// <summary>
/// Delete the current model from the parent /// Delete the current model from the parent
/// </summary> /// </summary>
public void Delete() public void Delete()
{ {
_conditionModel.DeleteCondition(this, LayerConditionModel); _conditionModel.DeleteCondition(this, LayerConditionModel);
} }
public struct NamedOperator public struct NamedOperator
{ {
public string Display { get; set; } public string Display { get; set; }
public string Value { get; set; } public string Value { get; set; }
public NamedOperator(string display, string value) public NamedOperator(string display, string value)
{ {
Display = display; Display = display;
Value = value; Value = value;
} }
} }
} }
} }

View File

@ -4,7 +4,7 @@ using Artemis.Models.Profiles.Properties;
using Artemis.Utilities; using Artemis.Utilities;
using Caliburn.Micro; using Caliburn.Micro;
namespace Artemis.ViewModels.LayerEditor namespace Artemis.ViewModels.Profiles
{ {
public sealed class LayerDynamicPropertiesViewModel : PropertyChangedBase public sealed class LayerDynamicPropertiesViewModel : PropertyChangedBase
{ {
@ -33,7 +33,7 @@ namespace Artemis.ViewModels.LayerEditor
Proposed.LayerPropertyType = LayerPropertyType.PercentageOf; Proposed.LayerPropertyType = LayerPropertyType.PercentageOf;
} }
else else
GeneralHelpers.CopyProperties(Proposed, original); Proposed = GeneralHelpers.Clone(original);
PropertyChanged += OnPropertyChanged; PropertyChanged += OnPropertyChanged;
SetupControls(dataModelProps); SetupControls(dataModelProps);

View File

@ -6,11 +6,11 @@ using Artemis.Models.Profiles;
using Artemis.Models.Profiles.Properties; using Artemis.Models.Profiles.Properties;
using Artemis.Services; using Artemis.Services;
using Artemis.Utilities; using Artemis.Utilities;
using Artemis.ViewModels.LayerEditor.Properties; using Artemis.ViewModels.Profiles.Properties;
using Caliburn.Micro; using Caliburn.Micro;
using Ninject; using Ninject;
namespace Artemis.ViewModels.LayerEditor namespace Artemis.ViewModels.Profiles
{ {
public sealed class LayerEditorViewModel : Screen public sealed class LayerEditorViewModel : Screen
{ {

View File

@ -0,0 +1,306 @@
using System;
using System.Linq;
using System.Timers;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Threading;
using Artemis.Events;
using Artemis.Managers;
using Artemis.Models.Profiles;
using Artemis.Models.Profiles.Properties;
using Artemis.Utilities;
using Caliburn.Micro;
using MahApps.Metro;
namespace Artemis.ViewModels.Profiles
{
public class ProfileViewModel : PropertyChangedBase, IHandle<ActiveKeyboardChanged>
{
private readonly DeviceManager _deviceManager;
private DateTime _downTime;
private LayerModel _draggingLayer;
private Point? _draggingLayerOffset;
private DrawingImage _keyboardPreview;
private Cursor _keyboardPreviewCursor;
private bool _resizing;
private LayerModel _selectedLayer;
public ProfileViewModel(IEventAggregator events, DeviceManager deviceManager)
{
events.Subscribe(this);
_deviceManager = deviceManager;
PreviewTimer = new Timer(40);
PreviewTimer.Elapsed += InvokeUpdateKeyboardPreview;
}
public ProfileModel SelectedProfile { get; set; }
public Timer PreviewTimer { get; set; }
public LayerModel SelectedLayer
{
get { return _selectedLayer; }
set
{
if (Equals(value, _selectedLayer)) return;
_selectedLayer = value;
NotifyOfPropertyChange(() => SelectedLayer);
}
}
public DrawingImage KeyboardPreview
{
get { return _keyboardPreview; }
set
{
if (Equals(value, _keyboardPreview)) return;
_keyboardPreview = value;
NotifyOfPropertyChange(() => KeyboardPreview);
}
}
public ImageSource KeyboardImage
{
get
{
return ImageUtilities.BitmapToBitmapImage(_deviceManager.ActiveKeyboard?.PreviewSettings.Image);
}
}
private void InvokeUpdateKeyboardPreview(object sender, ElapsedEventArgs e)
{
Application.Current.Dispatcher.InvokeAsync(UpdateKeyboardPreview, DispatcherPriority.ContextIdle);
}
public void Activate()
{
PreviewTimer.Start();
}
public void Deactivate()
{
PreviewTimer.Stop();
}
#region Drawing
/// <summary>
/// Generates a new image for the keyboard preview
/// </summary>
public void UpdateKeyboardPreview()
{
if (SelectedProfile == null || _deviceManager.ActiveKeyboard == null)
{
KeyboardPreview = new DrawingImage();
return;
}
var keyboardRect = _deviceManager.ActiveKeyboard.KeyboardRectangle(4);
var visual = new DrawingVisual();
using (var drawingContext = visual.RenderOpen())
{
// Setup the DrawingVisual's size
drawingContext.PushClip(new RectangleGeometry(keyboardRect));
drawingContext.DrawRectangle(new SolidColorBrush(Color.FromArgb(0, 0, 0, 0)), null, keyboardRect);
// Draw the layers
var drawLayers = SelectedProfile.Layers
.OrderByDescending(l => l.Order)
.Where(l => l.Enabled &&
(l.LayerType == LayerType.Keyboard ||
l.LayerType == LayerType.KeyboardGif ||
l.LayerType == LayerType.Folder));
foreach (var layer in drawLayers)
layer.Draw<object>(null, drawingContext, true, false);
// Get the selection color
var color = (Color) ThemeManager.DetectAppStyle(Application.Current).Item2.Resources["AccentColor"];
var pen = new Pen(new SolidColorBrush(color), 0.4);
// Draw the selection outline and resize indicator
if (SelectedLayer != null && SelectedLayer.MustDraw())
{
var layerRect = ((KeyboardPropertiesModel) SelectedLayer.Properties).GetRect();
// Deflate the rect so that the border is drawn on the inside
layerRect.Inflate(-0.2, -0.2);
// Draw an outline around the selected layer
drawingContext.DrawRectangle(null, pen, layerRect);
// Draw a resize indicator in the bottom-right
drawingContext.DrawLine(pen,
new Point(layerRect.BottomRight.X - 1, layerRect.BottomRight.Y - 0.5),
new Point(layerRect.BottomRight.X - 1.2, layerRect.BottomRight.Y - 0.7));
drawingContext.DrawLine(pen,
new Point(layerRect.BottomRight.X - 0.5, layerRect.BottomRight.Y - 1),
new Point(layerRect.BottomRight.X - 0.7, layerRect.BottomRight.Y - 1.2));
drawingContext.DrawLine(pen,
new Point(layerRect.BottomRight.X - 0.5, layerRect.BottomRight.Y - 0.5),
new Point(layerRect.BottomRight.X - 0.7, layerRect.BottomRight.Y - 0.7));
}
// Remove the clip
drawingContext.Pop();
}
KeyboardPreview = new DrawingImage(visual.Drawing);
}
#endregion
#region Processing
/// <summary>
/// Handler for clicking
/// </summary>
/// <param name="e"></param>
public void MouseDownKeyboardPreview(MouseButtonEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
_downTime = DateTime.Now;
}
/// <summary>
/// Second handler for clicking, selects a the layer the user clicked on
/// if the used clicked on an empty spot, deselects the current layer
/// </summary>
/// <param name="e"></param>
public void MouseUpKeyboardPreview(MouseButtonEventArgs e)
{
if (SelectedProfile == null)
return;
var timeSinceDown = DateTime.Now - _downTime;
if (!(timeSinceDown.TotalMilliseconds < 500))
return;
var keyboard = _deviceManager.ActiveKeyboard;
var pos = e.GetPosition((Image) e.OriginalSource);
var x = pos.X/((double) keyboard.PreviewSettings.Width/keyboard.Width);
var y = pos.Y/((double) keyboard.PreviewSettings.Height/keyboard.Height);
var hoverLayer = SelectedProfile.GetLayers()
.Where(l => l.MustDraw())
.FirstOrDefault(l => ((KeyboardPropertiesModel) l.Properties)
.GetRect(1)
.Contains(x, y));
SelectedLayer = hoverLayer;
}
/// <summary>
/// Handler for resizing and moving the currently selected layer
/// </summary>
/// <param name="e"></param>
public void MouseMoveKeyboardPreview(MouseEventArgs e)
{
if (SelectedProfile == null)
return;
var pos = e.GetPosition((Image) e.OriginalSource);
var keyboard = _deviceManager.ActiveKeyboard;
var x = pos.X/((double) keyboard.PreviewSettings.Width/keyboard.Width);
var y = pos.Y/((double) keyboard.PreviewSettings.Height/keyboard.Height);
var hoverLayer = SelectedProfile.GetLayers()
.Where(l => l.MustDraw())
.FirstOrDefault(l => ((KeyboardPropertiesModel) l.Properties)
.GetRect(1).Contains(x, y));
HandleDragging(e, x, y, hoverLayer);
if (hoverLayer == null)
{
KeyboardPreviewCursor = Cursors.Arrow;
return;
}
// Turn the mouse pointer into a hand if hovering over an active layer
if (hoverLayer == SelectedLayer)
{
var rect = ((KeyboardPropertiesModel) hoverLayer.Properties).GetRect(1);
KeyboardPreviewCursor =
Math.Sqrt(Math.Pow(x - rect.BottomRight.X, 2) + Math.Pow(y - rect.BottomRight.Y, 2)) < 0.6
? Cursors.SizeNWSE
: Cursors.SizeAll;
}
else
KeyboardPreviewCursor = Cursors.Hand;
}
public Cursor KeyboardPreviewCursor
{
get { return _keyboardPreviewCursor; }
set
{
if (Equals(value, _keyboardPreviewCursor)) return;
_keyboardPreviewCursor = value;
NotifyOfPropertyChange(() => KeyboardPreviewCursor);
}
}
/// <summary>
/// Handles dragging the given layer
/// </summary>
/// <param name="e"></param>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="hoverLayer"></param>
private void HandleDragging(MouseEventArgs e, double x, double y, LayerModel hoverLayer)
{
// Reset the dragging state on mouse release
if (e.LeftButton == MouseButtonState.Released ||
(_draggingLayer != null && SelectedLayer != _draggingLayer))
{
_draggingLayerOffset = null;
_draggingLayer = null;
return;
}
if (SelectedLayer == null)
return;
// Setup the dragging state on mouse press
if (_draggingLayerOffset == null && hoverLayer != null && e.LeftButton == MouseButtonState.Pressed)
{
var layerRect = ((KeyboardPropertiesModel) hoverLayer.Properties).GetRect(1);
var selectedProps = (KeyboardPropertiesModel) SelectedLayer.Properties;
_draggingLayerOffset = new Point(x - selectedProps.X, y - selectedProps.Y);
_draggingLayer = hoverLayer;
// Detect dragging if cursor is in the bottom right
_resizing = Math.Sqrt(Math.Pow(x - layerRect.BottomRight.X, 2) +
Math.Pow(y - layerRect.BottomRight.Y, 2)) < 0.6;
}
if (_draggingLayerOffset == null || _draggingLayer == null || (_draggingLayer != SelectedLayer))
return;
var draggingProps = (KeyboardPropertiesModel) _draggingLayer?.Properties;
// If no setup or reset was done, handle the actual dragging action
if (_resizing)
{
draggingProps.Width = (int) Math.Round(x - draggingProps.X);
draggingProps.Height = (int) Math.Round(y - draggingProps.Y);
if (draggingProps.Width < 1)
draggingProps.Width = 1;
if (draggingProps.Height < 1)
draggingProps.Height = 1;
}
else
{
draggingProps.X = (int) Math.Round(x - _draggingLayerOffset.Value.X);
draggingProps.Y = (int) Math.Round(y - _draggingLayerOffset.Value.Y);
}
}
#endregion
public void Handle(ActiveKeyboardChanged message)
{
NotifyOfPropertyChange(() => KeyboardImage);
}
}
}

View File

@ -2,7 +2,7 @@
using Artemis.Models.Profiles.Properties; using Artemis.Models.Profiles.Properties;
using Artemis.Utilities; using Artemis.Utilities;
namespace Artemis.ViewModels.LayerEditor.Properties namespace Artemis.ViewModels.Profiles.Properties
{ {
public class FolderPropertiesViewModel : LayerPropertiesViewModel public class FolderPropertiesViewModel : LayerPropertiesViewModel
{ {

View File

@ -2,7 +2,7 @@
using Artemis.Models.Profiles.Properties; using Artemis.Models.Profiles.Properties;
using Artemis.Utilities; using Artemis.Utilities;
namespace Artemis.ViewModels.LayerEditor.Properties namespace Artemis.ViewModels.Profiles.Properties
{ {
public class HeadsetPropertiesViewModel : LayerPropertiesViewModel public class HeadsetPropertiesViewModel : LayerPropertiesViewModel
{ {

View File

@ -4,7 +4,7 @@ using Artemis.Models.Profiles.Properties;
using Artemis.Utilities; using Artemis.Utilities;
using Caliburn.Micro; using Caliburn.Micro;
namespace Artemis.ViewModels.LayerEditor.Properties namespace Artemis.ViewModels.Profiles.Properties
{ {
public class KeyboardPropertiesViewModel : LayerPropertiesViewModel public class KeyboardPropertiesViewModel : LayerPropertiesViewModel
{ {

View File

@ -2,7 +2,7 @@
using Artemis.Models.Profiles.Properties; using Artemis.Models.Profiles.Properties;
using Caliburn.Micro; using Caliburn.Micro;
namespace Artemis.ViewModels.LayerEditor.Properties namespace Artemis.ViewModels.Profiles.Properties
{ {
public abstract class LayerPropertiesViewModel : PropertyChangedBase public abstract class LayerPropertiesViewModel : PropertyChangedBase
{ {

View File

@ -2,7 +2,7 @@
using Artemis.Models.Profiles.Properties; using Artemis.Models.Profiles.Properties;
using Artemis.Utilities; using Artemis.Utilities;
namespace Artemis.ViewModels.LayerEditor.Properties namespace Artemis.ViewModels.Profiles.Properties
{ {
public class MousePropertiesViewModel : LayerPropertiesViewModel public class MousePropertiesViewModel : LayerPropertiesViewModel
{ {

View File

@ -1,76 +1,75 @@
<UserControl x:Class="Artemis.Views.LayerEditor.LayerConditionView" <UserControl x:Class="Artemis.Views.Profiles.LayerConditionView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Artemis.Views.LayerEditor" xmlns:cal="http://www.caliburnproject.org"
xmlns:cal="http://www.caliburnproject.org" xmlns:utilities="clr-namespace:Artemis.Utilities"
xmlns:utilities="clr-namespace:Artemis.Utilities" mc:Ignorable="d" d:DesignWidth="613.296" Height="46">
mc:Ignorable="d" d:DesignWidth="613.296" Height="46"> <UserControl.Resources>
<UserControl.Resources> <ResourceDictionary>
<ResourceDictionary> <ResourceDictionary.MergedDictionaries>
<ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="/Resources/Icons.xaml" />
<ResourceDictionary Source="/Resources/Icons.xaml" /> </ResourceDictionary.MergedDictionaries>
</ResourceDictionary.MergedDictionaries> </ResourceDictionary>
</ResourceDictionary> </UserControl.Resources>
</UserControl.Resources> <Grid Margin="10">
<Grid Margin="10"> <Grid.ColumnDefinitions>
<Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="30" />
<ColumnDefinition Width="30" /> <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="*" /> </Grid.ColumnDefinitions>
</Grid.ColumnDefinitions> <!-- Left -->
<!-- Left --> <ComboBox x:Name="DataModelProps" Grid.Column="0" Width="210" MaxDropDownHeight="125"
<ComboBox x:Name="DataModelProps" Grid.Column="0" Width="210" MaxDropDownHeight="125" HorizontalAlignment="Center" VerticalAlignment="Top">
HorizontalAlignment="Center" VerticalAlignment="Top"> <ComboBox.ItemTemplate>
<ComboBox.ItemTemplate> <DataTemplate>
<DataTemplate> <Grid MinWidth="522">
<Grid MinWidth="522"> <Grid.ColumnDefinitions>
<Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="*" /> </Grid.ColumnDefinitions>
</Grid.ColumnDefinitions> <TextBlock Grid.Column="0" Text="{Binding Path=Display}" HorizontalAlignment="Left" />
<TextBlock Grid.Column="0" Text="{Binding Path=Display}" HorizontalAlignment="Left" /> <TextBlock Grid.Column="1" FontWeight="Bold" Text="{Binding Path=DisplayType}"
<TextBlock Grid.Column="1" FontWeight="Bold" Text="{Binding Path=DisplayType}" HorizontalAlignment="Right" />
HorizontalAlignment="Right" /> </Grid>
</Grid>
</DataTemplate>
</DataTemplate> </ComboBox.ItemTemplate>
</ComboBox.ItemTemplate> </ComboBox>
</ComboBox>
<!-- Center -->
<!-- Center --> <TextBlock Grid.Column="1" Text="is" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="0,3,0,0" />
<TextBlock Grid.Column="1" Text="is" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="0,3,0,0" /> <ComboBox x:Name="Operators" Grid.Column="2" Width="150" MaxDropDownHeight="125" HorizontalAlignment="Center"
<ComboBox x:Name="Operators" Grid.Column="2" Width="150" MaxDropDownHeight="125" HorizontalAlignment="Center" VerticalAlignment="Top" DisplayMemberPath="Display" />
VerticalAlignment="Top" DisplayMemberPath="Display" />
<!-- Right -->
<!-- Right --> <Grid Grid.Column="3" HorizontalAlignment="Left" Margin="10,0,0,0" Width="148">
<Grid Grid.Column="3" HorizontalAlignment="Left" Margin="10,0,0,0" Width="148"> <Grid.ColumnDefinitions>
<Grid.ColumnDefinitions> <ColumnDefinition Width="120" />
<ColumnDefinition Width="120" /> <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions>
</Grid.ColumnDefinitions> <StackPanel Grid.Column="0" x:Name="UserValueIsVisible" HorizontalAlignment="Left" VerticalAlignment="Top">
<StackPanel Grid.Column="0" x:Name="UserValueIsVisible" HorizontalAlignment="Left" VerticalAlignment="Top"> <TextBox x:Name="UserValue" VerticalAlignment="Center" HorizontalAlignment="Left" Width="110" />
<TextBox x:Name="UserValue" VerticalAlignment="Center" HorizontalAlignment="Left" Width="110" /> </StackPanel>
</StackPanel> <StackPanel Grid.Column="0" x:Name="EnumValueIsVisible" HorizontalAlignment="Left" VerticalAlignment="Top">
<StackPanel Grid.Column="0" x:Name="EnumValueIsVisible" HorizontalAlignment="Left" VerticalAlignment="Top"> <ComboBox x:Name="Enums" Width="110" MaxDropDownHeight="125" HorizontalAlignment="Center"
<ComboBox x:Name="Enums" Width="110" MaxDropDownHeight="125" HorizontalAlignment="Center" VerticalAlignment="Top"/>
VerticalAlignment="Top"/> </StackPanel>
</StackPanel> <Button Grid.Column="1" x:Name="Delete" Width="26" Height="26" Style="{DynamicResource SquareButtonStyle}"
<Button Grid.Column="1" x:Name="Delete" Width="26" Height="26" Style="{DynamicResource SquareButtonStyle}" VerticalAlignment="Top" HorizontalAlignment="Right">
VerticalAlignment="Top" HorizontalAlignment="Right"> <Button.Content>
<Button.Content> <Rectangle
<Rectangle Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}" Width="12" Height="12">
Width="12" Height="12"> <Rectangle.OpacityMask>
<Rectangle.OpacityMask> <VisualBrush Visual="{StaticResource appbar_delete}" Stretch="Fill" />
<VisualBrush Visual="{StaticResource appbar_delete}" Stretch="Fill" /> </Rectangle.OpacityMask>
</Rectangle.OpacityMask> </Rectangle>
</Rectangle> </Button.Content>
</Button.Content> </Button>
</Button> </Grid>
</Grid>
</Grid>
</Grid>
</UserControl> </UserControl>

View File

@ -1,15 +1,15 @@
using System.Windows.Controls; using System.Windows.Controls;
namespace Artemis.Views.LayerEditor namespace Artemis.Views.Profiles
{ {
/// <summary> /// <summary>
/// Interaction logic for LayerConditionView.xaml /// Interaction logic for LayerConditionView.xaml
/// </summary> /// </summary>
public partial class LayerConditionView : UserControl public partial class LayerConditionView : UserControl
{ {
public LayerConditionView() public LayerConditionView()
{ {
InitializeComponent(); InitializeComponent();
} }
} }
} }

View File

@ -1,4 +1,4 @@
<UserControl x:Class="Artemis.Views.LayerEditor.LayerDynamicPropertiesView" <UserControl x:Class="Artemis.Views.Profiles.LayerDynamicPropertiesView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

View File

@ -1,6 +1,6 @@
using System.Windows.Controls; using System.Windows.Controls;
namespace Artemis.Views.LayerEditor namespace Artemis.Views.Profiles
{ {
/// <summary> /// <summary>
/// Interaction logic for LayerDynamicPropertiesView.xaml /// Interaction logic for LayerDynamicPropertiesView.xaml

View File

@ -1,4 +1,4 @@
<controls:MetroWindow x:Class="Artemis.Views.LayerEditor.LayerEditorView" <controls:MetroWindow x:Class="Artemis.Views.Profiles.LayerEditorView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

View File

@ -1,6 +1,6 @@
using MahApps.Metro.Controls; using MahApps.Metro.Controls;
namespace Artemis.Views.LayerEditor namespace Artemis.Views.Profiles
{ {
/// <summary> /// <summary>
/// Interaction logic for LayerEditorView.xaml /// Interaction logic for LayerEditorView.xaml

View File

@ -1,235 +1,235 @@
<UserControl x:Class="Artemis.Views.ProfileEditorView" <UserControl x:Class="Artemis.Views.Profiles.ProfileEditorView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:cal="http://www.caliburnproject.org" xmlns:cal="http://www.caliburnproject.org"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:itemBehaviours="clr-namespace:Artemis.ItemBehaviours" xmlns:itemBehaviours="clr-namespace:Artemis.ItemBehaviours"
xmlns:utilities="clr-namespace:Artemis.Utilities" xmlns:utilities="clr-namespace:Artemis.Utilities"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro" xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:dragDrop="clr-namespace:GongSolutions.Wpf.DragDrop;assembly=GongSolutions.Wpf.DragDrop" xmlns:dragDrop="clr-namespace:GongSolutions.Wpf.DragDrop;assembly=GongSolutions.Wpf.DragDrop"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="510" Width="1055"> d:DesignHeight="510" Width="1055">
<UserControl.Resources> <UserControl.Resources>
<utilities:LayerOrderConverter x:Key="LayerOrderConverter" /> <utilities:LayerOrderConverter x:Key="LayerOrderConverter" />
</UserControl.Resources> </UserControl.Resources>
<Grid Width="Auto" Height="Auto"> <Grid Width="Auto" Height="Auto">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<!-- Preview --> <!-- Preview -->
<Label Grid.Column="0" Grid.Row="0" FontSize="20" HorizontalAlignment="Left" Content="Preview" /> <Label Grid.Column="0" Grid.Row="0" FontSize="20" HorizontalAlignment="Left" Content="Preview" />
<Border Grid.Column="0" Grid.Row="1" Background="#FF232323" BorderBrush="{DynamicResource HighlightBrush}" <Border Grid.Column="0" Grid.Row="1" Background="#FF232323" BorderBrush="{DynamicResource HighlightBrush}"
BorderThickness="3" Width="800" Height="400"> BorderThickness="3" Width="800" Height="400">
<Border> <Border>
<Border.Effect> <Border.Effect>
<!-- TODO: Pulse 10-20 --> <!-- TODO: Pulse 10-20 -->
<DropShadowEffect ShadowDepth="0" Color="{DynamicResource HighlightColor}" Opacity="1" <DropShadowEffect ShadowDepth="0" Color="{DynamicResource HighlightColor}" Opacity="1"
BlurRadius="20" /> BlurRadius="20" />
</Border.Effect> </Border.Effect>
<Grid> <Grid>
<Image Grid.Column="0" Grid.Row="0" Source="{Binding Path=KeyboardImage}" Margin="50" /> <Image Grid.Column="0" Grid.Row="0" Source="{Binding Path=ProfileViewModel.KeyboardImage}" Margin="50" />
<Image Grid.Column="0" Grid.Row="0" Source="{Binding Path=KeyboardPreview}" Opacity="0.8" <Image Grid.Column="0" Grid.Row="0" Source="{Binding Path=ProfileViewModel.KeyboardPreview}" Opacity="0.8"
Width="{Binding Path=PreviewSettings.Width}" Width="{Binding Path=PreviewSettings.Width}"
Height="{Binding Path=PreviewSettings.Height}" Height="{Binding Path=PreviewSettings.Height}"
Margin="{Binding Path=PreviewSettings.Margin}" Margin="{Binding Path=PreviewSettings.Margin}"
Stretch="Fill" Cursor="{Binding Path=KeyboardPreviewCursor}" Stretch="Fill" Cursor="{Binding Path=ProfileViewModel.KeyboardPreviewCursor}"
cal:Message.Attach="[Event MouseMove] = [Action MouseMoveKeyboardPreview($eventArgs)]; cal:Message.Attach="[Event MouseMove] = [Action MouseMoveKeyboardPreview($eventArgs)];
[Event MouseDown] = [Action MouseDownKeyboardPreview($eventArgs)]; [Event MouseDown] = [Action MouseDownKeyboardPreview($eventArgs)];
[Event MouseUp] = [Action MouseUpKeyboardPreview($eventArgs)]" /> [Event MouseUp] = [Action MouseUpKeyboardPreview($eventArgs)]" />
</Grid> </Grid>
</Border> </Border>
</Border> </Border>
<!-- Profile management --> <!-- Profile management -->
<StackPanel Grid.Column="0" Grid.Row="2" Orientation="Horizontal" Margin="0,5,0,0"> <StackPanel Grid.Column="0" Grid.Row="2" Orientation="Horizontal" Margin="0,5,0,0">
<Label Content="Active profile" /> <Label Content="Active profile" />
<ComboBox Width="110" VerticalAlignment="Top" x:Name="Profiles" DisplayMemberPath="Name" <ComboBox Width="110" VerticalAlignment="Top" x:Name="Profiles" DisplayMemberPath="Name"
Margin="5,0,0,0" /> Margin="5,0,0,0" />
<Button x:Name="AddProfile" VerticalAlignment="Top" Style="{DynamicResource SquareButtonStyle}" <Button x:Name="AddProfile" VerticalAlignment="Top" Style="{DynamicResource SquareButtonStyle}"
Width="26" Height="26" HorizontalAlignment="Right" Margin="10,0,0,0" ToolTip="Add profile"> Width="26" Height="26" HorizontalAlignment="Right" Margin="10,0,0,0" ToolTip="Add profile">
<Button.Content> <Button.Content>
<Rectangle <Rectangle
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}" Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
Width="12" Height="12"> Width="12" Height="12">
<Rectangle.OpacityMask> <Rectangle.OpacityMask>
<VisualBrush Visual="{StaticResource appbar_add}" Stretch="Fill" /> <VisualBrush Visual="{StaticResource appbar_add}" Stretch="Fill" />
</Rectangle.OpacityMask> </Rectangle.OpacityMask>
</Rectangle> </Rectangle>
</Button.Content> </Button.Content>
</Button> </Button>
<Button x:Name="RenameProfile" VerticalAlignment="Top" Style="{DynamicResource SquareButtonStyle}" <Button x:Name="RenameProfile" VerticalAlignment="Top" Style="{DynamicResource SquareButtonStyle}"
Width="26" Height="26" HorizontalAlignment="Right" Margin="10,0,0,0" ToolTip="Rename profile"> Width="26" Height="26" HorizontalAlignment="Right" Margin="10,0,0,0" ToolTip="Rename profile">
<Button.Content> <Button.Content>
<Rectangle <Rectangle
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}" Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
Width="12" Height="12"> Width="12" Height="12">
<Rectangle.OpacityMask> <Rectangle.OpacityMask>
<VisualBrush Visual="{StaticResource appbar_edit}" Stretch="Fill" /> <VisualBrush Visual="{StaticResource appbar_edit}" Stretch="Fill" />
</Rectangle.OpacityMask> </Rectangle.OpacityMask>
</Rectangle> </Rectangle>
</Button.Content> </Button.Content>
</Button> </Button>
<Button x:Name="DuplicateProfile" VerticalAlignment="Top" Style="{DynamicResource SquareButtonStyle}" <Button x:Name="DuplicateProfile" VerticalAlignment="Top" Style="{DynamicResource SquareButtonStyle}"
Width="26" Height="26" HorizontalAlignment="Right" Margin="10,0,0,0" ToolTip="Duplicate profile"> Width="26" Height="26" HorizontalAlignment="Right" Margin="10,0,0,0" ToolTip="Duplicate profile">
<Button.Content> <Button.Content>
<Rectangle <Rectangle
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}" Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
Width="12" Height="12"> Width="12" Height="12">
<Rectangle.OpacityMask> <Rectangle.OpacityMask>
<VisualBrush Visual="{StaticResource appbar_clipboard_paste}" Stretch="Fill" /> <VisualBrush Visual="{StaticResource appbar_clipboard_paste}" Stretch="Fill" />
</Rectangle.OpacityMask> </Rectangle.OpacityMask>
</Rectangle> </Rectangle>
</Button.Content> </Button.Content>
</Button> </Button>
<Button x:Name="DeleteProfile" VerticalAlignment="Top" Style="{DynamicResource SquareButtonStyle}" <Button x:Name="DeleteProfile" VerticalAlignment="Top" Style="{DynamicResource SquareButtonStyle}"
Width="26" Height="26" HorizontalAlignment="Right" Margin="10,0,0,0" ToolTip="Delete profile"> Width="26" Height="26" HorizontalAlignment="Right" Margin="10,0,0,0" ToolTip="Delete profile">
<Button.Content> <Button.Content>
<Rectangle <Rectangle
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}" Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
Width="12" Height="12"> Width="12" Height="12">
<Rectangle.OpacityMask> <Rectangle.OpacityMask>
<VisualBrush Visual="{StaticResource appbar_delete}" Stretch="Fill" /> <VisualBrush Visual="{StaticResource appbar_delete}" Stretch="Fill" />
</Rectangle.OpacityMask> </Rectangle.OpacityMask>
</Rectangle> </Rectangle>
</Button.Content> </Button.Content>
</Button> </Button>
</StackPanel> </StackPanel>
<StackPanel Grid.Column="0" Grid.Row="2" Orientation="Horizontal" Margin="0,5,0,0" HorizontalAlignment="Right"> <StackPanel Grid.Column="0" Grid.Row="2" Orientation="Horizontal" Margin="0,5,0,0" HorizontalAlignment="Right">
<Button x:Name="ImportProfile" VerticalAlignment="Top" Style="{DynamicResource SquareButtonStyle}" <Button x:Name="ImportProfile" VerticalAlignment="Top" Style="{DynamicResource SquareButtonStyle}"
Height="26" HorizontalAlignment="Right" ToolTip="Import profile"> Height="26" HorizontalAlignment="Right" ToolTip="Import profile">
<Button.Content> <Button.Content>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<Rectangle <Rectangle
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}" Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
Width="12" Height="12" Margin="3,0"> Width="12" Height="12" Margin="3,0">
<Rectangle.OpacityMask> <Rectangle.OpacityMask>
<VisualBrush Visual="{StaticResource appbar_cabinet_in}" Stretch="Fill" /> <VisualBrush Visual="{StaticResource appbar_cabinet_in}" Stretch="Fill" />
</Rectangle.OpacityMask> </Rectangle.OpacityMask>
</Rectangle> </Rectangle>
<TextBlock Margin="2,0,2,0">import profile</TextBlock> <TextBlock Margin="2,0,2,0">import profile</TextBlock>
</StackPanel> </StackPanel>
</Button.Content> </Button.Content>
</Button> </Button>
<Button x:Name="ExportProfile" VerticalAlignment="Top" Style="{DynamicResource SquareButtonStyle}" <Button x:Name="ExportProfile" VerticalAlignment="Top" Style="{DynamicResource SquareButtonStyle}"
Height="26" HorizontalAlignment="Right" Margin="10,0,0,0" IsEnabled="{Binding ProfileSelected}"> Height="26" HorizontalAlignment="Right" Margin="10,0,0,0" IsEnabled="{Binding ProfileSelected}">
<Button.Content> <Button.Content>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<Rectangle <Rectangle
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}" Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
Width="12" Height="12" Margin="3,0"> Width="12" Height="12" Margin="3,0">
<Rectangle.OpacityMask> <Rectangle.OpacityMask>
<VisualBrush Visual="{StaticResource appbar_cabinet_out}" Stretch="Fill" /> <VisualBrush Visual="{StaticResource appbar_cabinet_out}" Stretch="Fill" />
</Rectangle.OpacityMask> </Rectangle.OpacityMask>
</Rectangle> </Rectangle>
<TextBlock Margin="2,0,2,0">export profile</TextBlock> <TextBlock Margin="2,0,2,0">export profile</TextBlock>
</StackPanel> </StackPanel>
</Button.Content> </Button.Content>
</Button> </Button>
</StackPanel> </StackPanel>
<!-- Layer list --> <!-- Layer list -->
<Label Grid.Column="1" Grid.Row="0" FontSize="20" HorizontalAlignment="Left" Content="Layers" Margin="10,0,0,0" /> <Label Grid.Column="1" Grid.Row="0" FontSize="20" HorizontalAlignment="Left" Content="Layers" Margin="10,0,0,0" />
<Border Grid.Column="1" Grid.Row="1" Background="#FF232323" BorderBrush="{DynamicResource HighlightBrush}" <Border Grid.Column="1" Grid.Row="1" Background="#FF232323" BorderBrush="{DynamicResource HighlightBrush}"
BorderThickness="3" Margin="10,0,0,0" Height="400" Width="233"> BorderThickness="3" Margin="10,0,0,0" Height="400" Width="233">
<TreeView x:Name="ProfileTree" <TreeView x:Name="ProfileTree"
dragDrop:DragDrop.IsDragSource="True" dragDrop:DragDrop.IsDragSource="True"
dragDrop:DragDrop.IsDropTarget="True" dragDrop:DragDrop.IsDropTarget="True"
dragDrop:DragDrop.DropHandler="{Binding}" dragDrop:DragDrop.DropHandler="{Binding}"
ItemsSource="{Binding Path=Layers, Converter={StaticResource LayerOrderConverter}, ConverterParameter=Order}"> ItemsSource="{Binding Path=Layers, Converter={StaticResource LayerOrderConverter}, ConverterParameter=Order}">
<i:Interaction.Behaviors> <i:Interaction.Behaviors>
<itemBehaviours:BindableSelectedItemBehavior SelectedItem="{Binding SelectedLayer, Mode=TwoWay}" /> <itemBehaviours:BindableSelectedItemBehavior SelectedItem="{Binding ProfileViewModel.SelectedLayer, Mode=TwoWay}" />
</i:Interaction.Behaviors> </i:Interaction.Behaviors>
<TreeView.Resources> <TreeView.Resources>
<ResourceDictionary <ResourceDictionary
Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml" /> Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml" />
</TreeView.Resources> </TreeView.Resources>
<TreeView.ItemTemplate> <TreeView.ItemTemplate>
<HierarchicalDataTemplate <HierarchicalDataTemplate
ItemsSource="{Binding Children, Converter={StaticResource LayerOrderConverter}, ConverterParameter=Order}"> ItemsSource="{Binding Children, Converter={StaticResource LayerOrderConverter}, ConverterParameter=Order}">
<StackPanel Orientation="Horizontal" Tag="{Binding DataContext, ElementName=ProfileTree}"> <StackPanel Orientation="Horizontal" Tag="{Binding DataContext, ElementName=ProfileTree}">
<StackPanel.ContextMenu> <StackPanel.ContextMenu>
<ContextMenu <ContextMenu
cal:Action.TargetWithoutContext="{Binding Path=PlacementTarget.Tag, RelativeSource={RelativeSource Self}}"> cal:Action.TargetWithoutContext="{Binding Path=PlacementTarget.Tag, RelativeSource={RelativeSource Self}}">
<MenuItem Header="Rename" /> <MenuItem Header="Rename" />
<MenuItem Header="Duplicate" cal:Message.Attach="CloneLayer($datacontext)" /> <MenuItem Header="Duplicate" cal:Message.Attach="CloneLayer($datacontext)" />
<MenuItem Header="Delete" cal:Message.Attach="RemoveLayerFromMenu($datacontext)" /> <MenuItem Header="Delete" cal:Message.Attach="RemoveLayerFromMenu($datacontext)" />
<MenuItem Header="Properties" cal:Message.Attach="LayerEditor($datacontext)" /> <MenuItem Header="Properties" cal:Message.Attach="LayerEditor($datacontext)" />
</ContextMenu> </ContextMenu>
</StackPanel.ContextMenu> </StackPanel.ContextMenu>
<CheckBox VerticalAlignment="Center" ToolTip="Layer enabled" IsChecked="{Binding Enabled}" /> <CheckBox VerticalAlignment="Center" ToolTip="Layer enabled" IsChecked="{Binding Enabled}" />
<Image Height="18" Width="18" Source="{Binding LayerImage}" /> <Image Height="18" Width="18" Source="{Binding LayerImage}" />
<TextBlock Margin="5,0,0,0" Text="{Binding Name}" VerticalAlignment="Center" /> <TextBlock Margin="5,0,0,0" Text="{Binding Name}" VerticalAlignment="Center" />
</StackPanel> </StackPanel>
</HierarchicalDataTemplate> </HierarchicalDataTemplate>
</TreeView.ItemTemplate> </TreeView.ItemTemplate>
<TreeView.ItemContainerStyle> <TreeView.ItemContainerStyle>
<Style TargetType="{x:Type TreeViewItem}" BasedOn="{StaticResource {x:Type TreeViewItem}}"> <Style TargetType="{x:Type TreeViewItem}" BasedOn="{StaticResource {x:Type TreeViewItem}}">
<Setter Property="IsExpanded" Value="{Binding Path=Expanded, Mode=TwoWay}" /> <Setter Property="IsExpanded" Value="{Binding Path=Expanded, Mode=TwoWay}" />
</Style> </Style>
</TreeView.ItemContainerStyle> </TreeView.ItemContainerStyle>
</TreeView> </TreeView>
</Border> </Border>
<StackPanel Grid.Column="1" Grid.Row="2" Orientation="Horizontal" Margin="10,5,0,0" HorizontalAlignment="Right"> <StackPanel Grid.Column="1" Grid.Row="2" Orientation="Horizontal" Margin="10,5,0,0" HorizontalAlignment="Right">
<Button x:Name="AddLayer" VerticalAlignment="Top" <Button x:Name="AddLayer" VerticalAlignment="Top"
Style="{DynamicResource SquareButtonStyle}" IsEnabled="{Binding ProfileSelected}" Style="{DynamicResource SquareButtonStyle}" IsEnabled="{Binding ProfileSelected}"
Width="26" Height="26" ToolTip="Add layer" HorizontalAlignment="Left"> Width="26" Height="26" ToolTip="Add layer" HorizontalAlignment="Left">
<Button.Content> <Button.Content>
<Rectangle <Rectangle
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}" Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
Width="12" Height="12"> Width="12" Height="12">
<Rectangle.OpacityMask> <Rectangle.OpacityMask>
<VisualBrush Visual="{StaticResource appbar_add}" Stretch="Fill" /> <VisualBrush Visual="{StaticResource appbar_add}" Stretch="Fill" />
</Rectangle.OpacityMask> </Rectangle.OpacityMask>
</Rectangle> </Rectangle>
</Button.Content> </Button.Content>
</Button> </Button>
<Button x:Name="EditLayer" VerticalAlignment="Top" Style="{DynamicResource SquareButtonStyle}" <Button x:Name="EditLayer" VerticalAlignment="Top" Style="{DynamicResource SquareButtonStyle}"
Width="26" Height="26" HorizontalAlignment="Right" Margin="10,0,0,0" ToolTip="Rename layer" Width="26" Height="26" HorizontalAlignment="Right" Margin="10,0,0,0" ToolTip="Rename layer"
IsEnabled="{Binding Path=LayerSelected}"> IsEnabled="{Binding Path=LayerSelected}">
<Button.Content> <Button.Content>
<Rectangle <Rectangle
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}" Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
Width="12" Height="12"> Width="12" Height="12">
<Rectangle.OpacityMask> <Rectangle.OpacityMask>
<VisualBrush Visual="{StaticResource appbar_edit}" Stretch="Fill" /> <VisualBrush Visual="{StaticResource appbar_edit}" Stretch="Fill" />
</Rectangle.OpacityMask> </Rectangle.OpacityMask>
</Rectangle> </Rectangle>
</Button.Content> </Button.Content>
</Button> </Button>
<Button x:Name="CloneLayer" VerticalAlignment="Top" Style="{DynamicResource SquareButtonStyle}" <Button x:Name="CloneLayer" VerticalAlignment="Top" Style="{DynamicResource SquareButtonStyle}"
Width="26" Height="26" HorizontalAlignment="Right" Margin="10,0,0,0" ToolTip="Duplicate layer" Width="26" Height="26" HorizontalAlignment="Right" Margin="10,0,0,0" ToolTip="Duplicate layer"
IsEnabled="{Binding Path=LayerSelected}"> IsEnabled="{Binding Path=LayerSelected}">
<Button.Content> <Button.Content>
<Rectangle <Rectangle
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}" Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
Width="12" Height="12"> Width="12" Height="12">
<Rectangle.OpacityMask> <Rectangle.OpacityMask>
<VisualBrush Visual="{StaticResource appbar_clipboard_paste}" Stretch="Fill" /> <VisualBrush Visual="{StaticResource appbar_clipboard_paste}" Stretch="Fill" />
</Rectangle.OpacityMask> </Rectangle.OpacityMask>
</Rectangle> </Rectangle>
</Button.Content> </Button.Content>
</Button> </Button>
<Button x:Name="RemoveLayer" VerticalAlignment="Top" Style="{DynamicResource SquareButtonStyle}" <Button x:Name="RemoveLayer" VerticalAlignment="Top" Style="{DynamicResource SquareButtonStyle}"
Width="26" Height="26" HorizontalAlignment="Right" Margin="10,0,0,0" ToolTip="Delete layer" Width="26" Height="26" HorizontalAlignment="Right" Margin="10,0,0,0" ToolTip="Delete layer"
IsEnabled="{Binding Path=LayerSelected}"> IsEnabled="{Binding Path=LayerSelected}">
<Button.Content> <Button.Content>
<Rectangle <Rectangle
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}" Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
Width="12" Height="12"> Width="12" Height="12">
<Rectangle.OpacityMask> <Rectangle.OpacityMask>
<VisualBrush Visual="{StaticResource appbar_delete}" Stretch="Fill" /> <VisualBrush Visual="{StaticResource appbar_delete}" Stretch="Fill" />
</Rectangle.OpacityMask> </Rectangle.OpacityMask>
</Rectangle> </Rectangle>
</Button.Content> </Button.Content>
</Button> </Button>
</StackPanel> </StackPanel>
</Grid> </Grid>
</UserControl> </UserControl>

View File

@ -1,15 +1,15 @@
using System.Windows.Controls; using System.Windows.Controls;
namespace Artemis.Views namespace Artemis.Views.Profiles
{ {
/// <summary> /// <summary>
/// Interaction logic for ProfileEditorView.xaml /// Interaction logic for ProfileEditorView.xaml
/// </summary> /// </summary>
public partial class ProfileEditorView : UserControl public partial class ProfileEditorView : UserControl
{ {
public ProfileEditorView() public ProfileEditorView()
{ {
InitializeComponent(); InitializeComponent();
} }
} }
} }

View File

@ -1,4 +1,4 @@
<UserControl x:Class="Artemis.Views.LayerEditor.Properties.FolderPropertiesView" <UserControl x:Class="Artemis.Views.Profiles.Properties.FolderPropertiesView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

View File

@ -1,6 +1,6 @@
using System.Windows.Controls; using System.Windows.Controls;
namespace Artemis.Views.LayerEditor.Properties namespace Artemis.Views.Profiles.Properties
{ {
/// <summary> /// <summary>
/// Interaction logic for FolderPropertiesView.xaml /// Interaction logic for FolderPropertiesView.xaml

View File

@ -1,4 +1,4 @@
<UserControl x:Class="Artemis.Views.LayerEditor.Properties.HeadsetPropertiesView" <UserControl x:Class="Artemis.Views.Profiles.Properties.HeadsetPropertiesView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

View File

@ -1,6 +1,6 @@
using System.Windows.Controls; using System.Windows.Controls;
namespace Artemis.Views.LayerEditor.Properties namespace Artemis.Views.Profiles.Properties
{ {
/// <summary> /// <summary>
/// Interaction logic for HeadsetPropertiesView.xaml /// Interaction logic for HeadsetPropertiesView.xaml

View File

@ -1,4 +1,4 @@
<UserControl x:Class="Artemis.Views.LayerEditor.Properties.KeyboardPropertiesView" <UserControl x:Class="Artemis.Views.Profiles.Properties.KeyboardPropertiesView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

View File

@ -1,6 +1,6 @@
using System.Windows.Controls; using System.Windows.Controls;
namespace Artemis.Views.LayerEditor.Properties namespace Artemis.Views.Profiles.Properties
{ {
/// <summary> /// <summary>
/// Interaction logic for KeyboardPropertiesView.xaml /// Interaction logic for KeyboardPropertiesView.xaml

View File

@ -1,4 +1,4 @@
<UserControl x:Class="Artemis.Views.LayerEditor.Properties.MousePropertiesView" <UserControl x:Class="Artemis.Views.Profiles.Properties.MousePropertiesView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

View File

@ -1,6 +1,6 @@
using System.Windows.Controls; using System.Windows.Controls;
namespace Artemis.Views.LayerEditor.Properties namespace Artemis.Views.Profiles.Properties
{ {
/// <summary> /// <summary>
/// Interaction logic for MousePropertiesView.xaml /// Interaction logic for MousePropertiesView.xaml

View File

@ -0,0 +1,104 @@
// Original work by VRocker https://github.com/VRocker/LogiLed2Corsair
// I'm mainly a C# developer, and these modification aren't a piece of art, but it suits our needs.
// The MIT License (MIT)
//
// Copyright (c) 2015 VRocker
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include "Logger.h"
#include <time.h>
#include <stdlib.h>
#include <stdarg.h>
// Ok this looks butt-ugleh but its just to force the default log level to debug if we compile in debug
#ifdef _DEBUG
LogLevel CLogger::m_eLogLevel = LogLevel::Debug;
#else
LogLevel CLogger::m_eLogLevel = LogLevel::All;
#endif
FILE* CLogger::m_pFile = 0;
void CLogger::InitLogging(const char* szFile)
{
if (!m_pFile)
{
m_pFile = fopen(szFile, "a+");
if (!m_pFile)
{
// Hum, we couldn't open the file for writing
printf("ERROR: Unable to open log file %s.\n", szFile);
}
}
}
void CLogger::EndLogging(void)
{
if (m_pFile)
{
fclose(m_pFile);
m_pFile = 0;
}
}
void CLogger::OutputLog_s(const char* sz, const LogLevel eLevel)
{
// If the level of this log entry is less important than what we are told to log, just return
if (eLevel < m_eLogLevel)
return;
// If we don't have a file to write to, bail.
if (!m_pFile)
return;
char szOutput[512] = { 0 };
time_t rawtime;
struct tm* timeinfo;
time(&rawtime);
timeinfo = localtime(&rawtime);
// Timestamp the log entry
size_t uiLen = sprintf(szOutput, "<%.2d/%.2d/%.2d - %.2d:%.2d:%.2d> %s\n", timeinfo->tm_mday, timeinfo->tm_mon + 1, timeinfo->tm_year + 1900, timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec, sz);
// Write the text to the file
fwrite(szOutput, 1, uiLen, m_pFile);
// Flush the log file to the disk. May move this to a seperate function
fflush(m_pFile);
// Output the text to any console that may be attached
printf("%s", szOutput);
}
void CLogger::OutputLog(const char* sz, const LogLevel eLevel, ...)
{
char szText[1024] = { 0 };
va_list marker;
va_start(marker, eLevel);
vsprintf(szText, sz, marker);
va_end(marker);
// Since this function is pretty much the same as the safer function, we'll just redirect it there
OutputLog_s(szText, eLevel);
}

View File

@ -0,0 +1,82 @@
// Original work by VRocker https://github.com/VRocker/LogiLed2Corsair
// I'm mainly a C# developer, and these modification aren't a piece of art, but it suits our needs.
// The MIT License (MIT)
//
// Copyright (c) 2015 VRocker
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#pragma once
#ifndef _LOGGER_H
#define _LOGGER_H
#include <stdio.h>
enum class LogLevel
{
Debug,
All,
Critical,
Warning,
Information,
User,
Internal,
None,
// Just to force the compiler to treat the enum options as an int
FORCE_32BIT = 0x7fffffff
};
class CLogger
{
public:
static LogLevel GetLogLevel(void)
{
return m_eLogLevel;
}
static void SetLogLevel(const LogLevel e)
{
#ifndef _DEBUG
if (e == LogLevel::Debug) return;
#endif
m_eLogLevel = e;
}
static void InitLogging(const char* szFile);
// Always remember to end logging when you are finished otherwise you will have file handles floating around
static void EndLogging(void);
// Output the text to a log file.
static void OutputLog_s(const char* sz, const LogLevel eLevel);
static void OutputLog(const char* sz, const LogLevel eLevel, ...);
static FILE* GetFile()
{
return m_pFile;
}
private:
static LogLevel m_eLogLevel;
static FILE* m_pFile;
};
#endif

View File

@ -0,0 +1,17 @@
LIBRARY Razer2Artemis.dll
EXPORTS
CreateEffect
CreateHeadsetEffect
CreateKeyboardEffect
CreateKeypadEffect
CreateMouseEffect
CreateMousepadEffect
DeleteEffect
Init
QueryDevice
RegisterEventNotification
SetEffect
UnInit
UnregisterEventNotification

View File

@ -0,0 +1,142 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{39711909-C1D5-46CE-A9EA-2D561692EA47}</ProjectGuid>
<RootNamespace>Razer2Artemis</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<TargetExt>.dll</TargetExt>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<TargetExt>.dll</TargetExt>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>
</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<ModuleDefinitionFile>Razer2Artemis.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>
</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<ModuleDefinitionFile>Razer2Artemis.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="Razer2Artemis.def" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="Logger.cpp" />
<ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Logger.h" />
<ClInclude Include="main.h" />
<ClInclude Include="RzChromaSDKDefines.h" />
<ClInclude Include="RzChromaSDKTypes.h" />
<ClInclude Include="RzErrors.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="Razer2Artemis.def">
<Filter>Source Files</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Logger.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="main.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Logger.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="RzChromaSDKDefines.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="RzChromaSDKTypes.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="RzErrors.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -0,0 +1,148 @@
//! \file RzChromaSDKDefines.h
//! \brief Definitions of global and static variables.
#ifndef _RZSCHROMADKDEFINES_H_
#define _RZSCHROMADKDEFINES_H_
#pragma once
#ifndef GUID_DEFINED
#include <Guiddef.h>
#endif
namespace ChromaSDK
{
// Keyboards
//! Razer Blackwidow Chroma device.
// {2EA1BB63-CA28-428D-9F06-196B88330BBB}
static const GUID BLACKWIDOW_CHROMA =
{ 0x2ea1bb63, 0xca28, 0x428d,{ 0x9f, 0x06, 0x19, 0x6b, 0x88, 0x33, 0x0b, 0xbb } };
//! Razer Blackwidow Chroma Tournament Edition device.
// {ED1C1B82-BFBE-418F-B49D-D03F05B149DF}
static const GUID BLACKWIDOW_CHROMA_TE =
{ 0xed1c1b82, 0xbfbe, 0x418f,{ 0xb4, 0x9d, 0xd0, 0x3f, 0x5, 0xb1, 0x49, 0xdf } };
//! Razer Deathstalker device.
// {18C5AD9B-4326-4828-92C4-2669A66D2283}
static const GUID DEATHSTALKER_CHROMA =
{ 0x18c5ad9b, 0x4326, 0x4828,{ 0x92, 0xc4, 0x26, 0x69, 0xa6, 0x6d, 0x22, 0x83 } };
//! Overwatch Keyboard.
// {872AB2A9-7959-4478-9FED-15F6186E72E4}
static const GUID OVERWATCH_KEYBOARD =
{ 0x872ab2a9, 0x7959, 0x4478,{ 0x9f, 0xed, 0x15, 0xf6, 0x18, 0x6e, 0x72, 0xe4 } };
//! Razer Blackwidow X Chroma device.
// {5AF60076-ADE9-43D4-B574-52599293B554}
static const GUID BLACKWIDOW_X_CHROMA =
{ 0x5af60076, 0xade9, 0x43d4,{ 0xb5, 0x74, 0x52, 0x59, 0x92, 0x93, 0xb5, 0x54 } };
//! Razer Blackwidow X TE Chroma device.
// {2D84DD51-3290-4AAC-9A89-D8AFDE38B57C}
static const GUID BLACKWIDOW_X_TE_CHROMA =
{ 0x2d84dd51, 0x3290, 0x4aac,{ 0x9a, 0x89, 0xd8, 0xaf, 0xde, 0x38, 0xb5, 0x7c } };
//! Razer Blade Stealth.
// {C83BDFE8-E7FC-40E0-99DB-872E23F19891}
static const GUID BLADE_STEALTH =
{ 0xc83bdfe8, 0xe7fc, 0x40e0,{ 0x99, 0xdb, 0x87, 0x2e, 0x23, 0xf1, 0x98, 0x91 } };
//! Razer Blade
// {F2BEDFAF-A0FE-4651-9D41-B6CE603A3DDD}
static const GUID BLADE =
{ 0xf2bedfaf, 0xa0fe, 0x4651,{ 0x9d, 0x41, 0xb6, 0xce, 0x60, 0x3a, 0x3d, 0xdd } };
// Mice
//! Razer Deathadder Chroma device.
// {AEC50D91-B1F1-452F-8E16-7B73F376FDF3}
static const GUID DEATHADDER_CHROMA =
{ 0xaec50d91, 0xb1f1, 0x452f,{ 0x8e, 0x16, 0x7b, 0x73, 0xf3, 0x76, 0xfd, 0xf3 } };
//! Razer Mamba Chroma Tournament Edition device.
// {7EC00450-E0EE-4289-89D5-0D879C19061A}
static const GUID MAMBA_CHROMA_TE =
{ 0x7ec00450, 0xe0ee, 0x4289,{ 0x89, 0xd5, 0xd, 0x87, 0x9c, 0x19, 0x6, 0x1a } };
//! Razer Diamondback device.
// {FF8A5929-4512-4257-8D59-C647BF9935D0}
static const GUID DIAMONDBACK_CHROMA =
{ 0xff8a5929, 0x4512, 0x4257,{ 0x8d, 0x59, 0xc6, 0x47, 0xbf, 0x99, 0x35, 0xd0 } };
//! Razer Mamba device.
// {D527CBDC-EB0A-483A-9E89-66D50463EC6C}
static const GUID MAMBA_CHROMA =
{ 0xd527cbdc, 0xeb0a, 0x483a,{ 0x9e, 0x89, 0x66, 0xd5, 0x4, 0x63, 0xec, 0x6c } };
//! Razer Naga Epic device.
// {D714C50B-7158-4368-B99C-601ACB985E98}
static const GUID NAGA_EPIC_CHROMA =
{ 0xd714c50b, 0x7158, 0x4368,{ 0xb9, 0x9c, 0x60, 0x1a, 0xcb, 0x98, 0x5e, 0x98 } };
//! Razer Naga device.
// {F1876328-6CA4-46AE-BE04-BE812B414433}
static const GUID NAGA_CHROMA =
{ 0xf1876328, 0x6ca4, 0x46ae,{ 0xbe, 0x4, 0xbe, 0x81, 0x2b, 0x41, 0x44, 0x33 } };
//! Razer Orochi Chroma device.
// {52C15681-4ECE-4DD9-8A52-A1418459EB34}
static const GUID OROCHI_CHROMA =
{ 0x52c15681, 0x4ece, 0x4dd9,{ 0x8a, 0x52, 0xa1, 0x41, 0x84, 0x59, 0xeb, 0x34 } };
//! Razer Naga Hex Chroma device.
// {195D70F5-F285-4CFF-99F2-B8C0E9658DB4}
static const GUID NAGA_HEX_CHROMA =
{ 0x195d70f5, 0xf285, 0x4cff,{ 0x99, 0xf2, 0xb8, 0xc0, 0xe9, 0x65, 0x8d, 0xb4 } };
// Headsets
//! Razer Kraken 7.1 Chroma device.
// {CD1E09A5-D5E6-4A6C-A93B-E6D9BF1D2092}
static const GUID KRAKEN71_CHROMA =
{ 0xcd1e09a5, 0xd5e6, 0x4a6c,{ 0xa9, 0x3b, 0xe6, 0xd9, 0xbf, 0x1d, 0x20, 0x92 } };
//! Razer ManO'War device.
// {DF3164D7-5408-4A0E-8A7F-A7412F26BEBF}
static const GUID MANOWAR_HEADSET =
{ 0xdf3164d7, 0x5408, 0x4a0e,{ 0x8a, 0x7f, 0xa7, 0x41, 0x2f, 0x26, 0xbe, 0xbf } };
// Mouse mat
//! Razer Firefly device.
// {80F95A94-73D2-48CA-AE9A-0986789A9AF2}
static const GUID FIREFLY_CHROMA =
{ 0x80f95a94, 0x73d2, 0x48ca,{ 0xae, 0x9a, 0x9, 0x86, 0x78, 0x9a, 0x9a, 0xf2 } };
// Keypads
//! Razer Tartarus device.
// {00F0545C-E180-4AD1-8E8A-419061CE505E}
static const GUID TARTARUS_CHROMA =
{ 0xf0545c, 0xe180, 0x4ad1,{ 0x8e, 0x8a, 0x41, 0x90, 0x61, 0xce, 0x50, 0x5e } };
//! Razer Orbweaver device.
// {9D24B0AB-0162-466C-9640-7A924AA4D9FD}
static const GUID ORBWEAVER_CHROMA =
{ 0x9d24b0ab, 0x162, 0x466c,{ 0x96, 0x40, 0x7a, 0x92, 0x4a, 0xa4, 0xd9, 0xfd } };
// Systems
// {35F6F18D-1AE5-436C-A575-AB44A127903A}
static const GUID LENOVO_Y900 =
{ 0x35f6f18d, 0x1ae5, 0x436c,{ 0xa5, 0x75, 0xab, 0x44, 0xa1, 0x27, 0x90, 0x3a } };
// {47DB1FA7-6B9B-4EE6-B6F4-4071A3B2053B}
static const GUID LENOVO_Y27 =
{ 0x47db1fa7, 0x6b9b, 0x4ee6,{ 0xb6, 0xf4, 0x40, 0x71, 0xa3, 0xb2, 0x5, 0x3b } };
// Accessories
// {0201203B-62F3-4C50-83DD-598BABD208E0}
static const GUID CORE_CHROMA =
{ 0x201203b, 0x62f3, 0x4c50,{ 0x83, 0xdd, 0x59, 0x8b, 0xab, 0xd2, 0x8, 0xe0 } };
}
#endif

View File

@ -0,0 +1,787 @@
#include <windows.h>
//! \file RzChromaSDKTypes.h
//! \brief Data types.
#ifndef _RZCHROMASDKTYPES_H_
#define _RZCHROMASDKTYPES_H_
#pragma once
typedef LONG RZRESULT; //!< Return result.
typedef GUID RZEFFECTID; //!< Effect Id.
typedef GUID RZDEVICEID; //!< Device Id.
typedef unsigned int RZDURATION; //!< Milliseconds.
typedef size_t RZSIZE; //!< Size.
typedef void* PRZPARAM; //!< Context sensitive pointer.
typedef DWORD RZID; //!< Generic data type for Identifier.
typedef DWORD RZCOLOR; //!< Color data. 1st byte = Red; 2nd byte = Green; 3rd byte = Blue; 4th byte = Alpha (if applicable)
namespace ChromaSDK
{
//! Event notification Window message
const UINT WM_CHROMA_EVENT = WM_APP + 0x2000;
//! Chroma generic effects. Note: Not all devices supported the listed effects.
typedef enum EFFECT_TYPE
{
CHROMA_NONE = 0, //!< No effect.
CHROMA_WAVE, //!< Wave effect.
CHROMA_SPECTRUMCYCLING, //!< Spectrum cycling effect.
CHROMA_BREATHING, //!< Breathing effect.
CHROMA_BLINKING, //!< Blinking effect.
CHROMA_REACTIVE, //!< Reactive effect.
CHROMA_STATIC, //!< Static effect.
CHROMA_CUSTOM, //!< Custom effect. For mice, please see Mouse::CHROMA_CUSTOM2.
CHROMA_STARLIGHT, //!< TODO
CHROMA_INVALID //!< Invalid effect.
} EFFECT_TYPE;
//! Device info.
typedef struct DEVICE_INFO_TYPE
{
//! Device types.
enum DeviceType
{
DEVICE_KEYBOARD = 1, //!< Keyboard device.
DEVICE_MOUSE = 2, //!< Mouse device.
DEVICE_HEADSET = 3, //!< Headset device.
DEVICE_MOUSEPAD = 4, //!< Mousepad device.
DEVICE_KEYPAD = 5, //!< Keypad device.
DEVICE_SYSTEM = 6, //!< System device.
DEVICE_INVALID //!< Invalid device.
} DeviceType;
DWORD Connected; //!< Number of devices connected.
} DEVICE_INFO_TYPE;
const RZSIZE MAX_ROW = 30; //!< Maximum rows for custom effects.
const RZSIZE MAX_COLUMN = 30; //!< Maximum columns for custom effects.
//! Blinking effect.
typedef struct BLINKING_EFFECT_TYPE
{
RZSIZE Size; //!< Size of the structure. Size = sizeof(BLINKING_EFFECT_TYPE)
DWORD Param; //!< Extra parameters.
COLORREF Color; //!< Blinking color
} BLINKING_EFFECT_TYPE;
//! Breathing effect.
typedef struct BREATHING_EFFECT_TYPE
{
RZSIZE Size; //!< Size of ths structure. Size = sizeof(BREATHING_EFFECT_TYPE)
DWORD Param; //!< Extra parameters.
//! Breathing effect types.
enum _Type
{
ONE_COLOR = 1, //!< 1 color (Only fill Color1).
TWO_COLORS, //!< 2 colors.
RANDOM_COLORS //!< Random colors
} Type;
COLORREF Color1; //!< First color.
COLORREF Color2; //!< Second color.
} BREATHING_EFFECT_TYPE;
//! Custom effect.
typedef struct CUSTOM_EFFECT_TYPE
{
RZSIZE Size; //!< Size of the structure. Size = sizeof(CUSTOM_EFFECT_TYPE)
DWORD Param; //!< Extra parameters.
RZCOLOR Color[MAX_ROW][MAX_COLUMN];
} CUSTOM_EFFECT_TYPE;
//! No effect.
typedef struct NO_EFFECT_TYPE
{
RZSIZE Size; //!< Size of the structure. Size = sizeof(NO_EFFECT_TYPE)
DWORD Param; //!< Extra parameters.
} NO_EFFECT_TYPE;
//! Reactive effect.
typedef struct REACTIVE_EFFECT_TYPE
{
RZSIZE Size; //!< Size of the structure. Size = sizeof(REACTIVE_EFFECT_TYPE)
DWORD Param; //!< Extra parameters.
//! Duration of the effect.
enum _Duration
{
DURATION_SHORT = 1, //!< Short duration.
DURATION_MEDIUM, //!< Medium duration.
DURATION_LONG //!< Long duration.
} Duration; //!< The time taken for the effect to fade away.
COLORREF Color; //!< Color of the effect.
} REACTIVE_EFFECT_TYPE;
//! Spectrum cycling effect.
typedef struct SPECTRUMCYCLING_EFFECT_TYPE
{
RZSIZE Size; //!< Size of the structure. Size = sizeof(SPECTRUMCYCLING_EFFECT_TYPE)
DWORD Param; //!< Extra parameters.
} SPECTRUMCYCLING_EFFECT_TYPE;
//! Starlight effect.
typedef struct STARLIGHT_EFFECT_TYPE
{
RZSIZE Size; //!< Size of the structure. Size = sizeof(SPECTRUMCYCLING_EFFECT_TYPE)
DWORD Param; //!< Extra parameters.
//! Starlight effect types.
enum _Type
{
TWO_COLORS = 1, //!< 2 colors.
RANDOM_COLORS //!< Random colors
} Type;
COLORREF Color1; //!< First color.
COLORREF Color2; //!< Second color.
//! Duration of the effect.
enum _Duration
{
DURATION_SHORT = 1, //!< Short duration.
DURATION_MEDIUM, //!< Medium duration.
DURATION_LONG //!< Long duration.
} Duration; //!< The time taken for the effect to fade away.
} STARLIGHT_EFFECT_TYPE;
//! Static effect.
typedef struct STATIC_EFFECT_TYPE
{
RZSIZE Size; //!< Size of the structure. Size = sizeof(STATIC_EFFECT_TYPE)
DWORD Param; //!< Extra parameters.
COLORREF Color; //!< Color of the effect.
} STATIC_EFFECT_TYPE;
//! Wave effect.
typedef struct WAVE_EFFECT_TYPE
{
RZSIZE Size; //!< Size of the structure. Size = sizeof(WAVE_EFFECT_TYPE)
DWORD Param; //!< Extra parameters.
//! Direction of effect.
enum _Direction
{
DIRECTION_LEFT_TO_RIGHT = 1, //!< Left to right.
DIRECTION_RIGHT_TO_LEFT, //!< Right to left.
DIRECTION_FRONT_TO_BACK, //!< Front to back
DIRECTION_BACK_TO_FRONT //!< Back top front
} Direction;
} WAVE_EFFECT_TYPE;
//! Keyboards
namespace Keyboard
{
//! Definitions of keys.
typedef enum RZKEY
{
RZKEY_ESC = 0x0001, /*!< Esc (VK_ESCAPE) */
RZKEY_F1 = 0x0003, /*!< F1 (VK_F1) */
RZKEY_F2 = 0x0004, /*!< F2 (VK_F2) */
RZKEY_F3 = 0x0005, /*!< F3 (VK_F3) */
RZKEY_F4 = 0x0006, /*!< F4 (VK_F4) */
RZKEY_F5 = 0x0007, /*!< F5 (VK_F5) */
RZKEY_F6 = 0x0008, /*!< F6 (VK_F6) */
RZKEY_F7 = 0x0009, /*!< F7 (VK_F7) */
RZKEY_F8 = 0x000A, /*!< F8 (VK_F8) */
RZKEY_F9 = 0x000B, /*!< F9 (VK_F9) */
RZKEY_F10 = 0x000C, /*!< F10 (VK_F10) */
RZKEY_F11 = 0x000D, /*!< F11 (VK_F11) */
RZKEY_F12 = 0x000E, /*!< F12 (VK_F12) */
RZKEY_1 = 0x0102, /*!< 1 (VK_1) */
RZKEY_2 = 0x0103, /*!< 2 (VK_2) */
RZKEY_3 = 0x0104, /*!< 3 (VK_3) */
RZKEY_4 = 0x0105, /*!< 4 (VK_4) */
RZKEY_5 = 0x0106, /*!< 5 (VK_5) */
RZKEY_6 = 0x0107, /*!< 6 (VK_6) */
RZKEY_7 = 0x0108, /*!< 7 (VK_7) */
RZKEY_8 = 0x0109, /*!< 8 (VK_8) */
RZKEY_9 = 0x010A, /*!< 9 (VK_9) */
RZKEY_0 = 0x010B, /*!< 0 (VK_0) */
RZKEY_A = 0x0302, /*!< A (VK_A) */
RZKEY_B = 0x0407, /*!< B (VK_B) */
RZKEY_C = 0x0405, /*!< C (VK_C) */
RZKEY_D = 0x0304, /*!< D (VK_D) */
RZKEY_E = 0x0204, /*!< E (VK_E) */
RZKEY_F = 0x0305, /*!< F (VK_F) */
RZKEY_G = 0x0306, /*!< G (VK_G) */
RZKEY_H = 0x0307, /*!< H (VK_H) */
RZKEY_I = 0x0209, /*!< I (VK_I) */
RZKEY_J = 0x0308, /*!< J (VK_J) */
RZKEY_K = 0x0309, /*!< K (VK_K) */
RZKEY_L = 0x030A, /*!< L (VK_L) */
RZKEY_M = 0x0409, /*!< M (VK_M) */
RZKEY_N = 0x0408, /*!< N (VK_N) */
RZKEY_O = 0x020A, /*!< O (VK_O) */
RZKEY_P = 0x020B, /*!< P (VK_P) */
RZKEY_Q = 0x0202, /*!< Q (VK_Q) */
RZKEY_R = 0x0205, /*!< R (VK_R) */
RZKEY_S = 0x0303, /*!< S (VK_S) */
RZKEY_T = 0x0206, /*!< T (VK_T) */
RZKEY_U = 0x0208, /*!< U (VK_U) */
RZKEY_V = 0x0406, /*!< V (VK_V) */
RZKEY_W = 0x0203, /*!< W (VK_W) */
RZKEY_X = 0x0404, /*!< X (VK_X) */
RZKEY_Y = 0x0207, /*!< Y (VK_Y) */
RZKEY_Z = 0x0403, /*!< Z (VK_Z) */
RZKEY_NUMLOCK = 0x0112, /*!< Numlock (VK_NUMLOCK) */
RZKEY_NUMPAD0 = 0x0513, /*!< Numpad 0 (VK_NUMPAD0) */
RZKEY_NUMPAD1 = 0x0412, /*!< Numpad 1 (VK_NUMPAD1) */
RZKEY_NUMPAD2 = 0x0413, /*!< Numpad 2 (VK_NUMPAD2) */
RZKEY_NUMPAD3 = 0x0414, /*!< Numpad 3 (VK_NUMPAD3) */
RZKEY_NUMPAD4 = 0x0312, /*!< Numpad 4 (VK_NUMPAD4) */
RZKEY_NUMPAD5 = 0x0313, /*!< Numpad 5 (VK_NUMPAD5) */
RZKEY_NUMPAD6 = 0x0314, /*!< Numpad 6 (VK_NUMPAD6) */
RZKEY_NUMPAD7 = 0x0212, /*!< Numpad 7 (VK_NUMPAD7) */
RZKEY_NUMPAD8 = 0x0213, /*!< Numpad 8 (VK_NUMPAD8) */
RZKEY_NUMPAD9 = 0x0214, /*!< Numpad 9 (VK_ NUMPAD9*/
RZKEY_NUMPAD_DIVIDE = 0x0113, /*!< Divide (VK_DIVIDE) */
RZKEY_NUMPAD_MULTIPLY = 0x0114, /*!< Multiply (VK_MULTIPLY) */
RZKEY_NUMPAD_SUBTRACT = 0x0115, /*!< Subtract (VK_SUBTRACT) */
RZKEY_NUMPAD_ADD = 0x0215, /*!< Add (VK_ADD) */
RZKEY_NUMPAD_ENTER = 0x0415, /*!< Enter (VK_RETURN - Extended) */
RZKEY_NUMPAD_DECIMAL = 0x0514, /*!< Decimal (VK_DECIMAL) */
RZKEY_PRINTSCREEN = 0x000F, /*!< Print Screen (VK_PRINT) */
RZKEY_SCROLL = 0x0010, /*!< Scroll Lock (VK_SCROLL) */
RZKEY_PAUSE = 0x0011, /*!< Pause (VK_PAUSE) */
RZKEY_INSERT = 0x010F, /*!< Insert (VK_INSERT) */
RZKEY_HOME = 0x0110, /*!< Home (VK_HOME) */
RZKEY_PAGEUP = 0x0111, /*!< Page Up (VK_PRIOR) */
RZKEY_DELETE = 0x020f, /*!< Delete (VK_DELETE) */
RZKEY_END = 0x0210, /*!< End (VK_END) */
RZKEY_PAGEDOWN = 0x0211, /*!< Page Down (VK_NEXT) */
RZKEY_UP = 0x0410, /*!< Up (VK_UP) */
RZKEY_LEFT = 0x050F, /*!< Left (VK_LEFT) */
RZKEY_DOWN = 0x0510, /*!< Down (VK_DOWN) */
RZKEY_RIGHT = 0x0511, /*!< Right (VK_RIGHT) */
RZKEY_TAB = 0x0201, /*!< Tab (VK_TAB) */
RZKEY_CAPSLOCK = 0x0301, /*!< Caps Lock(VK_CAPITAL) */
RZKEY_BACKSPACE = 0x010E, /*!< Backspace (VK_BACK) */
RZKEY_ENTER = 0x030E, /*!< Enter (VK_RETURN) */
RZKEY_LCTRL = 0x0501, /*!< Left Control(VK_LCONTROL) */
RZKEY_LWIN = 0x0502, /*!< Left Window (VK_LWIN) */
RZKEY_LALT = 0x0503, /*!< Left Alt (VK_LMENU) */
RZKEY_SPACE = 0x0507, /*!< Spacebar (VK_SPACE) */
RZKEY_RALT = 0x050B, /*!< Right Alt (VK_RMENU) */
RZKEY_FN = 0x050C, /*!< Function key. */
RZKEY_RMENU = 0x050D, /*!< Right Menu (VK_APPS) */
RZKEY_RCTRL = 0x050E, /*!< Right Control (VK_RCONTROL) */
RZKEY_LSHIFT = 0x0401, /*!< Left Shift (VK_LSHIFT) */
RZKEY_RSHIFT = 0x040E, /*!< Right Shift (VK_RSHIFT) */
RZKEY_MACRO1 = 0x0100, /*!< Macro Key 1 */
RZKEY_MACRO2 = 0x0200, /*!< Macro Key 2 */
RZKEY_MACRO3 = 0x0300, /*!< Macro Key 3 */
RZKEY_MACRO4 = 0x0400, /*!< Macro Key 4 */
RZKEY_MACRO5 = 0x0500, /*!< Macro Key 5 */
RZKEY_OEM_1 = 0x0101, /*!< ~ (tilde/半角/全角) (VK_OEM_3) */
RZKEY_OEM_2 = 0x010C, /*!< -- (minus) (VK_OEM_MINUS) */
RZKEY_OEM_3 = 0x010D, /*!< = (equal) (VK_OEM_PLUS) */
RZKEY_OEM_4 = 0x020C, /*!< [ (left sqaure bracket) (VK_OEM_4) */
RZKEY_OEM_5 = 0x020D, /*!< ] (right square bracket) (VK_OEM_6) */
RZKEY_OEM_6 = 0x020E, /*!< \ (backslash) (VK_OEM_5) */
RZKEY_OEM_7 = 0x030B, /*!< ; (semi-colon) (VK_OEM_1) */
RZKEY_OEM_8 = 0x030C, /*!< ' (apostrophe) (VK_OEM_7) */
RZKEY_OEM_9 = 0x040A, /*!< , (comma) (VK_OEM_COMMA) */
RZKEY_OEM_10 = 0x040B, /*!< . (period) (VK_OEM_PERIOD) */
RZKEY_OEM_11 = 0x040C, /*!< / (forward slash) (VK_OEM_2) */
RZKEY_EUR_1 = 0x030D, /*!< "#" (VK_OEM_5) */
RZKEY_EUR_2 = 0x0402, /*!< \ (VK_OEM_102) */
RZKEY_JPN_1 = 0x0015, /*!< ¥ (0xFF) */
RZKEY_JPN_2 = 0x040D, /*!< \ (0xC1) */
RZKEY_JPN_3 = 0x0504, /*!< 無変換 (VK_OEM_PA1) */
RZKEY_JPN_4 = 0x0509, /*!< 変換 (0xFF) */
RZKEY_JPN_5 = 0x050A, /*!< ひらがな/カタカナ (0xFF) */
RZKEY_KOR_1 = 0x0015, /*!< | (0xFF) */
RZKEY_KOR_2 = 0x030D, /*!< (VK_OEM_5) */
RZKEY_KOR_3 = 0x0402, /*!< (VK_OEM_102) */
RZKEY_KOR_4 = 0x040D, /*!< (0xC1) */
RZKEY_KOR_5 = 0x0504, /*!< (VK_OEM_PA1) */
RZKEY_KOR_6 = 0x0509, /*!< 한/영 (0xFF) */
RZKEY_KOR_7 = 0x050A, /*!< (0xFF) */
RZKEY_INVALID = 0xFFFF /*!< Invalid keys. */
} RZKEY;
//! Definition of LEDs.
typedef enum RZLED
{
RZLED_LOGO = 0x0014 /*!< Razer logo */
} RZLED;
//! Maximum number of rows in a keyboard.
const RZSIZE MAX_ROW = 6;
//! Maximum number of columns in a keyboard.
const RZSIZE MAX_COLUMN = 22;
//! Maximum number of keys.
const RZSIZE MAX_KEYS = MAX_ROW * MAX_COLUMN;
//! Maximum number of custom effects.
const RZSIZE MAX_CUSTOM_EFFECTS = MAX_KEYS;
//! Keyboard LED layout.
const COLORREF RZKEY_LAYOUT[MAX_ROW][MAX_COLUMN] = {};
//! Chroma keyboard effect types
typedef enum EFFECT_TYPE
{
CHROMA_NONE = 0, //!< No effect.
CHROMA_BREATHING, //!< Breathing effect.
CHROMA_CUSTOM, //!< Custom effect.
CHROMA_REACTIVE, //!< Reactive effect.
CHROMA_STATIC, //!< Static effect.
CHROMA_SPECTRUMCYCLING, //!< Spectrum cycling effect.
CHROMA_WAVE, //!< Wave effect.
CHROMA_STARLIGHT, //!< Starlight effect.
CHROMA_CUSTOM_KEY, //!< Custom effects with keys.
CHROMA_INVALID //!< Invalid effect.
} EFFECT_TYPE;
// Chroma keyboard effects
//! Breathing effect type
typedef struct BREATHING_EFFECT_TYPE
{
//! Breathing effects.
enum Type
{
TWO_COLORS = 1, //!< 2 colors
RANDOM_COLORS, //!< Random colors
INVALID //!< Invalid type
} Type;
COLORREF Color1; //!< First color.
COLORREF Color2; //!< Second color.
} BREATHING_EFFECT_TYPE;
//! Custom effect using a matrix type.
typedef struct CUSTOM_EFFECT_TYPE
{
COLORREF Color[MAX_ROW][MAX_COLUMN]; //!< Grid layout. 6 rows by 22 columns.
} CUSTOM_EFFECT_TYPE;
//! Custom effect with keys.
typedef struct CUSTOM_KEY_EFFECT_TYPE
{
COLORREF Color[MAX_ROW][MAX_COLUMN]; //!< Grid layout. 6 rows by 22 columns.
COLORREF Key[MAX_ROW][MAX_COLUMN]; //!< Keys information. 6 rows by 22 columns. To indidate there is a key effect, OR with 0x01000000. i.e. Key[0][1] = 0x01000000 | Color;
} CUSTOM_KEY_EFFECT_TYPE;
//! Reactive effect type
typedef struct REACTIVE_EFFECT_TYPE
{
//! Duration of the effect.
enum Duration
{
DURATION_NONE = 0, //!< No duration.
DURATION_SHORT, //!< Short duration.
DURATION_MEDIUM, //!< Medium duration.
DURATION_LONG, //!< Long duration.
DURATION_INVALID //!< Invalid duration.
} Duration; //!< The time taken for the effect to fade away.
COLORREF Color; //!< Color of the effect
} REACTIVE_EFFECT_TYPE;
//! Starlight effect.
typedef struct STARLIGHT_EFFECT_TYPE
{
//! Starlight effect types.
enum _Type
{
TWO_COLORS = 1, //!< 2 colors.
RANDOM_COLORS //!< Random colors
} Type;
COLORREF Color1; //!< First color.
COLORREF Color2; //!< Second color.
//! Duration of the effect.
enum _Duration
{
DURATION_SHORT = 1, //!< Short duration.
DURATION_MEDIUM, //!< Medium duration.
DURATION_LONG //!< Long duration.
} Duration; //!< The time taken for the effect to fade away.
} STARLIGHT_EFFECT_TYPE;
//! Static effect type
typedef struct STATIC_EFFECT_TYPE
{
COLORREF Color; //!< Color of the effect
} STATIC_EFFECT_TYPE;
//! Wave effect type
typedef struct WAVE_EFFECT_TYPE
{
//! Direction of the wave effect.
enum Direction
{
DIRECTION_NONE = 0, //!< No direction.
DIRECTION_LEFT_TO_RIGHT, //!< Left to right.
DIRECTION_RIGHT_TO_LEFT, //!< Right to left.
DIRECTION_INVALID //!< Invalid direction.
} Direction; //!< Direction of the wave.
} WAVE_EFFECT_TYPE;
}
//! Mice
namespace Mouse
{
//! Maximum number of custom LEDs (old definition to maintain backward compatibility).
const RZSIZE MAX_LEDS = 30;
//! Mice LED layout (old definition to maintain backward compatibility).
const RZCOLOR RZLED_LAYOUT[MAX_LEDS] = {};
//! Maximum number of rows of the virtual grid.
const RZSIZE MAX_ROW = 9;
//! Maximum number of columns of the virtual grid.
const RZSIZE MAX_COLUMN = 7;
//! Maximum number of LEDs of the virtual grid.
const RZSIZE MAX_LEDS2 = MAX_ROW * MAX_COLUMN;
//! Mice LED virtual grid layout.
const RZCOLOR RZLED_LAYOUT2[MAX_ROW][MAX_COLUMN] = {};
//! Mouse LED Id defintion (old definition to maintain backward compatibility).
typedef enum RZLED
{
RZLED_NONE = 0, //!< No LED.
RZLED_SCROLLWHEEL = 1, //!< Scroll Wheel LED.
RZLED_LOGO = 2, //!< Logo LED.
RZLED_BACKLIGHT = 3, //!< Backlight or numpad.
RZLED_SIDE_STRIP1 = 4, //!< Side strip LED 1. (For Mamba TE, starts from top left hand)
RZLED_SIDE_STRIP2 = 5, //!< Side strip LED 2. (For Mamba TE)
RZLED_SIDE_STRIP3 = 6, //!< Side strip LED 3. (For Mamba TE)
RZLED_SIDE_STRIP4 = 7, //!< Side strip LED 4. (For Mamba TE)
RZLED_SIDE_STRIP5 = 8, //!< Side strip LED 5. (For Mamba TE)
RZLED_SIDE_STRIP6 = 9, //!< Side strip LED 6. (For Mamba TE)
RZLED_SIDE_STRIP7 = 10, //!< Side strip LED 7. (For Mamba TE)
RZLED_SIDE_STRIP8 = 11, //!< Side strip LED 8. (For Mamba TE)
RZLED_SIDE_STRIP9 = 12, //!< Side strip LED 9. (For Mamba TE)
RZLED_SIDE_STRIP10 = 13, //!< Side strip LED 10. (For Mamba TE)
RZLED_SIDE_STRIP11 = 14, //!< Side strip LED 11. (For Mamba TE)
RZLED_SIDE_STRIP12 = 15, //!< Side strip LED 12. (For Mamba TE)
RZLED_SIDE_STRIP13 = 16, //!< Side strip LED 13. (For Mamba TE)
RZLED_SIDE_STRIP14 = 17, //!< Side strip LED 14. (For Mamba TE)
RZLED_ALL = 0xFFFF
} RZLED;
//! Mouse LED Id defintion for the virtual grid.
typedef enum RZLED2
{
RZLED2_SCROLLWHEEL = 0x0203, //!< Scroll Wheel LED.
RZLED2_LOGO = 0x0703, //!< Logo LED.
RZLED2_BACKLIGHT = 0x0403, //!< Backlight LED.
RZLED2_LEFT_SIDE1 = 0x0100, //!< Left LED 1.
RZLED2_LEFT_SIDE2 = 0x0200, //!< Left LED 2.
RZLED2_LEFT_SIDE3 = 0x0300, //!< Left LED 3.
RZLED2_LEFT_SIDE4 = 0x0400, //!< Left LED 4.
RZLED2_LEFT_SIDE5 = 0x0500, //!< Left LED 5.
RZLED2_LEFT_SIDE6 = 0x0600, //!< Left LED 6.
RZLED2_LEFT_SIDE7 = 0x0700, //!< Left LED 7.
RZLED2_BOTTOM1 = 0x0801, //!< Bottom LED 1.
RZLED2_BOTTOM2 = 0x0802, //!< Bottom LED 2.
RZLED2_BOTTOM3 = 0x0803, //!< Bottom LED 3.
RZLED2_BOTTOM4 = 0x0804, //!< Bottom LED 4.
RZLED2_BOTTOM5 = 0x0805, //!< Bottom LED 5.
RZLED2_RIGHT_SIDE1 = 0x0106, //!< Right LED 1.
RZLED2_RIGHT_SIDE2 = 0x0206, //!< Right LED 2.
RZLED2_RIGHT_SIDE3 = 0x0306, //!< Right LED 3.
RZLED2_RIGHT_SIDE4 = 0x0406, //!< Right LED 4.
RZLED2_RIGHT_SIDE5 = 0x0506, //!< Right LED 5.
RZLED2_RIGHT_SIDE6 = 0x0606, //!< Right LED 6.
RZLED2_RIGHT_SIDE7 = 0x0706 //!< Right LED 7.
} RZLED2;
//! Chroma mouse effect types
typedef enum EFFECT_TYPE
{
CHROMA_NONE = 0, //!< No effect.
CHROMA_BLINKING, //!< Blinking effect.
CHROMA_BREATHING, //!< Breathing effect.
CHROMA_CUSTOM, //!< Custom effect (old definition to maintain backward compatibility).
CHROMA_REACTIVE, //!< Reactive effect.
CHROMA_SPECTRUMCYCLING, //!< Spectrum cycling effect.
CHROMA_STATIC, //!< Static effect.
CHROMA_WAVE, //!< Wave effect.
CHROMA_CUSTOM2, //!< Custom effects using a virtual grid.
CHROMA_INVALID //!< Invalid effect.
} EFFECT_TYPE;
//! Static effect type
typedef struct STATIC_EFFECT_TYPE
{
RZLED LEDId; //!< LED Id
COLORREF Color; //!< Color of the effect.
} STATIC_EFFECT_TYPE;
//! Blinking effect type.
typedef struct BLINKING_EFFECT_TYPE
{
RZLED LEDId; //!< LED Id
COLORREF Color; //!< Color.
} BLINKING_EFFECT_TYPE;
//! Breathing effect.
typedef struct BREATHING_EFFECT_TYPE
{
RZLED LEDId; //!< LED Id
//! Breathing type.
enum Type
{
ONE_COLOR = 1, //!< 1 color (Only fill Color1).
TWO_COLORS, //!< 2 colors.
RANDOM_COLORS, //!< Random colors
INVALID //!< Invalid type
} Type;
COLORREF Color1; //!< First color.
COLORREF Color2; //!< Second color.
} BREATHING_EFFECT_TYPE;
//! Custom effect.
typedef struct CUSTOM_EFFECT_TYPE
{
RZCOLOR Color[MAX_LEDS]; //!< Array of colors.
} CUSTOM_EFFECT_TYPE;
//! Custom effect using virtual grid.
//! Indexes of the LED are defined in RZLED2.i.e. Row = HIBYTE(RZLED2_SCROLLWHEEL), Column = LOBYTE(RZLED2_SCROLLWHEEL)
typedef struct CUSTOM_EFFECT_TYPE2
{
RZCOLOR Color[MAX_ROW][MAX_COLUMN]; //!< Array of colors.
} CUSTOM_EFFECT_TYPE2;
//! Reactive effect.
typedef struct REACTIVE_EFFECT_TYPE
{
RZLED LEDId; //!< LED Id
//! Duration of the effect.
enum Duration
{
DURATION_NONE = 0, //!< No duration.
DURATION_SHORT, //!< Short duration.
DURATION_MEDIUM, //!< Medium duration.
DURATION_LONG //!< Long duration.
} Duration;
RZCOLOR Color; //!< Color of the effect.
} REACTIVE_EFFECT_TYPE;
//! No effect.
typedef struct NO_EFFECT_TYPE
{
RZLED LEDId; //!< LED Id
} NO_EFFECT_TYPE;
//! Spectrum cycling.
typedef struct SPECTRUMCYCLING_EFFECT_TYPE
{
RZLED LEDId; //!< LED id.
} SPECTRUMCYCLING_EFFECT_TYPE;
//! Wave effect.
typedef struct WAVE_EFFECT_TYPE
{
//! Direction of the wave effect.
enum Direction
{
FRONT_TO_BACK, //!< Front to back
BACK_TO_FRONT //!< Back to front
} Direction;
} WAVE_EFFECT_TYPE;
}
//! Headsets
namespace Headset
{
//! Maximum number of LEDs
const RZSIZE MAX_LEDS = 5;
//! Chroma headset effect types
typedef enum EFFECT_TYPE
{
CHROMA_NONE = 0, //!< No effect.
CHROMA_STATIC, //!< Static effect.
CHROMA_BREATHING, //!< Breathing effect.
CHROMA_SPECTRUMCYCLING, //!< Spectrum cycling effect.
CHROMA_CUSTOM, //!< Custom effects.
CHROMA_INVALID //!< Invalid effect.
} EFFECT_TYPE;
//! Static effect type
typedef struct STATIC_EFFECT_TYPE
{
COLORREF Color; //!< Color of the effect.
} STATIC_EFFECT_TYPE;
//! Breathing effect type.
typedef struct BREATHING_EFFECT_TYPE
{
COLORREF Color; //!< Color.
} BREATHING_EFFECT_TYPE;
//! Custom effect type.
typedef struct CUSTOM_EFFECT_TYPE
{
RZCOLOR Color[MAX_LEDS]; //!< Array of colors.
} CUSTOM_EFFECT_TYPE;
}
//! Mousepads
namespace Mousepad
{
//! Maximum number of LEDs
const RZSIZE MAX_LEDS = 15;
//! Chroma mousepad effect types
typedef enum EFFECT_TYPE
{
CHROMA_NONE = 0, //!< No effect.
CHROMA_BREATHING, //!< Breathing effect.
CHROMA_CUSTOM, //!< Custom effect.
CHROMA_SPECTRUMCYCLING, //!< Spectrum cycling effect.
CHROMA_STATIC, //!< Static effect.
CHROMA_WAVE, //!< Wave effect.
CHROMA_INVALID //!< Invalid effect.
} EFFECT_TYPE;
// Chroma mousepad effects
//! Breathing effect type.
typedef struct BREATHING_EFFECT_TYPE
{
//! Breathing effects.
enum Type
{
TWO_COLORS = 1, //!< 2 colors
RANDOM_COLORS, //!< Random colors
INVALID
} Type;
COLORREF Color1; //!< First color.
COLORREF Color2; //!< Second color.
} BREATHING_EFFECT_TYPE;
//! Custom effect type.
typedef struct CUSTOM_EFFECT_TYPE
{
RZCOLOR Color[MAX_LEDS]; //!< An array of colors for all the sides of the mousepad. First LED starts from top-right corner.
//!< LED 0-4 right side, 5-9 bottom side, 10-14 left side.
} CUSTOM_EFFECT_TYPE;
//! Static effect type
typedef struct STATIC_EFFECT_TYPE
{
COLORREF Color; //!< Color of the effect
} STATIC_EFFECT_TYPE;
//! Wave effect type
typedef struct WAVE_EFFECT_TYPE
{
//! Direction of the wave effect.
enum Direction
{
DIRECTION_NONE = 0, //!< No direction.
DIRECTION_LEFT_TO_RIGHT, //!< Left to right.
DIRECTION_RIGHT_TO_LEFT, //!< Right to left.
DIRECTION_INVALID //!< Invalid direction.
} Direction; //!< Direction of the wave.
} WAVE_EFFECT_TYPE;
}
//! Keypads
namespace Keypad
{
//! Maximum number of rows.
const RZSIZE MAX_ROW = 4;
//! Maximum number of columns.
const RZSIZE MAX_COLUMN = 5;
//! Total number of keys.
const RZSIZE MAX_KEYS = MAX_ROW * MAX_COLUMN;
//! Chroma keypad effect types
typedef enum EFFECT_TYPE
{
CHROMA_NONE = 0, //!< No effect.
CHROMA_BREATHING, //!< Breathing effect.
CHROMA_CUSTOM, //!< Custom effect.
CHROMA_REACTIVE, //!< Reactive effect.
CHROMA_SPECTRUMCYCLING, //!< Spectrum cycling effect.
CHROMA_STATIC, //!< Static effect.
CHROMA_WAVE, //!< Wave effect.
CHROMA_INVALID //!< Invalid effect.
} EFFECT_TYPE;
// Chroma keypad effects
//! Breathing effect type.
typedef struct BREATHING_EFFECT_TYPE
{
//! Breathing effects.
enum Type
{
TWO_COLORS = 1, //!< 2 colors
RANDOM_COLORS, //!< Random colors
INVALID //!< Invalid type
} Type;
COLORREF Color1; //!< First color.
COLORREF Color2; //!< Second color.
} BREATHING_EFFECT_TYPE;
//! Custom effect type
typedef struct CUSTOM_EFFECT_TYPE
{
RZCOLOR Color[MAX_ROW][MAX_COLUMN]; //!< Custom effect.
//!< For Razer Tartarus Chroma only Color[0] is valid. Use index '0' to change the keypad color.
} CUSTOM_EFFECT_TYPE;
//! Reactive effect type
typedef struct REACTIVE_EFFECT_TYPE
{
//! Duration of the effect.
enum Duration
{
DURATION_NONE = 0, //!< No duration.
DURATION_SHORT, //!< Short duration.
DURATION_MEDIUM, //!< Medium duration.
DURATION_LONG, //!< Long duration.
DURATION_INVALID //!< Invalid duration.
} Duration; //!< The time taken for the effect to fade away.
COLORREF Color; //!< Color of the effect
} REACTIVE_EFFECT_TYPE;
//! Static effect type
typedef struct STATIC_EFFECT_TYPE
{
RZCOLOR Color; //!< Color of the effect.
} STATIC_EFFECT_TYPE;
//! Wave effect type
typedef struct WAVE_EFFECT_TYPE
{
//! Direction of the wave effect.
enum Direction
{
DIRECTION_NONE = 0, //!< No direction.
DIRECTION_LEFT_TO_RIGHT, //!< Left to right.
DIRECTION_RIGHT_TO_LEFT, //!< Right to left.
DIRECTION_INVALID //!< Invalid direction.
} Direction; //!< Direction of the wave.
} WAVE_EFFECT_TYPE;
}
}
#endif

View File

@ -0,0 +1,46 @@
//! \file RzErrors.h
//! \brief Error codes for Chroma SDK. If the error is not defined here, refer to WinError.h from the Windows SDK.
#ifndef _RZERRORS_H_
#define _RZERRORS_H_
#pragma once
// Error codes
//! Invalid
#define RZRESULT_INVALID -1L
//! Success
#define RZRESULT_SUCCESS 0L
//! Access denied
#define RZRESULT_ACCESS_DENIED 5L
//! Invalid handle
#define RZRESULT_INVALID_HANDLE 6L
//! Not supported
#define RZRESULT_NOT_SUPPORTED 50L
//! Invalid parameter.
#define RZRESULT_INVALID_PARAMETER 87L
//! The service has not been started
#define RZRESULT_SERVICE_NOT_ACTIVE 1062L
//! Cannot start more than one instance of the specified program.
#define RZRESULT_SINGLE_INSTANCE_APP 1152L
//! Device not connected
#define RZRESULT_DEVICE_NOT_CONNECTED 1167L
//! Element not found.
#define RZRESULT_NOT_FOUND 1168L
//! Request aborted.
#define RZRESULT_REQUEST_ABORTED 1235L
//! An attempt was made to perform an initialization operation when initialization has already been completed.
#define RZRESULT_ALREADY_INITIALIZED 1247L
//! Resource not available or disabled
#define RZRESULT_RESOURCE_DISABLED 4309L
//! Device not available or supported
#define RZRESULT_DEVICE_NOT_AVAILABLE 4319L
//! The group or resource is not in the correct state to perform the requested operation.
#define RZRESULT_NOT_VALID_STATE 5023L
//! No more items
#define RZRESULT_NO_MORE_ITEMS 259L
//! General failure.
#define RZRESULT_FAILED 2147500037L
#endif

View File

@ -0,0 +1,157 @@
// Original work by VRocker https://github.com/VRocker/LogiLed2Corsair
// I'm mainly a C# developer, and these modification aren't a piece of art, but it suits our needs.
// The MIT License (MIT)
//
// Copyright (c) 2015 VRocker
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include "main.h"
#include <stdio.h>
#include <tchar.h>
#include <thread>
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include "Logger.h"
#include <filesystem>
static bool g_hasInitialised = false;
const char* game = "";
void cleanup()
{
CLogger::EndLogging();
}
BOOL WINAPI DllMain(HINSTANCE hInst, DWORD fdwReason, LPVOID)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
{
atexit(cleanup);
CLogger::InitLogging("Log.txt");
CLogger::SetLogLevel(LogLevel::Debug);
// Get the process that loaded the DLL
TCHAR overwatchFind[] = _T("Overwatch");
TCHAR szPath[MAX_PATH];
GetModuleFileName(NULL, szPath, MAX_PATH);
if (_tcscmp(szPath, overwatchFind) != 0)
game = "overwatch";
CLogger::OutputLog("Attached to process.", LogLevel::Debug);
}
break;
case DLL_PROCESS_DETACH:
{
cleanup();
CLogger::OutputLog_s("Detached from process.", LogLevel::Debug);
}
break;
}
return true;
}
RZRESULT Init()
{
CLogger::OutputLog_s("Razer Init called.", LogLevel::Debug);
g_hasInitialised = true;
return 0;
}
RZRESULT UnInit()
{
CLogger::OutputLog_s("Razer UnInit called.", LogLevel::Debug);
return 0;
}
RZRESULT CreateEffect(RZDEVICEID DeviceId, ChromaSDK::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID* pEffectId)
{
CLogger::OutputLog_s("Razer CreateEffect called.", LogLevel::Debug);
return 0;
}
RZRESULT CreateKeyboardEffect(ChromaSDK::Keyboard::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID* pEffectId)
{
CLogger::OutputLog_s("Razer CreateKeyboardEffect called.", LogLevel::Debug);
return 0;
}
RZRESULT CreateMouseEffect(ChromaSDK::Mouse::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID* pEffectId)
{
CLogger::OutputLog_s("Razer CreateMouseEffect called.", LogLevel::Debug);
return 0;
}
RZRESULT CreateHeadsetEffect(ChromaSDK::Headset::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID* pEffectId)
{
CLogger::OutputLog_s("Razer CreateHeadsetEffect called.", LogLevel::Debug);
return 0;
}
RZRESULT CreateMousepadEffect(ChromaSDK::Mousepad::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID* pEffectId)
{
CLogger::OutputLog_s("Razer CreateMousepadEffect called.", LogLevel::Debug);
return 0;
}
RZRESULT CreateKeypadEffect(ChromaSDK::Keypad::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID* pEffectId)
{
CLogger::OutputLog_s("Razer CreateKeypadEffect called.", LogLevel::Debug);
return 0;
}
RZRESULT DeleteEffect(RZEFFECTID EffectId)
{
CLogger::OutputLog_s("Razer DeleteEffect called.", LogLevel::Debug);
return 0;
}
RZRESULT SetEffect(RZEFFECTID EffectId)
{
CLogger::OutputLog_s("Razer SetEffect called.", LogLevel::Debug);
return 0;
}
RZRESULT RegisterEventNotification(HWND hWnd)
{
CLogger::OutputLog_s("Razer RegisterEventNotification called.", LogLevel::Debug);
return 0;
}
RZRESULT UnregisterEventNotification()
{
CLogger::OutputLog_s("Razer UnregisterEventNotification called.", LogLevel::Debug);
return 0;
}
RZRESULT QueryDevice(RZDEVICEID DeviceId, DEVICE_INFO_TYPE& DeviceInfo)
{
CLogger::OutputLog_s("Razer QueryDevice called.", LogLevel::Debug);
return 0;
}

View File

@ -0,0 +1,48 @@
#define _RZCHROMASDK_H_
#pragma once
#include "RzChromaSDKTypes.h"
using namespace ChromaSDK;
using namespace Keyboard;
using namespace Mouse;
using namespace Headset;
using namespace Mousepad;
using namespace Keypad;
// Exported functions
#ifdef __cplusplus
extern "C"
{
#endif
RZRESULT Init(void);
RZRESULT UnInit(void);
RZRESULT CreateEffect(RZDEVICEID DeviceId, ChromaSDK::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID* pEffectId);
RZRESULT CreateKeyboardEffect(Keyboard::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID* pEffectId);
RZRESULT CreateMouseEffect(Mouse::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID* pEffectId);
RZRESULT CreateHeadsetEffect(Headset::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID* pEffectId);
RZRESULT CreateMousepadEffect(Mousepad::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID* pEffectId);
RZRESULT CreateKeypadEffect(Keypad::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID* pEffectId);
RZRESULT DeleteEffect(RZEFFECTID EffectId);
RZRESULT SetEffect(RZEFFECTID EffectId);
RZRESULT RegisterEventNotification(HWND hWnd);
RZRESULT UnregisterEventNotification();
RZRESULT QueryDevice(RZDEVICEID DeviceId, DEVICE_INFO_TYPE& DeviceInfo);
#ifdef __cplusplus
}
#endif