Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 42 additions & 23 deletions res/controllers/midi-components-0.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,12 @@
Component.call(this, options);
};
Button.prototype = new Component({
onlyOnPress: true,
types: {
push: 0,
toggle: 1,
powerWindow: 2,
},
type: 0,
on: 127,
off: 0,
// Time in milliseconds to distinguish a short press from a long press.
Expand All @@ -174,31 +179,26 @@
isPress: function (channel, control, value, status) {
return value > 0;
},
inValueScale: function () { return ! this.inGetValue(); },
input: function (channel, control, value, status, group) {
if (this.powerWindow) {
if (this.type === undefined || this.type === this.types.push) {
this.inSetValue(this.isPress(channel, control, value, status));
} else if (this.type === this.types.toggle) {
if (this.isPress(channel, control, value, status)) {
this.inToggle();
}
} else if (this.type === this.types.powerWindow) {
if (this.isPress(channel, control, value, status)) {
script.toggleControl(this.group, this.inKey);
this.inToggle();
this.longPressTimer = engine.beginTimer(this.longPressTimeout, function () {
this.isLongPressed = true;
}, true);
} else {
if (this.isLongPressed) {
script.toggleControl(this.group, this.inKey);
}
if (this.longPressTimer) {
this.inToggle();
} else {
engine.stopTimer(this.longPressTimer);
this.isLongPressed = false;
this.longPressTimer = 0;
}
}
} else {
if (this.onlyOnPress) {
if (this.isPress(channel, control, value, status)) {
this.inSetValue(this.inValueScale(value));
}
} else {
this.inSetValue(this.inValueScale(value));
this.isLongPressed = false;
}
}
},
Expand All @@ -217,6 +217,7 @@
shift: function () {
this.inKey = 'reverse';
},
type: Button.prototype.types.toggle,
outKey: 'play_indicator',
});

Expand All @@ -230,9 +231,6 @@
shift: function () {
this.inKey = 'start_stop';
},
input: function (channel, control, value, status, group) {
this.inSetValue(this.isPress(channel, control, value, status));
},
outKey: 'cue_indicator',
});

Expand All @@ -258,6 +256,7 @@
},
shift: function () {
this.inKey = 'quantize';
this.type = Button.prototype.types.toggle;
this.input = Button.prototype.input;
},
outKey: 'sync_enabled',
Expand Down Expand Up @@ -290,7 +289,6 @@
shift: function () {
this.inKey = 'hotcue_' + this.number + '_clear';
},
onlyOnPress: false,
});

var SamplerButton = function (options) {
Expand Down Expand Up @@ -354,7 +352,9 @@
options.group = '[EffectRack1_EffectUnit' + options.effectUnit + ']';
Button.call(this, options);
};
EffectAssignmentButton.prototype = new Button();
EffectAssignmentButton.prototype = new Button({
type: Button.prototype.types.toggle,
});

var Pot = function (options) {
Component.call(this, options);
Expand Down Expand Up @@ -496,6 +496,15 @@
shift: function () {
this.forEachComponent(function (component) {
if (typeof component.shift === 'function') {
if (component instanceof Button
&& (component.type === Button.prototype.types.push
|| component.type === undefined)
&& component.inKey !== undefined
&& component.input === Button.prototype.input) {
if (engine.getValue(component.group, component.inKey) !== 0) {
engine.setValue(component.group, component.inKey, 0);
}
}
component.shift();
}
// Set isShifted for child ComponentContainers forEachComponent is iterating through recursively
Expand All @@ -505,6 +514,15 @@
unshift: function () {
this.forEachComponent(function (component) {
if (typeof component.unshift === 'function') {
if (component instanceof Button
&& (component.type === Button.prototype.types.push
|| component.type === undefined)
&& component.inKey !== undefined
&& component.input === Button.prototype.input) {
if (engine.getValue(component.group, component.inKey) !== 0) {
engine.setValue(component.group, component.inKey, 0);
}
}
component.unshift();
}
// Set isShifted for child ComponentContainers forEachComponent is iterating through recursively
Expand Down Expand Up @@ -721,6 +739,7 @@
this[channel] = new Button({
group: eu.group,
key: 'group_[' + channel + ']_enable',
type: Button.prototype.types.toggle,
outConnect: false,
});
};
Expand Down Expand Up @@ -807,7 +826,7 @@
this.EffectEnableButton.prototype = new Button({
stopEffectFocusChooseMode: function () {
this.inKey = 'enabled';
this.powerWindow = true;
this.type = Button.prototype.types.powerWindow;
this.input = Button.prototype.input;

this.outKey = 'enabled';
Expand Down