Skip to content

Commit

Permalink
fix: scan for devices at startup while no companion connection. show …
Browse files Browse the repository at this point in the history
…key status on devices before they are fully initialised
  • Loading branch information
Julusian committed Jan 20, 2021
1 parent 01039b4 commit cee053f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/devices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export class DeviceManager {
usbDetect.on('add:4057', (dev) => this.foundDevice(dev))
usbDetect.on('remove:4057', (dev) => this.removeDevice(dev))

this.scanDevices()

client.on('connected', () => {
console.log('connected')
this.clearIdMap()
Expand Down Expand Up @@ -144,6 +146,10 @@ export class DeviceManager {
}
}

this.scanDevices()
}

public scanDevices(): void {
for (const device of listStreamDecks()) {
this.tryAddDevice(device.path, device.serialNumber ?? '')
}
Expand All @@ -158,6 +164,8 @@ export class DeviceManager {
const sd = openStreamDeck(path, { resetToLogoOnExit: true })
const serial = sd.getSerialNumber()

this.showNewDevice(sd)

const queue =
sd.ICON_SIZE !== 72
? new ImageWriteQueue(async (key: number, buffer: Buffer) => {
Expand Down Expand Up @@ -195,6 +203,11 @@ export class DeviceManager {
}
}

private showNewDevice(deck: StreamDeck): void {
deck.clearAllKeys()
deck.fillColor(0, 255, 0, 255)
}

private showOffline(): void {
// TODO
for (const dev of this.devices.values()) {
Expand Down

0 comments on commit cee053f

Please sign in to comment.