Skip to content

Commit

Permalink
feat: support for pedal (untested)
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Apr 13, 2022
1 parent 6d5c6df commit 2d4ba39
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 35 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
54 changes: 29 additions & 25 deletions src/device-types/streamdeck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
}
Expand Down Expand Up @@ -88,34 +88,38 @@ export class StreamDeckWrapper implements WrappedDevice {
await this.#deck.clearPanel()
}
async draw(d: DeviceDrawProps): Promise<void> {
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<void> {
// 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)
})
}
}
}
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit 2d4ba39

Please sign in to comment.