@elgato-stream-deck/core
Version:
An npm module for interfacing with the Elgato Stream Deck
91 lines • 3.18 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.GalleonK100Factory = GalleonK100Factory;
const base_js_1 = require("./base.js");
const generic_gen2_js_1 = require("./generic-gen2.js");
const id_js_1 = require("../id.js");
const controlsGenerator_js_1 = require("../controlsGenerator.js");
const galleonK100_js_1 = require("../services/encoderLed/galleonK100.js");
const generic_js_1 = require("../services/lcdSegmentDisplay/generic.js");
const k100Controls = (0, controlsGenerator_js_1.generateButtonsGrid)(3, 4, { width: 160, height: 160 }, false, 0, 2);
k100Controls.push({
type: 'encoder',
row: 0,
column: 0,
index: 0,
hidIndex: 0,
hasLed: false,
ledRingSteps: 4,
lcdRingOffset: 3,
}, {
type: 'encoder',
row: 0,
column: 2,
index: 1,
hidIndex: 1,
hasLed: false,
ledRingSteps: 4,
lcdRingOffset: 1,
}, {
type: 'lcd-segment',
row: 1,
column: 0,
columnSpan: 3,
rowSpan: 1,
id: 0,
pixelSize: Object.freeze({
width: 720,
height: 384,
}),
drawRegions: true,
});
const galleonK100Properties = {
MODEL: id_js_1.DeviceModelId.GALLEON_K100,
PRODUCT_NAME: id_js_1.MODEL_NAMES[id_js_1.DeviceModelId.GALLEON_K100],
SUPPORTS_RGB_KEY_FILL: true,
CONTROLS: (0, controlsGenerator_js_1.freezeDefinitions)(k100Controls),
KEY_SPACING_HORIZONTAL: 64,
KEY_SPACING_VERTICAL: 64,
FULLSCREEN_PANELS: 0,
HAS_NFC_READER: false,
SUPPORTS_CHILD_DEVICES: false,
};
const lcdSegmentControls = galleonK100Properties.CONTROLS.filter((control) => control.type === 'lcd-segment');
async function GalleonK100Factory(device, options, _tcpPropertiesService) {
const services = (0, generic_gen2_js_1.createBaseGen2Properties)(device, options, galleonK100Properties, null, {
xFlip: false,
yFlip: false,
});
services.encoderLed = new galleonK100_js_1.GalleonK100EncoderLedService(device, galleonK100Properties.CONTROLS);
services.lcdSegmentDisplay = new generic_js_1.StreamdeckDefaultLcdService(options.encodeJPEG, device, lcdSegmentControls, false, id_js_1.DeviceModelId.GALLEON_K100);
const streamDeck = new GalleonK100StreamDeck(device, options, services);
// Wait for the device to be ready
await new Promise((resolve) => setTimeout(resolve, 200));
return streamDeck;
}
class GalleonK100StreamDeck extends base_js_1.StreamDeckBase {
#pingInterval;
constructor(device, options, services) {
super(device, options, services);
// Stop the ping upon error
device.on('error', () => this.#stopPing());
this.#pingInterval = setInterval(this.#sendPing, 500);
this.#sendPing();
}
async close() {
this.#stopPing();
return super.close();
}
#sendPing = () => {
this.device.sendFeatureReport(new Uint8Array([0x03, 0x27])).catch((e) => {
// Emit as an error on the streamdeck
this.emit('error', e);
this.#stopPing();
});
};
#stopPing() {
// Stop pinging
clearInterval(this.#pingInterval);
}
}
//# sourceMappingURL=galleon-k100.js.map