Skip to content
This repository has been archived by the owner on Aug 6, 2021. It is now read-only.

Initializing CUE.NET

DarthAffe edited this page Jan 7, 2017 · 5 revisions

CUE.NET needs to be initialized once (and only once!) before use.
This can be done anytime (preferable at the application start) by calling

CueSDK.Initialize();

After this you are free to work with the KeyboardSDK, MouseSDK, HeadsetSDK or MousematSDK provided by the static CueSDK class whenever you like.

Since there could always be a problem while initializing CUE.NET you should catch the WrapperException and CUEException and check if the SDK you want to use is initialized.

A full initialization block could look like this:

try
{
    CueSDK.Initialize();
    Debug.WriteLine("Initialized with " + CueSDK.LoadedArchitecture + "-SDK");

    CorsairKeyboard keyboard = CueSDK.KeyboardSDK;
    if (keyboard == null)
        throw new WrapperException("No keyboard found");
}
catch (CUEException ex)
{
    Debug.WriteLine("CUE Exception! ErrorCode: " + Enum.GetName(typeof(CorsairError), ex.Error));
}
catch (WrapperException ex)
{
    Debug.WriteLine("Wrapper Exception! Message:" + ex.Message);
}

Exclusive Access

You can take exclusive access over the SDK by passing true to the Initialize-method. This will make the lighting you make superior over all other programs using the SDK (including CUE itself).

Reinitializing

If you ever want to remove the lighting you added through the SDK and hand the control over the device back to CUE, you can this by calling

CueSDK.Reinitialize();

this offers the same overload taking a bool-parameter to capture exclusive access as Initialize.

Checking SDK availability.

If you want to know if the CUE-SDK available and at least one light-controllable device is connected you can achieve this by calling

bool hasSomethingContollable = CueSDK.IsSDKAvailable();

Alternative you can specify a device-type to check for:

bool hasControllableKeyboard = CueSDK.IsSDKAvailable(CorsairDeviceType.Keyboard);
Clone this wiki locally