Skip to content

Commit

Permalink
feat: only include open surfaces in api
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Feb 2, 2025
1 parent 8712618 commit 6e0a526
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 41 deletions.
14 changes: 7 additions & 7 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -160,21 +160,21 @@ components:
surfaceId:
type: string
description: ID of the surface
description:
productName:
type: string
description: Description of the surface
description: Product Name of the surface
pluginId:
type: string
description: Plugin ID of the surface
pluginName:
type: string
description: Plugin name of the surface
isOpen:
type: boolean
description: Whether the surface is currently open
# isOpen:
# type: boolean
# description: Whether the surface is currently open
required:
- surfaceId
- description
- productName
- pluginId
- pluginName
- isOpen
# - isOpen
2 changes: 1 addition & 1 deletion satellite/src/device-types/infinitton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class InfinittonWrapper extends EventEmitter<WrappedSurfaceEvents> implem
return this.#deviceId
}
public get productName(): string {
return `Satellite Infinitton`
return `Infinitton`
}

public constructor(deviceId: string, panel: Infinitton, cardGenerator: CardGenerator) {
Expand Down
4 changes: 2 additions & 2 deletions satellite/src/device-types/streamdeck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const PLUGIN_ID = 'elgato-streamdeck'

export class StreamDeckPlugin implements SurfacePlugin<StreamDeckDeviceInfo> {
readonly pluginId = PLUGIN_ID
readonly pluginName = 'Elgato StreamDeck'
readonly pluginName = 'Elgato Stream Deck'

async init(): Promise<void> {
// Nothing to do
Expand Down Expand Up @@ -115,7 +115,7 @@ export class StreamDeckWrapper extends EventEmitter<WrappedSurfaceEvents> implem
return this.#deviceId
}
public get productName(): string {
return `Satellite StreamDeck: ${this.#deck.MODEL}`
return this.#deck.PRODUCT_NAME
}

public constructor(deviceId: string, deck: StreamDeck, cardGenerator: CardGenerator) {
Expand Down
6 changes: 2 additions & 4 deletions satellite/src/generated/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,12 @@ export interface components {
SurfaceInfo: {
/** @description ID of the surface */
surfaceId: string;
/** @description Description of the surface */
description: string;
/** @description Product Name of the surface */
productName: string;
/** @description Plugin ID of the surface */
pluginId: string;
/** @description Plugin name of the surface */
pluginName: string;
/** @description Whether the surface is currently open */
isOpen: boolean;
};
};
responses: never;
Expand Down
32 changes: 5 additions & 27 deletions satellite/src/surface-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ export class SurfaceManager {
#scanIsRunning = false
#scanPending = false

#lastScannedSurfaces: ApiSurfaceInfo[] = []

public static async create(client: CompanionSatelliteClient): Promise<SurfaceManager> {
const manager = new SurfaceManager(client)

Expand Down Expand Up @@ -266,8 +264,6 @@ export class SurfaceManager {
this.#scanIsRunning = true
this.#scanPending = false

const detectedSurfaces: ApiSurfaceInfo[] = []

void Promise.allSettled([
HID.devicesAsync()
.then(async (devices) => {
Expand All @@ -277,14 +273,6 @@ export class SurfaceManager {
const info = plugin.checkSupportsHidDevice?.(device)
if (!info) continue

detectedSurfaces.push({
pluginId: plugin.pluginId,
pluginName: plugin.pluginName,
surfaceId: info.surfaceId,
description: info.description,
isOpen: false,
})

this.#tryAddSurfaceFromPlugin(plugin, info)
return
}
Expand All @@ -300,14 +288,6 @@ export class SurfaceManager {
if (plugin.scanForSurfaces) {
const surfaceInfos = await plugin.scanForSurfaces()
for (const surfaceInfo of surfaceInfos) {
detectedSurfaces.push({
pluginId: plugin.pluginId,
pluginName: plugin.pluginName,
surfaceId: surfaceInfo.surfaceId,
description: surfaceInfo.description,
isOpen: false,
})

this.#tryAddSurfaceFromPlugin(plugin, surfaceInfo)
}
} else if (plugin.detection?.triggerScan) {
Expand All @@ -320,20 +300,18 @@ export class SurfaceManager {
]).finally(() => {
this.#scanIsRunning = false

this.#lastScannedSurfaces = detectedSurfaces

if (this.#scanPending) {
this.scanForSurfaces()
}
})
}

public getKnownSurfaces(): ApiSurfaceInfo[] {
// TODO - include auto-detected surfaces

return this.#lastScannedSurfaces.map((surface) => ({
...surface,
isOpen: this.#surfaces.has(surface.surfaceId),
return Array.from(this.#surfaces.values()).map((surface) => ({
pluginId: surface.pluginId,
pluginName: this.#plugins.get(surface.pluginId)?.pluginName ?? 'Unknown',
surfaceId: surface.surfaceId,
productName: surface.productName,
}))
}

Expand Down

0 comments on commit 6e0a526

Please sign in to comment.