@elgato-stream-deck/core
Version:
An npm module for interfacing with the Elgato Stream Deck
65 lines • 2.5 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Gen1PropertiesService = void 0;
class Gen1PropertiesService {
#device;
constructor(device) {
this.#device = device;
}
async setBrightness(percentage) {
if (percentage < 0 || percentage > 100) {
throw new RangeError('Expected brightness percentage to be between 0 and 100');
}
// prettier-ignore
const brightnessCommandBuffer = new Uint8Array([
0x05,
0x55, 0xaa, 0xd1, 0x01, percentage, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
]);
await this.#device.sendFeatureReport(brightnessCommandBuffer);
}
async resetToLogo() {
// prettier-ignore
const resetCommandBuffer = new Uint8Array([
0x0b,
0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
]);
await this.#device.sendFeatureReport(resetCommandBuffer);
}
async getFirmwareVersion() {
let val;
try {
val = await this.#device.getFeatureReport(4, 32);
}
catch (_e) {
// In case some devices can't handle the different report length
val = await this.#device.getFeatureReport(4, 17);
}
const end = val.indexOf(0, 5);
return new TextDecoder('ascii').decode(val.subarray(5, end === -1 ? undefined : end));
}
async getAllFirmwareVersions() {
// Not supported for gen1 models
return {};
}
async getSerialNumber() {
try {
const val = await this.#device.getFeatureReport(3, 32);
// At some point the serials changed from 12 to 14 chars. Not sure if this
// aligned with a hardware revision or a firmware change.
// So while it is messy, we attempt to handle both cases here
let end = 5;
while (end < val.length && val[end] >= 0x20 && val[end] <= 0x7e)
end++;
return new TextDecoder('ascii').decode(val.subarray(5, end));
}
catch (_e) {
// In case some devices can't handle the different report length
const val = await this.#device.getFeatureReport(3, 17);
return new TextDecoder('ascii').decode(val.subarray(5, 17));
}
}
}
exports.Gen1PropertiesService = Gen1PropertiesService;
//# sourceMappingURL=gen1.js.map