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

Perform basic lighting

DarthAffe edited this page Feb 4, 2018 · 12 revisions

The most basic form of using CUE.NET is by individually setting the color of every LED and manually triggering an update.

Even if this seems easy to use it's not recommended. You should take a look at groups and brushes instead!
Especially on keyboards you might run into a lot of trouble mixing direct lighting and brushes! Just take the time and check out how it works.

You can do everything with brushes that's possible with direct lightning and in most cases it will safe you a whole lot of work.
It's not that difficult or take that much extra work as you might think now!

Direct lighting of a key can be achieved by getting the LED you want to color through one of the indexers from the SDK. (The one connected to the device you want to control.)

This code would set the color of the A-key on your keyboard to red and the color of the B-key to green. After that it would set the B1-LED (location depends on the device) to blue.
All other keys would keep the color they had before:

CorsairKeyboard keyboard = CueSDK.KeyboardSDK;
keyboard.Brush = (SolidColorBrush)Color.Transparent; // This 'enables' manual color changes.

keyboard['A'].Color = Color.Red;
keyboard[CorsairKeyboardKeyId.B].Color = Color.Green;
keyboard.Update();

CorsairMouse mouse = CueSDK.MouseSDK;
mouse[CorsairMouseLedId.B1].Color = Color.Blue;
mouse.Update();

Manual/automatic update

By default you need to call device.Update() every time you want your changes be written to the device. Since this is quite unhandy in some situations you can activate automatic updates:

CueSDK.UpdateMode = UpdateMode.Continuous;

This would instruct the keyboard to apply changes 30 times a second (every 33.3 millisecond) [default value].

Of course you can change the update rate to better fit your needs. The value is set in seconds. You can calculate it quite easy by dividing 1 by the amount of updates per second you need (make sure it's calculated as a floating point number!). The following example would set the update-rate to 60 times a second:

CueSDK.UpdateFrequency = 1f/60f;

Be aware of the performance impact of high update-rates!
Since the update rate is limited by CUE and the hardware, you'll most likely not see any improvements by using more then 40 updates per second.

CorsairColor

Inside of CUE.NET colors are represented as a own class called CorsairColor.

This allows colors to be reference and processed in an advanced way. To keep things simple when working with CUE.NET any CorsairColor is implicit convertible to and from System.Drawing.Color.

CorsairColors are unlike System.Draw.Colors reference-types. Keep that in mind when modifying a color that might be used multiple times!
You can copy any color by simply creating a new one and pass the old as a parameter to the constructor.

Clone this wiki locally