All Projects → danieltian → Stream Deck Api

danieltian / Stream Deck Api

API to interact with the Elgato Stream Deck controller

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Stream Deck Api

Node Elgato Stream Deck
A Node.js library for interfacing with the Elgato Stream Deck.
Stars: ✭ 359 (+897.22%)
Mutual labels:  deck, stream, usb, hid
usb stack
Tiny and portable USB device/host stack for embedded system with USB IP
Stars: ✭ 175 (+386.11%)
Mutual labels:  usb, hid
android-usb-script
An Android app that allows you to script USB gadgets (work-in-progress).
Stars: ✭ 15 (-58.33%)
Mutual labels:  usb, hid
Device.net
A C# cross platform connected device framework
Stars: ✭ 347 (+863.89%)
Mutual labels:  usb, hid
pi400kb
Raw HID keyboard forwarder to turn the Pi 400 into a USB keyboard
Stars: ✭ 182 (+405.56%)
Mutual labels:  usb, hid
ESP32-USB-Soft-Host
An Arduino wrapper to @sdima1357's usb_soft_host esp-idf example
Stars: ✭ 119 (+230.56%)
Mutual labels:  usb, hid
Teenyusb
Lightweight USB device and host stack for STM32 and other MCUs.
Stars: ✭ 287 (+697.22%)
Mutual labels:  usb, hid
Twitch Js
A community-centric, community-supported version of tmi.js
Stars: ✭ 225 (+525%)
Mutual labels:  api, stream
Headsetcontrol
Sidetone and Battery status for Logitech G930, G533, G633, G933 SteelSeries Arctis 7/PRO 2019 and Corsair VOID (Pro) in Linux and MacOSX
Stars: ✭ 392 (+988.89%)
Mutual labels:  usb, hid
Hidapi
A Simple library for communicating with USB and Bluetooth HID devices on Linux, Mac and Windows.
Stars: ✭ 465 (+1191.67%)
Mutual labels:  usb, hid
Zerocode
A community-developed, free, open source, microservices API automation and load testing framework built using JUnit core runners for Http REST, SOAP, Security, Database, Kafka and much more. Zerocode Open Source enables you to create, change, orchestrate and maintain your automated test cases declaratively with absolute ease.
Stars: ✭ 482 (+1238.89%)
Mutual labels:  api, stream
ES-Timer
A USB timer powered by Digispark ATtiny85 according to 🍅 pomodoro time management technique
Stars: ✭ 45 (+25%)
Mutual labels:  usb, hid
python-hid-parser
Typed pure Python library to parse HID report descriptors
Stars: ✭ 31 (-13.89%)
Mutual labels:  usb, hid
RaspberryPi-Joystick
A virtual HID USB joystick created using Raspberry Pi
Stars: ✭ 73 (+102.78%)
Mutual labels:  usb, hid
EspTinyUSB
ESP32S2 native USB library. Implemented few common classes, like MIDI, CDC, HID or DFU (update).
Stars: ✭ 375 (+941.67%)
Mutual labels:  usb, hid
StreamDeckMonitor
Customizable C# app to display Real-Time System Statistics on the Elgato 'Stream Deck' Device
Stars: ✭ 36 (+0%)
Mutual labels:  deck, stream
Node Instagram
Instagram api client for node that support promises.
Stars: ✭ 185 (+413.89%)
Mutual labels:  api, stream
Streamdecksharp
A simple .NET wrapper for Stream Deck
Stars: ✭ 203 (+463.89%)
Mutual labels:  api, hid
Vigembus
Windows kernel-mode driver emulating well-known USB game controllers.
Stars: ✭ 721 (+1902.78%)
Mutual labels:  usb, hid
Hidviz
A tool for in-depth analysis of USB HID devices communication
Stars: ✭ 505 (+1302.78%)
Mutual labels:  usb, hid

Stream Deck API

Stream Deck API is a library that allows you to interact with an Elgato Stream Deck controller.

NOTE: API is not stable and will not follow semver until version >=1.0.0. If you need a specific version, hard-lock it to an exact version for now (in package.json):

"dependencies": {
  "stream-deck-api": "0.0.4"
}

Examples

Detect Button Press

const streamDeckDeckApi = require('stream-deck-api');
var streamDeck = streamDeckApi.getStreamDeck();

// -----------------------------------
// Individual button presses by number
// -----------------------------------
streamDeck.on('down:1', () => { console.log('button 1 pressed'); });
streamDeck.on('up:1', () => { console.log('button 1 released'); });

// -------------------------------------------------------------
// Individual button presses, button number as callback argument
// -------------------------------------------------------------
streamDeck.on('down', (buttonNumber) => {
  if (buttonNumber == 1) { console.log('button 1 pressed'); }
  else if (buttonNumber == 2) { console.log('button 2 pressed'); }
});

streamDeck.on('up', (buttonNumber) => {
  if (buttonNumber == 1) { console.log('button 1 released'); }
  else if (buttonNumber == 2) { console.log('button 2 released'); }
});

// -----------------------------------------------------
// Button state changed, callback with all button states
// -----------------------------------------------------
streamDeck.on('state', (buttonState) => {
  // buttonState is the object { 1: 1, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, 10: 0, ... }
  // where the key is the button number and the value is whether the button is pressed or released
  if (buttonState.8 == 1) { console.log('button 8 pressed'); }
  else if (!buttonState.8 == 0) { console.log('button 8 released'); }
});

// ----------------------------------------
// Synchronous function to get button state
// ----------------------------------------
var buttonState = streamDeck.getButtonState();
if (buttonState.8 == 1) { console.log('button 8 pressed') };
if (buttonState.8 == 0) { console.log('button 8 released') };

Draw Image or Color to Button

const streamDeckDeckApi = require('stream-deck-api');
var streamDeck = streamDeckApi.getStreamDeck();
var buttonNumber = 2;

// -------------------------
// Draw image from file path
// -------------------------
streamDeck.drawImageFile('path/to/file/image.png', buttonNumber);

// --------------------------
// Draw image from raw buffer
// --------------------------
var buffer = someImageLibraryopen('path/to/file/image.png').getRawBuffer();
var isRGBA = true; // buffer is in RGBA format where each pixel uses 4 bytes in the buffer
streamDeck.drawImageBuffer(buffer, buttonNumber, isRGBA);

// ----------------------------------------------
// Draw pure color, colors provided as hex values
// ----------------------------------------------
streamDeck.drawColor(0x000000, buttonNumber); // black
streamDeck.drawColor(0xFF0000, buttonNumber); // red
streamDeck.drawColor(0x00FF00, buttonNumber); // green
streamDeck.drawColor(0x0000FF, buttonNumber); // blue
streamDeck.drawColor(0xFFFFFF, buttonNumber); // white

API

TODO: Write API docs

Caching

TODO: Clean this up

Quick and dirty explanation: Because it takes a non-trivial amount of time to process an image (reading it from disk and resizing it) and to create the data that gets sent to the Stream Deck, caching has been implemented in order to speed up this process.

You won't see the caching/non-caching effects if you draw to only one button; it's too quick to notice. However, if you draw to all 15 buttons at once, you'll notice that without caching (for example, the first time you draw to all the buttons), there will be a ripple effect as the buttons draw one after another. With caching enabled (currently forced and no way to disable), they will be drawn instantly.

Caching is currently enabled in two places:

  1. By image path. If you call streamDeck.drawImageFile(), the image will be opened, resized, and the raw buffer data cached. Subsequent calls to streamDeck.drawImageFile() with the same path will load the cached data instead. This means that if you alter the image without restarting the app, it won't have any effect because the cached data is used, not the disk copy. The ability to disable this cache selectively or globally will be added in the future.

  2. By image buffer contents. Before the image is sent to the Stream Deck, it must be split into two byte arrays. The byte arrays are cached once constructed, with the cache key being the image buffer hash. This means that the same image buffer will create the same byte arrays, and so the byte arrays are cached. The ability to disable this cache selectively or globally will be added in the future, which can be useful if you're dynamically generating a lot of image buffers (for example, displaying dynamic text in a button).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].