mirror of
https://github.com/DarthAffe/CUE.NET.git
synced 2026-11-11 21:16:24 +00:00
Fixed an issue that prevents further reinitializing if an exception was thrown earlier
This commit is contained in:
1 parent
c786710b65
commit
220953bfe7
1 file changed
+10
-7
@@ -166,7 +166,7 @@ namespace CUE.NET
|
||||
|
||||
CorsairError error = LastError;
|
||||
if (error != CorsairError.Success)
|
||||
Throw(error);
|
||||
Throw(error, true);
|
||||
|
||||
if (ProtocolDetails.BreakingChanges)
|
||||
throw new WrapperException("The SDK currently used isn't compatible with the installed version of CUE.\r\n"
|
||||
@@ -176,7 +176,7 @@ namespace CUE.NET
|
||||
if (exclusiveAccess)
|
||||
{
|
||||
if (!_CUESDK.CorsairRequestControl(CorsairAccessMode.ExclusiveLightingControl))
|
||||
Throw(LastError);
|
||||
Throw(LastError, true);
|
||||
|
||||
HasExclusiveAccess = true;
|
||||
}
|
||||
@@ -216,7 +216,7 @@ namespace CUE.NET
|
||||
|
||||
error = LastError;
|
||||
if (error != CorsairError.Success)
|
||||
Throw(error);
|
||||
Throw(error, true);
|
||||
}
|
||||
|
||||
InitializedDevices = new ReadOnlyCollection<ICueDevice>(devices);
|
||||
@@ -252,7 +252,7 @@ namespace CUE.NET
|
||||
|
||||
CorsairError error = LastError;
|
||||
if (error != CorsairError.Success)
|
||||
Throw(error);
|
||||
Throw(error, false);
|
||||
|
||||
if (ProtocolDetails.BreakingChanges)
|
||||
throw new WrapperException("The SDK currently used isn't compatible with the installed version of CUE.\r\n"
|
||||
@@ -261,7 +261,7 @@ namespace CUE.NET
|
||||
|
||||
if (exclusiveAccess)
|
||||
if (!_CUESDK.CorsairRequestControl(CorsairAccessMode.ExclusiveLightingControl))
|
||||
Throw(LastError);
|
||||
Throw(LastError, false);
|
||||
HasExclusiveAccess = exclusiveAccess;
|
||||
|
||||
int deviceCount = _CUESDK.CorsairGetDeviceCount();
|
||||
@@ -276,7 +276,7 @@ namespace CUE.NET
|
||||
|
||||
error = LastError;
|
||||
if (error != CorsairError.Success)
|
||||
Throw(error);
|
||||
Throw(error, false);
|
||||
}
|
||||
|
||||
if (KeyboardSDK != null)
|
||||
@@ -299,7 +299,9 @@ namespace CUE.NET
|
||||
IsInitialized = true;
|
||||
}
|
||||
|
||||
private static void Throw(CorsairError error)
|
||||
private static void Throw(CorsairError error, bool reset)
|
||||
{
|
||||
if (reset)
|
||||
{
|
||||
ProtocolDetails = null;
|
||||
HasExclusiveAccess = false;
|
||||
@@ -308,6 +310,7 @@ namespace CUE.NET
|
||||
HeadsetSDK = null;
|
||||
MousematSDK = null;
|
||||
IsInitialized = false;
|
||||
}
|
||||
|
||||
throw new CUEException(error);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user