Skip to main content

DeviceCapabilities

Struct DeviceCapabilities 

Source
pub struct DeviceCapabilities { /* private fields */ }
Expand description

Addressable controls and family counts exposed by one connected device.

Implementations§

Source§

impl DeviceCapabilities

Source

pub fn model(&self) -> DeviceModel

Detected hardware model.

Examples found in repository?
examples/usb_monitor.rs (line 45)
11fn main() -> Result<(), Box<dyn std::error::Error>> {
12    let path = env::args_os()
13        .nth(1)
14        .ok_or("usage: usb_monitor <path-to-hidraw>")?;
15    let file = OpenOptions::new().read(true).write(true).open(path)?;
16
17    // The device stays silent until a client requests its initial full sync.
18    (&file).write_all(&usb::Packet::new(usb::HANDSHAKE_BODY.to_vec()).to_bytes())?;
19
20    let mut session = ProtocolSession::new();
21    let mut buffered = Vec::new();
22    let mut report = [0_u8; usb::REPORT_SIZE];
23    loop {
24        let read = (&file).read(&mut report)?;
25        buffered.extend_from_slice(&report[..read]);
26
27        loop {
28            let len = match usb::scan_frame(&buffered) {
29                FrameScan::Complete { len } => len,
30                FrameScan::Incomplete => break,
31                FrameScan::Desync => {
32                    buffered.drain(..usb::REPORT_SIZE.min(buffered.len()));
33                    continue;
34                }
35            };
36            let (packet, consumed) = usb::Packet::from_bytes(&buffered[..len])
37                .ok_or("USB scanner returned an invalid packet")?;
38            buffered.drain(..consumed);
39
40            match session.ingest(&packet.payload)? {
41                SessionUpdate::Ready { initial_events } => {
42                    let capabilities = session.capabilities().unwrap();
43                    println!(
44                        "connected: {} fw {} ({} faders, {} sources, {} mixes)",
45                        capabilities.model(),
46                        capabilities.firmware().unwrap_or("unknown"),
47                        capabilities.faders().len(),
48                        capabilities.sources().len(),
49                        capabilities.mix_outputs().len(),
50                    );
51                    println!("initial state: {} typed events", initial_events.len());
52                }
53                SessionUpdate::Event(event) => println!("{event:?}"),
54                SessionUpdate::NeedsFullSync => {
55                    eprintln!("layout changed, requesting a fresh full sync");
56                    (&file)
57                        .write_all(&usb::Packet::new(usb::HANDSHAKE_BODY.to_vec()).to_bytes())?;
58                }
59            }
60        }
61    }
62}
Source

pub fn firmware(&self) -> Option<&str>

Firmware version reported by the full sync, when present.

Examples found in repository?
examples/usb_monitor.rs (line 46)
11fn main() -> Result<(), Box<dyn std::error::Error>> {
12    let path = env::args_os()
13        .nth(1)
14        .ok_or("usage: usb_monitor <path-to-hidraw>")?;
15    let file = OpenOptions::new().read(true).write(true).open(path)?;
16
17    // The device stays silent until a client requests its initial full sync.
18    (&file).write_all(&usb::Packet::new(usb::HANDSHAKE_BODY.to_vec()).to_bytes())?;
19
20    let mut session = ProtocolSession::new();
21    let mut buffered = Vec::new();
22    let mut report = [0_u8; usb::REPORT_SIZE];
23    loop {
24        let read = (&file).read(&mut report)?;
25        buffered.extend_from_slice(&report[..read]);
26
27        loop {
28            let len = match usb::scan_frame(&buffered) {
29                FrameScan::Complete { len } => len,
30                FrameScan::Incomplete => break,
31                FrameScan::Desync => {
32                    buffered.drain(..usb::REPORT_SIZE.min(buffered.len()));
33                    continue;
34                }
35            };
36            let (packet, consumed) = usb::Packet::from_bytes(&buffered[..len])
37                .ok_or("USB scanner returned an invalid packet")?;
38            buffered.drain(..consumed);
39
40            match session.ingest(&packet.payload)? {
41                SessionUpdate::Ready { initial_events } => {
42                    let capabilities = session.capabilities().unwrap();
43                    println!(
44                        "connected: {} fw {} ({} faders, {} sources, {} mixes)",
45                        capabilities.model(),
46                        capabilities.firmware().unwrap_or("unknown"),
47                        capabilities.faders().len(),
48                        capabilities.sources().len(),
49                        capabilities.mix_outputs().len(),
50                    );
51                    println!("initial state: {} typed events", initial_events.len());
52                }
53                SessionUpdate::Event(event) => println!("{event:?}"),
54                SessionUpdate::NeedsFullSync => {
55                    eprintln!("layout changed, requesting a fresh full sync");
56                    (&file)
57                        .write_all(&usb::Packet::new(usb::HANDSHAKE_BODY.to_vec()).to_bytes())?;
58                }
59            }
60        }
61    }
62}
Source

pub fn faders(&self) -> &[Fader]

Addressable fader strips in protocol order.

Examples found in repository?
examples/usb_monitor.rs (line 47)
11fn main() -> Result<(), Box<dyn std::error::Error>> {
12    let path = env::args_os()
13        .nth(1)
14        .ok_or("usage: usb_monitor <path-to-hidraw>")?;
15    let file = OpenOptions::new().read(true).write(true).open(path)?;
16
17    // The device stays silent until a client requests its initial full sync.
18    (&file).write_all(&usb::Packet::new(usb::HANDSHAKE_BODY.to_vec()).to_bytes())?;
19
20    let mut session = ProtocolSession::new();
21    let mut buffered = Vec::new();
22    let mut report = [0_u8; usb::REPORT_SIZE];
23    loop {
24        let read = (&file).read(&mut report)?;
25        buffered.extend_from_slice(&report[..read]);
26
27        loop {
28            let len = match usb::scan_frame(&buffered) {
29                FrameScan::Complete { len } => len,
30                FrameScan::Incomplete => break,
31                FrameScan::Desync => {
32                    buffered.drain(..usb::REPORT_SIZE.min(buffered.len()));
33                    continue;
34                }
35            };
36            let (packet, consumed) = usb::Packet::from_bytes(&buffered[..len])
37                .ok_or("USB scanner returned an invalid packet")?;
38            buffered.drain(..consumed);
39
40            match session.ingest(&packet.payload)? {
41                SessionUpdate::Ready { initial_events } => {
42                    let capabilities = session.capabilities().unwrap();
43                    println!(
44                        "connected: {} fw {} ({} faders, {} sources, {} mixes)",
45                        capabilities.model(),
46                        capabilities.firmware().unwrap_or("unknown"),
47                        capabilities.faders().len(),
48                        capabilities.sources().len(),
49                        capabilities.mix_outputs().len(),
50                    );
51                    println!("initial state: {} typed events", initial_events.len());
52                }
53                SessionUpdate::Event(event) => println!("{event:?}"),
54                SessionUpdate::NeedsFullSync => {
55                    eprintln!("layout changed, requesting a fresh full sync");
56                    (&file)
57                        .write_all(&usb::Packet::new(usb::HANDSHAKE_BODY.to_vec()).to_bytes())?;
58                }
59            }
60        }
61    }
62}
Source

pub fn sources(&self) -> &[Source]

Addressable input sources in protocol order.

Examples found in repository?
examples/usb_monitor.rs (line 48)
11fn main() -> Result<(), Box<dyn std::error::Error>> {
12    let path = env::args_os()
13        .nth(1)
14        .ok_or("usage: usb_monitor <path-to-hidraw>")?;
15    let file = OpenOptions::new().read(true).write(true).open(path)?;
16
17    // The device stays silent until a client requests its initial full sync.
18    (&file).write_all(&usb::Packet::new(usb::HANDSHAKE_BODY.to_vec()).to_bytes())?;
19
20    let mut session = ProtocolSession::new();
21    let mut buffered = Vec::new();
22    let mut report = [0_u8; usb::REPORT_SIZE];
23    loop {
24        let read = (&file).read(&mut report)?;
25        buffered.extend_from_slice(&report[..read]);
26
27        loop {
28            let len = match usb::scan_frame(&buffered) {
29                FrameScan::Complete { len } => len,
30                FrameScan::Incomplete => break,
31                FrameScan::Desync => {
32                    buffered.drain(..usb::REPORT_SIZE.min(buffered.len()));
33                    continue;
34                }
35            };
36            let (packet, consumed) = usb::Packet::from_bytes(&buffered[..len])
37                .ok_or("USB scanner returned an invalid packet")?;
38            buffered.drain(..consumed);
39
40            match session.ingest(&packet.payload)? {
41                SessionUpdate::Ready { initial_events } => {
42                    let capabilities = session.capabilities().unwrap();
43                    println!(
44                        "connected: {} fw {} ({} faders, {} sources, {} mixes)",
45                        capabilities.model(),
46                        capabilities.firmware().unwrap_or("unknown"),
47                        capabilities.faders().len(),
48                        capabilities.sources().len(),
49                        capabilities.mix_outputs().len(),
50                    );
51                    println!("initial state: {} typed events", initial_events.len());
52                }
53                SessionUpdate::Event(event) => println!("{event:?}"),
54                SessionUpdate::NeedsFullSync => {
55                    eprintln!("layout changed, requesting a fresh full sync");
56                    (&file)
57                        .write_all(&usb::Packet::new(usb::HANDSHAKE_BODY.to_vec()).to_bytes())?;
58                }
59            }
60        }
61    }
62}
Source

pub fn mix_outputs(&self) -> &[MixOutput]

Addressable mix outputs in protocol order.

Examples found in repository?
examples/usb_monitor.rs (line 49)
11fn main() -> Result<(), Box<dyn std::error::Error>> {
12    let path = env::args_os()
13        .nth(1)
14        .ok_or("usage: usb_monitor <path-to-hidraw>")?;
15    let file = OpenOptions::new().read(true).write(true).open(path)?;
16
17    // The device stays silent until a client requests its initial full sync.
18    (&file).write_all(&usb::Packet::new(usb::HANDSHAKE_BODY.to_vec()).to_bytes())?;
19
20    let mut session = ProtocolSession::new();
21    let mut buffered = Vec::new();
22    let mut report = [0_u8; usb::REPORT_SIZE];
23    loop {
24        let read = (&file).read(&mut report)?;
25        buffered.extend_from_slice(&report[..read]);
26
27        loop {
28            let len = match usb::scan_frame(&buffered) {
29                FrameScan::Complete { len } => len,
30                FrameScan::Incomplete => break,
31                FrameScan::Desync => {
32                    buffered.drain(..usb::REPORT_SIZE.min(buffered.len()));
33                    continue;
34                }
35            };
36            let (packet, consumed) = usb::Packet::from_bytes(&buffered[..len])
37                .ok_or("USB scanner returned an invalid packet")?;
38            buffered.drain(..consumed);
39
40            match session.ingest(&packet.payload)? {
41                SessionUpdate::Ready { initial_events } => {
42                    let capabilities = session.capabilities().unwrap();
43                    println!(
44                        "connected: {} fw {} ({} faders, {} sources, {} mixes)",
45                        capabilities.model(),
46                        capabilities.firmware().unwrap_or("unknown"),
47                        capabilities.faders().len(),
48                        capabilities.sources().len(),
49                        capabilities.mix_outputs().len(),
50                    );
51                    println!("initial state: {} typed events", initial_events.len());
52                }
53                SessionUpdate::Event(event) => println!("{event:?}"),
54                SessionUpdate::NeedsFullSync => {
55                    eprintln!("layout changed, requesting a fresh full sync");
56                    (&file)
57                        .write_all(&usb::Packet::new(usb::HANDSHAKE_BODY.to_vec()).to_bytes())?;
58                }
59            }
60        }
61    }
62}
Source

pub fn supports_fader(&self, fader: Fader) -> bool

Whether this exact device topology contains the named fader.

Source

pub fn channel_count(&self) -> u8

Source

pub fn input_source_count(&self) -> u8

Source

pub fn headphone_count(&self) -> u8

Source

pub fn physical_combo_count(&self) -> u8

Physical analog combo XLR preamp jack count on the physical device: 2 on Duo, 4 on Pro II.

Source

pub fn physical_headphone_count(&self) -> u8

Physical headphone output jack count on the physical device: 2 on Duo, 4 on Pro II.

Source

pub fn effects_count(&self) -> u8

Source

pub fn pad_count(&self) -> u8

Source

pub fn sip_call_slots_count(&self) -> u8

Source

pub fn sip_registration_count(&self) -> u8

Source

pub fn is_in_setup(&self) -> bool

Whether the device is currently in initial setup mode (outputs or controls disabled).

Trait Implementations§

Source§

impl Clone for DeviceCapabilities

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DeviceCapabilities

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for DeviceCapabilities

Source§

impl PartialEq for DeviceCapabilities

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for DeviceCapabilities

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.