From eec08dcbafcf374954ffd400a52886216cc74e88 Mon Sep 17 00:00:00 2001 From: Antoine C Date: Mon, 16 Dec 2024 22:58:12 +0000 Subject: [PATCH] S4MK3: stop wheel led blinking when track is over/stopped --- res/controllers/Traktor-Kontrol-S4-MK3.js | 24 +++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/res/controllers/Traktor-Kontrol-S4-MK3.js b/res/controllers/Traktor-Kontrol-S4-MK3.js index 8c25d7ebb0ac..2b5b0b09986f 100644 --- a/res/controllers/Traktor-Kontrol-S4-MK3.js +++ b/res/controllers/Traktor-Kontrol-S4-MK3.js @@ -2523,8 +2523,25 @@ class S4Mk3Deck extends Deck { this.wheelLED = new Component({ deck: this, lastPos: 0, - outKey: "playposition", - output: function(fractionOfTrack) { + outConnect: function() { + if (this.group !== undefined) { + const connection0 = engine.makeConnection(this.group, "playposition", (position) => this.output.bind(this)(position, true)); + // This is useful for case where effect would have been fully disabled in Mixxx. This appears to be the case during unit tests. + if (connection0) { + this.outConnections[0] = connection0; + } else { + console.warn(`Unable to connect ${this.group}.playposition' to the controller output. The control appears to be unavailable.`); + } + const connection1 = engine.makeConnection(this.group, "play", (play) => this.output.bind(this)(engine.getValue(this.group, "playposition"), play)); + // This is useful for case where effect would have been fully disabled in Mixxx. This appears to be the case during unit tests. + if (connection1) { + this.outConnections[0] = connection1; + } else { + console.warn(`Unable to connect ${this.group}.play' to the controller output. The control appears to be unavailable.`); + } + } + }, + output: function(fractionOfTrack, playstate) { if (this.deck.wheelMode > wheelModes.motor) { return; } @@ -2568,7 +2585,7 @@ class S4Mk3Deck extends Deck { const wheelOutput = new Uint8Array(40).fill(0); wheelOutput[0] = decks[0] - 1; - if (engine.getValue(this.group, "end_of_track") && WheelLedBlinkOnTrackEnd) { + if (playstate && fractionOfTrack < 1 && engine.getValue(this.group, "end_of_track") && WheelLedBlinkOnTrackEnd) { wheelOutput[1] = wheelLEDmodes.ringFlash; } else { wheelOutput[1] = wheelLEDmodes.spot; @@ -2578,7 +2595,6 @@ class S4Mk3Deck extends Deck { wheelOutput[4] = this.color + Button.prototype.brightnessOn; controller.sendOutputReport(50, wheelOutput.buffer, true); - } });