Skip to content

Commit

Permalink
Update README.md, move api reference to a separate document
Browse files Browse the repository at this point in the history
  • Loading branch information
intrueder committed May 27, 2020
1 parent 3adbd52 commit 1fa390e
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 104 deletions.
113 changes: 9 additions & 104 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Node.js native wrapper around CUE SDK
=====================================
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:
Expand All @@ -8,8 +10,6 @@ It uses [prebuildify](https://github.com/prebuild/prebuildify) and is prebuilt f

**Electron**: 6.0.0, 7.0.0, 8.0.0

The API is almost the same as in [CUE SDK](https://github.com/CorsairOfficial/cue-sdk) itself.

## Prerequisites

- Microsoft Visual C++ Redistributable for Visual Studio 2017.
Expand All @@ -22,10 +22,10 @@ The API is almost the same as in [CUE SDK](https://github.com/CorsairOfficial/cu
> 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
npm install cue-sdk --save
```

## How to use
## Usage

### 1. Create sdk instance
```js
Expand Down Expand Up @@ -72,102 +72,7 @@ for (let i = 0; i < n; ++i) {
}
```

## API Reference

The `sdk` has the following methods (see CUESDK documentation for full description)

### `CorsairGetLastError()`

Returns `Number`: error code

`sdk.CorsairErrorString[sdk.CorsairGetLastError()]` converts error code to string

### `CorsairGetDeviceCount()`

Returns `Number`: number of connected devices

### `CorsairPerformProtocolHandshake()`

Returns `Object`: protocol handshake details

### `CorsairGetDeviceInfo(deviceIndex)`

* `deviceIndex` - zero based device index

Returns `Object | undefined`: device info

### `CorsairGetLedsColors(colors)`

* `colors` - array of led color objects (e.g., `{ ledId: 1, r: 0, g: 0, b: 0 }`) (see `CorsairLedIdEnum.h` from CUE SDK package to get values for `ledId`)

Returns `Boolean`: true for success

### `CorsairSetLedsColors(colors)`

* `colors` - array of led color objects (e.g., `{ ledId: 1, r: 0, g: 0, b: 0 }`) (see `CorsairLedIdEnum.h` from CUE SDK package to get values for `ledId`)

Returns `Boolean`: true for success

### `CorsairGetLedsColorsByDeviceIndex(deviceIndex, colors)`

* `deviceIndex` - zero based device index
* `colors` - array of led color objects (e.g., `{ ledId: 1, r: 0, g: 0, b: 0 }`) (see `CorsairLedIdEnum.h` from CUE SDK package to get values for `ledId`)

### `CorsairSetLedsColorsBufferByDeviceIndex(deviceIndex, colors)`

* `deviceIndex` - zero based device index
* `colors` - array of led color objects (e.g., `{ ledId: 1, r: 0, g: 0, b: 0 }`) (see `CorsairLedIdEnum.h` from CUE SDK package to get values for `ledId`)

Returns `Boolean`: true for success

### `CorsairSetLedsColorsFlushBuffer()`

Returns `Boolean`: true for success

### `CorsairSetLedsColorsFlushBufferAsync(callback)`

Returns `Boolean`: true for success

### `CorsairSetLedsColorsAsync(colors, callback)`

Returns `Boolean`: true for success

### `CorsairGetLedPositions()`

Returns `Object[]`: array of led positions for keyboard. Can be empty if keyboard is not connected

### `CorsairGetLedPositionsByDeviceIndex(deviceIndex)`

* `deviceIndex` - zero based device index

Returns `Object[]`: array of led positions for specified device. Can be empty if `deviceIndex` is invalid

### `CorsairGetLedIdForKeyName(keyName)`

* `keyName` - single character, name of the key on keyboard

Returns `Number`: led id

### `CorsairRequestControl()`

### `CorsairReleaseControl()`

### `CorsairSetLayerPriority(priority)`

### `CorsairGetDeviceProperty(deviceIndex, propertyId)`

* `deviceIndex` - zero based device index
* `propertyId` - id of property, `sdk.CorsairDevicePropertyId`'s member

### `CorsairSubscribeForEvents(onEvent)`
Sets up a function that will be called whenever the event has occurred. Supported events are: `macrokeydown`, `macrokeyup`, `deviceconnect` and `devicedisconnect`

* `onEvent(event)` - event listener specified as a callback function. The callback accepts a single parameter: an object describing the event which has occurred, and it returns nothing.

Returns `Boolean`: flag indicating whether subscription was successful or not

### `CorsairUnsubscribeFromEvents()`

Removes callback set by `CorsairSubscribeForEvents()` call
# Links

Returns `Boolean`: flag indicating whether unsubscription was successful or not
- API reference: https://github.com/intrueder/cue-sdk/blob/master/api-reference.md
- Code examples: https://github.com/intrueder/cue-sdk/tree/master/example
100 changes: 100 additions & 0 deletions api-reference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@

# API Reference

The `sdk` has the following methods (see [CUE SDK](https://github.com/CorsairOfficial/cue-sdk) documentation for full description)

### `CorsairGetLastError()`

Returns `Number`: error code

`sdk.CorsairErrorString[sdk.CorsairGetLastError()]` converts error code to string

### `CorsairGetDeviceCount()`

Returns `Number`: number of connected devices

### `CorsairPerformProtocolHandshake()`

Returns `Object`: protocol handshake details

### `CorsairGetDeviceInfo(deviceIndex)`

* `deviceIndex` - zero based device index

Returns `Object | undefined`: device info

### `CorsairGetLedsColors(colors)`

* `colors` - array of led color objects (e.g., `{ ledId: 1, r: 0, g: 0, b: 0 }`) (see `CorsairLedIdEnum.h` from CUE SDK package to get values for `ledId`)

Returns `Boolean`: true for success

### `CorsairSetLedsColors(colors)`

* `colors` - array of led color objects (e.g., `{ ledId: 1, r: 0, g: 0, b: 0 }`) (see `CorsairLedIdEnum.h` from CUE SDK package to get values for `ledId`)

Returns `Boolean`: true for success

### `CorsairGetLedsColorsByDeviceIndex(deviceIndex, colors)`

* `deviceIndex` - zero based device index
* `colors` - array of led color objects (e.g., `{ ledId: 1, r: 0, g: 0, b: 0 }`) (see `CorsairLedIdEnum.h` from CUE SDK package to get values for `ledId`)

### `CorsairSetLedsColorsBufferByDeviceIndex(deviceIndex, colors)`

* `deviceIndex` - zero based device index
* `colors` - array of led color objects (e.g., `{ ledId: 1, r: 0, g: 0, b: 0 }`) (see `CorsairLedIdEnum.h` from CUE SDK package to get values for `ledId`)

Returns `Boolean`: true for success

### `CorsairSetLedsColorsFlushBuffer()`

Returns `Boolean`: true for success

### `CorsairSetLedsColorsFlushBufferAsync(callback)`

Returns `Boolean`: true for success

### `CorsairSetLedsColorsAsync(colors, callback)`

Returns `Boolean`: true for success

### `CorsairGetLedPositions()`

Returns `Object[]`: array of led positions for keyboard. Can be empty if keyboard is not connected

### `CorsairGetLedPositionsByDeviceIndex(deviceIndex)`

* `deviceIndex` - zero based device index

Returns `Object[]`: array of led positions for specified device. Can be empty if `deviceIndex` is invalid

### `CorsairGetLedIdForKeyName(keyName)`

* `keyName` - single character, name of the key on keyboard

Returns `Number`: led id

### `CorsairRequestControl()`

### `CorsairReleaseControl()`

### `CorsairSetLayerPriority(priority)`

### `CorsairGetDeviceProperty(deviceIndex, propertyId)`

* `deviceIndex` - zero based device index
* `propertyId` - id of property, `sdk.CorsairDevicePropertyId`'s member

### `CorsairSubscribeForEvents(onEvent)`
Sets up a function that will be called whenever the event has occurred. Supported events are: `macrokeydown`, `macrokeyup`, `deviceconnect` and `devicedisconnect`

* `onEvent(event)` - event listener specified as a callback function. The callback accepts a single parameter: an object describing the event which has occurred, and it returns nothing.

Returns `Boolean`: flag indicating whether subscription was successful or not

### `CorsairUnsubscribeFromEvents()`

Removes callback set by `CorsairSubscribeForEvents()` call

Returns `Boolean`: flag indicating whether unsubscription was successful or not

0 comments on commit 1fa390e

Please sign in to comment.