diff --git a/package.json b/package.json index ff6d561..e000571 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "node": "14 || 16" }, "dependencies": { - "@elgato-stream-deck/node": "^5.3.1", + "@elgato-stream-deck/node": "^5.4.0-alpha.0", "@julusian/jpeg-turbo": "^1.1.2", "@xencelabs-quick-keys/node": "^0.4.0", "electron-about-window": "^1.15.2", diff --git a/src/device-types/streamdeck.ts b/src/device-types/streamdeck.ts index e2679cb..b018568 100644 --- a/src/device-types/streamdeck.ts +++ b/src/device-types/streamdeck.ts @@ -27,7 +27,7 @@ export class StreamDeckWrapper implements WrappedDevice { this.#queueOutputId = 0 - if (this.#deck.ICON_SIZE !== 72) { + if (this.#deck.ICON_SIZE !== 72 && this.#deck.ICON_SIZE !== 0) { this.#queue = new ImageWriteQueue(async (key: number, buffer: Buffer) => { const outputId = this.#queueOutputId let newbuffer: Buffer | null = null @@ -57,7 +57,7 @@ export class StreamDeckWrapper implements WrappedDevice { return { keysTotal: this.#deck.NUM_KEYS, keysPerRow: this.#deck.KEY_COLUMNS, - bitmaps: true, + bitmaps: this.#deck.ICON_SIZE !== 0, colours: false, text: false, } @@ -88,34 +88,38 @@ export class StreamDeckWrapper implements WrappedDevice { await this.#deck.clearPanel() } async draw(d: DeviceDrawProps): Promise { - if (d.image) { - if (this.#queue) { - this.#queue.queue(d.keyIndex, d.image) + if (this.#deck.ICON_SIZE !== 0) { + if (d.image) { + if (this.#queue) { + this.#queue.queue(d.keyIndex, d.image) + } else { + await this.#deck.fillKeyBuffer(d.keyIndex, d.image) + } } else { - await this.#deck.fillKeyBuffer(d.keyIndex, d.image) + throw new Error(`Cannot draw for Streamdeck without image`) } - } else { - throw new Error(`Cannot draw for Streamdeck without image`) } } async showStatus(hostname: string, status: string): Promise { - // abort and discard current operations - this.#queue?.abort() - this.#queueOutputId++ + if (this.#deck.ICON_SIZE !== 0) { + // abort and discard current operations + this.#queue?.abort() + this.#queueOutputId++ - const outputId = this.#queueOutputId - const width = this.#deck.ICON_SIZE * this.#deck.KEY_COLUMNS - const height = this.#deck.ICON_SIZE * this.#deck.KEY_ROWS - this.#cardGenerator - .generateBasicCard(width, height, hostname, status) - .then(async (buffer) => { - if (outputId === this.#queueOutputId) { - // still valid - await this.#deck.fillPanelBuffer(buffer, { format: 'rgba' }) - } - }) - .catch((e) => { - console.error(`Failed to fill device`, e) - }) + const outputId = this.#queueOutputId + const width = this.#deck.ICON_SIZE * this.#deck.KEY_COLUMNS + const height = this.#deck.ICON_SIZE * this.#deck.KEY_ROWS + this.#cardGenerator + .generateBasicCard(width, height, hostname, status) + .then(async (buffer) => { + if (outputId === this.#queueOutputId) { + // still valid + await this.#deck.fillPanelBuffer(buffer, { format: 'rgba' }) + } + }) + .catch((e) => { + console.error(`Failed to fill device`, e) + }) + } } } diff --git a/yarn.lock b/yarn.lock index 95637a8..61997f9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -63,19 +63,19 @@ dir-compare "^2.4.0" fs-extra "^9.0.1" -"@elgato-stream-deck/core@5.2.0": - version "5.2.0" - resolved "https://registry.yarnpkg.com/@elgato-stream-deck/core/-/core-5.2.0.tgz#42b9c540d1528bce53e02554fb8e94382a501a31" - integrity sha512-WcyWvXFh+V8FjVzGpCJo3HN5DQVx27zskgQUVTUaXMtIM9UWMhqvOtKp2vS6i9iWvZnozKbXNXOTGe++1Bfuvw== +"@elgato-stream-deck/core@5.4.0-alpha.0": + version "5.4.0-alpha.0" + resolved "https://registry.yarnpkg.com/@elgato-stream-deck/core/-/core-5.4.0-alpha.0.tgz#c35fbab24b024a5000ca9106395aa62d39757e77" + integrity sha512-PyXf79qdA79dYWve2ohERLomSdKN6gF1oyAAlc+PmdKMirbc38P/xVqql7pNlduTuzFbjIRhXGaHNTG2E1D3Zw== dependencies: eventemitter3 "^4.0.7" -"@elgato-stream-deck/node@^5.3.1": - version "5.3.1" - resolved "https://registry.yarnpkg.com/@elgato-stream-deck/node/-/node-5.3.1.tgz#62271471f56f7005720457662d32a1d51f6b4656" - integrity sha512-xcdI+NYcMKtV1WOjx7p1VezUChTubYjdb9nYeCpjCN2EqhbhPHfwGltW5nHiLpoz+aU6SHZnzAxGetUAX75dfw== +"@elgato-stream-deck/node@^5.4.0-alpha.0": + version "5.4.0-alpha.0" + resolved "https://registry.yarnpkg.com/@elgato-stream-deck/node/-/node-5.4.0-alpha.0.tgz#95a4daf299b21070235d41005f74055382639766" + integrity sha512-5G3ZgEG/jYafyD5S2ampaRRR4XK2AfT2xcmjsUKZHGwRWlep0Sa0JELseD3BOEfm4JLa3aTURJA5mYFFblFUTA== dependencies: - "@elgato-stream-deck/core" "5.2.0" + "@elgato-stream-deck/core" "5.4.0-alpha.0" jpeg-js "^0.4.2" node-hid "^2.1.1"