# cue-cove

> A Node.js native wrapper around CUE SDK

Latest version **1.5.1** (published 2020-10-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install cue-cove
pnpm add cue-cove
yarn add cue-cove
bun add cue-cove
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.5.1 |
| Published | 2020-10-17 |
| First published | 2020-10-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 13.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| Author | Corsair Memory, Inc. |
| Maintainers | ahadcove |

## Links

- npm: https://www.npmjs.com/package/cue-cove
- Repository: https://github.com/CorsairOfficial/cue-sdk-node
- Homepage: https://github.com/CorsairOfficial/cue-sdk-node#readme
- Issues: https://github.com/CorsairOfficial/cue-sdk-node/issues
- npm.io page: https://npm.io/package/cue-cove

## Dependencies (2)

- [node-addon-api](https://npm.io/package/node-addon-api.md) 3.0.2
- [node-gyp-build](https://npm.io/package/node-gyp-build.md) 4.2.3

## Recent versions

- 1.5.1 (latest) — 2020-10-17
- 1.5.2-beta1 (beta) — 2020-10-17

## README

cue-sdk-node
============

## Intro

This wrapper can be used in node and electron apps.
It uses [prebuildify](https://github.com/prebuild/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

- Microsoft Visual C++ Redistributable for Visual Studio 2017.
  - x86 https://aka.ms/vs/15/release/VC_redist.x86.exe
  - x64 https://aka.ms/vs/15/release/VC_redist.x64.exe 
- Node have to have N-API v4 (see [N-API Version Matrix](https://nodejs.org/api/n-api.html#n_api_n_api_version_matrix))

## Installation

> Note: you might need to install some tools to build from source before running `npm install` : https://github.com/nodejs/node-gyp#installation

```
npm install cue-sdk --save
```

## Usage

### 1. Create sdk instance
```js
const sdk = require('cue-sdk');
```

### 2. Perform handshake
```js
const details = sdk.CorsairPerformProtocolHandshake();
const errCode = sdk.CorsairGetLastError();
if (errCode === 0) {
  // 'CE_Success'
}
```

### 3. Control your devices
```js
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

- API reference: https://github.com/CorsairOfficial/cue-sdk-node/blob/master/api-reference.md
- Code examples: https://github.com/CorsairOfficial/cue-sdk-node/tree/master/example

---
_Source: https://npm.io/package/cue-cove · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
