Skip to content

Commit

Permalink
(MINOR) Merge pull request #382 from DarthAffe/Fix/CorsairCallback
Browse files Browse the repository at this point in the history
Fix/corsair callback
  • Loading branch information
DarthAffe committed Apr 10, 2024
2 parents 29e68ae + 8f7e24b commit 51373e4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
uses: PaulHatch/[email protected]
with:
short_tags: false
format: "${major}.${minor}.${patch}-prerelease.${increment}"
format: "${major}.${minor}.${patch}"
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand Down
14 changes: 13 additions & 1 deletion RGB.NET.Devices.Corsair/Native/_CUESDK.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ internal static unsafe class _CUESDK

#region Properties & Fields

// ReSharper disable once NotAccessedField.Local - This is important, the delegate can be collected if it's not stored!
private static readonly CorsairSessionStateChangedHandler SESSION_STATE_CHANGED_CALLBACK;

internal static bool IsConnected => SesionState == CorsairSessionState.Connected;
internal static CorsairSessionState SesionState { get; private set; }

Expand All @@ -58,6 +61,15 @@ internal static unsafe class _CUESDK

#endregion

#region Constructors

static _CUESDK()
{
SESSION_STATE_CHANGED_CALLBACK = CorsairSessionStateChangedCallback;
}

#endregion

#region Methods

private static void CorsairSessionStateChangedCallback(nint context, _CorsairSessionStateChanged eventdata)
Expand Down Expand Up @@ -174,7 +186,7 @@ internal static CorsairError CorsairConnect()
{
if (_corsairConnectPtr == null) throw new RGBDeviceException("The Corsair-SDK is not initialized.");
if (IsConnected) throw new RGBDeviceException("The Corsair-SDK is already connected.");
return _corsairConnectPtr(CorsairSessionStateChangedCallback, 0);
return _corsairConnectPtr(SESSION_STATE_CHANGED_CALLBACK, 0);
}

internal static CorsairError CorsairGetSessionDetails(out _CorsairSessionDetails? details)
Expand Down

0 comments on commit 51373e4

Please sign in to comment.