Skip to content

Commit

Permalink
Merge pull request mixxxdj#13425 from christophehenry/dont-return-on-…
Browse files Browse the repository at this point in the history
…no-deck-JogWheelBasic

Don't return in JogWheelBasic on deck absent in option
  • Loading branch information
Swiftb0y authored Jul 24, 2024
2 parents fb79fc2 + 93248e2 commit 02a6f26
Showing 1 changed file with 51 additions and 17 deletions.
68 changes: 51 additions & 17 deletions res/controllers/midi-components-0.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -762,16 +762,50 @@
});

const JogWheelBasic = function(options) {
if (options.deck !== undefined && options.group !== undefined) {
console.warn(
"options.deck and option.group are both set; " +
"options.deck will take priority"
);
}

const deck = options.deck;
const group = script.deckFromGroup(options.group);
delete options.deck;
delete options.group;

Component.call(this, options);

if (!Number.isInteger(this.deck)) {
console.warn("missing scratch deck");
return;
}
if (this.deck <= 0) {
console.warn("invalid deck number: " + this.deck);
return;
this._deck = undefined;

Object.defineProperties(this, {
deck: {
get: () => this._deck,
set: (value) => {
if (Number.isInteger(value) && value > 0) {
this._deck = value;
this.reset();
}
},
},
group: {
get: () => `[Channel${deck}]`,
set: value => {
const deck = script.deckFromGroup(value);
if (deck > 0) {
this._deck = deck;
this.reset();
}
},
}
});

this.deck = deck;

if (!this.deck) {
this.group = group; // try setting deck from group
}

if (!Number.isInteger(this.wheelResolution)) {
console.warn("missing jogwheel resolution");
return;
Expand All @@ -786,9 +820,7 @@
if (!Number.isFinite(this.rpm)) {
this.rpm = 33 + 1/3;
}
if (this.group === undefined) {
this.group = "[Channel" + this.deck + "]";
}

this.inKey = "jog";
};

Expand All @@ -800,6 +832,10 @@
return value < 0x40 ? value : value - (this.max + 1);
},
inputWheel: function(_channel, _control, value, _status, _group) {
if (!this.deck) {
return;
}

value = this.inValueScale(value);
if (engine.isScratching(this.deck)) {
engine.scratchTick(this.deck, value);
Expand All @@ -808,6 +844,10 @@
}
},
inputTouch: function(channel, control, value, status, _group) {
if (!this.deck) {
return;
}

if (this.isPress(channel, control, value, status) && this.vinylMode) {
engine.scratchEnable(this.deck,
this.wheelResolution,
Expand All @@ -822,13 +862,7 @@
throw "Called wrong input handler for " + status + ": " + control + ".\n" +
"Please bind jogwheel-related messages to inputWheel and inputTouch!\n";
},
// this is needed for features such as "deck switching" that work
// by changing the component group. It is assumed they call `connect`
// afterwards.
connect: function() {
Component.prototype.connect.call(this);
this.deck = parseInt(script.channelRegEx.exec(this.group)[1]);
}
reset() {},
});

const EffectUnit = function(unitNumbers, allowFocusWhenParametersHidden, colors) {
Expand Down

0 comments on commit 02a6f26

Please sign in to comment.