From f9213a89d09a4199dc403184b1dd2fe634735e7a Mon Sep 17 00:00:00 2001 From: Silvio Ankermann Date: Fri, 16 Mar 2018 22:57:28 +0100 Subject: [PATCH] Roland DJ-202: Add range button --- res/controllers/Roland_DJ-202-scripts.js | 27 ++++++++++++++++++++++-- res/controllers/Roland_DJ-202.midi.xml | 9 ++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/res/controllers/Roland_DJ-202-scripts.js b/res/controllers/Roland_DJ-202-scripts.js index 1b7bde05715..d909ed764a5 100644 --- a/res/controllers/Roland_DJ-202-scripts.js +++ b/res/controllers/Roland_DJ-202-scripts.js @@ -1,5 +1,7 @@ var DJ202 = {}; +DJ202.tempoRange = [0.08, 0.16, 0.5] + DJ202.init = function () { DJ202.leftDeck = new DJ202.Deck([1,3], 0); @@ -61,9 +63,30 @@ DJ202.Deck = function (deckNumbers, offset) { this.keylock = new components.Button({ midi: [0x90 + offset, 0x0D], - type: components.Button.prototype.types.toggle, - inKey: 'keylock', + shiftOffset: 1, + shiftControl: true, + sendShifted: true, outKey: 'keylock', + currentRangeIndex: 0, + unshift: function () { + this.type = components.Button.prototype.types.toggle; + this.input = components.Button.prototype.input; + this.inKey = 'keylock'; + }, + shift: function () { + this.inKey = 'rateRange'; + this.type = undefined; + this.input = function (channel, control, value, status, group) { + if (this.isPress(channel, control, value, status)) { + print(this.currentRangeIndex) + this.currentRangeIndex++; + if (this.currentRangeIndex >= DJ202.tempoRange.length) { + this.currentRangeIndex = 0; + } + this.inSetValue(DJ202.tempoRange[this.currentRangeIndex]); + } + } + } }); engine.setValue(this.currentDeck, "rate_dir", -1); diff --git a/res/controllers/Roland_DJ-202.midi.xml b/res/controllers/Roland_DJ-202.midi.xml index 21cb81b4ed7..ec8827eceb7 100644 --- a/res/controllers/Roland_DJ-202.midi.xml +++ b/res/controllers/Roland_DJ-202.midi.xml @@ -94,6 +94,15 @@ + + [Channel1] + DJ202.leftDeck.keylock.input + 0x90 + 0x0E + + + + [Channel1] DJ202.leftDeck.hotcueButton[1].input