@elgato-stream-deck/core
Version:
An npm module for interfacing with the Elgato Stream Deck
33 lines • 1.16 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateButtonsGrid = generateButtonsGrid;
exports.freezeDefinitions = freezeDefinitions;
function generateButtonsGrid(width, height, pixelSize, rtl = false, columnOffset = 0) {
const controls = [];
for (let row = 0; row < height; row++) {
for (let column = 0; column < width; column++) {
const index = row * width + column;
const hidIndex = rtl ? flipKeyIndex(width, index) : index;
controls.push({
type: 'button',
row,
column: column + columnOffset,
index,
hidIndex,
feedbackType: 'lcd',
pixelSize,
});
}
}
return controls;
}
function flipKeyIndex(columns, keyIndex) {
// Horizontal flip
const half = (columns - 1) / 2;
const diff = ((keyIndex % columns) - half) * -half;
return keyIndex + diff;
}
function freezeDefinitions(controls) {
return Object.freeze(controls.map((control) => Object.freeze(control)));
}
//# sourceMappingURL=controlsGenerator.js.map