1
0
mirror of https://github.com/DarthAffe/CUE.NET.git synced 2025-12-13 09:08:34 +00:00

Compare commits

..

4 Commits

Author SHA1 Message Date
c93f53d3e6 Merge pull request #63 from darosultan/GlaiveSupport
Merged glaive support into own branch
2017-09-30 10:34:21 +02:00
Daro
c364d4b253 Removed unnecessary usings 2017-09-29 17:14:21 +02:00
Daro
0d2882e7ea Glaive support 2017-09-29 17:12:20 +02:00
Daro
372cc51477 Experimental Glaive support 2017-09-29 16:48:14 +02:00
24 changed files with 578 additions and 941 deletions

View File

@ -36,6 +36,9 @@
<DocumentationFile>bin\CUE.NET.XML</DocumentationFile> <DocumentationFile>bin\CUE.NET.XML</DocumentationFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="HidSharp, Version=1.5.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\HidSharp.1.5\lib\net35\HidSharp.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
@ -59,7 +62,6 @@
<Compile Include="Devices\Generic\Enums\CorsairAccessMode.cs" /> <Compile Include="Devices\Generic\Enums\CorsairAccessMode.cs" />
<Compile Include="Devices\Generic\Enums\CorsairDeviceCaps.cs" /> <Compile Include="Devices\Generic\Enums\CorsairDeviceCaps.cs" />
<Compile Include="Devices\Generic\Enums\CorsairDeviceType.cs" /> <Compile Include="Devices\Generic\Enums\CorsairDeviceType.cs" />
<Compile Include="Devices\Generic\Enums\CorsairKeyId.cs" />
<Compile Include="Devices\Generic\Enums\CorsairLedId.cs" /> <Compile Include="Devices\Generic\Enums\CorsairLedId.cs" />
<Compile Include="Devices\Generic\EventArgs\ExceptionEventArgs.cs" /> <Compile Include="Devices\Generic\EventArgs\ExceptionEventArgs.cs" />
<Compile Include="Brushes\AbstractBrush.cs" /> <Compile Include="Brushes\AbstractBrush.cs" />
@ -68,12 +70,8 @@
<Compile Include="Devices\Generic\EventArgs\UpdatedEventArgs.cs" /> <Compile Include="Devices\Generic\EventArgs\UpdatedEventArgs.cs" />
<Compile Include="Devices\Generic\EventArgs\UpdatingEventArgs.cs" /> <Compile Include="Devices\Generic\EventArgs\UpdatingEventArgs.cs" />
<Compile Include="Devices\Generic\LedUpateRequest.cs" /> <Compile Include="Devices\Generic\LedUpateRequest.cs" />
<Compile Include="Devices\HeadsetStand\CorsairHeadsetStand.cs" />
<Compile Include="Devices\HeadsetStand\CorsairHeadsetStandDeviceInfo.cs" />
<Compile Include="Devices\HeadsetStand\Enums\CorsairHeadsetStandLedId.cs" />
<Compile Include="Devices\Keyboard\Enums\BrushCalculationMode.cs" /> <Compile Include="Devices\Keyboard\Enums\BrushCalculationMode.cs" />
<Compile Include="Devices\Keyboard\Enums\CorsairKeyboardKeyId.cs" /> <Compile Include="Devices\Mouse\GlaiveMouse.cs" />
<Compile Include="Devices\Mouse\Enums\CorsairMouseKeyId.cs" />
<Compile Include="Effects\AbstractLedGroupEffect.cs" /> <Compile Include="Effects\AbstractLedGroupEffect.cs" />
<Compile Include="Effects\AbstractBrushEffect.cs" /> <Compile Include="Effects\AbstractBrushEffect.cs" />
<Compile Include="Effects\AbstractEffectTarget.cs" /> <Compile Include="Effects\AbstractEffectTarget.cs" />
@ -82,7 +80,6 @@
<Compile Include="Devices\Mousemat\CorsairMousematDeviceInfo.cs" /> <Compile Include="Devices\Mousemat\CorsairMousematDeviceInfo.cs" />
<Compile Include="Devices\Mousemat\Enums\CorsairMousematLedId.cs" /> <Compile Include="Devices\Mousemat\Enums\CorsairMousematLedId.cs" />
<Compile Include="Effects\MoveGradientEffect.cs" /> <Compile Include="Effects\MoveGradientEffect.cs" />
<Compile Include="EventArgs\KeyPressedEventArgs.cs" />
<Compile Include="Gradients\AbstractGradient.cs" /> <Compile Include="Gradients\AbstractGradient.cs" />
<Compile Include="Gradients\GradientStop.cs" /> <Compile Include="Gradients\GradientStop.cs" />
<Compile Include="Gradients\IGradient.cs" /> <Compile Include="Gradients\IGradient.cs" />
@ -139,7 +136,9 @@
<Compile Include="CueSDK.cs" /> <Compile Include="CueSDK.cs" />
<Compile Include="Devices\ICueDevice.cs" /> <Compile Include="Devices\ICueDevice.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup /> <ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildProjectDirectory)\CUE.NET.targets" /> <Import Project="$(MSBuildProjectDirectory)\CUE.NET.targets" />
</Project> </Project>

View File

@ -3,7 +3,7 @@
<metadata> <metadata>
<id>CUE.NET</id> <id>CUE.NET</id>
<title>CUE.NET</title> <title>CUE.NET</title>
<version>1.2.0.1</version> <version>1.1.3.1</version>
<authors>Darth Affe</authors> <authors>Darth Affe</authors>
<owners>Darth Affe</owners> <owners>Darth Affe</owners>
<projectUrl>https://github.com/DarthAffe/CUE.NET</projectUrl> <projectUrl>https://github.com/DarthAffe/CUE.NET</projectUrl>
@ -11,11 +11,8 @@
<requireLicenseAcceptance>true</requireLicenseAcceptance> <requireLicenseAcceptance>true</requireLicenseAcceptance>
<description>Corsair HID SDK Wrapper</description> <description>Corsair HID SDK Wrapper</description>
<releaseNotes> <releaseNotes>
- Updated SDK to 2.18.127 - Added an effect-list to the effect-target
- Added methods to use the new GetColor method - Added two lists to allow modification of the native-dll-paths
- Added an event to get the key-change of special keys (G and M)
- Fixed missing LoadedArchitecture assignment
- Fixed an issue that prevents further reinitializing if an exception was thrown earlier
</releaseNotes> </releaseNotes>
<summary>C# (.NET) Wrapper library around the Corsair CUE-SDK</summary> <summary>C# (.NET) Wrapper library around the Corsair CUE-SDK</summary>
<copyright>Copyright © Wyrez 2017</copyright> <copyright>Copyright © Wyrez 2017</copyright>

View File

@ -1,7 +1,6 @@
// ReSharper disable MemberCanBePrivate.Global // ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedMember.Global // ReSharper disable UnusedMember.Global
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
@ -9,13 +8,12 @@ using CUE.NET.Devices;
using CUE.NET.Devices.Generic; using CUE.NET.Devices.Generic;
using CUE.NET.Devices.Generic.Enums; using CUE.NET.Devices.Generic.Enums;
using CUE.NET.Devices.Headset; using CUE.NET.Devices.Headset;
using CUE.NET.Devices.HeadsetStand;
using CUE.NET.Devices.Keyboard; using CUE.NET.Devices.Keyboard;
using CUE.NET.Devices.Mouse; using CUE.NET.Devices.Mouse;
using CUE.NET.Devices.Mousemat; using CUE.NET.Devices.Mousemat;
using CUE.NET.EventArgs;
using CUE.NET.Exceptions; using CUE.NET.Exceptions;
using CUE.NET.Native; using CUE.NET.Native;
using System;
namespace CUE.NET namespace CUE.NET
{ {
@ -82,6 +80,7 @@ namespace CUE.NET
/// </summary> /// </summary>
public static CorsairMouse MouseSDK { get; private set; } public static CorsairMouse MouseSDK { get; private set; }
/// <summary> /// <summary>
/// Gets the managed representation of a headset managed by the CUE-SDK. /// Gets the managed representation of a headset managed by the CUE-SDK.
/// Note that currently only one connected headset is supported. /// Note that currently only one connected headset is supported.
@ -89,35 +88,13 @@ namespace CUE.NET
public static CorsairHeadset HeadsetSDK { get; private set; } public static CorsairHeadset HeadsetSDK { get; private set; }
/// <summary> /// <summary>
/// Gets the managed representation of a mousemat managed by the CUE-SDK. /// Gets the managed representation of a moustmat managed by the CUE-SDK.
/// Note that currently only one connected mousemat is supported. /// Note that currently only one connected mousemat is supported.
/// </summary> /// </summary>
public static CorsairMousemat MousematSDK { get; private set; } public static CorsairMousemat MousematSDK { get; private set; }
/// <summary>
/// Gets the managed representation of a headset stand managed by the CUE-SDK.
/// Note that currently only one connected headset stand is supported.
/// </summary>
public static CorsairHeadsetStand HeadsetStandSDK { get; private set; }
// ReSharper restore UnusedAutoPropertyAccessor.Global // ReSharper restore UnusedAutoPropertyAccessor.Global
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void OnKeyPressedDelegate(IntPtr context, CorsairKeyId keyId, [MarshalAs(UnmanagedType.I1)] bool pressed);
private static OnKeyPressedDelegate _onKeyPressedDelegate;
#endregion
#region Events
/// <summary>
/// Occurs when the SDK reports that a key is pressed.
/// Notice that right now only G- (keyboard) and M- (mouse) keys are supported.
///
/// To enable this event <see cref="EnableKeypressCallback"/> needs to be called.
/// </summary>
public static event EventHandler<KeyPressedEventArgs> KeyPressed;
#endregion #endregion
#region Methods #region Methods
@ -145,8 +122,6 @@ namespace CUE.NET
return HeadsetSDK != null; return HeadsetSDK != null;
case CorsairDeviceType.Mousemat: case CorsairDeviceType.Mousemat:
return MousematSDK != null; return MousematSDK != null;
case CorsairDeviceType.HeadsetStand:
return HeadsetStandSDK != null;
default: default:
return true; return true;
} }
@ -224,7 +199,14 @@ namespace CUE.NET
device = KeyboardSDK = new CorsairKeyboard(new CorsairKeyboardDeviceInfo(nativeDeviceInfo)); device = KeyboardSDK = new CorsairKeyboard(new CorsairKeyboardDeviceInfo(nativeDeviceInfo));
break; break;
case CorsairDeviceType.Mouse: case CorsairDeviceType.Mouse:
device = MouseSDK = new CorsairMouse(new CorsairMouseDeviceInfo(nativeDeviceInfo)); if(info.Model.ToLower().Contains("glaive"))
{
device = MouseSDK = new GlaiveMouse(new CorsairMouseDeviceInfo(nativeDeviceInfo));
}
else
{
device = MouseSDK = new CorsairMouse(new CorsairMouseDeviceInfo(nativeDeviceInfo));
}
break; break;
case CorsairDeviceType.Headset: case CorsairDeviceType.Headset:
device = HeadsetSDK = new CorsairHeadset(new CorsairHeadsetDeviceInfo(nativeDeviceInfo)); device = HeadsetSDK = new CorsairHeadset(new CorsairHeadsetDeviceInfo(nativeDeviceInfo));
@ -232,9 +214,6 @@ namespace CUE.NET
case CorsairDeviceType.Mousemat: case CorsairDeviceType.Mousemat:
device = MousematSDK = new CorsairMousemat(new CorsairMousematDeviceInfo(nativeDeviceInfo)); device = MousematSDK = new CorsairMousemat(new CorsairMousematDeviceInfo(nativeDeviceInfo));
break; break;
case CorsairDeviceType.HeadsetStand:
device = HeadsetStandSDK = new CorsairHeadsetStand(new CorsairHeadsetStandDeviceInfo(nativeDeviceInfo));
break;
// ReSharper disable once RedundantCaseLabel // ReSharper disable once RedundantCaseLabel
case CorsairDeviceType.Unknown: case CorsairDeviceType.Unknown:
default: default:
@ -249,42 +228,11 @@ namespace CUE.NET
Throw(error, true); Throw(error, true);
} }
error = LastError;
if (error != CorsairError.Success)
Throw(error, false);
InitializedDevices = new ReadOnlyCollection<ICueDevice>(devices); InitializedDevices = new ReadOnlyCollection<ICueDevice>(devices);
IsInitialized = true; IsInitialized = true;
} }
/// <summary>
/// Enables the keypress-callback.
/// This method needs to be called to enable the <see cref="KeyPressed"/>-event.
///
/// WARNING: AFTER THIS METHOD IS CALLED IT'S NO LONGER POSSIBLE TO REINITIALIZE THE SDK!
/// </summary>
public static void EnableKeypressCallback()
{
if (!IsInitialized)
throw new WrapperException("CueSDK isn't initialized.");
if (_onKeyPressedDelegate != null)
return;
_onKeyPressedDelegate = OnKeyPressed;
_CUESDK.CorsairRegisterKeypressCallback(Marshal.GetFunctionPointerForDelegate(_onKeyPressedDelegate), IntPtr.Zero);
}
/// <summary>
/// Resets the colors of all devices back to the last saved color-data. (If there wasn't a manual save, that's the data from the time the SDK was initialized.)
/// </summary>
public static void Reset()
{
foreach (ICueDevice device in InitializedDevices)
device.RestoreColors();
}
/// <summary> /// <summary>
/// Reinitialize the CUE-SDK and temporarily hand back full control to CUE. /// Reinitialize the CUE-SDK and temporarily hand back full control to CUE.
/// </summary> /// </summary>
@ -302,14 +250,10 @@ namespace CUE.NET
if (!IsInitialized) if (!IsInitialized)
throw new WrapperException("CueSDK isn't initialized."); throw new WrapperException("CueSDK isn't initialized.");
if (_onKeyPressedDelegate != null)
throw new WrapperException("Keypress-Callback is enabled.");
KeyboardSDK?.ResetLeds(); KeyboardSDK?.ResetLeds();
MouseSDK?.ResetLeds(); MouseSDK?.ResetLeds();
HeadsetSDK?.ResetLeds(); HeadsetSDK?.ResetLeds();
MousematSDK?.ResetLeds(); MousematSDK?.ResetLeds();
HeadsetStandSDK?.ResetLeds();
_CUESDK.Reload(); _CUESDK.Reload();
@ -360,14 +304,6 @@ namespace CUE.NET
if (!reloadedDevices.ContainsKey(CorsairDeviceType.Mousemat) if (!reloadedDevices.ContainsKey(CorsairDeviceType.Mousemat)
|| MousematSDK.MousematDeviceInfo.Model != reloadedDevices[CorsairDeviceType.Mousemat].Model) || MousematSDK.MousematDeviceInfo.Model != reloadedDevices[CorsairDeviceType.Mousemat].Model)
throw new WrapperException("The previously loaded Mousemat got disconnected."); throw new WrapperException("The previously loaded Mousemat got disconnected.");
if (HeadsetStandSDK != null)
if (!reloadedDevices.ContainsKey(CorsairDeviceType.HeadsetStand)
|| HeadsetStandSDK.HeadsetStandDeviceInfo.Model != reloadedDevices[CorsairDeviceType.HeadsetStand].Model)
throw new WrapperException("The previously loaded Headset Stand got disconnected.");
error = LastError;
if (error != CorsairError.Success)
Throw(error, false);
IsInitialized = true; IsInitialized = true;
} }
@ -382,16 +318,12 @@ namespace CUE.NET
MouseSDK = null; MouseSDK = null;
HeadsetSDK = null; HeadsetSDK = null;
MousematSDK = null; MousematSDK = null;
HeadsetStandSDK = null;
IsInitialized = false; IsInitialized = false;
} }
throw new CUEException(error); throw new CUEException(error);
} }
private static void OnKeyPressed(IntPtr context, CorsairKeyId keyId, bool pressed)
=> KeyPressed?.Invoke(null, new KeyPressedEventArgs(keyId, pressed));
#endregion #endregion
} }
} }

View File

@ -29,8 +29,6 @@ namespace CUE.NET.Devices.Generic
private static DateTime _lastUpdate = DateTime.Now; private static DateTime _lastUpdate = DateTime.Now;
private Dictionary<CorsairLedId, CorsairColor> _colorDataSave;
/// <summary> /// <summary>
/// Gets generic information provided by CUE for the device. /// Gets generic information provided by CUE for the device.
/// </summary> /// </summary>
@ -58,7 +56,6 @@ namespace CUE.NET.Devices.Generic
/// <summary> /// <summary>
/// Gets or sets the background brush of the keyboard. /// Gets or sets the background brush of the keyboard.
/// If this is null the last saved color-data is used as background.
/// </summary> /// </summary>
public IBrush Brush { get; set; } public IBrush Brush { get; set; }
@ -156,7 +153,6 @@ namespace CUE.NET.Devices.Generic
public virtual void Initialize() public virtual void Initialize()
{ {
DeviceRectangle = RectangleHelper.CreateRectangleFromRectangles((this).Select(x => x.LedRectangle)); DeviceRectangle = RectangleHelper.CreateRectangleFromRectangles((this).Select(x => x.LedRectangle));
SaveColors();
} }
/// <summary> /// <summary>
@ -191,26 +187,19 @@ namespace CUE.NET.Devices.Generic
/// Performs an update for all dirty keys, or all keys if flushLeds is set to true. /// Performs an update for all dirty keys, or all keys if flushLeds is set to true.
/// </summary> /// </summary>
/// <param name="flushLeds">Specifies whether all keys (including clean ones) should be updated.</param> /// <param name="flushLeds">Specifies whether all keys (including clean ones) should be updated.</param>
/// <param name="noRender">Only updates the hardware-leds skippin effects and the render-pass. Only use this if you know what that means!</param> public void Update(bool flushLeds = false)
public void Update(bool flushLeds = false, bool noRender = false)
{ {
OnUpdating(); OnUpdating();
if (!noRender) // Update effects
{ foreach (ILedGroup ledGroup in LedGroups)
// Update effects ledGroup.UpdateEffects();
foreach (ILedGroup ledGroup in LedGroups)
ledGroup.UpdateEffects();
// Render brushes // Render brushes
if (Brush != null) Render(this);
Render(this); foreach (ILedGroup ledGroup in LedGroups.OrderBy(x => x.ZIndex))
else Render(ledGroup);
ApplyColorData(_colorDataSave);
foreach (ILedGroup ledGroup in LedGroups.OrderBy(x => x.ZIndex))
Render(ledGroup);
}
// Device-specific updates // Device-specific updates
DeviceUpdate(); DeviceUpdate();
@ -273,7 +262,7 @@ namespace CUE.NET.Devices.Generic
catch (Exception ex) { OnException(ex); } catch (Exception ex) { OnException(ex); }
} }
private void UpdateLeds(ICollection<LedUpateRequest> updateRequests) protected virtual void UpdateLeds(ICollection<LedUpateRequest> updateRequests)
{ {
updateRequests = updateRequests.Where(x => x.Color != CorsairColor.Transparent).ToList(); updateRequests = updateRequests.Where(x => x.Color != CorsairColor.Transparent).ToList();
@ -304,63 +293,6 @@ namespace CUE.NET.Devices.Generic
OnLedsUpdated(updateRequests); OnLedsUpdated(updateRequests);
} }
/// <inheritdoc />
public void SyncColors()
{
Dictionary<CorsairLedId, CorsairColor> colorData = GetColors();
ApplyColorData(colorData);
Update(true, true);
}
/// <inheritdoc />
public void SaveColors()
{
_colorDataSave = GetColors();
}
/// <inheritdoc />
public void RestoreColors()
{
ApplyColorData(_colorDataSave);
Update(true, true);
}
private void ApplyColorData(Dictionary<CorsairLedId, CorsairColor> colorData)
{
if (colorData == null) return;
foreach (KeyValuePair<CorsairLedId, CorsairColor> corsairColor in _colorDataSave)
LedMapping[corsairColor.Key].Color = corsairColor.Value;
}
private Dictionary<CorsairLedId, CorsairColor> GetColors()
{
int structSize = Marshal.SizeOf(typeof(_CorsairLedColor));
IntPtr ptr = Marshal.AllocHGlobal(structSize * LedMapping.Count);
IntPtr addPtr = new IntPtr(ptr.ToInt64());
foreach (KeyValuePair<CorsairLedId, CorsairLed> led in LedMapping)
{
_CorsairLedColor color = new _CorsairLedColor { ledId = (int)led.Value.Id };
Marshal.StructureToPtr(color, addPtr, false);
addPtr = new IntPtr(addPtr.ToInt64() + structSize);
}
_CUESDK.CorsairGetLedsColors(LedMapping.Count, ptr);
IntPtr readPtr = ptr;
Dictionary<CorsairLedId, CorsairColor> colorData = new Dictionary<CorsairLedId, CorsairColor>();
for (int i = 0; i < LedMapping.Count; i++)
{
_CorsairLedColor ledColor = (_CorsairLedColor)Marshal.PtrToStructure(readPtr, typeof(_CorsairLedColor));
colorData.Add((CorsairLedId)ledColor.ledId, new CorsairColor((byte)ledColor.r, (byte)ledColor.g, (byte)ledColor.b));
readPtr = new IntPtr(readPtr.ToInt64() + structSize);
}
Marshal.FreeHGlobal(ptr);
return colorData;
}
#endregion #endregion
#region LedGroup #region LedGroup

View File

@ -15,7 +15,6 @@ namespace CUE.NET.Devices.Generic.Enums
Mouse = 1, Mouse = 1,
Keyboard = 2, Keyboard = 2,
Headset = 3, Headset = 3,
Mousemat = 4, Mousemat = 4
HeadsetStand = 5
}; };
} }

View File

@ -1,46 +0,0 @@
// ReSharper disable InconsistentNaming
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
namespace CUE.NET.Devices.Generic.Enums
{
/// <summary>
/// Contains list of all KeyIds available for all corsair devices.
/// </summary>
public enum CorsairKeyId
{
Invalid = 0,
G1 = 1,
G2 = 2,
G3 = 3,
G4 = 4,
G5 = 5,
G6 = 6,
G7 = 7,
G8 = 8,
G9 = 9,
G10 = 10,
G11 = 11,
G12 = 12,
G13 = 13,
G14 = 14,
G15 = 15,
G16 = 16,
G17 = 17,
G18 = 18,
M1 = 19,
M2 = 20,
M3 = 21,
M4 = 22,
M5 = 23,
M6 = 24,
M7 = 25,
M8 = 26,
M9 = 27,
M10 = 28,
M11 = 29,
M12 = 30,
}
}

View File

@ -205,15 +205,5 @@ namespace CUE.NET.Devices.Generic.Enums
Lightbar17 = 186, Lightbar17 = 186,
Lightbar18 = 187, Lightbar18 = 187,
Lightbar19 = 188, Lightbar19 = 188,
HeadsetStandZone1 = 191,
HeadsetStandZone2 = 192,
HeadsetStandZone3 = 193,
HeadsetStandZone4 = 194,
HeadsetStandZone5 = 195,
HeadsetStandZone6 = 196,
HeadsetStandZone7 = 197,
HeadsetStandZone8 = 198,
HeadsetStandZone9 = 199,
} }
} }

View File

@ -1,91 +0,0 @@
// ReSharper disable UnusedAutoPropertyAccessor.Global
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedMember.Global
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using CUE.NET.Devices.Generic;
using CUE.NET.Devices.Generic.Enums;
using CUE.NET.Exceptions;
using CUE.NET.Native;
namespace CUE.NET.Devices.HeadsetStand
{
/// <summary>
/// Represents the SDK for a corsair headset stand.
/// </summary>
public class CorsairHeadsetStand : AbstractCueDevice
{
#region Properties & Fields
/// <summary>
/// Gets specific information provided by CUE for the headset stand.
/// </summary>
public CorsairHeadsetStandDeviceInfo HeadsetStandDeviceInfo { get; }
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="CorsairHeadsetStand"/> class.
/// </summary>
/// <param name="info">The specific information provided by CUE for the headset stand</param>
internal CorsairHeadsetStand(CorsairHeadsetStandDeviceInfo info)
: base(info)
{
this.HeadsetStandDeviceInfo = info;
}
#endregion
#region Methods
/// <summary>
/// Initializes the headset stand.
/// </summary>
public override void Initialize()
{
int deviceCount = _CUESDK.CorsairGetDeviceCount();
// Get headset stand device index
int headsetStandIndex = -1;
for (int i = 0; i < deviceCount; i++)
{
_CorsairDeviceInfo nativeDeviceInfo = (_CorsairDeviceInfo)Marshal.PtrToStructure(_CUESDK.CorsairGetDeviceInfo(i), typeof(_CorsairDeviceInfo));
GenericDeviceInfo info = new GenericDeviceInfo(nativeDeviceInfo);
if (info.Type != CorsairDeviceType.HeadsetStand)
continue;
headsetStandIndex = i;
break;
}
if (headsetStandIndex < 0)
throw new WrapperException("Can't determine headset stand device index");
_CorsairLedPositions nativeLedPositions = (_CorsairLedPositions)Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositionsByDeviceIndex(headsetStandIndex), typeof(_CorsairLedPositions));
int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition));
IntPtr ptr = nativeLedPositions.pLedPosition;
// Put the positions in an array for sorting later on
List<_CorsairLedPosition> positions = new List<_CorsairLedPosition>();
for (int i = 0; i < nativeLedPositions.numberOfLed; i++)
{
_CorsairLedPosition ledPosition = (_CorsairLedPosition)Marshal.PtrToStructure(ptr, typeof(_CorsairLedPosition));
ptr = new IntPtr(ptr.ToInt64() + structSize);
positions.Add(ledPosition);
}
// Sort for easy iteration by clients
foreach (_CorsairLedPosition ledPosition in positions.OrderBy(p => p.ledId))
InitializeLed(ledPosition.ledId, new RectangleF((float)ledPosition.left, (float)ledPosition.top, (float)ledPosition.width, (float)ledPosition.height));
base.Initialize();
}
#endregion
}
}

View File

@ -1,26 +0,0 @@
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedAutoPropertyAccessor.Global
using CUE.NET.Devices.Generic;
using CUE.NET.Native;
namespace CUE.NET.Devices.HeadsetStand
{
/// <summary>
/// Represents specific information for a CUE headset stand.
/// </summary>
public class CorsairHeadsetStandDeviceInfo : GenericDeviceInfo
{
#region Constructors
/// <summary>
/// Internal constructor of managed <see cref="CorsairHeadsetStandDeviceInfo" />.
/// </summary>
/// <param name="nativeInfo">The native <see cref="_CorsairDeviceInfo" />-struct</param>
internal CorsairHeadsetStandDeviceInfo(_CorsairDeviceInfo nativeInfo)
: base(nativeInfo)
{ }
#endregion
}
}

View File

@ -1,26 +0,0 @@
// ReSharper disable UnusedMember.Global
// ReSharper disable InconsistentNaming
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
using CUE.NET.Devices.Generic.Enums;
namespace CUE.NET.Devices.HeadsetStand.Enums
{
/// <summary>
/// Contains list of all LEDs available for corsair headset stands.
/// </summary>
public static class CorsairHeadsetStandLedId
{
public const CorsairLedId Invalid = CorsairLedId.Invalid;
public const CorsairLedId HeadsetStandZone1 = CorsairLedId.HeadsetStandZone1;
public const CorsairLedId HeadsetStandZone2 = CorsairLedId.HeadsetStandZone2;
public const CorsairLedId HeadsetStandZone3 = CorsairLedId.HeadsetStandZone3;
public const CorsairLedId HeadsetStandZone4 = CorsairLedId.HeadsetStandZone4;
public const CorsairLedId HeadsetStandZone5 = CorsairLedId.HeadsetStandZone5;
public const CorsairLedId HeadsetStandZone6 = CorsairLedId.HeadsetStandZone6;
public const CorsairLedId HeadsetStandZone7 = CorsairLedId.HeadsetStandZone7;
public const CorsairLedId HeadsetStandZone8 = CorsairLedId.HeadsetStandZone8;
public const CorsairLedId HeadsetStandZone9 = CorsairLedId.HeadsetStandZone9;
}
}

View File

@ -140,26 +140,10 @@ namespace CUE.NET.Devices
void Initialize(); void Initialize();
/// <summary> /// <summary>
/// Performs an update for all dirty keys, or all keys if flushLeds is set to true. /// Perform an update for all dirty keys, or all keys if flushLeds is set to true.
/// </summary> /// </summary>
/// <param name="flushLeds">Specifies whether all keys (including clean ones) should be updated.</param> /// <param name="flushLeds">Specifies whether all keys (including clean ones) should be updated.</param>
/// <param name="noRender">Only updates the hardware-leds skippin effects and the render-pass. Only use this if you know what that means!</param> void Update(bool flushLeds = false);
void Update(bool flushLeds = false, bool noRender = false);
/// <summary>
/// Reads the currently active colors from the device and sync them with the internal state.
/// </summary>
void SyncColors();
/// <summary>
/// Saves the currently active colors from the device.
/// </summary>
void SaveColors();
/// <summary>
/// Restores the last saved colors.
/// </summary>
void RestoreColors();
/// <summary> /// <summary>
/// Attaches the given ledgroup. /// Attaches the given ledgroup.

View File

@ -1,36 +0,0 @@
// ReSharper disable UnusedMember.Global
// ReSharper disable InconsistentNaming
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
using CUE.NET.Devices.Generic.Enums;
namespace CUE.NET.Devices.Keyboard.Enums
{
/// <summary>
/// Contains list of all LEDs available for corsair keyboards.
/// </summary>
public static class CorsairKeyboardKeyId
{
public const CorsairKeyId Invalid = CorsairKeyId.Invalid;
public const CorsairKeyId G1 = CorsairKeyId.G1;
public const CorsairKeyId G2 = CorsairKeyId.G2;
public const CorsairKeyId G3 = CorsairKeyId.G3;
public const CorsairKeyId G4 = CorsairKeyId.G4;
public const CorsairKeyId G5 = CorsairKeyId.G5;
public const CorsairKeyId G6 = CorsairKeyId.G6;
public const CorsairKeyId G7 = CorsairKeyId.G7;
public const CorsairKeyId G8 = CorsairKeyId.G8;
public const CorsairKeyId G9 = CorsairKeyId.G9;
public const CorsairKeyId G10 = CorsairKeyId.G10;
public const CorsairKeyId G11 = CorsairKeyId.G11;
public const CorsairKeyId G12 = CorsairKeyId.G12;
public const CorsairKeyId G13 = CorsairKeyId.G13;
public const CorsairKeyId G14 = CorsairKeyId.G14;
public const CorsairKeyId G15 = CorsairKeyId.G15;
public const CorsairKeyId G16 = CorsairKeyId.G16;
public const CorsairKeyId G17 = CorsairKeyId.G17;
public const CorsairKeyId G18 = CorsairKeyId.G18;
}
}

View File

@ -2,16 +2,10 @@
// ReSharper disable UnusedAutoPropertyAccessor.Global // ReSharper disable UnusedAutoPropertyAccessor.Global
// ReSharper disable UnusedMember.Global // ReSharper disable UnusedMember.Global
using System;
using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using CUE.NET.Devices.Generic; using CUE.NET.Devices.Generic;
using CUE.NET.Devices.Generic.Enums;
using CUE.NET.Devices.Mouse.Enums; using CUE.NET.Devices.Mouse.Enums;
using CUE.NET.Exceptions; using CUE.NET.Exceptions;
using CUE.NET.Native;
namespace CUE.NET.Devices.Mouse namespace CUE.NET.Devices.Mouse
{ {
@ -50,14 +44,6 @@ namespace CUE.NET.Devices.Mouse
/// </summary> /// </summary>
public override void Initialize() public override void Initialize()
{ {
// Glaive is a special flake that doesn't follow the default layout
if (MouseDeviceInfo.Model == "GLAIVE RGB")
{
InitializeLed(CorsairMouseLedId.B1, new RectangleF(0, 0, 1, 1)); // Logo
InitializeLed(CorsairMouseLedId.B2, new RectangleF(2, 0, 1, 1)); // Front
InitializeLed(CorsairMouseLedId.B5, new RectangleF(3, 0, 1, 1)); // Sides
return;
}
switch (MouseDeviceInfo.PhysicalLayout) switch (MouseDeviceInfo.PhysicalLayout)
{ {
case CorsairPhysicalMouseLayout.Zones1: case CorsairPhysicalMouseLayout.Zones1:

View File

@ -1,30 +0,0 @@
// ReSharper disable UnusedMember.Global
// ReSharper disable InconsistentNaming
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
using CUE.NET.Devices.Generic.Enums;
namespace CUE.NET.Devices.Mouse.Enums
{
/// <summary>
/// Contains list of all LEDs available for corsair mice.
/// </summary>
public static class CorsairMouseKeyId
{
public const CorsairKeyId Invalid = CorsairKeyId.Invalid;
public const CorsairKeyId M1 = CorsairKeyId.M1;
public const CorsairKeyId M2 = CorsairKeyId.M2;
public const CorsairKeyId M3 = CorsairKeyId.M3;
public const CorsairKeyId M4 = CorsairKeyId.M4;
public const CorsairKeyId M5 = CorsairKeyId.M5;
public const CorsairKeyId M6 = CorsairKeyId.M6;
public const CorsairKeyId M7 = CorsairKeyId.M7;
public const CorsairKeyId M8 = CorsairKeyId.M8;
public const CorsairKeyId M9 = CorsairKeyId.M9;
public const CorsairKeyId M10 = CorsairKeyId.M10;
public const CorsairKeyId M11 = CorsairKeyId.M11;
public const CorsairKeyId M12 = CorsairKeyId.M12;
}
}

View File

@ -0,0 +1,139 @@
using CUE.NET.Devices.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using HidSharp;
using System.Drawing;
using CUE.NET.Devices.Generic.Enums;
namespace CUE.NET.Devices.Mouse
{
public class GlaiveMouse : CorsairMouse
{
private const int vid = 0x1b1c;
private const int pid = 0x1b34;
private HidDevice dev;
private HidStream stream;
private Color bars;
private Color front;
private Color logo;
private bool initialized = false;
public GlaiveMouse(CorsairMouseDeviceInfo info) : base(info)
{ }
public static GlaiveMouse FromCorsairMouse(CorsairMouse mouse)
{
return new GlaiveMouse(mouse.MouseDeviceInfo);
}
public override void Initialize()
{
var loader = new HidDeviceLoader();
dev = loader.GetDeviceOrDefault(vid, pid);
if (!dev.TryOpen(out stream)) throw new Exception("Glaive mouse init error!");
initialized = true;
base.Initialize();
}
protected override void UpdateLeds(ICollection<LedUpateRequest> updateRequests)
{
updateRequests = updateRequests.Where(x => x.Color != CorsairColor.Transparent).ToList();
OnLedsUpdating(updateRequests);
if (updateRequests.Any()) // CUE seems to crash if 'CorsairSetLedsColors' is called with a zero length array
{
//int structSize = Marshal.SizeOf(typeof(_CorsairLedColor));
//IntPtr ptr = Marshal.AllocHGlobal(structSize * updateRequests.Count);
//IntPtr addPtr = new IntPtr(ptr.ToInt64());
//foreach (LedUpateRequest ledUpdateRequest in updateRequests)
//{
// _CorsairLedColor color = new _CorsairLedColor
// {
// ledId = (int)ledUpdateRequest.LedId,
// r = ledUpdateRequest.Color.R,
// g = ledUpdateRequest.Color.G,
// b = ledUpdateRequest.Color.B
// };
// Marshal.StructureToPtr(color, addPtr, false);
// addPtr = new IntPtr(addPtr.ToInt64() + structSize);
//}
//_CUESDK.CorsairSetLedsColors(updateRequests.Count, ptr);
//Marshal.FreeHGlobal(ptr);
foreach (LedUpateRequest ledUpdateRequest in updateRequests)
{
switch(ledUpdateRequest.LedId)
{
case CorsairLedId.B1:
logo = Color.FromArgb(ledUpdateRequest.Color.R, ledUpdateRequest.Color.G, ledUpdateRequest.Color.B);
break;
case CorsairLedId.B2:
front = Color.FromArgb(ledUpdateRequest.Color.R, ledUpdateRequest.Color.G, ledUpdateRequest.Color.B);
break;
case CorsairLedId.B3:
bars = Color.FromArgb(ledUpdateRequest.Color.R, ledUpdateRequest.Color.G, ledUpdateRequest.Color.B);
break;
default:
break;
}
}
HidUpdate();
}
OnLedsUpdated(updateRequests);
}
private void HidUpdate()
{
if (initialized)
{
byte[] buff = new byte[65];
buff[1] = 7;
buff[2] = 34;
buff[3] = 4;
buff[4] = 1;
//dpi indicator (no idea why but this crap doesnt work)
buff[5] = 3;
//if (dpiIndicator == 1 || dpiIndicator == 2 || dpiIndicator == 4)
//buff[6] = 255;
//if (dpiIndicator >= 2)
buff[7] = 255;
//if (dpiIndicator == 2 || dpiIndicator == 5)
buff[8] = 255;
//bars rgb
buff[9] = 6;
buff[10] = bars.R;
buff[11] = bars.G;
buff[12] = bars.B;
//front rgb
buff[13] = 1;
buff[14] = front.R;
buff[15] = front.G;
buff[16] = front.B;
//logo rgb
buff[17] = 2;
buff[18] = logo.R;
buff[19] = logo.G;
buff[20] = logo.B;
stream.Write(buff);
}
else throw new Exception("not initialized");
}
}
}

View File

@ -1,41 +0,0 @@
// ReSharper disable MemberCanBePrivate.Global
using CUE.NET.Devices.Generic.Enums;
namespace CUE.NET.EventArgs
{
/// <summary>
/// Represents the data provided by the <see cref="CueSDK.KeyPressed"/>-event.
/// </summary>
public class KeyPressedEventArgs : System.EventArgs
{
#region Properties & Fields
/// <summary>
/// Gets the id of the key.
/// </summary>
public CorsairKeyId KeyId { get; }
/// <summary>
/// Gets the current status of the key (true = pressed, flase = released).
/// </summary>
public bool IsPressed { get; }
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="KeyPressedEventArgs"/> class.
/// </summary>
/// <param name="keyId">The id of the key.</param>
/// <param name="isPressed">The current status of the key (true = pressed, flase = released).</param>
public KeyPressedEventArgs(CorsairKeyId keyId, bool isPressed)
{
this.KeyId = keyId;
this.IsPressed = isPressed;
}
#endregion
}
}

View File

@ -13,6 +13,7 @@ using CUE.NET.Effects;
using CUE.NET.Exceptions; using CUE.NET.Exceptions;
using CUE.NET.Gradients; using CUE.NET.Gradients;
using CUE.NET.Groups; using CUE.NET.Groups;
using CUE.NET.Devices.Mouse;
namespace SimpleDevTest namespace SimpleDevTest
{ {
@ -22,407 +23,403 @@ namespace SimpleDevTest
public static void Main(string[] args) public static void Main(string[] args)
{ {
Console.WriteLine("Press any key to exit ..."); //Console.WriteLine("Press any key to exit ...");
Console.WriteLine(); //Console.WriteLine();
Task.Factory.StartNew( //Task.Factory.StartNew(
() => // () =>
{ // {
Console.ReadKey(); // Console.ReadKey();
Environment.Exit(0); // Environment.Exit(0);
}); // });
try //try
{ //{
bool test = CueSDK.IsSDKAvailable(); // bool test = CueSDK.IsSDKAvailable();
// Initialize CUE-SDK // // Initialize CUE-SDK
CueSDK.Initialize(); // CueSDK.Initialize();
Console.WriteLine("Initialized with " + CueSDK.LoadedArchitecture + "-SDK"); // Console.WriteLine("Initialized with " + CueSDK.LoadedArchitecture + "-SDK");
CueSDK.EnableKeypressCallback(); // CueSDK.KeyboardSDK.Brush = (SolidColorBrush)Color.Black;
// //CueSDK.KeyboardSDK[CorsairLedId.Z].Color = Color.Red;
CueSDK.KeyPressed += (sender, eventArgs) => Console.WriteLine($"Key {eventArgs.KeyId} {(eventArgs.IsPressed ? "pressed" : "released")}"); // //CueSDK.KeyboardSDK[CorsairLedId.Z].IsLocked = true;
//CueSDK.KeyboardSDK.Brush = (SolidColorBrush)Color.Black; // float thirdKeyboardWidth = CueSDK.KeyboardSDK.DeviceRectangle.Width / 3f;
//CueSDK.KeyboardSDK[CorsairLedId.Z].Color = Color.Red; // ILedGroup left = new RectangleLedGroup(CueSDK.KeyboardSDK, new RectangleF(CueSDK.KeyboardSDK.DeviceRectangle.X, CueSDK.KeyboardSDK.DeviceRectangle.Y, thirdKeyboardWidth, CueSDK.KeyboardSDK.DeviceRectangle.Height));
//CueSDK.KeyboardSDK[CorsairLedId.Z].IsLocked = true; // ILedGroup mid = new RectangleLedGroup(CueSDK.KeyboardSDK, new RectangleF(CueSDK.KeyboardSDK.DeviceRectangle.X + thirdKeyboardWidth, CueSDK.KeyboardSDK.DeviceRectangle.Y, thirdKeyboardWidth, CueSDK.KeyboardSDK.DeviceRectangle.Height));
// ILedGroup right = new RectangleLedGroup(CueSDK.KeyboardSDK, new RectangleF(CueSDK.KeyboardSDK.DeviceRectangle.X + thirdKeyboardWidth * 2, CueSDK.KeyboardSDK.DeviceRectangle.Y, thirdKeyboardWidth, CueSDK.KeyboardSDK.DeviceRectangle.Height));
float thirdKeyboardWidth = CueSDK.KeyboardSDK.DeviceRectangle.Width / 3f;
ILedGroup left = new RectangleLedGroup(CueSDK.KeyboardSDK, new RectangleF(CueSDK.KeyboardSDK.DeviceRectangle.X, CueSDK.KeyboardSDK.DeviceRectangle.Y, thirdKeyboardWidth, CueSDK.KeyboardSDK.DeviceRectangle.Height)); // //CueSDK.KeyboardSDK.Brush = new LinearGradientBrush(new LinearGradient(true, new GradientStop(0, Color.Blue), new GradientStop(0.5f, Color.Red)));
ILedGroup mid = new RectangleLedGroup(CueSDK.KeyboardSDK, new RectangleF(CueSDK.KeyboardSDK.DeviceRectangle.X + thirdKeyboardWidth, CueSDK.KeyboardSDK.DeviceRectangle.Y, thirdKeyboardWidth, CueSDK.KeyboardSDK.DeviceRectangle.Height)); // left.Brush = new ConicalGradientBrush(new PointF(0.6f, 0.7f), new RainbowGradient(360, 0));
ILedGroup right = new RectangleLedGroup(CueSDK.KeyboardSDK, new RectangleF(CueSDK.KeyboardSDK.DeviceRectangle.X + thirdKeyboardWidth * 2, CueSDK.KeyboardSDK.DeviceRectangle.Y, thirdKeyboardWidth, CueSDK.KeyboardSDK.DeviceRectangle.Height)); // left.Brush.AddEffect(new MoveGradientEffect());
//CueSDK.KeyboardSDK.Brush = new LinearGradientBrush(new LinearGradient(true, new GradientStop(0, Color.Blue), new GradientStop(0.5f, Color.Red))); // mid.Brush = new ConicalGradientBrush(new PointF(0.5f, 0.3f), new RainbowGradient());
left.Brush = new ConicalGradientBrush(new PointF(0.6f, 0.7f), new RainbowGradient(360, 0)); // mid.Brush.AddEffect(new MoveGradientEffect());
left.Brush.AddEffect(new MoveGradientEffect());
left.Brush.AddEffect(new FlashEffect { Attack = 2, Sustain = 1f, Release = 2, Interval = 1f }); // right.Brush = new ConicalGradientBrush(new PointF(0.4f, 0.7f), new RainbowGradient(360, 0));
// right.Brush.AddEffect(new MoveGradientEffect());
mid.Brush = new ConicalGradientBrush(new PointF(0.5f, 0.3f), new RainbowGradient());
mid.Brush.AddEffect(new MoveGradientEffect()); // //float halfKeyboardWidth = CueSDK.KeyboardSDK.DeviceRectangle.Width / 2f;
mid.Brush.AddEffect(new FlashEffect { Attack = 2, Sustain = 1f, Release = 2, Interval = 1f }); // //ILedGroup left = new RectangleLedGroup(CueSDK.KeyboardSDK, new RectangleF(CueSDK.KeyboardSDK.DeviceRectangle.X, CueSDK.KeyboardSDK.DeviceRectangle.Y, halfKeyboardWidth, CueSDK.KeyboardSDK.DeviceRectangle.Height));
// //ILedGroup right = new RectangleLedGroup(CueSDK.KeyboardSDK, new RectangleF(CueSDK.KeyboardSDK.DeviceRectangle.X + halfKeyboardWidth, CueSDK.KeyboardSDK.DeviceRectangle.Y, halfKeyboardWidth, CueSDK.KeyboardSDK.DeviceRectangle.Height));
right.Brush = new ConicalGradientBrush(new PointF(0.4f, 0.7f), new RainbowGradient(360, 0));
right.Brush.AddEffect(new MoveGradientEffect()); // ////CueSDK.KeyboardSDK.Brush = new LinearGradientBrush(new LinearGradient(true, new GradientStop(0, Color.Blue), new GradientStop(0.5f, Color.Red)));
right.Brush.AddEffect(new FlashEffect { Attack = 2, Sustain = 1f, Release = 2, Interval = 1f }); // //left.Brush = new ConicalGradientBrush(new PointF(0.6f, 0.6f), new RainbowGradient(360, 0));
// //left.Brush.AddEffect(new MoveGradientEffect());
//float halfKeyboardWidth = CueSDK.KeyboardSDK.DeviceRectangle.Width / 2f;
//ILedGroup left = new RectangleLedGroup(CueSDK.KeyboardSDK, new RectangleF(CueSDK.KeyboardSDK.DeviceRectangle.X, CueSDK.KeyboardSDK.DeviceRectangle.Y, halfKeyboardWidth, CueSDK.KeyboardSDK.DeviceRectangle.Height)); // //right.Brush = new ConicalGradientBrush(new PointF(0.4f, 0.6f), new RainbowGradient());
//ILedGroup right = new RectangleLedGroup(CueSDK.KeyboardSDK, new RectangleF(CueSDK.KeyboardSDK.DeviceRectangle.X + halfKeyboardWidth, CueSDK.KeyboardSDK.DeviceRectangle.Y, halfKeyboardWidth, CueSDK.KeyboardSDK.DeviceRectangle.Height)); // //right.Brush.AddEffect(new MoveGradientEffect());
////CueSDK.KeyboardSDK.Brush = new LinearGradientBrush(new LinearGradient(true, new GradientStop(0, Color.Blue), new GradientStop(0.5f, Color.Red))); // CueSDK.UpdateMode = UpdateMode.Continuous;
//left.Brush = new ConicalGradientBrush(new PointF(0.6f, 0.6f), new RainbowGradient(360, 0));
//left.Brush.AddEffect(new MoveGradientEffect()); // //IBrush rainbowBrush = new LinearGradientBrush(new RainbowGradient());
// //rainbowBrush.AddEffect(new FlashEffect { Attack = 5f, Sustain = 1f, Decay = 0, Release = 5f, Interval = 1f });
//right.Brush = new ConicalGradientBrush(new PointF(0.4f, 0.6f), new RainbowGradient()); // //rainbowBrush.AddEffect(new MoveRainbowEffect());
//right.Brush.AddEffect(new MoveGradientEffect()); // //rainbowBrush.AddEffect(new RemoveRedEffect());
CueSDK.UpdateMode = UpdateMode.Continuous; // //foreach (ICueDevice device in CueSDK.InitializedDevices)
// // AddTestBrush(device, rainbowBrush);
Wait(5);
CueSDK.UpdateMode = UpdateMode.Manual; // //// Get connected keyboard or throw exception if there is no light controllable keyboard connected
for (int i = 0; i < 100000; i++) // //CorsairKeyboard keyboard = CueSDK.KeyboardSDK;
{ // //if (keyboard == null)
CueSDK.Reinitialize(); // // throw new WrapperException("No keyboard found");
Console.WriteLine(i);
} // //const float SPEED = 100f; // mm/sec
// //const float BRUSH_MODE_CHANGE_TIMER = 2f;
Console.WriteLine("done!"); // //Random random = new Random();
Wait(5);
// //keyboard.UpdateMode = UpdateMode.Continuous;
//IBrush rainbowBrush = new LinearGradientBrush(new RainbowGradient()); // //keyboard.Brush = new SolidColorBrush(Color.Black);
//rainbowBrush.AddEffect(new FlashEffect { Attack = 5f, Sustain = 1f, Decay = 0, Release = 5f, Interval = 1f });
//rainbowBrush.AddEffect(new MoveRainbowEffect()); // //RectangleF spot = new RectangleF(keyboard.DeviceRectangle.Width / 2f, keyboard.DeviceRectangle.Y / 2f, 160, 80);
//rainbowBrush.AddEffect(new RemoveRedEffect()); // //PointF target = new PointF(spot.X, spot.Y);
// //RectangleLedGroup spotGroup = new RectangleLedGroup(keyboard, spot) { Brush = new LinearGradientBrush(new RainbowGradient()) };
//foreach (ICueDevice device in CueSDK.InitializedDevices)
// AddTestBrush(device, rainbowBrush); // //float brushModeTimer = BRUSH_MODE_CHANGE_TIMER;
// //keyboard.Updating += (sender, eventArgs) =>
//// Get connected keyboard or throw exception if there is no light controllable keyboard connected // //{
//CorsairKeyboard keyboard = CueSDK.KeyboardSDK; // // brushModeTimer -= eventArgs.DeltaTime;
//if (keyboard == null) // // if (brushModeTimer <= 0)
// throw new WrapperException("No keyboard found"); // // {
// // spotGroup.Brush.BrushCalculationMode = spotGroup.Brush.BrushCalculationMode == BrushCalculationMode.Relative
//const float SPEED = 100f; // mm/sec // // ? BrushCalculationMode.Absolute : BrushCalculationMode.Relative;
//const float BRUSH_MODE_CHANGE_TIMER = 2f; // // brushModeTimer = BRUSH_MODE_CHANGE_TIMER + brushModeTimer;
//Random random = new Random(); // // }
//keyboard.UpdateMode = UpdateMode.Continuous; // // if (spot.Contains(target))
//keyboard.Brush = new SolidColorBrush(Color.Black); // // target = new PointF((float)(keyboard.DeviceRectangle.X + (random.NextDouble() * keyboard.DeviceRectangle.Width)),
// // (float)(keyboard.DeviceRectangle.Y + (random.NextDouble() * keyboard.DeviceRectangle.Height)));
//RectangleF spot = new RectangleF(keyboard.DeviceRectangle.Width / 2f, keyboard.DeviceRectangle.Y / 2f, 160, 80); // // else
//PointF target = new PointF(spot.X, spot.Y); // // spot.Location = Interpolate(spot.Location, target, eventArgs.DeltaTime * SPEED);
//RectangleLedGroup spotGroup = new RectangleLedGroup(keyboard, spot) { Brush = new LinearGradientBrush(new RainbowGradient()) }; // // spotGroup.Rectangle = spot;
// //};
//float brushModeTimer = BRUSH_MODE_CHANGE_TIMER;
//keyboard.Updating += (sender, eventArgs) => // //CorsairMousemat mousemat = CueSDK.MousematSDK;
//{ // //mousemat.UpdateMode = UpdateMode.Continuous;
// brushModeTimer -= eventArgs.DeltaTime;
// if (brushModeTimer <= 0) // //// Left
// { // //mousemat[CorsairMousematLedId.Zone1].Color = Color.Red;
// spotGroup.Brush.BrushCalculationMode = spotGroup.Brush.BrushCalculationMode == BrushCalculationMode.Relative // //mousemat[CorsairMousematLedId.Zone2].Color = Color.Red;
// ? BrushCalculationMode.Absolute : BrushCalculationMode.Relative; // //mousemat[CorsairMousematLedId.Zone3].Color = Color.Red;
// brushModeTimer = BRUSH_MODE_CHANGE_TIMER + brushModeTimer; // //mousemat[CorsairMousematLedId.Zone4].Color = Color.Red;
// } // //mousemat[CorsairMousematLedId.Zone5].Color = Color.Red;
// //// Bottom
// if (spot.Contains(target)) // //mousemat[CorsairMousematLedId.Zone6].Color = Color.LawnGreen;
// target = new PointF((float)(keyboard.DeviceRectangle.X + (random.NextDouble() * keyboard.DeviceRectangle.Width)), // //mousemat[CorsairMousematLedId.Zone7].Color = Color.LawnGreen;
// (float)(keyboard.DeviceRectangle.Y + (random.NextDouble() * keyboard.DeviceRectangle.Height))); // //mousemat[CorsairMousematLedId.Zone8].Color = Color.LawnGreen;
// else // //mousemat[CorsairMousematLedId.Zone9].Color = Color.LawnGreen;
// spot.Location = Interpolate(spot.Location, target, eventArgs.DeltaTime * SPEED); // //mousemat[CorsairMousematLedId.Zone10].Color = Color.LawnGreen;
// spotGroup.Rectangle = spot; // //// Right
//}; // //mousemat[CorsairMousematLedId.Zone11].Color = Color.Blue;
// //mousemat[CorsairMousematLedId.Zone12].Color = Color.Blue;
//CorsairMousemat mousemat = CueSDK.MousematSDK; // //mousemat[CorsairMousematLedId.Zone13].Color = Color.Blue;
//mousemat.UpdateMode = UpdateMode.Continuous; // //mousemat[CorsairMousematLedId.Zone14].Color = Color.Blue;
// //mousemat[CorsairMousematLedId.Zone15].Color = Color.Blue;
//// Left
//mousemat[CorsairMousematLedId.Zone1].Color = Color.Red; // // Random colors to show update rate
//mousemat[CorsairMousematLedId.Zone2].Color = Color.Red; // //foreach (var mousematLed in mousemat.Leds)
//mousemat[CorsairMousematLedId.Zone3].Color = Color.Red; // // mousematLed.Color = GetRandomRainbowColor();
//mousemat[CorsairMousematLedId.Zone4].Color = Color.Red;
//mousemat[CorsairMousematLedId.Zone5].Color = Color.Red; // //mousemat.Updating += (sender, eventArgs) =>
//// Bottom // //{
//mousemat[CorsairMousematLedId.Zone6].Color = Color.LawnGreen; // // foreach (var mousematLed in mousemat.Leds)
//mousemat[CorsairMousematLedId.Zone7].Color = Color.LawnGreen; // // {
//mousemat[CorsairMousematLedId.Zone8].Color = Color.LawnGreen; // // mousematLed.Color = ShiftColor(mousematLed.Color, 20);
//mousemat[CorsairMousematLedId.Zone9].Color = Color.LawnGreen; // // }
//mousemat[CorsairMousematLedId.Zone10].Color = Color.LawnGreen; // //};
//// Right
//mousemat[CorsairMousematLedId.Zone11].Color = Color.Blue; // //keyboard.Brush = new SolidColorBrush(Color.Black);
//mousemat[CorsairMousematLedId.Zone12].Color = Color.Blue; // //ILedGroup group = new RectangleLedGroup(keyboard, CorsairKeyboardKeyId.F1, CorsairKeyboardKeyId.RightShift);
//mousemat[CorsairMousematLedId.Zone13].Color = Color.Blue; // //group.Brush = new LinearGradientBrush(new RainbowGradient());
//mousemat[CorsairMousematLedId.Zone14].Color = Color.Blue; // //bool tmp = false;
//mousemat[CorsairMousematLedId.Zone15].Color = Color.Blue; // //while (true)
// //{
// Random colors to show update rate // // group.Brush.BrushCalculationMode = tmp ? BrushCalculationMode.Absolute : BrushCalculationMode.Relative;
//foreach (var mousematLed in mousemat.Leds)
// mousematLed.Color = GetRandomRainbowColor(); // // tmp = !tmp;
// // keyboard.Update();
//mousemat.Updating += (sender, eventArgs) => // // Wait(1);
//{ // //}
// foreach (var mousematLed in mousemat.Leds)
// { // //keyboard.Brush = new SolidColorBrush(Color.Aqua);
// mousematLed.Color = ShiftColor(mousematLed.Color, 20); // //keyboard.Update();
// }
//}; // //ILedGroup specialKeyGroup = new ListLedGroup(keyboard, CorsairKeyboardKeyId.Brightness, CorsairKeyboardKeyId.WinLock);
// //specialKeyGroup.Brush = new SolidColorBrush(Color.Aqua);
//keyboard.Brush = new SolidColorBrush(Color.Black); // //keyboard.Update();
//ILedGroup group = new RectangleLedGroup(keyboard, CorsairKeyboardKeyId.F1, CorsairKeyboardKeyId.RightShift);
//group.Brush = new LinearGradientBrush(new RainbowGradient()); // //// Replacing the specialKeyGroup with this won't work
//bool tmp = false; // //keyboard[CorsairKeyboardKeyId.Brightness].Led.Color = Color.Aqua;
//while (true) // //keyboard[CorsairKeyboardKeyId.Brightness].Led.IsLocked = true;
//{ // //keyboard[CorsairKeyboardKeyId.WinLock].Led.Color = Color.Aqua;
// group.Brush.BrushCalculationMode = tmp ? BrushCalculationMode.Absolute : BrushCalculationMode.Relative; // //keyboard[CorsairKeyboardKeyId.WinLock].Led.IsLocked = true;
// //keyboard.Update();
// tmp = !tmp;
// keyboard.Update(); // //Wait(3);
// Wait(1);
//} // //CueSDK.Reinitialize();
// ////keyboard.Brush = CueProfiles.LoadProfileByID()[null];
//keyboard.Brush = new SolidColorBrush(Color.Aqua); // ////keyboard.Update();
//keyboard.Update();
// //Wait(3);
//ILedGroup specialKeyGroup = new ListLedGroup(keyboard, CorsairKeyboardKeyId.Brightness, CorsairKeyboardKeyId.WinLock);
//specialKeyGroup.Brush = new SolidColorBrush(Color.Aqua); // //// My Profile 'K95 RGB Default 2' is all black - this could lead to different behavior than cue has since transparent isn't black in CUE.NET
//keyboard.Update(); // //// To swap a profile like CUE does we would need to black out the keyboard before
// //// OR work with a key group containing all keys and leave the background black - this should be always the prefered solution
//// Replacing the specialKeyGroup with this won't work // //keyboard.Brush = new SolidColorBrush(Color.Black);
//keyboard[CorsairKeyboardKeyId.Brightness].Led.Color = Color.Aqua; // //keyboard.Update();
//keyboard[CorsairKeyboardKeyId.Brightness].Led.IsLocked = true; // ////keyboard.Brush = CueProfiles.LoadProfileByID()["K95 RGB Default 2"];
//keyboard[CorsairKeyboardKeyId.WinLock].Led.Color = Color.Aqua; // ////keyboard.Update();
//keyboard[CorsairKeyboardKeyId.WinLock].Led.IsLocked = true;
//keyboard.Update(); // //Wait(3);
//Wait(3); // //ListLedGroup ledGroup = new ListLedGroup(keyboard, keyboard['R'].KeyId);
// //ledGroup.Brush = new SolidColorBrush(Color.White);
//CueSDK.Reinitialize(); // //keyboard.Update();
////keyboard.Brush = CueProfiles.LoadProfileByID()[null]; // //Wait(2);
////keyboard.Update(); // //ledGroup.RemoveKey(keyboard['R'].KeyId);
// //keyboard['R'].Led.Color = Color.Black;
//Wait(3); // //ledGroup.AddKey(keyboard['T'].KeyId);
// //keyboard.Update();
//// My Profile 'K95 RGB Default 2' is all black - this could lead to different behavior than cue has since transparent isn't black in CUE.NET
//// To swap a profile like CUE does we would need to black out the keyboard before // //Wait(10);
//// OR work with a key group containing all keys and leave the background black - this should be always the prefered solution
//keyboard.Brush = new SolidColorBrush(Color.Black); // //return;
//keyboard.Update();
////keyboard.Brush = CueProfiles.LoadProfileByID()["K95 RGB Default 2"]; // // ---------------------------------------------------------------------------
////keyboard.Update(); // // First we'll look at some basic coloring
//Wait(3); // //Console.WriteLine("Basic color-test ...");
// //// Ink all numbers on the keypad except the '5' purple, we want that to be gray
//ListLedGroup ledGroup = new ListLedGroup(keyboard, keyboard['R'].KeyId); // //ListLedGroup purpleGroup = new RectangleLedGroup(keyboard, CorsairKeyboardKeyId.Keypad7, CorsairKeyboardKeyId.Keypad3)
//ledGroup.Brush = new SolidColorBrush(Color.White); // //{ Brush = new SolidColorBrush(Color.Purple) }
//keyboard.Update(); // //.Exclude(CorsairKeyboardKeyId.Keypad5);
//Wait(2); // //keyboard[CorsairKeyboardKeyId.Keypad5].Led.Color = Color.Gray;
//ledGroup.RemoveKey(keyboard['R'].KeyId);
//keyboard['R'].Led.Color = Color.Black; // //// Ink the Keys 'r', 'g', 'b' in their respective color
//ledGroup.AddKey(keyboard['T'].KeyId); // //// The char access fails for everything except letters (SDK doesn't return a valid keyId)
//keyboard.Update(); // //keyboard['R'].Led.Color = Color.Red;
// //keyboard[CorsairKeyboardKeyId.G].Led.Color = Color.Green;
//Wait(10); // //keyboard['B'].Led.Color = Color.Blue;
//return; // //// Lock the 'r', 'g', 'b' keys. We want them to stay like this forever (commented since it looks quite stupid later, but feel free tu uncomment this)
// ////keyboard['R'].Led.IsLocked = true;
// --------------------------------------------------------------------------- // ////keyboard['G'].Led.IsLocked = true;
// First we'll look at some basic coloring // ////keyboard['B'].Led.IsLocked = true;
//Console.WriteLine("Basic color-test ..."); // //// Ink the letters of 'white' white
//// Ink all numbers on the keypad except the '5' purple, we want that to be gray // //ListLedGroup whiteGroup = new ListLedGroup(keyboard, CorsairKeyboardKeyId.W, CorsairKeyboardKeyId.H, CorsairKeyboardKeyId.I, CorsairKeyboardKeyId.T, CorsairKeyboardKeyId.E)
//ListLedGroup purpleGroup = new RectangleLedGroup(keyboard, CorsairKeyboardKeyId.Keypad7, CorsairKeyboardKeyId.Keypad3) // //{ Brush = new SolidColorBrush(Color.White) };
//{ Brush = new SolidColorBrush(Color.Purple) }
//.Exclude(CorsairKeyboardKeyId.Keypad5); // //// Ink the keys '1' to '0' yellow
//keyboard[CorsairKeyboardKeyId.Keypad5].Led.Color = Color.Gray; // //RectangleLedGroup yellowGroup = new RectangleLedGroup(keyboard, CorsairKeyboardKeyId.D1, CorsairKeyboardKeyId.D0)
// //{ Brush = new SolidColorBrush(Color.Yellow) };
//// Ink the Keys 'r', 'g', 'b' in their respective color
//// The char access fails for everything except letters (SDK doesn't return a valid keyId) // //// Update the keyboard to show the configured colors, (your CUE settings defines the rest)
//keyboard['R'].Led.Color = Color.Red; // //keyboard.Update();
//keyboard[CorsairKeyboardKeyId.G].Led.Color = Color.Green;
//keyboard['B'].Led.Color = Color.Blue; // //Wait(3);
//// Lock the 'r', 'g', 'b' keys. We want them to stay like this forever (commented since it looks quite stupid later, but feel free tu uncomment this) // //// Remove all the groups we created above to clear the keyboard
////keyboard['R'].Led.IsLocked = true; // //purpleGroup.Detach();
////keyboard['G'].Led.IsLocked = true; // //whiteGroup.Detach();
////keyboard['B'].Led.IsLocked = true; // //yellowGroup.Detach();
//// Ink the letters of 'white' white
//ListLedGroup whiteGroup = new ListLedGroup(keyboard, CorsairKeyboardKeyId.W, CorsairKeyboardKeyId.H, CorsairKeyboardKeyId.I, CorsairKeyboardKeyId.T, CorsairKeyboardKeyId.E) // //// ---------------------------------------------------------------------------
//{ Brush = new SolidColorBrush(Color.White) }; // //// Next we add a nice linear gradient brush over the keyboard and play around with the offset of one stop
//// Ink the keys '1' to '0' yellow // //Console.WriteLine("gradient-brush-test");
//RectangleLedGroup yellowGroup = new RectangleLedGroup(keyboard, CorsairKeyboardKeyId.D1, CorsairKeyboardKeyId.D0)
//{ Brush = new SolidColorBrush(Color.Yellow) }; // //// Create our gradient stop to play with
// //GradientStop moveableStop = new GradientStop(0, Color.FromArgb(0, 255, 0));
//// Update the keyboard to show the configured colors, (your CUE settings defines the rest)
//keyboard.Update(); // //// Create a basic (by default horizontal) brush ...
// //LinearGradientBrush linearBrush = new LinearGradientBrush(new LinearGradient(new GradientStop(0, Color.Blue), moveableStop, new GradientStop(1f, Color.White)));
//Wait(3);
// //// ... and add it as the keyboard background
//// Remove all the groups we created above to clear the keyboard // //keyboard.Brush = linearBrush;
//purpleGroup.Detach();
//whiteGroup.Detach(); // //// Move the brush from left to right
//yellowGroup.Detach(); // //for (float offset = 0; offset <= 1f; offset += 0.02f)
// //{
// // moveableStop.Offset = offset;
//// --------------------------------------------------------------------------- // // keyboard.Update();
//// Next we add a nice linear gradient brush over the keyboard and play around with the offset of one stop // // Thread.Sleep(100);
// //}
//Console.WriteLine("gradient-brush-test");
// //// And back to center
//// Create our gradient stop to play with // //for (float offset = 1f; offset >= 0.5f; offset -= 0.02f)
//GradientStop moveableStop = new GradientStop(0, Color.FromArgb(0, 255, 0)); // //{
// // moveableStop.Offset = offset;
//// Create a basic (by default horizontal) brush ... // // keyboard.Update();
//LinearGradientBrush linearBrush = new LinearGradientBrush(new LinearGradient(new GradientStop(0, Color.Blue), moveableStop, new GradientStop(1f, Color.White))); // // Thread.Sleep(100);
// //}
//// ... and add it as the keyboard background
//keyboard.Brush = linearBrush; // //// "Rotate" the brush (this is of course not the best implementation for this but you see the point)
// //for (float rotateX = 0, rotateY = 0; rotateX <= 1f; rotateX += 0.02f, rotateY = 0.04f)
//// Move the brush from left to right // //{
//for (float offset = 0; offset <= 1f; offset += 0.02f) // // if (rotateY > 1f)
//{ // // rotateY = 1f - (rotateY - 1f);
// moveableStop.Offset = offset;
// keyboard.Update(); // // linearBrush.StartPoint = new PointF(rotateX, rotateY);
// Thread.Sleep(100); // // linearBrush.EndPoint = new PointF(1f - rotateX, 1f - rotateY);
//}
// // keyboard.Update();
//// And back to center // // Thread.Sleep(100);
//for (float offset = 1f; offset >= 0.5f; offset -= 0.02f) // //}
//{
// moveableStop.Offset = offset; // //Wait(2);
// keyboard.Update();
// Thread.Sleep(100); // //// ---------------------------------------------------------------------------
//} // //// Time for an even better brush: rainbow
//// "Rotate" the brush (this is of course not the best implementation for this but you see the point) // //Console.WriteLine("rainbow-test");
//for (float rotateX = 0, rotateY = 0; rotateX <= 1f; rotateX += 0.02f, rotateY = 0.04f)
//{ // //// Create an simple horizontal rainbow containing two times the full spectrum
// if (rotateY > 1f) // //RainbowGradient rainbowGradient = new RainbowGradient(0, 720);
// rotateY = 1f - (rotateY - 1f);
// //// Add the rainbow to the keyboard and perform an initial update
// linearBrush.StartPoint = new PointF(rotateX, rotateY); // //keyboard.Brush = new LinearGradientBrush(rainbowGradient);
// linearBrush.EndPoint = new PointF(1f - rotateX, 1f - rotateY); // //keyboard.Update();
// keyboard.Update(); // //// Let the rainbow move around for 10 secs
// Thread.Sleep(100); // //for (int i = 0; i < 100; i++)
//} // //{
// // rainbowGradient.StartHue += 10f;
//Wait(2); // // rainbowGradient.EndHue += 10f;
// // keyboard.Update();
//// --------------------------------------------------------------------------- // // Thread.Sleep(100);
//// Time for an even better brush: rainbow // //}
//Console.WriteLine("rainbow-test"); // //Wait(2);
//// Create an simple horizontal rainbow containing two times the full spectrum
//RainbowGradient rainbowGradient = new RainbowGradient(0, 720); // // ---------------------------------------------------------------------------
// // Now let us move some points random over the keyboard
//// Add the rainbow to the keyboard and perform an initial update // // Something like this could become some sort of effect
//keyboard.Brush = new LinearGradientBrush(rainbowGradient);
//keyboard.Update(); // // Initialize needed stuff
// // const float SPEED = 6f; // mm/tick
//// Let the rainbow move around for 10 secs // //Random random = new Random();
//for (int i = 0; i < 100; i++)
//{ // //// Flash whole keyboard three times to ... well ... just to make it happen
// rainbowGradient.StartHue += 10f; // //for (int i = 0; i < 3; i++)
// rainbowGradient.EndHue += 10f; // //{
// keyboard.Update(); // // keyboard.Brush = new SolidColorBrush(Color.Aquamarine);
// Thread.Sleep(100); // // keyboard.Update();
//} // // Thread.Sleep(160);
// // keyboard.Brush = new SolidColorBrush(Color.Black);
//Wait(2); // // keyboard.Update();
// // Thread.Sleep(200);
// //}
// ---------------------------------------------------------------------------
// Now let us move some points random over the keyboard // //// Set keyboard 'background' to black with low alpha (this will add a nice "fade" effect instead of just clearing the keyboard every frame)
// Something like this could become some sort of effect // //keyboard.Brush = new SolidColorBrush(Color.FromArgb(25, 0, 0, 0));
// Initialize needed stuff // //// Define how many points we have
// const float SPEED = 6f; // mm/tick // //const int NUM_POINTS = 6;
//Random random = new Random();
// //// The points we want to draw (rectangle since circles are too hard to calculate :p)
//// Flash whole keyboard three times to ... well ... just to make it happen // //RectangleF[] points = new RectangleF[NUM_POINTS];
//for (int i = 0; i < 3; i++)
//{ // //// KeyGroups which represents our point on the keyboard
// keyboard.Brush = new SolidColorBrush(Color.Aquamarine); // //RectangleLedGroup[] pointGroups = new RectangleLedGroup[NUM_POINTS];
// keyboard.Update();
// Thread.Sleep(160); // //// Target of our movement
// keyboard.Brush = new SolidColorBrush(Color.Black); // //PointF[] targets = new PointF[NUM_POINTS];
// keyboard.Update();
// Thread.Sleep(200); // //// Initialize all the stuff
//} // //for (int i = 0; i < NUM_POINTS; i++)
// //{
//// Set keyboard 'background' to black with low alpha (this will add a nice "fade" effect instead of just clearing the keyboard every frame) // // // Spawn our point in the top-left corner (right over G1 or on ESC depending on your keyboard)
//keyboard.Brush = new SolidColorBrush(Color.FromArgb(25, 0, 0, 0)); // // points[i] = new RectangleF(keyboard.KeyboardRectangle.X, keyboard.KeyboardRectangle.Y, 60, 60);
// // pointGroups[i] = new RectangleLedGroup(keyboard, points[i], 0.1f) { Brush = new SolidColorBrush(Color.White) };
//// Define how many points we have // // targets[i] = new PointF(points[i].X, points[i].Y);
//const int NUM_POINTS = 6; // //}
//// The points we want to draw (rectangle since circles are too hard to calculate :p) // //// We set colors manually since white points are kinda boring (notice, that we use alpha values)
//RectangleF[] points = new RectangleF[NUM_POINTS]; // //pointGroups[0].Brush = new RadialGradientBrush(new LinearGradient(new GradientStop(0, Color.FromArgb(127, 255, 0, 0)), new GradientStop(0.5f, Color.FromArgb(127, 255, 0, 0)), new GradientStop(1, Color.FromArgb(0, 255, 0, 0))));
// //pointGroups[1].Brush = new RadialGradientBrush(new LinearGradient(new GradientStop(0, Color.FromArgb(127, 0, 255, 0)), new GradientStop(0.5f, Color.FromArgb(127, 0, 255, 0)), new GradientStop(1, Color.FromArgb(0, 0, 255, 0))));
//// KeyGroups which represents our point on the keyboard // //pointGroups[2].Brush = new RadialGradientBrush(new LinearGradient(new GradientStop(0, Color.FromArgb(127, 0, 0, 255)), new GradientStop(0.5f, Color.FromArgb(127, 0, 0, 255)), new GradientStop(1, Color.FromArgb(0, 0, 0, 255))));
//RectangleLedGroup[] pointGroups = new RectangleLedGroup[NUM_POINTS]; // //pointGroups[3].Brush = new RadialGradientBrush(new LinearGradient(new GradientStop(0, Color.FromArgb(127, 255, 0, 255)), new GradientStop(0.5f, Color.FromArgb(127, 255, 0, 255)), new GradientStop(1, Color.FromArgb(0, 255, 0, 255))));
// //pointGroups[4].Brush = new RadialGradientBrush(new LinearGradient(new GradientStop(0, Color.FromArgb(127, 255, 255, 0)), new GradientStop(0.5f, Color.FromArgb(127, 255, 255, 0)), new GradientStop(1, Color.FromArgb(0, 255, 255, 0))));
//// Target of our movement // //pointGroups[5].Brush = new RadialGradientBrush(new LinearGradient(new GradientStop(0, Color.FromArgb(127, 0, 255, 255)), new GradientStop(0.5f, Color.FromArgb(127, 0, 255, 255)), new GradientStop(1, Color.FromArgb(0, 0, 255, 255))));
//PointF[] targets = new PointF[NUM_POINTS];
// //while (true)
//// Initialize all the stuff // //{
//for (int i = 0; i < NUM_POINTS; i++) // // // Calculate all the points
//{ // // for (int i = 0; i < NUM_POINTS; i++)
// // Spawn our point in the top-left corner (right over G1 or on ESC depending on your keyboard) // // {
// points[i] = new RectangleF(keyboard.KeyboardRectangle.X, keyboard.KeyboardRectangle.Y, 60, 60); // // // Choose new target if we arrived
// pointGroups[i] = new RectangleLedGroup(keyboard, points[i], 0.1f) { Brush = new SolidColorBrush(Color.White) }; // // if (points[i].Contains(targets[i]))
// targets[i] = new PointF(points[i].X, points[i].Y); // // targets[i] = new PointF((float)(keyboard.KeyboardRectangle.X + (random.NextDouble() * keyboard.KeyboardRectangle.Width)),
//} // // (float)(keyboard.KeyboardRectangle.Y + (random.NextDouble() * keyboard.KeyboardRectangle.Height)));
// // else
//// We set colors manually since white points are kinda boring (notice, that we use alpha values) // // // Calculate movement
//pointGroups[0].Brush = new RadialGradientBrush(new LinearGradient(new GradientStop(0, Color.FromArgb(127, 255, 0, 0)), new GradientStop(0.5f, Color.FromArgb(127, 255, 0, 0)), new GradientStop(1, Color.FromArgb(0, 255, 0, 0)))); // // points[i].Location = Interpolate(points[i].Location, targets[i], SPEED); // It would be better to calculate from the center of our rectangle but the easy way is enough here
//pointGroups[1].Brush = new RadialGradientBrush(new LinearGradient(new GradientStop(0, Color.FromArgb(127, 0, 255, 0)), new GradientStop(0.5f, Color.FromArgb(127, 0, 255, 0)), new GradientStop(1, Color.FromArgb(0, 0, 255, 0))));
//pointGroups[2].Brush = new RadialGradientBrush(new LinearGradient(new GradientStop(0, Color.FromArgb(127, 0, 0, 255)), new GradientStop(0.5f, Color.FromArgb(127, 0, 0, 255)), new GradientStop(1, Color.FromArgb(0, 0, 0, 255)))); // // // Move our rectangle to the new position
//pointGroups[3].Brush = new RadialGradientBrush(new LinearGradient(new GradientStop(0, Color.FromArgb(127, 255, 0, 255)), new GradientStop(0.5f, Color.FromArgb(127, 255, 0, 255)), new GradientStop(1, Color.FromArgb(0, 255, 0, 255)))); // // pointGroups[i].Rectangle = points[i];
//pointGroups[4].Brush = new RadialGradientBrush(new LinearGradient(new GradientStop(0, Color.FromArgb(127, 255, 255, 0)), new GradientStop(0.5f, Color.FromArgb(127, 255, 255, 0)), new GradientStop(1, Color.FromArgb(0, 255, 255, 0)))); // // }
//pointGroups[5].Brush = new RadialGradientBrush(new LinearGradient(new GradientStop(0, Color.FromArgb(127, 0, 255, 255)), new GradientStop(0.5f, Color.FromArgb(127, 0, 255, 255)), new GradientStop(1, Color.FromArgb(0, 0, 255, 255))));
// // // Update changed leds
//while (true) // // keyboard.Update();
//{
// // Calculate all the points // // // 20 updates per sec should be enought for this
// for (int i = 0; i < NUM_POINTS; i++) // // Thread.Sleep(50);
// { // //}
// // Choose new target if we arrived //}
// if (points[i].Contains(targets[i])) //catch (CUEException ex)
// targets[i] = new PointF((float)(keyboard.KeyboardRectangle.X + (random.NextDouble() * keyboard.KeyboardRectangle.Width)), //{
// (float)(keyboard.KeyboardRectangle.Y + (random.NextDouble() * keyboard.KeyboardRectangle.Height))); // Console.WriteLine("CUE Exception! ErrorCode: " + Enum.GetName(typeof(CorsairError), ex.Error));
// else //}
// // Calculate movement //catch (WrapperException ex)
// points[i].Location = Interpolate(points[i].Location, targets[i], SPEED); // It would be better to calculate from the center of our rectangle but the easy way is enough here //{
// Console.WriteLine("Wrapper Exception! Message:" + ex.Message);
// // Move our rectangle to the new position //}
// pointGroups[i].Rectangle = points[i]; //catch (Exception ex)
// } //{
// Console.WriteLine("Exception! Message:" + ex.Message);
// // Update changed leds //}
// keyboard.Update();
//while (true)
// // 20 updates per sec should be enought for this // Thread.Sleep(1000); // Don't exit after exception
// Thread.Sleep(50);
//} CueSDK.Initialize();
}
catch (CUEException ex) CorsairMouse mouse = CueSDK.MouseSDK;
{
Console.WriteLine("CUE Exception! ErrorCode: " + Enum.GetName(typeof(CorsairError), ex.Error)); //mouse.Initialize();
}
catch (WrapperException ex) mouse[CorsairLedId.B1].Color = Color.Red;
{ mouse[CorsairLedId.B2].Color = Color.Green;
Console.WriteLine("Wrapper Exception! Message:" + ex.Message); mouse[CorsairLedId.B3].Color = Color.Blue;
}
catch (Exception ex) mouse.Update();
{
Console.WriteLine("Exception! Message:" + ex.Message); Console.ReadLine();
}
while (true)
Thread.Sleep(1000); // Don't exit after exception
} }
private static void AddTestBrush(ICueDevice device, IBrush brush) private static void AddTestBrush(ICueDevice device, IBrush brush)

View File

@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.0.1")] [assembly: AssemblyVersion("1.1.3.1")]
[assembly: AssemblyFileVersion("1.2.0.1")] [assembly: AssemblyFileVersion("1.1.3.1")]

View File

@ -53,7 +53,6 @@ namespace CUE.NET.Native
_dllHandle = LoadLibrary(dllPath); _dllHandle = LoadLibrary(dllPath);
_corsairSetLedsColorsPointer = (CorsairSetLedsColorsPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairSetLedsColors"), typeof(CorsairSetLedsColorsPointer)); _corsairSetLedsColorsPointer = (CorsairSetLedsColorsPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairSetLedsColors"), typeof(CorsairSetLedsColorsPointer));
_corsairGetLedsColorsPointer = (CorsairGetLedsColorsPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetLedsColors"), typeof(CorsairGetLedsColorsPointer));
_corsairGetDeviceCountPointer = (CorsairGetDeviceCountPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetDeviceCount"), typeof(CorsairGetDeviceCountPointer)); _corsairGetDeviceCountPointer = (CorsairGetDeviceCountPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetDeviceCount"), typeof(CorsairGetDeviceCountPointer));
_corsairGetDeviceInfoPointer = (CorsairGetDeviceInfoPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetDeviceInfo"), typeof(CorsairGetDeviceInfoPointer)); _corsairGetDeviceInfoPointer = (CorsairGetDeviceInfoPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetDeviceInfo"), typeof(CorsairGetDeviceInfoPointer));
_corsairGetLedPositionsPointer = (CorsairGetLedPositionsPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetLedPositions"), typeof(CorsairGetLedPositionsPointer)); _corsairGetLedPositionsPointer = (CorsairGetLedPositionsPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetLedPositions"), typeof(CorsairGetLedPositionsPointer));
@ -63,7 +62,6 @@ namespace CUE.NET.Native
_corsairReleaseControlPointer = (CorsairReleaseControlPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairReleaseControl"), typeof(CorsairReleaseControlPointer)); _corsairReleaseControlPointer = (CorsairReleaseControlPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairReleaseControl"), typeof(CorsairReleaseControlPointer));
_corsairPerformProtocolHandshakePointer = (CorsairPerformProtocolHandshakePointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairPerformProtocolHandshake"), typeof(CorsairPerformProtocolHandshakePointer)); _corsairPerformProtocolHandshakePointer = (CorsairPerformProtocolHandshakePointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairPerformProtocolHandshake"), typeof(CorsairPerformProtocolHandshakePointer));
_corsairGetLastErrorPointer = (CorsairGetLastErrorPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetLastError"), typeof(CorsairGetLastErrorPointer)); _corsairGetLastErrorPointer = (CorsairGetLastErrorPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetLastError"), typeof(CorsairGetLastErrorPointer));
_corsairRegisterKeypressCallbackPointer = (CorsairRegisterKeypressCallbackPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairRegisterKeypressCallback"), typeof(CorsairRegisterKeypressCallbackPointer));
} }
private static void UnloadCUESDK() private static void UnloadCUESDK()
@ -91,7 +89,6 @@ namespace CUE.NET.Native
#region Pointers #region Pointers
private static CorsairSetLedsColorsPointer _corsairSetLedsColorsPointer; private static CorsairSetLedsColorsPointer _corsairSetLedsColorsPointer;
private static CorsairGetLedsColorsPointer _corsairGetLedsColorsPointer;
private static CorsairGetDeviceCountPointer _corsairGetDeviceCountPointer; private static CorsairGetDeviceCountPointer _corsairGetDeviceCountPointer;
private static CorsairGetDeviceInfoPointer _corsairGetDeviceInfoPointer; private static CorsairGetDeviceInfoPointer _corsairGetDeviceInfoPointer;
private static CorsairGetLedPositionsPointer _corsairGetLedPositionsPointer; private static CorsairGetLedPositionsPointer _corsairGetLedPositionsPointer;
@ -101,7 +98,6 @@ namespace CUE.NET.Native
private static CorsairReleaseControlPointer _corsairReleaseControlPointer; private static CorsairReleaseControlPointer _corsairReleaseControlPointer;
private static CorsairPerformProtocolHandshakePointer _corsairPerformProtocolHandshakePointer; private static CorsairPerformProtocolHandshakePointer _corsairPerformProtocolHandshakePointer;
private static CorsairGetLastErrorPointer _corsairGetLastErrorPointer; private static CorsairGetLastErrorPointer _corsairGetLastErrorPointer;
private static CorsairRegisterKeypressCallbackPointer _corsairRegisterKeypressCallbackPointer;
#endregion #endregion
@ -110,9 +106,6 @@ namespace CUE.NET.Native
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate bool CorsairSetLedsColorsPointer(int size, IntPtr ledsColors); private delegate bool CorsairSetLedsColorsPointer(int size, IntPtr ledsColors);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate bool CorsairGetLedsColorsPointer(int size, IntPtr ledsColors);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate int CorsairGetDeviceCountPointer(); private delegate int CorsairGetDeviceCountPointer();
@ -140,9 +133,6 @@ namespace CUE.NET.Native
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate CorsairError CorsairGetLastErrorPointer(); private delegate CorsairError CorsairGetLastErrorPointer();
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate bool CorsairRegisterKeypressCallbackPointer(IntPtr callback, IntPtr context);
#endregion #endregion
// ReSharper disable EventExceptionNotDocumented // ReSharper disable EventExceptionNotDocumented
@ -155,14 +145,6 @@ namespace CUE.NET.Native
return _corsairSetLedsColorsPointer(size, ledsColors); return _corsairSetLedsColorsPointer(size, ledsColors);
} }
/// <summary>
/// CUE-SDK: get current color for the list of requested LEDs.
/// </summary>
internal static bool CorsairGetLedsColors(int size, IntPtr ledsColors)
{
return _corsairGetLedsColorsPointer(size, ledsColors);
}
/// <summary> /// <summary>
/// CUE-SDK: returns number of connected Corsair devices that support lighting control. /// CUE-SDK: returns number of connected Corsair devices that support lighting control.
/// </summary> /// </summary>
@ -236,11 +218,6 @@ namespace CUE.NET.Native
return _corsairGetLastErrorPointer(); return _corsairGetLastErrorPointer();
} }
internal static bool CorsairRegisterKeypressCallback(IntPtr callback, IntPtr context)
{
return _corsairRegisterKeypressCallbackPointer(callback, context);
}
// ReSharper restore EventExceptionNotDocumented // ReSharper restore EventExceptionNotDocumented
#endregion #endregion

View File

@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.0.1")] [assembly: AssemblyVersion("1.1.3.1")]
[assembly: AssemblyFileVersion("1.2.0.1")] [assembly: AssemblyFileVersion("1.1.3.1")]

View File

@ -1,6 +1,3 @@
**CUE.NET is considered done now and will be no longer actively developed.
It is superseded by [RGB.NET](https://github.com/DarthAffe/RGB.NET). Feel free to join the [discord-channel](https://discord.gg/9kytURv) if you're interested what's happening there :)**
# CUE.NET # CUE.NET
C# (.NET) Wrapper library around the Corsair CUE-SDK C# (.NET) Wrapper library around the Corsair CUE-SDK

Binary file not shown.

Binary file not shown.

4
packages.config Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="HidSharp" version="1.5" targetFramework="net45" />
</packages>