@sdeck/elgato 0.0.0-stage → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bytes.d.ts +8 -0
- package/dist/bytes.d.ts.map +1 -0
- package/dist/deck.d.ts +34 -0
- package/dist/deck.d.ts.map +1 -0
- package/dist/detect.d.ts +33 -0
- package/dist/detect.d.ts.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +675 -0
- package/dist/index.js.map +16 -0
- package/dist/legacy.d.ts +51 -0
- package/dist/legacy.d.ts.map +1 -0
- package/dist/models.d.ts +71 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/protocol.d.ts +73 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/virtual.d.ts +23 -0
- package/dist/virtual.d.ts.map +1 -0
- package/package.json +36 -4
- package/src/bytes.ts +32 -0
- package/src/deck.ts +129 -0
- package/src/detect.ts +77 -0
- package/src/index.ts +6 -0
- package/src/legacy.ts +211 -0
- package/src/models.ts +151 -0
- package/src/protocol.ts +317 -0
- package/src/virtual.ts +75 -0
- package/README.md +0 -3
package/src/detect.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type DeckDriver,
|
|
3
|
+
type DeckInfo,
|
|
4
|
+
findDecks,
|
|
5
|
+
type HidDeviceInfo,
|
|
6
|
+
type HidTransport,
|
|
7
|
+
listDecks,
|
|
8
|
+
type OpenOptions,
|
|
9
|
+
openDeck,
|
|
10
|
+
} from "@sdeck/core";
|
|
11
|
+
import { ElgatoStreamDeck } from "./deck.ts";
|
|
12
|
+
import { LegacyStreamDeck } from "./legacy.ts";
|
|
13
|
+
import { type ElgatoModel, MODELS, type ModelId } from "./models.ts";
|
|
14
|
+
|
|
15
|
+
/** A Stream Deck of any model, on a transport that is already open. */
|
|
16
|
+
export function createStreamDeck(transport: HidTransport, model: ElgatoModel): AnyStreamDeck {
|
|
17
|
+
return model.protocol === "general"
|
|
18
|
+
? new ElgatoStreamDeck(transport, model)
|
|
19
|
+
: new LegacyStreamDeck(transport, model);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** A Stream Deck of any model. */
|
|
23
|
+
export type AnyStreamDeck = ElgatoStreamDeck | LegacyStreamDeck;
|
|
24
|
+
|
|
25
|
+
export interface ElgatoDriver extends DeckDriver<AnyStreamDeck> {
|
|
26
|
+
readonly model: ElgatoModel;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** One for every model; pass them to `openDeck` or `listDecks`, with others if you like. */
|
|
30
|
+
export const drivers: readonly ElgatoDriver[] = Object.values(MODELS).map((model) => ({
|
|
31
|
+
model,
|
|
32
|
+
create: (transport) => createStreamDeck(transport, model),
|
|
33
|
+
}));
|
|
34
|
+
|
|
35
|
+
export interface StreamDeckInfo {
|
|
36
|
+
/** OS-level device path; pass to {@link OpenOptions.path} to select this device. */
|
|
37
|
+
path: string;
|
|
38
|
+
serialNumber?: string | undefined;
|
|
39
|
+
model: ElgatoModel;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface OpenStreamDeckOptions extends OpenOptions {
|
|
43
|
+
/** Only these models (default: any). */
|
|
44
|
+
models?: readonly ModelId[];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const driversOf = (models: readonly ModelId[] | undefined) =>
|
|
48
|
+
models ? drivers.filter(({ model }) => models.includes(model.id)) : drivers;
|
|
49
|
+
|
|
50
|
+
const toInfo = ({ path, serialNumber, driver }: DeckInfo<AnyStreamDeck>): StreamDeckInfo => ({
|
|
51
|
+
path,
|
|
52
|
+
serialNumber,
|
|
53
|
+
model: (driver as ElgatoDriver).model,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
/** Filters raw HID device descriptions down to Stream Decks, de-duplicated by path. */
|
|
57
|
+
export function findStreamDecks(devices: readonly HidDeviceInfo[]): StreamDeckInfo[] {
|
|
58
|
+
return findDecks(devices, drivers).map(toInfo);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Lists the Stream Decks connected right now. */
|
|
62
|
+
export async function listStreamDecks(
|
|
63
|
+
options: Pick<OpenOptions, "hid"> = {},
|
|
64
|
+
): Promise<StreamDeckInfo[]> {
|
|
65
|
+
return (await listDecks(drivers, options)).map(toInfo);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Opens a connected Stream Deck, waiting for one to be plugged in if necessary. See
|
|
70
|
+
* {@link openDeck} for the options.
|
|
71
|
+
*/
|
|
72
|
+
export async function openStreamDeck({
|
|
73
|
+
models,
|
|
74
|
+
...options
|
|
75
|
+
}: OpenStreamDeckOptions = {}): Promise<AnyStreamDeck> {
|
|
76
|
+
return openDeck(driversOf(models), options);
|
|
77
|
+
}
|
package/src/index.ts
ADDED
package/src/legacy.ts
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Mini family and the very first Stream Deck speak an older protocol: they take bitmaps, one key
|
|
3
|
+
* at a time, and have no command for the whole screen.
|
|
4
|
+
*
|
|
5
|
+
* Elgato documents the Mini's (https://docs.elgato.com/streamdeck/hid/mini), but not how its packets
|
|
6
|
+
* and keys are numbered or what is in the bitmap, and nothing about the first one. Those parts are as
|
|
7
|
+
* other drivers have had them for years (`python-elgato-streamdeck`, `@elgato-stream-deck/core`).
|
|
8
|
+
*/
|
|
9
|
+
import {
|
|
10
|
+
type DeckInput,
|
|
11
|
+
type Framebuffer,
|
|
12
|
+
type HidTransport,
|
|
13
|
+
type Rect,
|
|
14
|
+
type Size,
|
|
15
|
+
StreamDeck,
|
|
16
|
+
} from "@sdeck/core";
|
|
17
|
+
import { asciiString, assertUint, i32At } from "./bytes.ts";
|
|
18
|
+
import type { ElgatoModel } from "./models.ts";
|
|
19
|
+
|
|
20
|
+
/** The shortest feature report any of them takes. */
|
|
21
|
+
const FEATURE_SIZE = 17;
|
|
22
|
+
const LONG_FEATURE_SIZE = 32;
|
|
23
|
+
const HEADER_SIZE = 16;
|
|
24
|
+
const BITMAP_HEADER_SIZE = 54;
|
|
25
|
+
|
|
26
|
+
const feature = (...bytes: number[]): Uint8Array => {
|
|
27
|
+
const report = new Uint8Array(FEATURE_SIZE);
|
|
28
|
+
report.set(bytes);
|
|
29
|
+
return report;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const legacyLogoReport = (): Uint8Array => feature(0x0b, 0x63);
|
|
33
|
+
|
|
34
|
+
/** @param percent 0 – 100 */
|
|
35
|
+
export function legacyBrightnessReport(percent: number): Uint8Array {
|
|
36
|
+
assertUint("brightness", percent, 100);
|
|
37
|
+
return feature(0x05, 0x55, 0xaa, 0xd1, 0x01, percent);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** @param seconds Idle time before the device sleeps. `0` disables sleep. */
|
|
41
|
+
export function legacySleepReport(seconds: number): Uint8Array {
|
|
42
|
+
assertUint("sleep duration", seconds, 0x7fffffff);
|
|
43
|
+
const bytes = [0, 8, 16, 24].map((shift) => (seconds >>> shift) & 0xff);
|
|
44
|
+
return feature(0x0b, 0xa2, ...bytes);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The packets that put `bitmap` on a key. The first Stream Deck takes it in two large halves counted
|
|
49
|
+
* from 1, the others in small packets counted from 0.
|
|
50
|
+
*/
|
|
51
|
+
export function legacyKeyPackets(
|
|
52
|
+
key: number,
|
|
53
|
+
bitmap: Uint8Array,
|
|
54
|
+
protocol: "mini" | "original",
|
|
55
|
+
): Uint8Array[] {
|
|
56
|
+
assertUint("key index", key, 254);
|
|
57
|
+
const original = protocol === "original";
|
|
58
|
+
const size = original ? 8191 : 1024;
|
|
59
|
+
const chunk = original ? Math.ceil(bitmap.length / 2) : size - HEADER_SIZE;
|
|
60
|
+
const packets: Uint8Array[] = [];
|
|
61
|
+
for (let offset = 0, page = original ? 1 : 0; offset < bitmap.length; offset += chunk, page++) {
|
|
62
|
+
const packet = new Uint8Array(size);
|
|
63
|
+
const last = offset + chunk >= bitmap.length;
|
|
64
|
+
packet.set([0x02, 0x01, page, 0, last ? 1 : 0, key + 1]);
|
|
65
|
+
packet.set(bitmap.subarray(offset, offset + chunk), HEADER_SIZE);
|
|
66
|
+
packets.push(packet);
|
|
67
|
+
}
|
|
68
|
+
return packets;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Upright RGB pixels of a square key as a bitmap. These decks read the rows in the order they are in
|
|
73
|
+
* the file, though a bitmap starts with its lowest one. The Mini's panel is mounted turned to its side,
|
|
74
|
+
* and the first one's mirrored.
|
|
75
|
+
*/
|
|
76
|
+
export function keyBitmap(
|
|
77
|
+
rgb: Uint8Array,
|
|
78
|
+
{ width, height }: Size,
|
|
79
|
+
protocol: "mini" | "original",
|
|
80
|
+
): Uint8Array {
|
|
81
|
+
const bytes = width * height * 3;
|
|
82
|
+
const file = new Uint8Array(BITMAP_HEADER_SIZE + bytes);
|
|
83
|
+
const header = new DataView(file.buffer);
|
|
84
|
+
const perMeter = protocol === "mini" ? 2835 : 3780;
|
|
85
|
+
header.setUint16(0, 0x4d42, true); // "BM"
|
|
86
|
+
header.setUint32(2, file.length, true);
|
|
87
|
+
header.setUint32(10, BITMAP_HEADER_SIZE, true);
|
|
88
|
+
header.setUint32(14, 40, true); // the size of what follows
|
|
89
|
+
header.setInt32(18, width, true);
|
|
90
|
+
header.setInt32(22, height, true);
|
|
91
|
+
header.setUint16(26, 1, true); // planes
|
|
92
|
+
header.setUint16(28, 24, true); // bits per pixel
|
|
93
|
+
header.setUint32(34, bytes, true);
|
|
94
|
+
header.setInt32(38, perMeter, true);
|
|
95
|
+
header.setInt32(42, perMeter, true);
|
|
96
|
+
for (let y = 0; y < height; y++) {
|
|
97
|
+
for (let x = 0; x < width; x++) {
|
|
98
|
+
const from = protocol === "mini" ? x * width + (width - 1 - y) : y * width + (width - 1 - x);
|
|
99
|
+
const to = BITMAP_HEADER_SIZE + (y * width + x) * 3;
|
|
100
|
+
file[to] = rgb[from * 3 + 2] as number;
|
|
101
|
+
file[to + 1] = rgb[from * 3 + 1] as number;
|
|
102
|
+
file[to + 2] = rgb[from * 3] as number;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return file;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** Drives the Mini, its relatives and the first Stream Deck. */
|
|
109
|
+
export class LegacyStreamDeck extends StreamDeck {
|
|
110
|
+
declare readonly model: ElgatoModel;
|
|
111
|
+
readonly #protocol: "mini" | "original";
|
|
112
|
+
|
|
113
|
+
constructor(transport: HidTransport, model: ElgatoModel) {
|
|
114
|
+
super(transport, model);
|
|
115
|
+
this.#protocol = model.protocol === "original" ? "original" : "mini";
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** The device's number for a key, and the other way round: the first one counts from the right. */
|
|
119
|
+
#number(key: number): number {
|
|
120
|
+
if (this.#protocol !== "original") return key;
|
|
121
|
+
const columns = this.model.layout.keys.filter((r, _, [first]) => r.y === first?.y).length;
|
|
122
|
+
return key + columns - 1 - 2 * (key % columns);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// -- Protocol (called inside the write queue) ----------------------------------
|
|
126
|
+
|
|
127
|
+
protected override parseInput(data: Uint8Array): DeckInput | undefined {
|
|
128
|
+
if (data[0] !== 0x01 || data.length <= this.keyCount) return undefined;
|
|
129
|
+
const pressed = this.model.layout.keys.map((_, key) => data[1 + this.#number(key)] === 1);
|
|
130
|
+
return { type: "buttons", pressed };
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
protected override async encodeImage(rgb: Uint8Array, size: Size): Promise<Uint8Array> {
|
|
134
|
+
return keyBitmap(rgb, size, this.#protocol);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
protected override async sendKeyImage(index: number, bitmap: Uint8Array): Promise<void> {
|
|
138
|
+
for (const packet of legacyKeyPackets(this.#number(index), bitmap, this.#protocol)) {
|
|
139
|
+
await this.transport.write(packet);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
protected override sendScreenImage(): Promise<void> {
|
|
144
|
+
return Promise.reject(new Error(`${this.model.name} takes images for its keys only`));
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** Only what is on the keys can be seen, so that is all there is to send. */
|
|
148
|
+
protected override prepareFrame(screen: Framebuffer): () => Promise<void> {
|
|
149
|
+
const keys = this.model.layout.keys.map((rect: Rect) =>
|
|
150
|
+
keyBitmap(screen.read(rect).data, rect, this.#protocol),
|
|
151
|
+
);
|
|
152
|
+
return async () => {
|
|
153
|
+
for (const [index, bitmap] of keys.entries()) await this.sendKeyImage(index, bitmap);
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
protected override async sendFillScreen(
|
|
158
|
+
color: Parameters<StreamDeck["fillScreen"]>[0],
|
|
159
|
+
): Promise<void> {
|
|
160
|
+
for (let index = 0; index < this.keyCount; index++) await this.sendFillKey(index, color);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** Restores the boot logo, as recommended by Elgato. */
|
|
164
|
+
protected override async onClosing(): Promise<void> {
|
|
165
|
+
await this.transport.sendFeatureReport(legacyLogoReport());
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// -- Settings and info -----------------------------------------------------------
|
|
169
|
+
|
|
170
|
+
/** @param percent 0 – 100 */
|
|
171
|
+
setBrightness(percent: number): Promise<void> {
|
|
172
|
+
return this.#feature(legacyBrightnessReport(percent));
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** Forcibly shows the boot logo. */
|
|
176
|
+
showLogo(): Promise<void> {
|
|
177
|
+
return this.#feature(legacyLogoReport());
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** @param seconds Idle time before sleeping; `0` disables sleep. The first Stream Deck has none. */
|
|
181
|
+
async setSleepDuration(seconds: number): Promise<void> {
|
|
182
|
+
if (this.#protocol === "original") return;
|
|
183
|
+
await this.#feature(legacySleepReport(seconds));
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
async getSleepDuration(): Promise<number> {
|
|
187
|
+
return this.#protocol === "original" ? 0 : i32At(await this.#read(0xa3), 2);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
async getFirmwareVersion(): Promise<string> {
|
|
191
|
+
const report = await this.#read(this.#protocol === "original" ? 0x04 : 0xa1);
|
|
192
|
+
return asciiString(report.subarray(5));
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
async getSerialNumber(): Promise<string> {
|
|
196
|
+
return asciiString((await this.#read(0x03)).subarray(5));
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
#feature(report: Uint8Array): Promise<void> {
|
|
200
|
+
return this.enqueue(() => this.transport.sendFeatureReport(report));
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** Older ones refuse to be asked for more than they have. */
|
|
204
|
+
#read(reportId: number): Promise<Uint8Array> {
|
|
205
|
+
return this.enqueue(() =>
|
|
206
|
+
this.transport
|
|
207
|
+
.getFeatureReport(reportId, LONG_FEATURE_SIZE)
|
|
208
|
+
.catch(() => this.transport.getFeatureReport(reportId, FEATURE_SIZE)),
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
}
|
package/src/models.ts
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every Stream Deck there is a driver for. The layouts are the ones drawn in Elgato's documentation:
|
|
3
|
+
* https://docs.elgato.com/streamdeck/hid/intro
|
|
4
|
+
*/
|
|
5
|
+
import type { DeckLayout, DeckModel, Rect, Rotation, Size } from "@sdeck/core";
|
|
6
|
+
|
|
7
|
+
export const ELGATO_VENDOR_ID = 0x0fd9;
|
|
8
|
+
|
|
9
|
+
/** Stream Decks that look and work alike, whatever they are sold as. */
|
|
10
|
+
export type DeckFamily = "neo" | "classic" | "scissor" | "xl" | "plus" | "plus-xl" | "mini";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* How it talks: `general` is what Elgato calls the main protocol, `mini` is the Mini's, and `original`
|
|
14
|
+
* that of the very first Stream Deck.
|
|
15
|
+
*/
|
|
16
|
+
export type DeckProtocol = "general" | "mini" | "original";
|
|
17
|
+
|
|
18
|
+
export interface ElgatoModel extends DeckModel {
|
|
19
|
+
id: ModelId;
|
|
20
|
+
family: DeckFamily;
|
|
21
|
+
protocol: DeckProtocol;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** A grid of keys from the top left. `x` and `y` are where its columns and rows start. */
|
|
25
|
+
const grid = (size: number, x: readonly number[], y: readonly number[]): Rect[] =>
|
|
26
|
+
y.flatMap((top) => x.map((left) => ({ x: left, y: top, width: size, height: size })));
|
|
27
|
+
|
|
28
|
+
/** `count` starts, `step` pixels apart. */
|
|
29
|
+
const every = (count: number, first: number, step: number) =>
|
|
30
|
+
Array.from({ length: count }, (_, i) => first + i * step);
|
|
31
|
+
|
|
32
|
+
/** The window shared out among the dials under it. */
|
|
33
|
+
const split = (window: Rect, count: number): Rect[] =>
|
|
34
|
+
Array.from({ length: count }, (_, i) => {
|
|
35
|
+
const width = window.width / count;
|
|
36
|
+
return { ...window, x: window.x + i * width, width };
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const NEO = {
|
|
40
|
+
screen: { width: 480, height: 320 },
|
|
41
|
+
keys: grid(96, every(4, 3, 126), every(2, 9, 126)),
|
|
42
|
+
/** Indicator strips for the two touch sensors, under the first and last column. */
|
|
43
|
+
sensors: [
|
|
44
|
+
{ x: 3, y: 283, width: 96, height: 16 },
|
|
45
|
+
{ x: 381, y: 283, width: 96, height: 16 },
|
|
46
|
+
],
|
|
47
|
+
window: { x: 116, y: 262, width: 248, height: 58 },
|
|
48
|
+
} as const satisfies DeckLayout;
|
|
49
|
+
|
|
50
|
+
const CLASSIC: DeckLayout = {
|
|
51
|
+
screen: { width: 480, height: 272 },
|
|
52
|
+
keys: grid(72, every(5, 11, 97), every(3, 5, 97)),
|
|
53
|
+
sensors: [],
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const XL: DeckLayout = {
|
|
57
|
+
screen: { width: 1024, height: 600 },
|
|
58
|
+
// The drawing says 32 pixels between columns, which leaves two pixels over.
|
|
59
|
+
keys: grid(96, [14, 142, 270, 399, 527, 655, 784, 912], every(4, 47, 135)),
|
|
60
|
+
sensors: [],
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const PLUS_WINDOW: Rect = { x: 0, y: 380, width: 800, height: 100 };
|
|
64
|
+
const PLUS: DeckLayout = {
|
|
65
|
+
screen: { width: 800, height: 480 },
|
|
66
|
+
keys: grid(120, every(4, 13, 219), every(2, 12, 160)),
|
|
67
|
+
sensors: [],
|
|
68
|
+
window: PLUS_WINDOW,
|
|
69
|
+
dials: split(PLUS_WINDOW, 4),
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const PLUS_XL_WINDOW: Rect = { x: 40, y: 674, width: 1200, height: 100 };
|
|
73
|
+
const PLUS_XL: DeckLayout = {
|
|
74
|
+
screen: { width: 1280, height: 800 },
|
|
75
|
+
keys: grid(112, [11, 154, 298, 441, 585, 728, 872, 1015, 1159], [32, 176, 318, 462]),
|
|
76
|
+
sensors: [],
|
|
77
|
+
window: PLUS_XL_WINDOW,
|
|
78
|
+
dials: split(PLUS_XL_WINDOW, 6),
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const MINI: DeckLayout = {
|
|
82
|
+
screen: { width: 320, height: 240 },
|
|
83
|
+
keys: grid(80, [14, 122, 229], [26, 134]),
|
|
84
|
+
sensors: [],
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/** What things are drawn for: the Neo's sizes. Other keys show the same, larger or smaller. */
|
|
88
|
+
const DESIGN: Readonly<Record<"key" | "sensor" | "dial" | "window", Size>> = {
|
|
89
|
+
key: { width: 96, height: 96 },
|
|
90
|
+
sensor: { width: 96, height: 16 },
|
|
91
|
+
dial: { width: 200, height: 100 },
|
|
92
|
+
window: { width: 248, height: 58 },
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const FAMILIES: Record<DeckFamily, { layout: DeckLayout; rotation: Rotation }> = {
|
|
96
|
+
neo: { layout: NEO, rotation: 180 },
|
|
97
|
+
classic: { layout: CLASSIC, rotation: 180 },
|
|
98
|
+
scissor: { layout: CLASSIC, rotation: 180 },
|
|
99
|
+
xl: { layout: XL, rotation: 180 },
|
|
100
|
+
plus: { layout: PLUS, rotation: 0 },
|
|
101
|
+
"plus-xl": { layout: PLUS_XL, rotation: 270 },
|
|
102
|
+
mini: { layout: MINI, rotation: 270 },
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
/** Name, USB product id, family and protocol. */
|
|
106
|
+
const TABLE = {
|
|
107
|
+
neo: ["Stream Deck Neo", 0x009a, "neo"],
|
|
108
|
+
original: ["Stream Deck (2017)", 0x0060, "classic", "original"],
|
|
109
|
+
classic: ["Stream Deck", 0x006d, "classic"],
|
|
110
|
+
mk2: ["Stream Deck MK.2", 0x0080, "classic"],
|
|
111
|
+
"mk2-scissor": ["Stream Deck MK.2 Scissor Keys", 0x00a5, "scissor"],
|
|
112
|
+
"module-15": ["Stream Deck Module 15 Keys", 0x00b9, "classic"],
|
|
113
|
+
"module-15-scissor": ["Stream Deck Module 15 Scissor Keys", 0x00e4, "scissor"],
|
|
114
|
+
xl: ["Stream Deck XL", 0x006c, "xl"],
|
|
115
|
+
"xl-2022": ["Stream Deck XL (2022)", 0x008f, "xl"],
|
|
116
|
+
"module-32": ["Stream Deck Module 32 Keys", 0x00ba, "xl"],
|
|
117
|
+
plus: ["Stream Deck +", 0x0084, "plus"],
|
|
118
|
+
"plus-xl": ["Stream Deck + XL", 0x00c6, "plus-xl"],
|
|
119
|
+
mini: ["Stream Deck Mini", 0x0063, "mini", "mini"],
|
|
120
|
+
"mini-2022": ["Stream Deck Mini (2022)", 0x0090, "mini", "mini"],
|
|
121
|
+
"mini-discord": ["Stream Deck Mini Discord Edition", 0x00b3, "mini", "mini"],
|
|
122
|
+
"module-6": ["Stream Deck Module 6 Keys", 0x00b8, "mini", "mini"],
|
|
123
|
+
} as const satisfies Record<
|
|
124
|
+
string,
|
|
125
|
+
readonly [name: string, productId: number, family: DeckFamily, protocol?: DeckProtocol]
|
|
126
|
+
>;
|
|
127
|
+
|
|
128
|
+
export type ModelId = keyof typeof TABLE;
|
|
129
|
+
|
|
130
|
+
/** Every model, by id. */
|
|
131
|
+
export const MODELS = Object.fromEntries(
|
|
132
|
+
Object.entries(TABLE).map(([id, [name, productId, family, protocol = "general"]]) => [
|
|
133
|
+
id,
|
|
134
|
+
{
|
|
135
|
+
id,
|
|
136
|
+
name,
|
|
137
|
+
vendorId: ELGATO_VENDOR_ID,
|
|
138
|
+
productId,
|
|
139
|
+
family,
|
|
140
|
+
protocol,
|
|
141
|
+
design: DESIGN,
|
|
142
|
+
...FAMILIES[family],
|
|
143
|
+
},
|
|
144
|
+
]),
|
|
145
|
+
) as Record<ModelId, ElgatoModel>;
|
|
146
|
+
|
|
147
|
+
/** The layout all decks of a family share. */
|
|
148
|
+
export const layoutOf = (family: DeckFamily): DeckLayout => FAMILIES[family].layout;
|
|
149
|
+
|
|
150
|
+
/** The Neo's, which looks are designed for. */
|
|
151
|
+
export const NEO_LAYOUT: typeof NEO = NEO;
|