cue-sdk-cove

1.5.2 • Public • Published

cue-sdk-node

Intro

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

Prerequisites

Windows:

macOS:

Installation

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

Usage

1. Create sdk instance

const sdk = require('cue-sdk');

2. Perform handshake

const details = sdk.CorsairPerformProtocolHandshake();
const errCode = sdk.CorsairGetLastError();
if (errCode === 0) {
  // 'CE_Success'
}

3. Control your devices

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();
  }
}

Links

Readme

Keywords

none

Package Sidebar

Install

npm i cue-sdk-cove

Weekly Downloads

9

Version

1.5.2

License

MIT

Unpacked Size

2.43 MB

Total Files

22

Last publish

Collaborators

  • ahadcove