1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
use crate::routing::InputDevice;
use goxlr_types::{ChannelName, EncoderName, FaderName};
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum Command {
ResetCommandIndex,
SystemInfo(SystemInfoCommand),
SetChannelState(ChannelName),
SetChannelVolume(ChannelName),
SetEncoderValue(EncoderName),
SetEncoderMode(EncoderName),
SetFader(FaderName),
SetRouting(InputDevice),
SetButtonStates(),
SetEffectParameters,
SetMicrophoneParameters,
GetMicrophoneLevel,
SetColourMap(),
SetFaderDisplayMode(FaderName),
SetScribble(FaderName),
GetButtonStates,
GetHardwareInfo(HardwareInfoCommand),
}
impl Command {
pub fn command_id(&self) -> u32 {
match self {
Command::ResetCommandIndex => 0,
Command::SystemInfo(sub) => sub.id(),
Command::SetChannelState(channel) => (0x809 << 12) | *channel as u32,
Command::SetChannelVolume(channel) => (0x806 << 12) | *channel as u32,
Command::SetEncoderValue(encoder) => (0x80a << 12) | *encoder as u32,
Command::SetEncoderMode(encoder) => (0x811 << 12) | *encoder as u32,
Command::SetFader(fader) => (0x805 << 12) | *fader as u32,
Command::SetRouting(input_device) => (0x804 << 12) | input_device.id() as u32,
Command::SetColourMap() => (0x803 << 12),
Command::SetButtonStates() => (0x808 << 12),
Command::SetFaderDisplayMode(fader) => (0x814 << 12) | *fader as u32,
Command::SetScribble(fader) => (0x802 << 12) | *fader as u32,
Command::GetButtonStates => (0x800 << 12),
Command::GetHardwareInfo(sub) => (0x80f << 12) | *sub as u32,
Command::GetMicrophoneLevel => (0x80c << 12),
Command::SetMicrophoneParameters => (0x80b << 12),
Command::SetEffectParameters => (0x801 << 12),
}
}
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum SystemInfoCommand {
FirmwareVersion,
SupportsDCPCategory,
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum HardwareInfoCommand {
FirmwareVersion = 0,
SerialNumber = 1,
}
impl SystemInfoCommand {
pub fn id(&self) -> u32 {
match self {
SystemInfoCommand::FirmwareVersion => 2,
SystemInfoCommand::SupportsDCPCategory => 1,
}
}
}