1
0
mirror of https://github.com/DarthAffe/RGB.NET.git synced 2025-12-13 10:08:31 +00:00

(MINOR) Merge pull request #382 from DarthAffe/Fix/CorsairCallback

Fix/corsair callback
This commit is contained in:
DarthAffe 2024-04-10 15:02:36 +02:00 committed by Darth Affe
commit 51373e4441
2 changed files with 14 additions and 2 deletions

View File

@ -28,7 +28,7 @@ jobs:
uses: PaulHatch/semantic-version@v4.0.3 uses: PaulHatch/semantic-version@v4.0.3
with: with:
short_tags: false short_tags: false
format: "${major}.${minor}.${patch}-prerelease.${increment}" format: "${major}.${minor}.${patch}"
- name: Restore dependencies - name: Restore dependencies
run: dotnet restore run: dotnet restore
- name: Build - name: Build

View File

@ -47,6 +47,9 @@ internal static unsafe class _CUESDK
#region Properties & Fields #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 bool IsConnected => SesionState == CorsairSessionState.Connected;
internal static CorsairSessionState SesionState { get; private set; } internal static CorsairSessionState SesionState { get; private set; }
@ -58,6 +61,15 @@ internal static unsafe class _CUESDK
#endregion #endregion
#region Constructors
static _CUESDK()
{
SESSION_STATE_CHANGED_CALLBACK = CorsairSessionStateChangedCallback;
}
#endregion
#region Methods #region Methods
private static void CorsairSessionStateChangedCallback(nint context, _CorsairSessionStateChanged eventdata) private static void CorsairSessionStateChangedCallback(nint context, _CorsairSessionStateChanged eventdata)
@ -174,7 +186,7 @@ internal static unsafe class _CUESDK
{ {
if (_corsairConnectPtr == null) throw new RGBDeviceException("The Corsair-SDK is not initialized."); if (_corsairConnectPtr == null) throw new RGBDeviceException("The Corsair-SDK is not initialized.");
if (IsConnected) throw new RGBDeviceException("The Corsair-SDK is already connected."); 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) internal static CorsairError CorsairGetSessionDetails(out _CorsairSessionDetails? details)