use std::future::Future;
use crate::{DeviceDescriptor, PortIndex};
#[cfg(feature = "midi")]
pub(super) mod midi;
#[cfg(feature = "controller-thread")]
pub(super) mod thread;
pub type BoxedControllerTask = Box<dyn Future<Output = ()> + Send + 'static>;
pub trait ControllerTypes {
type Context;
type InputEvent: std::fmt::Debug;
type ControlAction;
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ControllerDescriptor {
pub num_decks: u8,
pub num_virtual_decks: u8,
pub num_mixer_channels: u8,
pub num_pads_per_deck: u8,
pub num_effect_units: u8,
}
pub trait Controller {
type Types: ControllerTypes;
#[must_use]
fn device_descriptor(&self) -> DeviceDescriptor;
#[must_use]
fn controller_descriptor(&self) -> ControllerDescriptor;
#[must_use]
fn attach_context_listener(
&mut self,
context: &<Self::Types as ControllerTypes>::Context,
) -> Option<BoxedControllerTask>;
#[must_use]
fn input_port_index(&self) -> PortIndex {
PortIndex::INVALID
}
#[must_use]
fn map_input_event(
&mut self,
event: <Self::Types as ControllerTypes>::InputEvent,
) -> Option<<Self::Types as ControllerTypes>::ControlAction> {
log::debug!("Unmapped input event: {event:?}");
None
}
}