1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-12 21:38:38 +00:00

Experimental Corsair support

This commit is contained in:
SpoinkyNL 2016-01-20 19:39:22 +01:00
parent e8c6951e89
commit 51797c15f6
13 changed files with 172 additions and 62 deletions

View File

@ -204,7 +204,7 @@
<value>TypeWave</value> <value>TypeWave</value>
</setting> </setting>
<setting name="LastKeyboard" serializeAs="String"> <setting name="LastKeyboard" serializeAs="String">
<value>Logitech G910 Orion Spark</value> <value>Razer BlackWidow Chroma</value>
</setting> </setting>
<setting name="EnablePointersUpdate" serializeAs="String"> <setting name="EnablePointersUpdate" serializeAs="String">
<value>True</value> <value>True</value>

View File

@ -24,7 +24,6 @@ namespace Artemis
MessageBox.Show("Startup failed :c \n" + ex.InnerException.Message); MessageBox.Show("Startup failed :c \n" + ex.InnerException.Message);
throw; throw;
} }
} }
} }
} }

View File

@ -38,6 +38,8 @@
<UseApplicationTrust>false</UseApplicationTrust> <UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted> <PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled> <BootstrapperEnabled>true</BootstrapperEnabled>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>x64</PlatformTarget> <PlatformTarget>x64</PlatformTarget>
@ -87,6 +89,10 @@
<HintPath>..\packages\Colore.3.0.2\lib\net35\Corale.Colore.dll</HintPath> <HintPath>..\packages\Colore.3.0.2\lib\net35\Corale.Colore.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="CUE.NET, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\CUE.NET.1.0.0\lib\net45\CUE.NET.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="log4net, Version=1.2.14.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL"> <Reference Include="log4net, Version=1.2.14.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.4\lib\net45-full\log4net.dll</HintPath> <HintPath>..\packages\log4net.2.0.4\lib\net45-full\log4net.dll</HintPath>
<Private>True</Private> <Private>True</Private>
@ -134,6 +140,10 @@
<Reference Include="System.Xaml"> <Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework> <RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference> </Reference>
<Reference Include="VioletTape.WpfExceptionViewer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=bfd09609f6784d58, processorArchitecture=MSIL">
<HintPath>..\packages\WpfExceptionViewer.1.0.0.0\lib\VioletTape.WpfExceptionViewer.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="WindowsBase" /> <Reference Include="WindowsBase" />
<Reference Include="PresentationCore" /> <Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" /> <Reference Include="PresentationFramework" />
@ -269,6 +279,7 @@
<Compile Include="Modules\Games\Witcher3\Witcher3ViewModel.cs" /> <Compile Include="Modules\Games\Witcher3\Witcher3ViewModel.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\SettingsViewModel.cs" />
<Compile Include="ViewModels\ShellViewModel.cs" /> <Compile Include="ViewModels\ShellViewModel.cs" />
<Compile Include="Views\EffectsView.xaml.cs"> <Compile Include="Views\EffectsView.xaml.cs">
<DependentUpon>EffectsView.xaml</DependentUpon> <DependentUpon>EffectsView.xaml</DependentUpon>
@ -306,6 +317,9 @@
<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\SettingsView.xaml.cs">
<DependentUpon>SettingsView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\ShellView.xaml.cs"> <Compile Include="Views\ShellView.xaml.cs">
<DependentUpon>ShellView.xaml</DependentUpon> <DependentUpon>ShellView.xaml</DependentUpon>
</Compile> </Compile>
@ -347,6 +361,7 @@
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>VolumeDisplay.Designer.cs</LastGenOutput> <LastGenOutput>VolumeDisplay.Designer.cs</LastGenOutput>
</None> </None>
<None Include="MyMemory-x64.dll" />
<None Include="packages.config" /> <None Include="packages.config" />
<AppDesigner Include="Properties\" /> <AppDesigner Include="Properties\" />
<None Include="Settings\Offsets.settings"> <None Include="Settings\Offsets.settings">
@ -415,6 +430,10 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Views\SettingsView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\ShellView.xaml"> <Page Include="Views\ShellView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
@ -429,9 +448,6 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Resource Include="logo.ico" /> <Resource Include="logo.ico" />
<Content Include="MyMemory-x64.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Resources\gamestateConfigFileCsGo.txt" /> <Content Include="Resources\gamestateConfigFileCsGo.txt" />
<Resource Include="Resources\Entypo-license.txt" /> <Resource Include="Resources\Entypo-license.txt" />
<Resource Include="Resources\WindowsIcons-license.txt" /> <Resource Include="Resources\WindowsIcons-license.txt" />
@ -449,6 +465,13 @@
</BootstrapperPackage> </BootstrapperPackage>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\CUE.NET.1.0.0\build\net45\CUE.NET.targets" Condition="Exists('..\packages\CUE.NET.1.0.0\build\net45\CUE.NET.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\CUE.NET.1.0.0\build\net45\CUE.NET.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\CUE.NET.1.0.0\build\net45\CUE.NET.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild"> <Target Name="BeforeBuild">

View File

@ -1,16 +1,23 @@
using System.Drawing; using System.Drawing;
using CUE.NET;
using CUE.NET.Devices.Generic.Enums;
using CUE.NET.Devices.Keyboard;
namespace Artemis.KeyboardProviders.Corsair namespace Artemis.KeyboardProviders.Corsair
{ {
internal class K95 : KeyboardProvider internal class K70 : KeyboardProvider
{ {
public K95() private CorsairKeyboard _keyboard;
public K70()
{ {
Name = "Corsair Gaming K95 RGB"; Name = "Corsair Gaming K70 RGB";
} }
public override void Enable() public override void Enable()
{ {
_keyboard = CueSDK.KeyboardSDK;
_keyboard.UpdateMode = UpdateMode.Manual;
} }
public override void Disable() public override void Disable()
@ -19,6 +26,16 @@ namespace Artemis.KeyboardProviders.Corsair
public override void DrawBitmap(Bitmap bitmap) public override void DrawBitmap(Bitmap bitmap)
{ {
// TODO: Resize bitmap to keyboard's size
//if (bitmap.Width > width || bitmap.Height > height)
// bitmap = ResizeImage(bitmap, width, height);
// One way of doing this, not sure at all if it's any good
for (var y = 0; y < bitmap.Height - 1; y++)
for (var x = 0; x < bitmap.Width - 1; x++)
_keyboard[new PointF(x, y)].Led.Color = bitmap.GetPixel(x, y);
_keyboard.Update(true);
} }
} }
} }

View File

@ -1,16 +1,23 @@
using System.Drawing; using System.Drawing;
using CUE.NET;
using CUE.NET.Devices.Generic.Enums;
using CUE.NET.Devices.Keyboard;
namespace Artemis.KeyboardProviders.Corsair namespace Artemis.KeyboardProviders.Corsair
{ {
internal class K70 : KeyboardProvider internal class K95 : KeyboardProvider
{ {
public K70() private CorsairKeyboard _keyboard;
public K95()
{ {
Name = "Corsair Gaming K70 RGB"; Name = "Corsair Gaming K95 RGB";
} }
public override void Enable() public override void Enable()
{ {
_keyboard = CueSDK.KeyboardSDK;
_keyboard.UpdateMode = UpdateMode.Manual;
} }
public override void Disable() public override void Disable()
@ -19,7 +26,16 @@ namespace Artemis.KeyboardProviders.Corsair
public override void DrawBitmap(Bitmap bitmap) public override void DrawBitmap(Bitmap bitmap)
{ {
// TODO: Convert bitmap to something tasty for CUE.NET // TODO: Resize bitmap to keyboard's size
//if (bitmap.Width > width || bitmap.Height > height)
// bitmap = ResizeImage(bitmap, width, height);
// One way of doing this, not sure at all if it's any good
for (var y = 0; y < bitmap.Height - 1; y++)
for (var x = 0; x < bitmap.Width - 1; x++)
_keyboard[new PointF(x, y)].Led.Color = bitmap.GetPixel(x, y);
_keyboard.Update(true);
} }
} }
} }

View File

@ -1,5 +1,4 @@
using System; using System.Drawing;
using System.Drawing;
using System.Threading; using System.Threading;
using Artemis.KeyboardProviders.Logitech.Utilities; using Artemis.KeyboardProviders.Logitech.Utilities;

View File

@ -37,7 +37,7 @@ namespace Artemis.Settings {
[global::System.Configuration.UserScopedSettingAttribute()] [global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("Logitech G910 Orion Spark")] [global::System.Configuration.DefaultSettingValueAttribute("Razer BlackWidow Chroma")]
public string LastKeyboard { public string LastKeyboard {
get { get {
return ((string)(this["LastKeyboard"])); return ((string)(this["LastKeyboard"]));

View File

@ -1,12 +1,14 @@
<?xml version='1.0' encoding='utf-8'?> <?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="Artemis.Settings" GeneratedClassName="General">
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)"
GeneratedClassNamespace="Artemis.Settings" GeneratedClassName="General">
<Profiles /> <Profiles />
<Settings> <Settings>
<Setting Name="LastEffect" Type="System.String" Scope="User"> <Setting Name="LastEffect" Type="System.String" Scope="User">
<Value Profile="(Default)">TypeWave</Value> <Value Profile="(Default)">TypeWave</Value>
</Setting> </Setting>
<Setting Name="LastKeyboard" Type="System.String" Scope="User"> <Setting Name="LastKeyboard" Type="System.String" Scope="User">
<Value Profile="(Default)">Logitech G910 Orion Spark</Value> <Value Profile="(Default)">Razer BlackWidow Chroma</Value>
</Setting> </Setting>
<Setting Name="EnablePointersUpdate" Type="System.Boolean" Scope="User"> <Setting Name="EnablePointersUpdate" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value> <Value Profile="(Default)">True</Value>

View File

@ -0,0 +1,53 @@
using System;
using System.Windows;
using Artemis.Models;
using Caliburn.Micro;
namespace Artemis.ViewModels
{
internal sealed class ShellViewModel : Conductor<IScreen>.Collection.OneActive
{
public ShellViewModel()
{
IEventAggregator events = new EventAggregator();
MainModel = new MainModel(events);
DisplayName = "Artemis";
ActivateItem(new EffectsViewModel(MainModel) {DisplayName = "Effects"});
ActivateItem(new GamesViewModel(MainModel) {DisplayName = "Games"});
ActivateItem(new OverlaysViewModel(MainModel) {DisplayName = "Overlays"});
// By now Effects are added to the MainModel so we can savely start one
ToggleEffects();
}
public bool EffectsEnabled
{
get { return MainModel.Enabled; }
private set
{
MainModel.Enabled = value;
NotifyOfPropertyChange(() => EffectsEnabled);
}
}
public MainModel MainModel { get; set; }
public void ToggleEffects()
{
if (EffectsEnabled)
MainModel.ShutdownEffects();
else
MainModel.StartEffects();
EffectsEnabled = !EffectsEnabled;
}
public void OnClose(EventArgs e)
{
MainModel.ShutdownEffects();
Application.Current.Shutdown();
}
}
}

View File

@ -1,53 +1,12 @@
using System; using Caliburn.Micro;
using System.Windows;
using Artemis.Models;
using Caliburn.Micro;
namespace Artemis.ViewModels namespace Artemis.ViewModels
{ {
internal sealed class ShellViewModel : Conductor<IScreen>.Collection.OneActive internal sealed class SettingsViewModel : Conductor<IScreen>.Collection.OneActive
{ {
public ShellViewModel() public SettingsViewModel()
{ {
IEventAggregator events = new EventAggregator(); DisplayName = "Artemis - Settings";
MainModel = new MainModel(events);
DisplayName = "Artemis";
ActivateItem(new EffectsViewModel(MainModel) {DisplayName = "Effects"});
ActivateItem(new GamesViewModel(MainModel) {DisplayName = "Games"});
ActivateItem(new OverlaysViewModel(MainModel) {DisplayName = "Overlays"});
// By now Effects are added to the MainModel so we can savely start one
ToggleEffects();
}
public bool EffectsEnabled
{
get { return MainModel.Enabled; }
private set
{
MainModel.Enabled = value;
NotifyOfPropertyChange(() => EffectsEnabled);
}
}
public MainModel MainModel { get; set; }
public void ToggleEffects()
{
if (EffectsEnabled)
MainModel.ShutdownEffects();
else
MainModel.StartEffects();
EffectsEnabled = !EffectsEnabled;
}
public void OnClose(EventArgs e)
{
MainModel.ShutdownEffects();
Application.Current.Shutdown();
} }
} }
} }

View File

@ -0,0 +1,13 @@
<controls:MetroWindow x:Class="Artemis.Views.SettingsView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Artemis.Views"
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
mc:Ignorable="d"
Title="SettingsView" Height="300" Width="300">
<Grid>
</Grid>
</controls:MetroWindow>

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Artemis.Views
{
/// <summary>
/// Interaction logic for SettingsView.xaml
/// </summary>
public partial class SettingsView : Window
{
public SettingsView()
{
InitializeComponent();
}
}
}

View File

@ -4,6 +4,7 @@
<package id="Caliburn.Micro" version="2.0.2" targetFramework="net452" /> <package id="Caliburn.Micro" version="2.0.2" targetFramework="net452" />
<package id="Caliburn.Micro.Core" version="2.0.2" targetFramework="net452" /> <package id="Caliburn.Micro.Core" version="2.0.2" targetFramework="net452" />
<package id="Colore" version="3.0.2" targetFramework="net452" /> <package id="Colore" version="3.0.2" targetFramework="net452" />
<package id="CUE.NET" version="1.0.0" targetFramework="net452" />
<package id="Extended.Wpf.Toolkit" version="2.5" targetFramework="net452" /> <package id="Extended.Wpf.Toolkit" version="2.5" targetFramework="net452" />
<package id="log4net" version="2.0.4" targetFramework="net452" /> <package id="log4net" version="2.0.4" targetFramework="net452" />
<package id="MahApps.Metro" version="1.1.2.0" targetFramework="net452" /> <package id="MahApps.Metro" version="1.1.2.0" targetFramework="net452" />
@ -11,4 +12,5 @@
<package id="NAudio" version="1.7.3" targetFramework="net452" /> <package id="NAudio" version="1.7.3" targetFramework="net452" />
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net452" /> <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net452" />
<package id="Open.WinKeyboardHook" version="1.0.10.0" targetFramework="net452" /> <package id="Open.WinKeyboardHook" version="1.0.10.0" targetFramework="net452" />
<package id="WpfExceptionViewer" version="1.0.0.0" targetFramework="net452" />
</packages> </packages>