diff --git a/res/controllers/Roland_DJ-505-scripts.js b/res/controllers/Roland_DJ-505-scripts.js index 476552f8d01..c1ed44d10e9 100644 --- a/res/controllers/Roland_DJ-505-scripts.js +++ b/res/controllers/Roland_DJ-505-scripts.js @@ -599,8 +599,12 @@ DJ505.Deck = function(deckNumbers, offset) { this.sync = new components.Button({ midi: [0x90 + offset, 0x02], group: "[Channel" + deckNumbers + "]", - outKey: "sync_enabled", + outKey: "sync_mode", + flickerState: false, output: function(value, _group, _control) { + if (value === 3) { + value = this.flickerState; + } midi.sendShortMsg(this.midi[0], value ? 0x02 : 0x03, this.on); }, input: function(channel, control, value, _status, _group) { @@ -621,7 +625,15 @@ DJ505.Deck = function(deckNumbers, offset) { script.triggerControl(this.group, "beatsync", 1); }; this.onLongPress = function() { - engine.setValue(this.group, "sync_enabled", 1); + if (engine.getValue(this.group, "sync_enabled")) { + // If already explicit leader, reset explicit state + // (setting it to 0 may still make it implicit leader and + // immediately resetting it to 1). + var value = (engine.getValue(this.group, "sync_master") === 2) ? 0 : 2; + engine.setValue(this.group, "sync_master", value); + } else { + engine.setValue(this.group, "sync_enabled", 1); + } }; }, shift: function() { @@ -632,6 +644,20 @@ DJ505.Deck = function(deckNumbers, offset) { script.toggleControl(this.group, "quantize"); }; }, + connect: function() { + components.Button.prototype.connect.call(this); // call parent connect + this.flickerTimer = engine.beginTimer(500, function() { + this.flickerState = !this.flickerState; + this.trigger(); + }.bind(this)); + }, + disconnect: function() { + components.Button.prototype.disconnect.call(this); // call parent disconnect + if (this.flickerTimer) { + engine.stopTimer(this.flickerTimer); + this.flickerTimer = 0; + } + }, }); // =============================== MIXER ====================================