diff --git a/libs/surfaces/mackie/button.h b/libs/surfaces/mackie/button.h index e6712234c0..e028628707 100644 --- a/libs/surfaces/mackie/button.h +++ b/libs/surfaces/mackie/button.h @@ -30,6 +30,15 @@ class Surface; class Button : public Control { public: + enum base_id_t { + recenable_base_id = 0x0, + solo_base_id = 0x08, + mute_base_id = 0x10, + select_base_id = 0x18, + vselect_base_id = 0x20, + fader_touch_base_id = 0xe0, + }; + enum ButtonID { Io = 0x28, Sends = 0x29, diff --git a/libs/surfaces/mackie/controls.h b/libs/surfaces/mackie/controls.h index 71f2b57c8f..e3fe7ca131 100644 --- a/libs/surfaces/mackie/controls.h +++ b/libs/surfaces/mackie/controls.h @@ -40,19 +40,6 @@ class Surface; class Control { public: - enum base_id_t { - /* ID's associated with pot (Controller) messages */ - pot_base_id = 0x30, - jog_base_id = 0x3c, - /* ID's associated with button (NoteOn) messages */ - recenable_button_base_id = 0x0, - solo_button_base_id = 0x08, - mute_button_base_id = 0x10, - select_button_base_id = 0x18, - vselect_button_base_id = 0x20, - fader_touch_button_base_id = 0xe0, - }; - Control (int id, std::string name, Group& group); virtual ~Control() {} diff --git a/libs/surfaces/mackie/jog.h b/libs/surfaces/mackie/jog.h index abccd01b06..a4a6b739de 100644 --- a/libs/surfaces/mackie/jog.h +++ b/libs/surfaces/mackie/jog.h @@ -28,6 +28,10 @@ namespace Mackie { class Jog : public Pot { public: + enum base_id_t { + base_id = 0x3c + }; + Jog (int id, std::string name, Group & group) : Pot (id, name, group) { diff --git a/libs/surfaces/mackie/pot.h b/libs/surfaces/mackie/pot.h index fc9858e24c..ccb6eec0f1 100644 --- a/libs/surfaces/mackie/pot.h +++ b/libs/surfaces/mackie/pot.h @@ -8,6 +8,10 @@ namespace Mackie { class Pot : public Control { public: + enum base_id_t { + base_id = 0x30, + }; + enum Mode { dot = 0, boost_cut = 1, diff --git a/libs/surfaces/mackie/strip.cc b/libs/surfaces/mackie/strip.cc index 7751eed04f..ddc982aeb6 100644 --- a/libs/surfaces/mackie/strip.cc +++ b/libs/surfaces/mackie/strip.cc @@ -92,26 +92,54 @@ void Strip::add (Control & control) { Group::add (control); - if (control.name() == "gain") { - _gain = reinterpret_cast(&control); - } else if (control.name() == "vpot") { - _vpot = reinterpret_cast(&control); - } else if (control.name() == "recenable") { - _recenable = reinterpret_cast(&control); - } else if (control.name() == "solo") { - _solo = reinterpret_cast(&control); - } else if (control.name() == "mute") { - _mute = reinterpret_cast(&control); - } else if (control.name() == "select") { - _select = reinterpret_cast(&control); - } else if (control.name() == "vselect") { - _vselect = reinterpret_cast(&control); - } else if (control.name() == "fader_touch") { - _fader_touch = reinterpret_cast(&control); - } else if (control.name() == "meter") { - _meter = reinterpret_cast(&control); - } else { - // relax + Fader* fader; + Pot* pot; + Button* button; + Meter* meter; + + if ((fader = dynamic_cast(&control)) != 0) { + + _gain = fader; + + } else if ((pot = dynamic_cast(&control)) != 0) { + + _vpot = pot; + + } else if ((button = dynamic_cast(&control)) != 0) { + + if (control.raw_id() >= Button::recenable_base_id && + control.raw_id() < Button::recenable_base_id + 8) { + + _recenable = button; + + } else if (control.raw_id() >= Button::mute_base_id && + control.raw_id() < Button::mute_base_id + 8) { + + _mute = button; + + } else if (control.raw_id() >= Button::solo_base_id && + control.raw_id() < Button::solo_base_id + 8) { + + _solo = button; + + } else if (control.raw_id() >= Button::select_base_id && + control.raw_id() < Button::select_base_id + 8) { + + _select = button; + + } else if (control.raw_id() >= Button::vselect_base_id && + control.raw_id() < Button::vselect_base_id + 8) { + + _vselect = button; + + } else if (control.raw_id() >= Button::fader_touch_base_id && + control.raw_id() < Button::fader_touch_base_id + 8) { + + _fader_touch = button; + } + + } else if ((meter = dynamic_cast(&control)) != 0) { + _meter = meter; } } @@ -417,33 +445,34 @@ Strip::handle_button (Button& button, ButtonState bs) } if (bs == press) { - if (button.raw_id() >= Control::recenable_button_base_id && - button.raw_id() < Control::recenable_button_base_id + 8) { + if (button.raw_id() >= Button::recenable_base_id && + button.raw_id() < Button::recenable_base_id + 8) { _route->set_record_enabled (!_route->record_enabled(), this); - } else if (button.raw_id() >= Control::mute_button_base_id && - button.raw_id() < Control::mute_button_base_id + 8) { + } else if (button.raw_id() >= Button::mute_base_id && + button.raw_id() < Button::mute_base_id + 8) { _route->set_mute (!_route->muted(), this); - } else if (button.raw_id() >= Control::solo_button_base_id && - button.raw_id() < Control::solo_button_base_id + 8) { + } else if (button.raw_id() >= Button::solo_base_id && + button.raw_id() < Button::solo_base_id + 8) { _route->set_solo (!_route->soloed(), this); - } else if (button.raw_id() >= Control::select_button_base_id && - button.raw_id() < Control::select_button_base_id + 8) { + } else if (button.raw_id() >= Button::select_base_id && + button.raw_id() < Button::select_base_id + 8) { _surface->mcp().select_track (_route); - } else if (button.raw_id() >= Control::vselect_button_base_id && - button.raw_id() < Control::vselect_button_base_id + 8) { + } else if (button.raw_id() >= Button::vselect_base_id && + button.raw_id() < Button::vselect_base_id + 8) { } } - if (button.name() == "fader_touch") { + if (button.raw_id() >= Button::fader_touch_base_id && + button.raw_id() < Button::fader_touch_base_id + 8) { DEBUG_TRACE (DEBUG::MackieControl, string_compose ("fader touch, press ? %1\n", (bs == press))); diff --git a/libs/surfaces/mackie/surface.cc b/libs/surfaces/mackie/surface.cc index 86c2378ee9..1662819160 100644 --- a/libs/surfaces/mackie/surface.cc +++ b/libs/surfaces/mackie/surface.cc @@ -231,13 +231,13 @@ Surface::init_controls() static StripControlDefinition mackie_strip_controls[] = { { "gain", 0, Fader::factory, }, - { "vpot", Control::pot_base_id, Pot::factory, }, - { "recenable", Control::recenable_button_base_id, Button::factory, }, - { "solo", Control::solo_button_base_id, Button::factory, }, - { "mute", Control::mute_button_base_id, Button::factory, }, - { "select", Control::select_button_base_id, Button::factory, }, - { "vselect", Control::vselect_button_base_id, Button::factory, }, - { "fader_touch", Control::fader_touch_button_base_id, Button::factory, }, + { "vpot", Pot::base_id, Pot::factory, }, + { "recenable", Button::recenable_base_id, Button::factory, }, + { "solo", Button::solo_base_id, Button::factory, }, + { "mute", Button::mute_base_id, Button::factory, }, + { "select", Button::select_base_id, Button::factory, }, + { "vselect", Button::vselect_base_id, Button::factory, }, + { "fader_touch", Button::fader_touch_base_id, Button::factory, }, { "meter", 0, Meter::factory, }, { "", 0, Button::factory, } }; @@ -385,9 +385,9 @@ Surface::handle_midi_controller_message (MIDI::Parser &, MIDI::EventTwoBytes* ev { DEBUG_TRACE (DEBUG::MackieControl, string_compose ("SurfacePort::handle_midi_controller %1 = %2\n", ev->controller_number, ev->value)); - Pot* pot = pots[Control::pot_base_id | ev->controller_number]; + Pot* pot = pots[ev->controller_number]; - if (!pot && ev->controller_number == Control::jog_base_id) { + if (!pot && ev->controller_number == Jog::base_id) { pot = dynamic_cast (controls_by_name["jog"]); }