elgato-stream-deck-clean

elgato-stream-deck-clean
is a Node.js library for interfacing
with the Elgato Stream Deck.
❗ Please note that node-elgato-stream-deck
is NOT a standalone application. It is not something you download and run on its own. It is not an alternative to the official Stream Deck program provided by Elgato. Instead, node-elgato-stream-deck
is a code library, which developers can use to make their own applications which interface with the Stream Deck.
Custom version
This is a modified version of elgato-stream-deck
that does not have dependencies to image libraries. That way the end-application can use its own libraries, so the dependencies stay at a minimum.
Install
$ npm install --save elgato-stream-deck-clean
Table of Contents
Example
JavaScript
const path = require('path');
const StreamDeck = require('elgato-stream-deck');
const myStreamDeck = new StreamDeck();
myStreamDeck.on('down', keyIndex => {
console.log('key %d down', keyIndex);
});
myStreamDeck.on('up', keyIndex => {
console.log('key %d up', keyIndex);
});
myStreamDeck.on('error', error => {
console.error(error);
});
myStreamDeck.fillColor(4, 255, 0, 0);
console.log('Successfully wrote a red square to key 4.');
TypeScript
import StreamDeck = require('elgato-stream-deck');
const myStreamDeck = new StreamDeck();
myStreamDeck.on('down', keyIndex => {
console.log('key %d down', keyIndex);
});
myStreamDeck.on('up', keyIndex => {
console.log('key %d up', keyIndex);
});
myStreamDeck.on('error', error => {
console.error(error);
});
Features
- Multiplatform support: Windows 7-10, MacOS, Linux, and even Raspberry Pi!
- Key
down
and key up
events
- Fill keys with images or solid RGB colors
- Fill the entire panel with a single image, spread across all keys
- Set the Stream Deck brightness
- TypeScript support
Contributing
The elgato-stream-deck team enthusiastically welcomes contributions and project participation! There's a bunch of things you can do if you want to contribute! The Contributor Guide has all the information you need for everything from reporting bugs to contributing entire new features. Please don't hesitate to jump in if you'd like to, or even ask us questions if something isn't clear.
All participants and maintainers in this project are expected to follow Code of Conduct, and just generally be kind to each other.
Please refer to the Changelog for project history details, too.
API
> streamDeck.write(buffer) -> undefined
Synchronously writes an arbitrary Buffer
instance to the Stream Deck.
Throws if an error is encountered during the write operation.
Example
streamDeck.write(Buffer.alloc(16));
> streamDeck.fillColor(keyIndex, r, g, b) -> undefined
Synchronously sets the given keyIndex
's screen to a solid RGB color.
Example
streamDeck.fillColor(4, 255, 0, 0);
> streamDeck.fillImage(keyIndex, buffer) -> undefined
Synchronously writes a buffer of 72x72 RGB image data to the given keyIndex
's screen.
The buffer must be exactly 15552 bytes in length. Any other length will result in an error being thrown.
Example
const sharp = require('sharp');
sharp(path.resolve(__dirname, 'github_logo.png'))
.flatten()
.resize(streamDeck.ICON_SIZE, streamDeck.ICON_SIZE)
.raw()
.toBuffer()
.then(buffer => {
return streamDeck.fillImage(2, buffer);
})
.catch(err => {
console.error(err);
});
> streamDeck.clearKey(keyIndex) -> undefined
Synchronously clears the given keyIndex
's screen.
Example
streamDeck.clearKey(2);
> streamDeck.clearAllKeys() -> undefined
Synchronously clears all keys on the device.
Example
streamDeck.clearAllKeys();
> streamDeck.setBrightness(percentage) -> undefined
Synchronously set the brightness of the Stream Deck. This affects all keys at once. The brightness of individual keys cannot be controlled.
Example
streamDeck.setBrightness(100);
Events
> down
Fired whenever a key is pressed. keyIndex
is the 0-14 numerical index of that key.
Example
streamDeck.on('down', keyIndex => {
console.log('key %d down', keyIndex);
});
> up
Fired whenever a key is released. keyIndex
is the 0-14 numerical index of that key.
Example
streamDeck.on('up', keyIndex => {
console.log('key %d up', keyIndex);
});
> error
Fired whenever an error is detected by the node-hid
library.
Always add a listener for this event! If you don't, errors will be silently dropped.
Example
streamDeck.on('error', error => {
console.error(error);
});
Protocol Notes
Raw protocol notes can be found in NOTES.md. These detail the protocol and method for interacting with the Stream Deck which this module implements.