Skip to content

Commit

Permalink
chore: update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
nytamin committed Jan 6, 2021
1 parent 011ccf6 commit 8f06cc4
Showing 1 changed file with 41 additions and 39 deletions.
80 changes: 41 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@

[![CircleCI](https://circleci.com/gh/SuperFlyTV/xkeys.svg?style=svg)](https://circleci.com/gh/SuperFlyTV/xkeys)

A NodeJS module to interact with the X-keys panels.
A NodeJS module to interact with the [X-keys panels](https://xkeys.com/xkeys.html).

Licence: MIT

The project is based on the documentation available here: http://xkeys.com/PISupport/DeveloperHIDDataReports.php

## Installation

`$ npm install --save xkeys`
```
$ npm install --save xkeys
or
`$ yarn add xkeys`
$ yarn add xkeys
```



Expand All @@ -21,7 +23,6 @@ or
### JavaScript

```javascript

const { XKeys } = require('xkeys')

// Connect to an x-keys panel:
Expand Down Expand Up @@ -54,102 +55,103 @@ myXkeysPanel.on('shuttle', shuttlePos => {
myXkeysPanel.on('joystick', position => {
console.log('Joystick has changed:' + position) // {x, y, z}
})


// Listen to t-bar changes:
myXkeysPanel.on('tbar', (position, rawPosition) => {
console.log('T-bar position has changed: ' + position + ' (uncalibrated: ' + rawPosition + ')')
})
```

## Documentation

### Initalize
#### Connect to any connected X-keys panel
```javascript
const XKeys = require('xkeys');
const XKeys = require('xkeys')

var myXkeysPanel = new XKeys();
var myXkeysPanel = new XKeys()
```
#### Connect to a specific X-keys panel
```javascript
const HID = require('node-hid');
const XKeys = require('xkeys');
const HID = require('node-hid')
const XKeys = require('xkeys')

const devices = HID.devices();
const devices = HID.devices()
const connectedXKeys = devices.filter(device => {
return (device.vendorId === XKeys.vendorId && device.interface === 0); // Make sure that the interface-property is set to 0
});
return (device.vendorId === XKeys.vendorId && device.interface === 0) // Make sure that the interface-property is set to 0
})

if (connectedXKeys.length) {
var myXkeysPanel = new XKeys(connectedXKeys[0].path);
var myXkeysPanel = new XKeys(connectedXKeys[0].path)
} else {
console.log("Could not find any connected X-keys panels.");
console.log("Could not find any connected X-keys panels.")
}

```

### Events

* 'downKey' & 'upKey': Triggered when a regular button is pressed/released. Emitted with (keyIndex).
* 'downAlt' & 'upAlt': Triggered when an alternative button is pressed/released, such as the "program switch" (keyIndex 'PS'). Emitted with (keyIndex).
* 'down' & 'up': Triggered when ANY button is pressed/released. Emitted with (keyIndex).

* 'jog': Triggered when the jog wheel is moved. Emitted with (jogValue)
* 'shuttle': Triggered when the shuttle is moved. Emitted with (shuttleValue)
* 'joystick': Triggered when the joystick is moved. Emitted with ({x, y, z})
* 'tbar': Triggered when the T-bar is moved. Emitted with (tbarPosition, rawPosition)

* 'error': Triggered on error. Emitted with (error).
| Event | Description |
|---|---|
| `"down"`, `"up"` | Triggered when ANY button is pressed/released. Emitted with `(keyIndex)`. |
| `"downKey"`, `"upKey"` | Triggered when a regular button is pressed/released. Emitted with `(keyIndex)`. |
| `"downAlt"`, `"upAlt"` | Triggered when an alternative button is pressed/released, such as the "program switch" (keyIndex "PS"). Emitted with `(keyIndex)`. |
| `"jog"` | Triggered when the jog wheel is moved. Emitted with `(jogValue)` |
| `"shuttle"` | Triggered when the shuttle is moved. Emitted with `(shuttleValue)` |
| `"joystick"` | Triggered when the joystick is moved. Emitted with `({x, y, z})` |
| `"tbar"` | Triggered when the T-bar is moved. Emitted with `(tbarPosition, rawPosition)` |
| `"error"` | Triggered on error. Emitted with `(error)`. |


### Setting things
#### Set backlight of a button
```javascript
.setBacklight(keyIndex, on, redLight, flashing);
myXkeysPanel.setBacklight(keyIndex, on, redLight, flashing);

// Examples:
// Light up the backlight of bank 1 (blue light)
.setBacklight(keyIndex, true);
myXkeysPanel.setBacklight(keyIndex, true);
// Flash the backlight of bank 2 (red light)
.setBacklight(keyIndex, true, true, true);
myXkeysPanel.setBacklight(keyIndex, true, true, true);
```

#### Set the LEDs (the red/green status LED's)
```javascript
.setLED(keyIndex, on, flashing)
myXkeysPanel.setLED(keyIndex, on, flashing)

// Examples:
// Light up the green LED
.setBacklight(0, true);
myXkeysPanel.setBacklight(0, true);
// Light up the red LED
.setBacklight(1, true);
myXkeysPanel.setBacklight(1, true);
```

#### Set backlight intensity
```javascript
.setBacklightIntensity(intensity)
myXkeysPanel.setBacklightIntensity(intensity)

// Example:
// Set max intensity
.setBacklightIntensity(255)
myXkeysPanel.setBacklightIntensity(255)
```

#### Set all backlights on or off
```javascript
.setAllBacklights(on, redLight)
myXkeysPanel.setAllBacklights(on, redLight)

// Example:
// Light up all buttons
.setAllBacklights(true, false)
.setAllBacklights(true, true)
myXkeysPanel.setAllBacklights(true, false)
myXkeysPanel.setAllBacklights(true, true)
```

#### Set flashing frequency
```javascript
// The frequency can be set to 1-255, where 1 is fastest and 255 is the slowest.
// 255 is approximately 4 seconds between flashes.
.setFrequency(frequency)
myXkeysPanel.setFrequency(frequency)

// Example:
// Set the frequency to a pretty fast flash
.setFrequency(8)
myXkeysPanel.setFrequency(8)
```


Expand Down

0 comments on commit 8f06cc4

Please sign in to comment.