1
0
mirror of https://github.com/DarthAffe/CUE.NET.git synced 2025-12-12 16:58:29 +00:00

Compare commits

...

6 Commits

6 changed files with 45 additions and 8 deletions

View File

@ -3,7 +3,7 @@
<metadata>
<id>CUE.NET</id>
<title>CUE.NET</title>
<version>1.2.0.0</version>
<version>1.2.0.1</version>
<authors>Darth Affe</authors>
<owners>Darth Affe</owners>
<projectUrl>https://github.com/DarthAffe/CUE.NET</projectUrl>

View File

@ -104,7 +104,7 @@ namespace CUE.NET
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void OnKeyPressedDelegate(IntPtr context, CorsairKeyId keyId, [MarshalAs(UnmanagedType.I1)] bool pressed);
private static readonly OnKeyPressedDelegate _onKeyPressedDelegate = OnKeyPressed;
private static OnKeyPressedDelegate _onKeyPressedDelegate;
#endregion
@ -113,6 +113,8 @@ namespace CUE.NET
/// <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;
@ -247,7 +249,6 @@ namespace CUE.NET
Throw(error, true);
}
_CUESDK.CorsairRegisterKeypressCallback(Marshal.GetFunctionPointerForDelegate(_onKeyPressedDelegate), IntPtr.Zero);
error = LastError;
if (error != CorsairError.Success)
Throw(error, false);
@ -257,6 +258,24 @@ namespace CUE.NET
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>
@ -283,6 +302,9 @@ namespace CUE.NET
if (!IsInitialized)
throw new WrapperException("CueSDK isn't initialized.");
if (_onKeyPressedDelegate != null)
throw new WrapperException("Keypress-Callback is enabled.");
KeyboardSDK?.ResetLeds();
MouseSDK?.ResetLeds();
HeadsetSDK?.ResetLeds();
@ -343,7 +365,6 @@ namespace CUE.NET
|| HeadsetStandSDK.HeadsetStandDeviceInfo.Model != reloadedDevices[CorsairDeviceType.HeadsetStand].Model)
throw new WrapperException("The previously loaded Headset Stand got disconnected.");
_CUESDK.CorsairRegisterKeypressCallback(Marshal.GetFunctionPointerForDelegate(_onKeyPressedDelegate), IntPtr.Zero);
error = LastError;
if (error != CorsairError.Success)
Throw(error, false);

View File

@ -39,6 +39,8 @@ namespace SimpleDevTest
CueSDK.Initialize();
Console.WriteLine("Initialized with " + CueSDK.LoadedArchitecture + "-SDK");
CueSDK.EnableKeypressCallback();
CueSDK.KeyPressed += (sender, eventArgs) => Console.WriteLine($"Key {eventArgs.KeyId} {(eventArgs.IsPressed ? "pressed" : "released")}");
//CueSDK.KeyboardSDK.Brush = (SolidColorBrush)Color.Black;
@ -76,6 +78,17 @@ namespace SimpleDevTest
CueSDK.UpdateMode = UpdateMode.Continuous;
Wait(5);
CueSDK.UpdateMode = UpdateMode.Manual;
for (int i = 0; i < 100000; i++)
{
CueSDK.Reinitialize();
Console.WriteLine(i);
}
Console.WriteLine("done!");
Wait(5);
//IBrush rainbowBrush = new LinearGradientBrush(new RainbowGradient());
//rainbowBrush.AddEffect(new FlashEffect { Attack = 5f, Sustain = 1f, Decay = 0, Release = 5f, Interval = 1f });
//rainbowBrush.AddEffect(new MoveRainbowEffect());

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
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.0.0")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyVersion("1.2.0.1")]
[assembly: AssemblyFileVersion("1.2.0.1")]

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
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.0.0")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyVersion("1.2.0.1")]
[assembly: AssemblyFileVersion("1.2.0.1")]

View File

@ -1,3 +1,6 @@
**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
C# (.NET) Wrapper library around the Corsair CUE-SDK