From 265f433cf9b82ab1d075d0e95bf2234e4e8b9685 Mon Sep 17 00:00:00 2001 From: Owen Williams Date: Sat, 6 Apr 2024 17:18:09 -0400 Subject: [PATCH] Traktor S3: Load controller defaults after loading the controller report. --- .../Traktor-Kontrol-S3-hid-scripts.js | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/res/controllers/Traktor-Kontrol-S3-hid-scripts.js b/res/controllers/Traktor-Kontrol-S3-hid-scripts.js index c7e9d3b8ef1..9cc51b780fe 100644 --- a/res/controllers/Traktor-Kontrol-S3-hid-scripts.js +++ b/res/controllers/Traktor-Kontrol-S3-hid-scripts.js @@ -297,6 +297,11 @@ TraktorS3.Controller = class { TraktorS3.incomingData([inputReportIdx, ...reportData]); } + // The controller state may have overridden our preferred default values, so set them now. + for (const ch in this.Channels) { + TraktorS3.Channel.prototype.setDefaults(ch); + } + // NOTE: Soft takeovers must only be enabled after setting the initial // value, or the above line won't have any effect for (let ch = 1; ch <= 4; ch++) { @@ -1610,6 +1615,17 @@ TraktorS3.Channel = class { this.clipConnection = {}; this.hotcueCallbacks = []; + // The visual order of the channels in Mixxx is 4, 2, 1, 3, but we want + // the crossfader assignments array to match the visual layout + const visualChannelIndex = {3: 0, 1: 1, 2: 2, 4: 3}[this.groupNumber]; + if (TraktorS3.DefaultCrossfaderAssignments[visualChannelIndex] !== null) { + // This goes 0-2 for left, right, and center, but having the values + // in this script's config be -1, 0, and 1 makes much more sense + engine.setValue(group, "orientation", TraktorS3.DefaultCrossfaderAssignments[visualChannelIndex] + 1); + } + } + + setDefaults(group) { // The script by default doesn't change any of the deck's settings, but it's // useful to be able to initialize these settings to your preferences when // you turn on the controller @@ -1628,14 +1644,6 @@ TraktorS3.Channel = class { if (TraktorS3.DefaultKeylockEnabled !== null) { engine.setValue(group, "keylock", TraktorS3.DefaultKeylockEnabled); } - // The visual order of the channels in Mixxx is 4, 2, 1, 3, but we want - // the crossfader assignments array to match the visual layout - const visualChannelIndex = {3: 0, 1: 1, 2: 2, 4: 3}[this.groupNumber]; - if (TraktorS3.DefaultCrossfaderAssignments[visualChannelIndex] !== null) { - // This goes 0-2 for left, right, and center, but having the values - // in this script's config be -1, 0, and 1 makes much more sense - engine.setValue(group, "orientation", TraktorS3.DefaultCrossfaderAssignments[visualChannelIndex] + 1); - } } trackLoadedHandler() {