mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Merge pull request #94 from DarthAffe/development
Update to CUE.NET v1.0.3 (using the new SDK-checks)
This commit is contained in:
commit
4ec3640fbd
@ -144,8 +144,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.2, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\CUE.NET.1.0.2.2\lib\net45\CUE.NET.dll</HintPath>
|
||||
<Reference Include="CUE.NET, Version=1.0.3.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\CUE.NET.1.0.3\lib\net45\CUE.NET.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="GongSolutions.Wpf.DragDrop, Version=0.1.4.3, Culture=neutral, PublicKeyToken=d19974ea350ccea1, processorArchitecture=MSIL">
|
||||
@ -613,7 +613,9 @@
|
||||
<None Include="NLog.xsd">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
<None Include="packages.config" />
|
||||
<None Include="packages.config">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
<AppDesigner Include="Properties\" />
|
||||
<Resource Include="Resources\bow.png" />
|
||||
<Content Include="logo.ico">
|
||||
@ -793,12 +795,12 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.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')" />
|
||||
<Import Project="..\packages\CUE.NET.1.0.3\build\net45\CUE.NET.targets" Condition="Exists('..\packages\CUE.NET.1.0.3\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.2\build\net45\CUE.NET.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\CUE.NET.1.0.2.2\build\net45\CUE.NET.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\CUE.NET.1.0.3\build\net45\CUE.NET.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\CUE.NET.1.0.3\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.
|
||||
|
||||
@ -1,12 +1,10 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using Artemis.Utilities;
|
||||
using CUE.NET;
|
||||
using CUE.NET.Devices.Generic.Enums;
|
||||
using CUE.NET.Exceptions;
|
||||
using Ninject.Extensions.Logging;
|
||||
|
||||
namespace Artemis.DeviceProviders.Corsair
|
||||
@ -24,8 +22,8 @@ namespace Artemis.DeviceProviders.Corsair
|
||||
public override bool TryEnable()
|
||||
{
|
||||
CanUse = CanInitializeSdk();
|
||||
if (CanUse)
|
||||
CueSDK.HeadsetSDK.UpdateMode = UpdateMode.Manual;
|
||||
if (CanUse && !CueSDK.IsInitialized)
|
||||
CueSDK.Initialize();
|
||||
|
||||
Logger.Debug("Attempted to enable Corsair headset. CanUse: {0}", CanUse);
|
||||
return CanUse;
|
||||
@ -33,7 +31,7 @@ namespace Artemis.DeviceProviders.Corsair
|
||||
|
||||
public override void Disable()
|
||||
{
|
||||
if (CueSDK.ProtocolDetails != null)
|
||||
if (CueSDK.IsInitialized)
|
||||
CueSDK.Reinitialize();
|
||||
}
|
||||
|
||||
@ -43,7 +41,7 @@ namespace Artemis.DeviceProviders.Corsair
|
||||
return;
|
||||
|
||||
var leds = CueSDK.HeadsetSDK.Leds.Count();
|
||||
var rect = new Rect(new Size(leds*20, leds*20));
|
||||
var rect = new Rect(new Size(leds * 20, leds * 20));
|
||||
var img = brush.Dispatcher.Invoke(() =>
|
||||
{
|
||||
var visual = new DrawingVisual();
|
||||
@ -58,37 +56,26 @@ namespace Artemis.DeviceProviders.Corsair
|
||||
{
|
||||
corsairLed.Color = ledIndex == 0
|
||||
? img.GetPixel(0, 0)
|
||||
: img.GetPixel((ledIndex + 1)*20 - 1, (ledIndex + 1)*20 - 1);
|
||||
: img.GetPixel((ledIndex + 1) * 20 - 1, (ledIndex + 1) * 20 - 1);
|
||||
ledIndex++;
|
||||
}
|
||||
CueSDK.HeadsetSDK.Update(true);
|
||||
|
||||
CueSDK.HeadsetSDK.Update();
|
||||
}
|
||||
|
||||
private static bool CanInitializeSdk()
|
||||
{
|
||||
// If already initialized, return result right away
|
||||
if (CueSDK.ProtocolDetails != null)
|
||||
return CueSDK.HeadsetSDK != null;
|
||||
// This will skip the check-loop if the SDK is initialized
|
||||
if (CueSDK.IsInitialized)
|
||||
return CueSDK.IsSDKAvailable(CorsairDeviceType.Headset);
|
||||
|
||||
// Else try to enable the SDK
|
||||
for (var tries = 0; tries < 9; tries++)
|
||||
{
|
||||
if (CueSDK.ProtocolDetails != null)
|
||||
break;
|
||||
|
||||
try
|
||||
{
|
||||
CueSDK.Initialize();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Thread.Sleep(2000);
|
||||
}
|
||||
if (CueSDK.IsSDKAvailable(CorsairDeviceType.Headset))
|
||||
return true;
|
||||
Thread.Sleep(2000);
|
||||
}
|
||||
|
||||
if (CueSDK.ProtocolDetails == null)
|
||||
return false;
|
||||
return CueSDK.HeadsetSDK != null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
@ -23,8 +22,8 @@ namespace Artemis.DeviceProviders.Corsair
|
||||
public override bool TryEnable()
|
||||
{
|
||||
CanUse = CanInitializeSdk();
|
||||
if (CanUse)
|
||||
CueSDK.MouseSDK.UpdateMode = UpdateMode.Manual;
|
||||
if (CanUse && !CueSDK.IsInitialized)
|
||||
CueSDK.Initialize();
|
||||
|
||||
Logger.Debug("Attempted to enable Corsair mice. CanUse: {0}", CanUse);
|
||||
return CanUse;
|
||||
@ -32,7 +31,7 @@ namespace Artemis.DeviceProviders.Corsair
|
||||
|
||||
public override void Disable()
|
||||
{
|
||||
if (CueSDK.ProtocolDetails != null)
|
||||
if (CueSDK.IsInitialized)
|
||||
CueSDK.Reinitialize();
|
||||
}
|
||||
|
||||
@ -42,7 +41,7 @@ namespace Artemis.DeviceProviders.Corsair
|
||||
return;
|
||||
|
||||
var leds = CueSDK.MouseSDK.Leds.Count();
|
||||
var rect = new Rect(new Size(leds*20, leds*20));
|
||||
var rect = new Rect(new Size(leds * 20, leds * 20));
|
||||
var img = brush.Dispatcher.Invoke(() =>
|
||||
{
|
||||
var visual = new DrawingVisual();
|
||||
@ -57,38 +56,26 @@ namespace Artemis.DeviceProviders.Corsair
|
||||
{
|
||||
corsairLed.Color = ledIndex == 0
|
||||
? img.GetPixel(0, 0)
|
||||
: img.GetPixel((ledIndex + 1)*20 - 1, (ledIndex + 1)*20 - 1);
|
||||
: img.GetPixel((ledIndex + 1) * 20 - 1, (ledIndex + 1) * 20 - 1);
|
||||
ledIndex++;
|
||||
}
|
||||
|
||||
CueSDK.MouseSDK.Update(true);
|
||||
CueSDK.MouseSDK.Update();
|
||||
}
|
||||
|
||||
private static bool CanInitializeSdk()
|
||||
{
|
||||
// If already initialized, return result right away
|
||||
if (CueSDK.ProtocolDetails != null)
|
||||
return CueSDK.MouseSDK != null;
|
||||
// This will skip the check-loop if the SDK is initialized
|
||||
if (CueSDK.IsInitialized)
|
||||
return CueSDK.IsSDKAvailable(CorsairDeviceType.Mouse);
|
||||
|
||||
// Else try to enable the SDK
|
||||
for (var tries = 0; tries < 9; tries++)
|
||||
{
|
||||
if (CueSDK.ProtocolDetails != null)
|
||||
break;
|
||||
|
||||
try
|
||||
{
|
||||
CueSDK.Initialize();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Thread.Sleep(2000);
|
||||
}
|
||||
if (CueSDK.IsSDKAvailable(CorsairDeviceType.Mouse))
|
||||
return true;
|
||||
Thread.Sleep(2000);
|
||||
}
|
||||
|
||||
if (CueSDK.ProtocolDetails == null)
|
||||
return false;
|
||||
return CueSDK.MouseSDK != null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,11 +1,11 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using Artemis.Properties;
|
||||
using Artemis.Utilities;
|
||||
using CUE.NET;
|
||||
using CUE.NET.Brushes;
|
||||
using CUE.NET.Devices.Generic.Enums;
|
||||
using CUE.NET.Devices.Keyboard;
|
||||
using Point = System.Drawing.Point;
|
||||
|
||||
@ -14,6 +14,7 @@ namespace Artemis.DeviceProviders.Corsair
|
||||
public class CorsairRGB : KeyboardProvider
|
||||
{
|
||||
private CorsairKeyboard _keyboard;
|
||||
private ImageBrush _keyboardBrush;
|
||||
|
||||
public CorsairRGB()
|
||||
{
|
||||
@ -26,29 +27,17 @@ namespace Artemis.DeviceProviders.Corsair
|
||||
|
||||
public override bool CanEnable()
|
||||
{
|
||||
// If already initialized, return result right away
|
||||
if (CueSDK.ProtocolDetails != null)
|
||||
return CueSDK.KeyboardSDK != null;
|
||||
// This will skip the check-loop if the SDK is initialized
|
||||
if (CueSDK.IsInitialized)
|
||||
return CueSDK.IsSDKAvailable(CorsairDeviceType.Keyboard);
|
||||
|
||||
// Else try to enable the SDK
|
||||
for (var tries = 0; tries < 9; tries++)
|
||||
{
|
||||
if (CueSDK.ProtocolDetails != null)
|
||||
break;
|
||||
|
||||
try
|
||||
{
|
||||
CueSDK.Initialize();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Thread.Sleep(2000);
|
||||
}
|
||||
if (CueSDK.IsSDKAvailable(CorsairDeviceType.Keyboard))
|
||||
return true;
|
||||
Thread.Sleep(2000);
|
||||
}
|
||||
|
||||
if (CueSDK.ProtocolDetails == null)
|
||||
return false;
|
||||
return CueSDK.KeyboardSDK != null;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -56,7 +45,7 @@ namespace Artemis.DeviceProviders.Corsair
|
||||
/// </summary>
|
||||
public override void Enable()
|
||||
{
|
||||
if (CueSDK.ProtocolDetails == null)
|
||||
if (!CueSDK.IsInitialized)
|
||||
CueSDK.Initialize();
|
||||
|
||||
_keyboard = CueSDK.KeyboardSDK;
|
||||
@ -83,11 +72,13 @@ namespace Artemis.DeviceProviders.Corsair
|
||||
PreviewSettings = new PreviewSettings(665, 215, new Thickness(0, -5, 0, 0), Resources.strafe);
|
||||
break;
|
||||
}
|
||||
|
||||
_keyboard.Brush = _keyboardBrush ?? (_keyboardBrush = new ImageBrush());
|
||||
}
|
||||
|
||||
public override void Disable()
|
||||
{
|
||||
if (CueSDK.ProtocolDetails != null)
|
||||
if (CueSDK.IsInitialized)
|
||||
CueSDK.Reinitialize();
|
||||
}
|
||||
|
||||
@ -113,12 +104,7 @@ namespace Artemis.DeviceProviders.Corsair
|
||||
image = strafeBitmap;
|
||||
}
|
||||
|
||||
var brush = new ImageBrush
|
||||
{
|
||||
Image = image
|
||||
};
|
||||
|
||||
_keyboard.Brush = brush;
|
||||
_keyboardBrush.Image = image;
|
||||
_keyboard.Update();
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
<package id="Caliburn.Micro.Core" version="3.0.1" targetFramework="net452" />
|
||||
<package id="Castle.Core" version="3.3.3" targetFramework="net452" />
|
||||
<package id="Colore" version="4.0.0" targetFramework="net452" />
|
||||
<package id="CUE.NET" version="1.0.2.2" targetFramework="net452" />
|
||||
<package id="CUE.NET" version="1.0.3" targetFramework="net452" />
|
||||
<package id="Extended.Wpf.Toolkit" version="2.7" targetFramework="net452" />
|
||||
<package id="gong-wpf-dragdrop" version="0.1.4.3" targetFramework="net452" />
|
||||
<package id="Hardcodet.NotifyIcon.Wpf" version="1.0.8" targetFramework="net452" />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user