Search in sources :

Example 16 with IHwButton

use of de.mossgrabers.framework.controller.hardware.IHwButton in project DrivenByMoss by git-moss.

the class AbstractControllerSetup method addButtons.

/**
 * Create multiple hardware button proxies. Each button is matched by a specific value. The
 * first value is startValue, which gets increased by one for the other buttons.
 *
 * @param surface The control surface
 * @param startValue The first matched value
 * @param numberOfValues The number of buttons
 * @param firstButtonID The first ID of the buttons
 * @param label The label of the button
 * @param supplier Callback for retrieving the state of the light
 * @param midiChannel The MIDI channel
 * @param midiControl The MIDI CC or note
 * @param command The command to bind
 * @param colorIds The color IDs to map to the states
 */
protected void addButtons(final S surface, final int startValue, final int numberOfValues, final ButtonID firstButtonID, final String label, final TriggerCommand command, final int midiChannel, final int midiControl, final IntConsumerSupplier supplier, final String... colorIds) {
    for (int i = 0; i < numberOfValues; i++) {
        final int index = i;
        final ButtonID buttonID = ButtonID.get(firstButtonID, i);
        final IHwButton button = surface.createButton(buttonID, label + " " + (i + 1));
        button.bind((event, velocity) -> command.execute(event, index));
        if (midiControl < 0)
            continue;
        button.bind(surface.getMidiInput(), this.getTriggerBindType(buttonID), midiChannel, midiControl, startValue + i);
        final IntSupplier supp;
        if (supplier == null)
            supp = () -> button.isPressed() ? 1 : 0;
        else
            supp = () -> supplier.process(index);
        this.addLight(surface, null, buttonID, button, midiChannel, midiControl, supp, colorIds);
    }
}
Also used : IntSupplier(java.util.function.IntSupplier) IHwButton(de.mossgrabers.framework.controller.hardware.IHwButton)

Example 17 with IHwButton

use of de.mossgrabers.framework.controller.hardware.IHwButton in project DrivenByMoss by git-moss.

the class AbstractView method simulateShiftedButtonPress.

/**
 * Simulate pressing a button with combination of the shift button by sending a button down and
 * up event.
 *
 * @param buttonID The ID of the button to trigger
 */
protected void simulateShiftedButtonPress(final ButtonID buttonID) {
    final IHwButton button = this.surface.getButton(buttonID);
    final AbstractTriggerCommand<?, ?> triggerCommand = (AbstractTriggerCommand<?, ?>) button.getCommand();
    triggerCommand.executeShifted(ButtonEvent.DOWN);
    triggerCommand.executeShifted(ButtonEvent.UP);
}
Also used : AbstractTriggerCommand(de.mossgrabers.framework.command.core.AbstractTriggerCommand) IHwButton(de.mossgrabers.framework.controller.hardware.IHwButton)

Aggregations

IHwButton (de.mossgrabers.framework.controller.hardware.IHwButton)17 ButtonID (de.mossgrabers.framework.controller.ButtonID)4 IStepInfo (de.mossgrabers.framework.daw.IStepInfo)4 StepState (de.mossgrabers.framework.daw.StepState)4 IntSupplier (java.util.function.IntSupplier)4 BindType (de.mossgrabers.framework.controller.hardware.BindType)3 IMidiInput (de.mossgrabers.framework.daw.midi.IMidiInput)3 AbstractTriggerCommand (de.mossgrabers.framework.command.core.AbstractTriggerCommand)2 ContinuousCommand (de.mossgrabers.framework.command.core.ContinuousCommand)2 IHwLight (de.mossgrabers.framework.controller.hardware.IHwLight)2 IHost (de.mossgrabers.framework.daw.IHost)2 IMidiOutput (de.mossgrabers.framework.daw.midi.IMidiOutput)2 ModeManager (de.mossgrabers.framework.featuregroup.ModeManager)2 Views (de.mossgrabers.framework.view.Views)2 Color (com.bitwig.extension.api.Color)1 HardwareButton (com.bitwig.extension.controller.api.HardwareButton)1 HardwareLightVisualState (com.bitwig.extension.controller.api.HardwareLightVisualState)1 HardwareSurface (com.bitwig.extension.controller.api.HardwareSurface)1 InternalHardwareLightState (com.bitwig.extension.controller.api.InternalHardwareLightState)1 MultiStateHardwareLight (com.bitwig.extension.controller.api.MultiStateHardwareLight)1