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);
}
}
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);
}
Aggregations