use of de.mossgrabers.framework.controller.hardware.IHwContinuousControl in project DrivenByMoss by git-moss.
the class UserView method bindCurrentPage.
/**
* Update the binding to the current page.
*/
private void bindCurrentPage() {
for (int i = 0; i < 8; i++) {
final ContinuousID faderID = ContinuousID.get(ContinuousID.FADER1, i);
final IHwContinuousControl continuous = this.surface.getContinuous(faderID);
if (continuous != null)
continuous.bind(this.userParameterBank.getItem(i));
}
}
use of de.mossgrabers.framework.controller.hardware.IHwContinuousControl in project DrivenByMoss by git-moss.
the class UserView method onDeactivate.
/**
* {@inheritDoc}
*/
@Override
public void onDeactivate() {
for (int i = 0; i < 8; i++) {
final ContinuousID faderID = ContinuousID.get(ContinuousID.FADER1, i);
final IHwContinuousControl continuous = this.surface.getContinuous(faderID);
if (continuous != null)
continuous.bind((IParameter) null);
}
this.surface.rebindGrid();
super.onDeactivate();
}
use of de.mossgrabers.framework.controller.hardware.IHwContinuousControl in project DrivenByMoss by git-moss.
the class AbstractControllerSetup method test.
/**
* {@inheritDoc}
*/
@Override
public void test(final TestCallback callback) {
final TestFramework framework = new TestFramework(this.host);
this.getSurfaces().forEach(surface -> {
framework.scheduleFunction(() -> this.host.println("Testing controller: " + this.getClass().getName()));
final ViewManager viewManager = surface.getViewManager();
final ModeManager modeManager = surface.getModeManager();
final int max = this.model.getValueChanger().getUpperBound() - 1;
for (final Views viewID : Views.values()) {
if (viewManager.get(viewID) == null)
continue;
for (final Modes modeID : Modes.values()) {
if (modeManager.get(modeID) == null)
continue;
framework.scheduleFunction(() -> {
this.host.println("- View " + viewID + " Mode " + modeID);
viewManager.setActive(viewID);
modeManager.setActive(modeID);
for (final ButtonID buttonID : ButtonID.values()) {
final IHwButton button = surface.getButton(buttonID);
if (button == null)
continue;
button.trigger(ButtonEvent.DOWN);
button.trigger(ButtonEvent.LONG);
button.trigger(ButtonEvent.UP);
}
for (final ContinuousID continuousID : ContinuousID.values()) {
final IHwContinuousControl continuous = surface.getContinuous(continuousID);
if (continuous == null)
continue;
final TriggerCommand touchCommand = continuous.getTouchCommand();
if (touchCommand != null) {
touchCommand.execute(ButtonEvent.DOWN, 127);
touchCommand.execute(ButtonEvent.LONG, 127);
touchCommand.execute(ButtonEvent.UP, 0);
}
final ContinuousCommand command = continuous.getCommand();
if (command != null) {
command.execute(0);
command.execute(max);
command.execute(max / 2);
}
final PitchbendCommand pitchbendCommand = continuous.getPitchbendCommand();
if (pitchbendCommand != null) {
pitchbendCommand.onPitchbend(0, 0);
pitchbendCommand.onPitchbend(0, 127);
pitchbendCommand.onPitchbend(0, 64);
}
}
});
}
}
});
callback.startTesting();
framework.executeScheduler(callback);
}
use of de.mossgrabers.framework.controller.hardware.IHwContinuousControl in project DrivenByMoss by git-moss.
the class Kontrol1ControlSurface method buttonChange.
/**
* {@inheritDoc}
*/
@Override
public void buttonChange(final int usbControlNumber, final boolean isPressed) {
final ButtonID buttonID = BUTTON_MAP.get(Integer.valueOf(usbControlNumber));
if (buttonID == null) {
// Simulate knob touch via CC
final ContinuousID continuousID = CONTINUOUS_MAP.get(Integer.valueOf(usbControlNumber));
if (continuousID == null)
return;
final IHwContinuousControl continuous = this.getContinuous(continuousID);
if (isPressed) {
if (!continuous.isTouched())
continuous.triggerTouch(true);
} else if (continuous.isTouched())
continuous.triggerTouch(false);
return;
}
// Simulate button press via CC
if (isPressed) {
if (!this.isPressed(buttonID))
this.getButton(buttonID).trigger(ButtonEvent.DOWN);
} else if (this.isPressed(buttonID))
this.getButton(buttonID).trigger(ButtonEvent.UP);
}
Aggregations