Skip to content

Commit 975902e

Browse files
committed
Remove all layout selection from plugin and bug, refactor appliance to support StreamDeck Mini
1 parent d2e233c commit 975902e

File tree

23 files changed

+528
-434
lines changed

23 files changed

+528
-434
lines changed

appliance-application/packages/common/ipc.d.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ type close = () => void;
33
type requireVerification = () => void;
44
type verificationAccepted = () => void;
55
type verificationRejected = () => void;
6-
// @TODO: Remove, old implementation where the plugin generated the join URLs
7-
// type joinMeeting = (urls: string) => void;
8-
type joinMeeting = (url: string, layoutIndex: number) => void;
6+
type joinMeeting = (url: string) => void;
97
type pluginDisconnected = () => void;
108
type handleLeftMeeting = (callback: () => void) => void;
119
type handleVerificationAccepted = (callback: () => void) => void;
-8.7 KB
Binary file not shown.
-10.7 KB
Binary file not shown.
-15 KB
Binary file not shown.
-20 KB
Binary file not shown.
-16.6 KB
Binary file not shown.
-23.1 KB
Binary file not shown.
Lines changed: 8 additions & 0 deletions
Loading
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
import * as path from 'path';
2+
import * as fs from 'node:fs';
3+
import sharp from 'sharp';
4+
import type {StreamDeck} from '@elgato-stream-deck/node';
5+
import {fileURLToPath} from 'url';
6+
import type {HID, HIDActions} from './HID';
7+
8+
const __filename = fileURLToPath(import.meta.url);
9+
const __dirname = path.dirname(__filename);
10+
11+
export default abstract class BaseStreamDeckHID implements HID {
12+
protected streamDeck: StreamDeck;
13+
protected layouts: number = 0;
14+
protected activeLayout: number = 0;
15+
16+
protected hasVerificationPending = false;
17+
18+
protected acceptCallback!: () => void;
19+
protected rejectCallback!: () => void;
20+
21+
protected actions: HIDActions;
22+
23+
protected isConnected!: boolean;
24+
25+
constructor(streamDeck: StreamDeck, layouts: number) {
26+
this.streamDeck = streamDeck;
27+
this.layouts = layouts;
28+
29+
this.streamDeck.clearPanel();
30+
this.streamDeck.setBrightness(100);
31+
32+
this.streamDeck.on('error', error => {
33+
console.error(error);
34+
});
35+
}
36+
37+
async getButtonImageBuffer(width, height, image: string): Promise<Buffer> {
38+
return sharp(path.resolve(__dirname, '../assets/' + image))
39+
.flatten()
40+
.resize(width, height)
41+
.raw()
42+
.toBuffer();
43+
}
44+
45+
async getLayoutButtonImageBuffer(width, height, label: string, backgroundColor: string, textColor: string): Promise<Buffer> {
46+
// load svg file as string
47+
let svg = fs.readFileSync(path.resolve(__dirname, '../assets/Layout.svg'), 'utf8');
48+
// replace "L1" with label
49+
svg = svg.replace('L1', label);
50+
// replace style="fill: #FFF" with background color
51+
svg = svg.replace('style="fill: #FFF"', 'style="fill: ' + backgroundColor + '"');
52+
// replace fill="#000" with text color
53+
svg = svg.replace('fill="#000"', 'fill="' + textColor + '"');
54+
55+
return sharp(Buffer.from(svg))
56+
.flatten()
57+
.resize(width, height)
58+
.raw()
59+
.toBuffer();
60+
}
61+
62+
requireVerification(accept: () => void, reject: () => void): void {
63+
this.hasVerificationPending = true;
64+
65+
this.acceptCallback = accept;
66+
this.rejectCallback = reject;
67+
68+
this.showVerificationButtons();
69+
}
70+
71+
verificationAccepted(): void {
72+
this.hasVerificationPending = false;
73+
this.hideVerificationButtons();
74+
}
75+
76+
verificationRejected(): void {
77+
this.hasVerificationPending = false;
78+
this.hideVerificationButtons();
79+
}
80+
81+
showVerificationButtons(): void {
82+
this.streamDeck.clearPanel();
83+
}
84+
85+
showBBBScreen(): void {
86+
this.streamDeck.clearPanel();
87+
}
88+
89+
hideVerificationButtons(): void {
90+
}
91+
92+
93+
async close(): Promise<void> {
94+
this.streamDeck.removeAllListeners();
95+
await this.streamDeck.close();
96+
}
97+
98+
connected(actions: HIDActions): void {
99+
this.isConnected = true;
100+
this.muteCallback = actions.mute;
101+
this.unmuteCallback = actions.unmute;
102+
this.leaveCallback = actions.leave;
103+
104+
this.layout1Callback = actions.layout1;
105+
this.layout2Callback = actions.layout2;
106+
this.layout3Callback = actions.layout3;
107+
}
108+
109+
disconnected(): void {
110+
this.isConnected = false;
111+
this.showBBBScreen();
112+
}
113+
}

appliance-application/packages/main/src/HID.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ export interface HID {
44
verificationAccepted(): void;
55
verificationRejected(): void;
66

7+
selectedLayout(index: number): void;
8+
79
connected(actions: HIDActions): void;
810

911
disconnected(): void;
@@ -15,7 +17,5 @@ export interface HIDActions {
1517
leave: () => void;
1618
mute: () => void;
1719
unmute: () => void;
18-
layout1: () => void;
19-
layout2: () => void;
20-
layout3: () => void;
20+
changeLayout: (index: number) => void;
2121
}

0 commit comments

Comments
 (0)