Socket
Socket
Sign inDemoInstall

elgato-stream-deck

Package Overview
Dependencies
72
Maintainers
3
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.1 to 3.0.0

dist/index.d.ts

45

CHANGELOG.md

@@ -1,5 +0,48 @@

# Change Log
# Changelog
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
## [3.0.0](https://github.com/lange/node-elgato-stream-deck/compare/v2.1.1...v3.0.0) (2019-06-03)
### Bug Fixes
* Don't depend on tslib ([3ebd04f](https://github.com/lange/node-elgato-stream-deck/commit/3ebd04f))
* Failing tests ([c36125d](https://github.com/lange/node-elgato-stream-deck/commit/c36125d))
* **xl:** Fill full button with image. Fix images being horizontally flipped ([4044809](https://github.com/lange/node-elgato-stream-deck/commit/4044809))
* Gracefully handle missing jpeg-turbo ([574068f](https://github.com/lange/node-elgato-stream-deck/commit/574068f))
* ignore tests in coverage report. format config files. Add tests for device info and listing functions ([2c1db92](https://github.com/lange/node-elgato-stream-deck/commit/2c1db92))
* JPEG encoding tests ([8efb092](https://github.com/lange/node-elgato-stream-deck/commit/8efb092))
* Mini image display ([99c0c94](https://github.com/lange/node-elgato-stream-deck/commit/99c0c94))
* Missing dependencies in travis ([9e0f5b5](https://github.com/lange/node-elgato-stream-deck/commit/9e0f5b5))
* Missing devDependency ([f94ff51](https://github.com/lange/node-elgato-stream-deck/commit/f94ff51))
* Move static device info methods to be separately importable. Reformat examples ([6dfde88](https://github.com/lange/node-elgato-stream-deck/commit/6dfde88))
* Refactor fillImage command generation, and some attempted fixes for the mini ([15ce1f2](https://github.com/lange/node-elgato-stream-deck/commit/15ce1f2))
* Refactor the packet generation code to be simpler ([d0ef9cf](https://github.com/lange/node-elgato-stream-deck/commit/d0ef9cf))
* Remove padding from images for the mini ([751fc62](https://github.com/lange/node-elgato-stream-deck/commit/751fc62))
* Switch to testing version of jpeg-turbo ([01e2e30](https://github.com/lange/node-elgato-stream-deck/commit/01e2e30))
* Test and fix some extra commands for the XL ([7399b28](https://github.com/lange/node-elgato-stream-deck/commit/7399b28))
* Travis not updating coveralls ([ea57f08](https://github.com/lange/node-elgato-stream-deck/commit/ea57f08))
* update dependencies, and linux version used ([8916aec](https://github.com/lange/node-elgato-stream-deck/commit/8916aec))
* Update node-hid to 0.7.9 ([da010e5](https://github.com/lange/node-elgato-stream-deck/commit/da010e5))
### Features
* Add example for device detection ([81ad930](https://github.com/lange/node-elgato-stream-deck/commit/81ad930))
* Add function to list available devices ([8c55598](https://github.com/lange/node-elgato-stream-deck/commit/8c55598))
* Add resetToLogo function, ideal for when disconnecting from the device to reset it back to default ([1b94570](https://github.com/lange/node-elgato-stream-deck/commit/1b94570))
* Convert to typescript ([a1492bd](https://github.com/lange/node-elgato-stream-deck/commit/a1492bd))
* Functions to get firmware and serial numbers [#45](https://github.com/lange/node-elgato-stream-deck/issues/45) ([ba130b9](https://github.com/lange/node-elgato-stream-deck/commit/ba130b9))
* Initial (untested) support for StreamDeck Mini ([c41e684](https://github.com/lange/node-elgato-stream-deck/commit/c41e684))
* Port tests to jest and typescript ([4ceaf90](https://github.com/lange/node-elgato-stream-deck/commit/4ceaf90))
* Refactor logic to have a common base class with each device extending it ([8632d93](https://github.com/lange/node-elgato-stream-deck/commit/8632d93))
* Reimplement fillPanel to work solely on buffers. Fix up all the examples ([f35c26c](https://github.com/lange/node-elgato-stream-deck/commit/f35c26c))
* Removed references to sharp (BREAKING CHANGE) ([d17b7c4](https://github.com/lange/node-elgato-stream-deck/commit/d17b7c4))
* Reorder the keys on the original to be left to right. The old behaviour can be restored if desired ([fdff5f1](https://github.com/lange/node-elgato-stream-deck/commit/fdff5f1))
* Use jpeg-turbo as an optional dependency for image encoding, as it is significantly faster than jpeg-js but has a lot more dependencies ([e7e509e](https://github.com/lange/node-elgato-stream-deck/commit/e7e509e))
* Working XL, with slightly dodgey but working image transfer ([eb294e8](https://github.com/lange/node-elgato-stream-deck/commit/eb294e8))
<a name="2.1.1"></a>

@@ -6,0 +49,0 @@ ## [2.1.1](https://github.com/Lange/node-elgato-stream-deck/compare/v2.1.0...v2.1.1) (2018-04-05)

MIT License
Copyright (c) 2017 Alex Van Camp
Copyright (c) 2018 Bitfocus AS

@@ -5,0 +6,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

134

package.json
{
"name": "elgato-stream-deck",
"version": "2.1.1",
"version": "3.0.0",
"description": "An npm module for interfacing with the Elgato Stream Deck",
"main": "index.js",
"typings": "typings.d.ts",
"dependencies": {
"node-hid": "^0.6.0",
"sharp": "^0.20.0"
},
"devDependencies": {
"ava": "^0.23.0",
"coveralls": "^3.0.0",
"eslint": "^4.11.0",
"eslint-config-xo": "^0.19.0",
"eslint-plugin-ava": "^4.2.2",
"mockery": "^2.1.0",
"nyc": "^11.3.0",
"pureimage": "0.1.3",
"sinon": "^4.1.2",
"standard-version": "^4.2.0",
"stream-buffers": "^3.0.1",
"weallbehave": "^1.2.0",
"weallcontribute": "^1.0.8"
},
"scripts": {
"prerelease": "npm t",
"release": "standard-version",
"postrelease": "npm publish && git push --follow-tags",
"pretest": "npm run static",
"test": "nyc ava",
"report": "nyc report --reporter=html",
"coverage": "nyc report --reporter=text-lcov | coveralls",
"static": "eslint .",
"update-coc": "weallbehave -o . && git add CODE_OF_CONDUCT.md && git commit -m 'docs(coc): updated CODE_OF_CONDUCT.md'",
"update-contrib": "weallcontribute -o . && git add CONTRIBUTING.md && git commit -m 'docs(contributing): updated CONTRIBUTING.md'"
},
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"license": "MIT",
"homepage": "https://github.com/lange/node-elgato-stream-deck#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/Lange/node-elgato-stream-deck.git"
"url": "git+https://github.com/lange/node-elgato-stream-deck.git"
},
"keywords": [
"elgato",
"stream",
"deck",
"streamdeck",
"hid",
"usb",
"hardware",
"interface",
"controller"
],
"bugs": {
"url": "https://github.com/lange/node-elgato-stream-deck/issues"
},
"author": {

@@ -61,2 +24,6 @@ "name": "Alex Van Camp",

{
"name": "Håkon Nessjøen",
"email": "haakon@bitfocus.io"
},
{
"name": "Richard Fox",

@@ -70,19 +37,76 @@ "twitter": "ProbablePrime"

"url": "http://www.chrishanel.com/"
},
{
"name": "Julian Waller",
"email": "git@julusian.co.uk"
}
],
"license": "MIT",
"bugs": {
"url": "https://github.com/Lange/node-elgato-stream-deck/issues"
"keywords": [
"elgato",
"stream",
"deck",
"streamdeck",
"hid",
"usb",
"hardware",
"interface",
"controller"
],
"scripts": {
"build": "trash dist && yarn build:main",
"build:main": "tsc -p tsconfig.build.json",
"release": "standard-version",
"test": "yarn lint && yarn build && yarn unit",
"watch": "jest --watch",
"cov": "jest --coverage; open-cli coverage/lcov-report/index.html",
"cov-open": "open-cli coverage/lcov-report/index.html",
"testci": "yarn lint && jest --coverage && cat ./coverage/lcov.info | coveralls",
"unit": "jest",
"update-coc": "weallbehave -o . && git add CODE_OF_CONDUCT.md && git commit -m 'docs(coc): updated CODE_OF_CONDUCT.md'",
"update-contrib": "weallcontribute -o . && git add CONTRIBUTING.md && git commit -m 'docs(contributing): updated CONTRIBUTING.md'",
"lint": "tslint --project tsconfig.json --config tslint.json && yarn prettier --check \"src/**/*.ts\"",
"lint-fix": "tslint --project tsconfig.json --config tslint.json --fix && yarn prettier --write \"src/**/*.ts\"",
"tslint-check": "tslint-config-prettier-check ./tslint.json",
"validate:dependencies": "yarn audit && yarn license-validate",
"license-validate": "node-license-validator -p -d --allow-licenses MIT BSD BSD-3-Clause ISC Apache Unlicense WTFPL"
},
"homepage": "https://github.com/Lange/node-elgato-stream-deck#readme",
"eslintConfig": {
"extends": "xo/esnext"
},
"files": [
"*.js",
"lib"
"dist"
],
"engines": {
"node": ">=7.6"
},
"dependencies": {
"jpeg-js": "^0.3.5",
"node-hid": "^0.7.9"
},
"devDependencies": {
"@julusian/jpeg-turbo": "^0.5.1",
"@types/jest": "^24.0.11",
"@types/jpeg-js": "^0.3.0",
"@types/node": "^12.0.4",
"@types/node-hid": "^0.7.0",
"@types/sharp": "^0.22.2",
"coveralls": "^3.0.3",
"jest": "^24.7.1",
"jest-haste-map": "^24.7.1",
"jest-resolve": "^24.7.1",
"node-license-validator": "^1.3.0",
"open-cli": "^5.0.0",
"prettier": "^1.17.1",
"pureimage": "^0.1.3",
"sharp": "^0.22.1",
"standard-version": "^6.0.1",
"stream-buffers": "^3.0.1",
"trash-cli": "^3.0.0",
"ts-jest": "^24.0.2",
"ts-loader": "^6.0.0",
"ts-node": "^8.1.0",
"tslint": "^5.16.0",
"tslint-config-prettier": "^1.18.0",
"typescript": "^3.4.2",
"usb-detection": "^4.3.0",
"weallbehave": "^1.2.0",
"weallcontribute": "^1.0.8"
}
}
# elgato-stream-deck [![npm version](https://img.shields.io/npm/v/elgato-stream-deck.svg)](https://npm.im/elgato-stream-deck) [![license](https://img.shields.io/npm/l/elgato-stream-deck.svg)](https://npm.im/elgato-stream-deck) [![Travis](https://travis-ci.org/Lange/node-elgato-stream-deck.svg?branch=master)](https://travis-ci.org/Lange/node-elgato-stream-deck) [![Coverage Status](https://coveralls.io/repos/github/Lange/node-elgato-stream-deck/badge.svg?branch=master)](https://coveralls.io/github/Lange/node-elgato-stream-deck?branch=master) [![Join the chat at https://gitter.im/node-elgato-stream-deck/Lobby](https://badges.gitter.im/node-elgato-stream-deck/Lobby.svg)](https://gitter.im/node-elgato-stream-deck/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
![alt text](media/streamdeck_ui.png "elgato-stream-deck")
![alt text](media/streamdeck_ui.png 'elgato-stream-deck')
[`elgato-stream-deck`](https://github.com/lange/elgato-stream-deck) is a Node.js library for interfacing
with the [Elgato Stream Deck](https://www.elgato.com/en/gaming/stream-deck).
with the various models of the [Elgato Stream Deck](https://www.elgato.com/en/gaming/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](https://www.elgato.com/en/gaming/downloads). Instead, `node-elgato-stream-deck` is a code library, which developers can use to make their own applications which interface with the 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](https://www.elgato.com/en/gaming/downloads). Instead, `node-elgato-stream-deck` is a code library which provides an API to the Stream Deck. Developers can use this API to make their own applications which interface with the Stream Deck.
>
> To further clarify: **this is not an installable program**. There is no user interface, and you cannot do anything with this library on its own. Out of the box, this library does nothing. It's purpose is to provide tools for programmers to **build** programs from the ground up which interact with a Stream Deck.
>
> This is a tool for developers to use. It is not a program for end users. It cannot and will not replace the official Stream Deck program. That is not its goal. However, it does enable someone to more easily write a program which _does_ do that.

@@ -14,2 +18,22 @@ ## Install

`$ npm install --save @julusian/jpeg-turbo@^0.5.1` (Optional)
It is recommended to install `@julusian/jpeg-turbo@^0.5.1` to greatly improve performance for writing images to the StreamDeck XL. Without doing so `jpeg-js` will be used instead, but image transfers will be noticably more cpu intensive and slower. `jpeg-turbo` has prebuilt binaries, but is not installed by default to ensure installation time is kept to a minimum for users who do not need the performance or the XL.
### Linux
On linux, the udev subsystem blocks access to the StreamDeck without some special configuration.
Save the following to `/etc/udev/rules.d/50-elgato.rules` and reload the rules with `sudo udevadm control --reload-rules`
```
SUBSYSTEM=="input", GROUP="input", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="0060", MODE:="666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="0063", MODE:="666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="006c", MODE:="666", GROUP="plugdev"
```
Unplug and replug the device and it should be usable
### Native dependencies
All of this library's native dependencies ship with prebuilt binaries, so having a full compiler toolchain should not be necessary to install `node-elgato-stream-deck`.

@@ -53,21 +77,34 @@

* [Example](#example)
* [Features](#features)
* [Planned Features](#planned-features)
* [Contributing](#contributing)
* [API](#api)
* [`write`](#write)
* [`fillColor`](#fill-color)
* [`fillImageFromFile`](#fill-image-from-file)
* [`fillImage`](#fill-image)
* [`fillPanel`](#fill-panel)
* [`clearKey`](#clear-key)
* [`clearAllKeys`](#clear-all-keys)
* [`setBrightness`](#set-brightness)
* [Events](#events)
* [`down`](#down)
* [`up`](#up)
* [`error`](#error)
* [Protocol Notes](#protocol-notes)
- [Features](#features)
- [Example](#example)
- [API](#api)
- [`openStreamDeck`](#open-streamdeck)
- [`listDevices`](#list-devices)
- [`getStreamDeckInfo`](#get-streamdeck-info)
- [`fillColor`](#fill-color)
- [`fillImage`](#fill-image)
- [`fillPanel`](#fill-panel)
- [`clearKey`](#clear-key)
- [`clearAllKeys`](#clear-all-keys)
- [`setBrightness`](#set-brightness)
- [`resetToLogo`](#reset-to-logo)
- [`getFirmwareVersion`](#get-firmware-version)
- [`getSerialNumber`](#get-serial-number)
- [Events](#events)
- [`down`](#down)
- [`up`](#up)
- [`error`](#error)
- [Contributing](#contributing)
- [Protocol Notes](#protocol-notes)
### Features
- Multiplatform support: Windows 7-10, MacOS, Linux, and even Raspberry Pi!
- Support for every StreamDeck model (Original, Mini & XL)
- 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
### Example

@@ -78,4 +115,4 @@

```javascript
const path = require('path');
const StreamDeck = require('elgato-stream-deck');
const path = require('path')
const { openStreamDeck } = require('elgato-stream-deck')

@@ -86,26 +123,23 @@ // Automatically discovers connected Stream Decks, and attaches to the first one.

// For example: const myStreamDeck = new StreamDeck('\\\\?\\hid#vid_05f3&pid_0405&mi_00#7&56cf813&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}')
// Device paths can be obtained via node-hid: https://github.com/node-hid/node-hid
const myStreamDeck = new StreamDeck();
// On linux the equivalent would be: const myStreamDeck = new StreamDeck('0001:0021:00')
// Available devices can be found with listStreamDecks()
const myStreamDeck = openStreamDeck()
myStreamDeck.on('down', keyIndex => {
console.log('key %d down', keyIndex);
});
console.log('key %d down', keyIndex)
})
myStreamDeck.on('up', keyIndex => {
console.log('key %d up', keyIndex);
});
console.log('key %d up', keyIndex)
})
// 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.
myStreamDeck.on('error', error => {
console.error(error);
});
console.error(error)
})
// Fill the second button from the left in the first row with an image of the GitHub logo.
// This is asynchronous and returns a promise.
myStreamDeck.fillImageFromFile(3, path.resolve(__dirname, 'github_logo.png')).then(() => {
console.log('Successfully wrote a GitHub logo to key 3.');
});
// Fill the first button form the left in the first row with a solid red color. This is synchronous.
myStreamDeck.fillColor(4, 255, 0, 0);
console.log('Successfully wrote a red square to key 4.');
myStreamDeck.fillColor(4, 255, 0, 0)
console.log('Successfully wrote a red square to key 4.')
```

@@ -116,73 +150,89 @@

```typescript
import StreamDeck = require('elgato-stream-deck');
const myStreamDeck = new StreamDeck(); // Will throw an error if no Stream Decks are connected.
import { openStreamDeck } = require('elgato-stream-deck')
const myStreamDeck = openStreamDeck() // Will throw an error if no Stream Decks are connected.
myStreamDeck.on('down', keyIndex => {
console.log('key %d down', keyIndex);
});
console.log('key %d down', keyIndex)
})
myStreamDeck.on('up', keyIndex => {
console.log('key %d up', keyIndex);
});
console.log('key %d up', keyIndex)
})
// 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.
myStreamDeck.on('error', error => {
console.error(error);
});
console.error(error)
})
```
### Features
### API
* 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
#### <a name="open-streamdeck"></a> `> openStreamDeck(path?: string, options?: OpenStreamDeckOptions) -> StreamDeckDeviceInfo | undefined`
### Planned Features
Opens a StreamDeck.
* [Hotplugging](https://github.com/Lange/node-elgato-stream-deck/issues/14)
* [Key combinations](https://github.com/Lange/node-elgato-stream-deck/issues/9)
* Support "pages" feature from the official Elgato Stream Deck software
* [Text labels](https://github.com/Lange/node-elgato-stream-deck/issues/6)
* [Changing the standby image](https://github.com/Lange/node-elgato-stream-deck/issues/11)
If a path is provided, then a specific device will be opened, otherwise the first found device will be used. See [listDevices](#list-devices) for info on how to discover devices.
### Contributing
Some device types have additional options, as part of the options object. This is not required to be provided.
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](CONTRIBUTING.md) 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.
Options:
All participants and maintainers in this project are expected to follow [Code of Conduct](CODE_OF_CONDUCT.md), and just generally be kind to each other.
- useOriginalKeyOrder: This restores the right-to-left key order for the Original StreamDeck. Since v3.0.0 the default key order has been changed to make sense and be consistent with the other models
Please refer to the [Changelog](CHANGELOG.md) for project history details, too.
```javascript
const streamDeck = openStreamDeck()
### API
// Or
#### <a name="write"></a> `> streamDeck.write(buffer) -> undefined`
const streamDeck = openStreamDeck('0001:0021:00')
Synchronously writes an arbitrary [`Buffer`](https://nodejs.org/api/buffer.html) instance to the Stream Deck.
Throws if an error is encountered during the write operation.
// Or
##### Example
const streamDeck = openStreamDeck('0001:0021:00', {
useOriginalKeyOrder: true
})
```
#### <a name="list-devices"></a> `> listDevices() -> Array<StreamDeckDeviceInfo>`
This will scan for and list all detected StreamDeck devices on the system along with their model. The path property can be passed into the constructor to open a specific device.
```javascript
// Writes 16 bytes of zero to the Stream Deck.
streamDeck.write(Buffer.alloc(16));
console.log('Devices: ', listDevices())
/**
* Devices: [
* {
* model: 'original',
* path: '0001:0023:00',
* serialNumber: 'AL37G1A02840'
* },
* {
* model: 'xl',
* path: '0001:0021:00',
* serialNumber: 'CL18I1A00913'
* }
* ]
*/
```
#### <a name="fill-color"></a> `> streamDeck.fillColor(keyIndex, r, g, b) -> undefined`
#### <a name="get-streamdeck-info"></a> `> getStreamDeckInfo(path: string) -> StreamDeckDeviceInfo | undefined`
Synchronously sets the given `keyIndex`'s screen to a solid RGB color.
Get the info for a given device. Returns `undefined` if the path is not a valid StreamDeck
##### Example
```javascript
// Turn key 4 (the top left key) solid red.
streamDeck.fillColor(4, 255, 0, 0);
console.log('Info: ', getStreamDeckInfo('0001:0021:00'))
/**
* Info: {
* model: 'xl',
* path: '0001:0021:00',
* serialNumber: 'CL18I1A00913'
* }
*/
```
#### <a name="fill-image-from-file"></a> `> streamDeck.fillImageFromFile(keyIndex, filePath) -> Promise`
#### <a name="fill-color"></a> `> streamDeck.fillColor(keyIndex, r, g, b) -> undefined`
Asynchronously reads an image from `filePath` and sets the given `keyIndex`'s screen to that image.
Automatically scales the image to 72x72 and strips out the alpha channel.
If necessary, the image will be center-cropped to fit into a square.
Synchronously sets the given `keyIndex`'s screen to a solid RGB color.
An error will be thrown if the keyIndex is not valid, of a colour component is outside of the range 0-255

@@ -192,10 +242,4 @@ ##### Example

```javascript
// Fill the second button from the left in the first row with an image of the GitHub logo.
streamDeck.fillImageFromFile(3, path.resolve(__dirname, 'github_logo.png'))
.then(() => {
console.log('Successfully wrote a GitHub logo to key 3.');
})
.catch(err => {
console.error(err);
});
// Turn key 4 (the top left key) solid red.
streamDeck.fillColor(4, 255, 0, 0)
```

@@ -205,5 +249,11 @@

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.
Synchronously writes a buffer of RGB image data to the given `keyIndex`'s screen.
The required size of the buffer varies by device, and must be the exact length. Any other length will result in an error being thrown.
The expected sizes are:
- Original: 15552 (72px)
- Mini: 19200 (80px)
- XL: 27648 (96px)
##### Example

@@ -213,3 +263,3 @@

// Fill the third button from the left in the first row with an image of the GitHub logo.
const sharp = require('sharp'); // See http://sharp.dimens.io/en/stable/ for full docs on this great library!
const sharp = require('sharp') // See http://sharp.dimens.io/en/stable/ for full docs on this great library!
sharp(path.resolve(__dirname, 'github_logo.png'))

@@ -221,26 +271,29 @@ .flatten() // Eliminate alpha channel, if any.

.then(buffer => {
return streamDeck.fillImage(2, buffer);
streamDeck.fillImage(2, buffer)
})
.catch(err => {
console.error(err);
});
console.error(err)
})
```
#### <a name="fill-panel"></a> `> streamDeck.fillPanel(imagePathOrBuffer[, sharpOptions]) -> Promise`
#### <a name="fill-panel"></a> `> streamDeck.fillPanel(buffer) -> undefined`
Asynchronously applies an image to the entire panel, spreading it over all keys. The image is scaled down and center-cropped to fit. This method does not currently account for the gaps between keys, and behaves as if each key was directly connected to its neighbors. If you wish to account for the gaps between keys, you'll need to do so via other means, and bake that into the image you provide to `fillPanel`.
Applies an image to the entire panel, spreading it over all keys. The image must be exactly the correct resolution for your device. Any other size will result in an error being thrown.
This method accepts either a path to an image on the disk, or a buffer. The image or path or buffer is passed directly to [`sharp`](https://github.com/lovell/sharp). Therefore, this method accepts all images and buffers which `sharp` can accept.
##### Example
```javascript
// Fill the second button from the left in the first row with an image of the GitHub logo.
streamDeck.fillPanel(path.resolve(__dirname, 'examples/fixtures/sunny_field.png'))
.then(() => {
console.log('Successfully filled the panel with an image.');
// Fill the entire panel with a photo of a sunny field.
const sharp = require('sharp') // See http://sharp.dimens.io/en/stable/ for full docs on this great library!
sharp(path.resolve(__dirname, 'github_logo.png'))
.flatten() // Eliminate alpha channel, if any.
.resize(streamDeck.ICON_SIZE * streamDeck.KEY_COLUMNS, streamDeck.ICON_SIZE * streamDeck.KEY_ROWS) // Scale up/down to the right size, cropping if necessary.
.raw() // Give us uncompressed RGB.
.toBuffer()
.then(buffer => {
streamDeck.fillPanel(buffer)
})
.catch(err => {
console.error(err);
});
console.error(err)
})
```

@@ -251,3 +304,11 @@

Synchronously clears the given `keyIndex`'s screen.
An error will be thrown if the keyIndex is not valid
##### Example
```javascript
// Clear the third button from the left in the first row.
streamDeck.clearKey(2)
```
#### <a name="clear-all-keys"></a> `> streamDeck.clearAllKeys() -> undefined`

@@ -260,4 +321,4 @@

```javascript
// Clear the third button from the left in the first row.
streamDeck.clearKey(2);
// Clear all keys.
streamDeck.clearAllKeys()
```

@@ -268,2 +329,3 @@

Synchronously set the brightness of the Stream Deck. This affects all keys at once. The brightness of individual keys cannot be controlled.
An error will be thrown if the brightness is not in the range 0-100

@@ -274,5 +336,36 @@ ##### Example

// Set the Stream Deck to maximum brightness
streamDeck.setBrightness(100);
streamDeck.setBrightness(100)
```
#### <a name="reset-to-logo"></a> `> streamDeck.resetToLogo() -> undefined`
Resets the device back to the startup Elgato logo.
##### Example
```javascript
// Set the Stream Deck back to the Elgato logo
streamDeck.resetToLogo()
```
#### <a name="get-firmware-version"></a> `> streamDeck.getFirmwareVersion() -> string`
Gets the firmware version number.
##### Example
```javascript
console.log(streamDeck.getFirmwareVersion())
```
#### <a name="get-serial-number"></a> `> streamDeck.getSerialNumber() -> string`
Gets the serial number of the device.
##### Example
```javascript
console.log(streamDeck.getSerialNumber())
```
### Events

@@ -282,3 +375,3 @@

Fired whenever a key is pressed. `keyIndex` is the 0-14 numerical index of that key.
Fired whenever a key is pressed. `keyIndex` is the index of that key.

@@ -289,4 +382,4 @@ ##### Example

streamDeck.on('down', keyIndex => {
console.log('key %d down', keyIndex);
});
console.log('key %d down', keyIndex)
})
```

@@ -296,3 +389,3 @@

Fired whenever a key is released. `keyIndex` is the 0-14 numerical index of that key.
Fired whenever a key is released. `keyIndex` is the index of that key.

@@ -303,4 +396,4 @@ ##### Example

streamDeck.on('up', keyIndex => {
console.log('key %d up', keyIndex);
});
console.log('key %d up', keyIndex)
})
```

@@ -317,8 +410,16 @@

streamDeck.on('error', error => {
console.error(error);
});
console.error(error)
})
```
### 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](CONTRIBUTING.md) 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](CODE_OF_CONDUCT.md), and just generally be kind to each other.
Please refer to the [Changelog](CHANGELOG.md) for project history details, too.
### Protocol Notes
Raw protocol notes can be found in [NOTES.md](NOTES.md). These detail the protocol and method for interacting with the Stream Deck which this module implements.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc