DarthAffe / CUE.NET

C# (.NET) library to work with the Corsair CUE-SDK.
GNU Lesser General Public License v2.1
109 stars 18 forks source link

Help wanted: Applying color to all devices/all keys #30

Closed logicallysynced closed 8 years ago

logicallysynced commented 8 years ago

Hi there,

I'm trying to integrate this library into my application however I've been having quite a bit of trouble. I'm pretty sure I've got the initialization working correctly but the trouble is in sending a color to all keys of all devices/keyboards. I've been trying to use the code:

RectangleKeyGroup yellowGroup = new RectangleKeyGroup(corKeyboard, CorsairKeyboardKeyId.D1, CorsairKeyboardKeyId.D0) { Brush = new SolidColorBrush(System.Drawing.Color.Yellow) }; corKeyboard.Update(); yellowGroup.Detach();

taken from your example application source but nothing happens at all and i just get object exception errors all round.

The above code is just doing KeyID D1 through D0 but I've been trying to set the whole keyboard as well to a color without any success.

Any help would be much appreciated

DarthAffe commented 8 years ago

Hey,

which version of CUE.NET are you using? If it's not the latest nuget-package please try this. If you do this already could you please provide me the following information:

logicallysynced commented 8 years ago

I'm running CUE.NET 0.2 according to my reference properties. I'm running CUE 1.12.75 with latest firmware (I assume). Currently not testing on a live device, just trying to get code to compile without throwing errors.

The code I'm using can be found here: http://pastebin.com/mgDyfwGV

The error being output to the console (144 times) is: Object reference not set to an instance of an object.

DarthAffe commented 8 years ago

I'm honestly not sure what you're trying to do but from the code you posted I'd guess that you missed to initialize the SDK (https://github.com/DarthAffe/CUE.NET/wiki/Initializing-CUE.NET). Adding the initialization is the only change I needed to do to compile and run your code without errors.

(Btw: running this code without a attached keyboard won't work. Depending on what 'Currently not testing on a live device' referes to, this might be a problem too :p)

logicallysynced commented 8 years ago

I am initializing the CUE.NET library earlier in my code and decided to omit that from the pastebin to focus on the problematic code.

Unfortunately I don't have any Corsair devices to test on at the moment but if you're saying that the Object reference not set to an instance of an object. error is being caused by me forcing an output to a non-existent device, this would solve the problem.

When you ran the code I sent did it correctly output to a corsair device and change the color of all keys?

DarthAffe commented 8 years ago

Yes, seems like we tracked it down. This code http://pastebin.com/in9QuTb1 colors my whole keyboard (K95) cyan. If you haven't a device attached CueSDK.KeyboardSDK is null after the initialization. That's why you get the Object reference not set exception. I prefer to add something like CorsairKeyboard keyboard = CueSDK.KeyboardSDK; if (keyboard == null) throw new WrapperException("No keyboard found"); after the initialize call to prevent such problems.

Maybe something like a 'simulation mode' to develop without a keyboard would be useful ...