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

Updated CUE.NET and adjusted the Corsair keyboard provider

This commit is contained in:
SpoinkyNL 2016-03-17 09:28:21 +01:00
parent 5b5bc8b66d
commit 7ff1279e7a
3 changed files with 20 additions and 46 deletions

View File

@ -140,8 +140,8 @@
<HintPath>..\packages\Colore.4.0.0\lib\net35\Corale.Colore.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="CUE.NET, Version=1.0.2.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\CUE.NET.1.0.2.1\lib\net45\CUE.NET.dll</HintPath>
<Reference Include="CUE.NET, Version=1.0.2.2, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\CUE.NET.1.0.2.2\lib\net45\CUE.NET.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Hardcodet.Wpf.TaskbarNotification, Version=1.0.5.0, Culture=neutral, processorArchitecture=MSIL">
@ -615,13 +615,14 @@
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\CUE.NET.1.0.2.1\build\net45\CUE.NET.targets" Condition="Exists('..\packages\CUE.NET.1.0.2.1\build\net45\CUE.NET.targets')" />
<Import Project="..\packages\CUE.NET.1.0.2.2\build\net45\CUE.NET.targets" Condition="Exists('..\packages\CUE.NET.1.0.2.2\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.2.1\build\net45\CUE.NET.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\CUE.NET.1.0.2.1\build\net45\CUE.NET.targets'))" />
<Error Condition="!Exists('..\packages\CUE.NET.1.0.2.2\build\net45\CUE.NET.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\CUE.NET.1.0.2.2\build\net45\CUE.NET.targets'))" />
</Target>
<!-- 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.

View File

@ -3,6 +3,7 @@ using System.Drawing;
using System.Threading;
using Artemis.Utilities;
using CUE.NET;
using CUE.NET.Brushes;
using CUE.NET.Devices.Generic.Enums;
using CUE.NET.Devices.Keyboard;
using CUE.NET.Exceptions;
@ -98,36 +99,12 @@ namespace Artemis.KeyboardProviders.Corsair
Width = 22;
break;
}
_keyboard.UpdateMode = UpdateMode.Manual;
_keyboard.Update(true);
}
public override void Disable()
{
CueSDK.Reinitialize();
}
/*
//Should be able to scale the keyboard instead of resizing the bitmap for better speed. TODO: Test it
public override void DrawBitmapEfficiently(Bitmap bitmap)
{
foreach (var item in _keyboard.Keys)
{
item.Led.Color = Color.Black;
var ledColor = bitmap.GetPixel(
(int) 4*(item.KeyRectangle.X/_keyboard.KeyboardRectangle.Width)*MainManager.KeyboardManager.ActiveKeyboard.Width,
(int) 4*(item.KeyRectangle.Y/_keyboard.KeyboardRectangle.Height)*MainManager.KeyboardManager.ActiveKeyboard.Height);
if (ledColor.A == 0)
continue;
item.Led.Color = Color.FromArgb(255, (int) (ledColor.R/255.00*ledColor.A),
(int) (ledColor.G/255.00*ledColor.A), (int) (ledColor.B/255.00*ledColor.A));
}
_keyboard.Update(true);
}
*/
/// <summary>
/// Properly resizes any size bitmap to the keyboard by creating a rectangle whose size is dependent on the bitmap
@ -136,24 +113,20 @@ namespace Artemis.KeyboardProviders.Corsair
/// <param name="bitmap"></param>
public override void DrawBitmap(Bitmap bitmap)
{
var res = ImageUtilities.ResizeImage(bitmap, (int) _keyboard.KeyboardRectangle.Width,
(int) _keyboard.KeyboardRectangle.Height);
foreach (var item in _keyboard.Keys)
{
item.Led.Color = Color.Black;
var ledColor = res.GetPixel((int) item.KeyRectangle.X, (int) item.KeyRectangle.Y);
if (ledColor.A == 0)
continue;
// Since the brightness doesn't seem to be used,
// decrease the RGB value based on the brightness manually
item.Led.Color = Color.FromArgb(255, (int) (ledColor.R/255.00*ledColor.A),
(int) (ledColor.G/255.00*ledColor.A), (int) (ledColor.B/255.00*ledColor.A));
var fixedBmp = new Bitmap(bitmap.Width, bitmap.Height);
using (var g = Graphics.FromImage(fixedBmp))
{
g.Clear(Color.Black);
g.DrawImage(bitmap, 0,0);
}
_keyboard.Update(true);
var brush = new ImageBrush
{
Image = ImageUtilities.ResizeImage(fixedBmp, Width, Height)
};
_keyboard.Brush = brush;
_keyboard.Update();
}
}
}

View File

@ -5,7 +5,7 @@
<package id="Caliburn.Micro.AutofacBootstrap" version="2.0.9-beta" targetFramework="net452" />
<package id="Caliburn.Micro.Core" version="2.0.2" targetFramework="net452" />
<package id="Colore" version="4.0.0" targetFramework="net452" />
<package id="CUE.NET" version="1.0.2.1" targetFramework="net452" />
<package id="CUE.NET" version="1.0.2.2" targetFramework="net452" />
<package id="Extended.Wpf.Toolkit" version="2.6" targetFramework="net452" />
<package id="Hardcodet.NotifyIcon.Wpf" version="1.0.5" targetFramework="net452" />
<package id="ImageLibrary" version="2.0.5" targetFramework="net452" />