Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions qml/Engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ function restoreSavedSettings() {
const savedOutputs = JSON.parse(appSettings.savedOutputDevices);
for (let output of savedOutputs) {
createOutputDevice(output.name, output.host, output.port, output.type);
// Restore active state after creation
// Restore active state and source index offset after creation
const lastIdx = outputDevices.length - 1
if (output.sourceIndexOffset) {
outputDevices[lastIdx].sourceIndexOffset = output.sourceIndexOffset
}

if (output.active === false) {
outputDevices[outputDevices.length - 1].active = false;
updateOutputList();
outputDevices[lastIdx].active = false
}
updateOutputList();
}
} catch (e) {
console.log("Could not restore saved outputs:", e);
Expand All @@ -24,7 +29,8 @@ function saveOutputDevices() {
host: d.host,
port: d.port,
type: d.type,
active: d.active
active: d.active,
sourceIndexOffset: d.sourceIndexOffset || 0
};
});
appSettings.savedOutputDevices = JSON.stringify(toSave);
Expand Down Expand Up @@ -69,7 +75,8 @@ function onInputValueReceived(address, value) {
// Route to all active outputs
for (let output of outputDevices) {
if (output.active) {
const mapped = mapControlGRISMessage(command, sourceIndex, value, output.type);
const mapped = mapControlGRISMessage(command, sourceIndex + (output.sourceIndexOffset || 0), value, output.type);

if (mapped && mapped.length > 0) {
// Send each mapped message to output device
for (let msg of mapped) {
Expand Down Expand Up @@ -371,7 +378,8 @@ function createOutputDevice(name, host, port, type) {
host: host,
port: port,
type: type,
active: true
active: true,
sourceIndexOffset: 0
});

updateOutputList();
Expand Down
27 changes: 27 additions & 0 deletions qml/OutputSection.qml
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,33 @@ GroupBox {
font.pointSize: skin.fontSmall
}

Label {
text: "Offset:"
color: "#aaaaaa"
font.pixelSize: Math.min(11, window.height * 0.018)
}

TextField {
Layout.preferredWidth: 50
Layout.preferredHeight: 25
text: model.sourceIndexOffset !== undefined ? model.sourceIndexOffset : "0"
color: acceptableInput ? "#ffffff" : "#f00"
font.pixelSize: Math.min(11, window.height * 0.018)
horizontalAlignment: Text.AlignHCenter
validator: IntValidator { bottom: 0; top: 9999; }

background: Rectangle {
color: "#2a2a2a"
border.color: parent.focus ? "#5a5a5a" : "#4a4a4a"
radius: 2
}

onTextEdited: {
outputDevices[index].sourceIndexOffset = parseInt(text) || 0
Engine.saveOutputDevices()
}
}

Button {
Layout.preferredWidth: Math.max(60, Math.min(80, window.width * 0.08))
Layout.preferredHeight: 25
Expand Down
Loading