diff --git a/libs/surfaces/mackie/mackie_control_protocol.cc b/libs/surfaces/mackie/mackie_control_protocol.cc index d8c89ff37e..baf74596fa 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.cc +++ b/libs/surfaces/mackie/mackie_control_protocol.cc @@ -541,6 +541,12 @@ MackieControlProtocol::get_state() os << _current_initial_bank; node->add_property (X_("bank"), os.str()); + for (uint32_t n = 0; n < 16; ++n) { + ostringstream s; + s << string_compose ("f%1-action", n+1); + node->add_property (s.str().c_str(), f_action (n)); + } + return *node; } @@ -550,21 +556,27 @@ MackieControlProtocol::set_state (const XMLNode & node, int /*version*/) DEBUG_TRACE (DEBUG::MackieControl, string_compose ("MackieControlProtocol::set_state: active %1\n", _active)); int retval = 0; - + const XMLProperty* prop; // fetch current bank - if (node.property (X_("bank")) != 0) { - string bank = node.property (X_("bank"))->value(); - try { - set_active (true); - uint32_t new_bank = atoi (bank.c_str()); - if (_current_initial_bank != new_bank) { - switch_banks (new_bank); - } + if ((prop = node.property (X_("bank"))) != 0) { + string bank = prop->value(); + set_active (true); + uint32_t new_bank = atoi (bank.c_str()); + if (_current_initial_bank != new_bank) { + switch_banks (new_bank); } - catch (exception & e) { - DEBUG_TRACE (DEBUG::MackieControl, string_compose ("exception in MackieControlProtocol::set_state: %1\n", e.what())); - return -1; + } + + _f_actions.clear (); + _f_actions.resize (16); + + for (uint32_t n = 0; n < 16; ++n) { + ostringstream s; + s << string_compose ("f%1-action", n+1); + + if ((prop = node.property (s.str())) != 0) { + _f_actions[n] = prop->value(); } } @@ -1023,3 +1035,21 @@ MackieControlProtocol::clear_ports () port_sources.clear (); } +string +MackieControlProtocol::f_action (uint32_t fn) +{ + if (fn >= _f_actions.size()) { + return string(); + } + + return _f_actions[fn]; +} + +void +MackieControlProtocol::f_press (uint32_t fn) +{ + string action = f_action (0); + if (!action.empty()) { + access_action (action); + } +} diff --git a/libs/surfaces/mackie/mackie_control_protocol.h b/libs/surfaces/mackie/mackie_control_protocol.h index a93159f36c..82096d0997 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.h +++ b/libs/surfaces/mackie/mackie_control_protocol.h @@ -325,6 +325,11 @@ class MackieControlProtocol void thread_init (); + /* handling function key presses */ + + std::string f_action (uint32_t fn); + void f_press (uint32_t fn); + private: static MackieControlProtocol* _instance; @@ -392,6 +397,8 @@ class MackieControlProtocol ButtonMap button_map; void build_button_map (); + + std::vector _f_actions; }; diff --git a/libs/surfaces/mackie/mcp_buttons.cc b/libs/surfaces/mackie/mcp_buttons.cc index 9e2dd4637c..37035353bc 100644 --- a/libs/surfaces/mackie/mcp_buttons.cc +++ b/libs/surfaces/mackie/mcp_buttons.cc @@ -632,11 +632,10 @@ MackieControlProtocol::enter_release (Button &) { return off; } - LedState MackieControlProtocol::F1_press (Button &) { - GotoView (0); /* EMIT SIGNAL */ + f_press (0); return off; } LedState @@ -647,7 +646,7 @@ MackieControlProtocol::F1_release (Button &) LedState MackieControlProtocol::F2_press (Button &) { - GotoView (1); /* EMIT SIGNAL */ + f_press (1); return off; } LedState @@ -658,7 +657,7 @@ MackieControlProtocol::F2_release (Button &) LedState MackieControlProtocol::F3_press (Button &) { - GotoView (2); /* EMIT SIGNAL */ + f_press (2); return off; } LedState @@ -669,7 +668,7 @@ MackieControlProtocol::F3_release (Button &) LedState MackieControlProtocol::F4_press (Button &) { - GotoView (3); /* EMIT SIGNAL */ + f_press (3); return off; } LedState @@ -680,7 +679,7 @@ MackieControlProtocol::F4_release (Button &) LedState MackieControlProtocol::F5_press (Button &) { - GotoView (4); /* EMIT SIGNAL */ + f_press (4); return off; } LedState @@ -691,7 +690,7 @@ MackieControlProtocol::F5_release (Button &) LedState MackieControlProtocol::F6_press (Button &) { - GotoView (5); /* EMIT SIGNAL */ + f_press (5); return off; } LedState @@ -702,7 +701,7 @@ MackieControlProtocol::F6_release (Button &) LedState MackieControlProtocol::F7_press (Button &) { - GotoView (6); /* EMIT SIGNAL */ + f_press (6); return off; } LedState