This wrapper can be used in node and electron apps. It uses prebuildify and is prebuilt for some runtime environments:
Node: 10.16.0, 11.8.0, 12.x, 13.x, 14.x
Electron: 6.0.0, 7.0.0, 8.0.0
- Node have to have N-API v4 (see N-API Version Matrix)
- iCUE for Windows https://www.corsair.com/icue
- Microsoft Visual C++ Redistributable for Visual Studio 2017.
- iCUE for macOS https://www.corsair.com/icue-mac
Note: you might need to install some tools to build from source on Windows before running
npm install
: https://github.com/nodejs/node-gyp#installation
npm install cue-sdk --save
const sdk = require('cue-sdk');
const details = sdk.CorsairPerformProtocolHandshake();
const errCode = sdk.CorsairGetLastError();
if (errCode === 0) {
// 'CE_Success'
}
const n = sdk.CorsairGetDeviceCount();
for (let i = 0; i < n; ++i) {
const info = sdk.CorsairGetDeviceInfo(i);
// example: read device properties
if (info.capsMask & sdk.CorsairDeviceCaps.CDC_PropertyLookup) {
console.log(info);
Object.keys(sdk.CorsairDevicePropertyId).forEach(p => {
const prop = sdk.CorsairGetDeviceProperty(i, sdk.CorsairDevicePropertyId[p]);
if (!prop) {
console.log(p, ':', sdk.CorsairErrorString[sdk.CorsairGetLastError()]);
} else {
console.log(p, prop.value);
}
});
}
if (info.capsMask & sdk.CorsairDeviceCaps.CDC_Lighting) {
const positions = sdk.CorsairGetLedPositionsByDeviceIndex(i);
const maxX = positions.reduce((acc, curr) => Math.max(curr.left, acc), 0);
// create red gradient
const colors = positions.map(p => ({ ledId: p.ledId, r: Math.floor(p.left / maxX * 255), g: 0, b: 0 }));
sdk.CorsairSetLedsColorsBufferByDeviceIndex(i, colors);
sdk.CorsairSetLedsColorsFlushBuffer();
}
}