GithubHelp home page GithubHelp logo

inspired-futures / streamdeckjs Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 3.74 MB

JavaScript library to control the Stream Deck USB device

Home Page: https://inspired-futures.github.io/streamdeckjs/

License: Apache License 2.0

streamdeck javascript-library

streamdeckjs's Introduction

streamdeck.js

JavaScript library to control the Stream Deck USB device. Only tested on Chrome 85+

Demo at https://inspired-futures.github.io/streamdeckjs/

import StreamDeckXL from "./stream-deck-xl.js";
import StreamDeck from "./stream-deck.js";

const streamDeck = new StreamDeckXL();

window.addEventListener("unload", function()
{
    if (streamDeck.device) streamDeck.disconnect();
});

window.addEventListener("load", function()
{
    const connect = document.getElementById("connect");

    connect.addEventListener('click', event =>
    {
        streamDeck.connect(function(error)
        {
            if (!error)
            {
                streamDeck.reset();
                streamDeck.setBrightness(80);
                streamDeck.drawImage(0, "./images/normal/Webcam-On.png", "black");
                streamDeck.drawImage(1, "./images/normal/Multimedia-Mute.png", "black");
                streamDeck.drawImage(2, "./images/normal/Audio-Mixer-On.png", "black");
                streamDeck.setKeyColor(3, "#0000ff");
                streamDeck.writeText(4, "Hello", "white", "red");
            }
        });
    });

    const eventChannel = new BroadcastChannel('stream-deck-event');

    eventChannel.addEventListener('message', event =>
    {
        if (event.data.event == "keys")
        {     
            if (event.data.keys[0]?.down) streamDeck.drawImage(0, "./images/normal/Webcam-Off.png", "white");
            if (event.data.keys[1]?.down) streamDeck.drawImage(1, "./images/normal/Multimedia-Mute.png", "white");
            if (event.data.keys[2]?.down) streamDeck.drawImage(2, "./images/normal/Audio-Mixer-On.png", "white");
        }
    });
});

streamdeckjs's People

Contributors

deleolajide avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.