From 9403b116adb84a781db7f2201e0a1344b8a1c560 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 10 Dec 2022 10:32:47 -0700 Subject: [PATCH] Mackie: make AudioInstruments button work correctly Also toggle Global View LED appropriately --- .../mackie/mackie_control_protocol.cc | 27 ++++++++++++++++--- .../surfaces/mackie/mackie_control_protocol.h | 1 + libs/surfaces/mackie/mcp_buttons.cc | 5 +++- libs/surfaces/mackie/surface.cc | 5 ++++ 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/libs/surfaces/mackie/mackie_control_protocol.cc b/libs/surfaces/mackie/mackie_control_protocol.cc index c10a43cf2b..b08a1f81f0 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.cc +++ b/libs/surfaces/mackie/mackie_control_protocol.cc @@ -350,6 +350,14 @@ MackieControlProtocol::get_sorted_stripables() sorted.push_back (s); } break; + case AudioInstr: + if (has_instrument (s)){ + sorted.push_back (s); + } + break; + case Inputs: + // nothing to do right now + break; } } @@ -1581,7 +1589,7 @@ MackieControlProtocol::build_device_specific_button_map() { /* this maps our device-dependent button codes to the methods that handle them. */ - + #define DEFINE_BUTTON_HANDLER(b,p,r) button_map.insert (pair ((b), ButtonHandlers ((p),(r)))); if (_device_info.is_platformMp()) { @@ -1856,11 +1864,15 @@ MackieControlProtocol::set_view_mode (ViewMode m) void MackieControlProtocol::display_view_mode () { - Glib::Threads::Mutex::Lock lm (surfaces_lock); + { + Glib::Threads::Mutex::Lock lm (surfaces_lock); - for (Surfaces::iterator s = surfaces.begin(); s != surfaces.end(); ++s) { - (*s)->update_view_mode_display (true); + for (Surfaces::iterator s = surfaces.begin(); s != surfaces.end(); ++s) { + (*s)->update_view_mode_display (true); + } } + + update_global_button (Button::View, (view_mode() == MackieControlProtocol::Mixer) ? on : off); } void @@ -2350,6 +2362,13 @@ MackieControlProtocol::is_midi_track (boost::shared_ptr r) const return boost::dynamic_pointer_cast(r) != 0; } +bool +MackieControlProtocol::has_instrument (boost::shared_ptr r) const +{ + boost::shared_ptr mt = boost::dynamic_pointer_cast(r); + return mt && mt->the_instrument(); +} + bool MackieControlProtocol::is_mapped (boost::shared_ptr r) const { diff --git a/libs/surfaces/mackie/mackie_control_protocol.h b/libs/surfaces/mackie/mackie_control_protocol.h index 85282726b7..b6397ee6f1 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.h +++ b/libs/surfaces/mackie/mackie_control_protocol.h @@ -135,6 +135,7 @@ class MackieControlProtocol bool is_track (boost::shared_ptr) const; bool is_audio_track (boost::shared_ptr) const; bool is_midi_track (boost::shared_ptr) const; + bool has_instrument (boost::shared_ptr) const; bool is_mapped (boost::shared_ptr) const; boost::shared_ptr first_selected_stripable () const; diff --git a/libs/surfaces/mackie/mcp_buttons.cc b/libs/surfaces/mackie/mcp_buttons.cc index b1818418d6..54671f229d 100644 --- a/libs/surfaces/mackie/mcp_buttons.cc +++ b/libs/surfaces/mackie/mcp_buttons.cc @@ -1083,6 +1083,9 @@ MackieControlProtocol::audioinstruments_press (Mackie::Button& b) Mackie::LedState MackieControlProtocol::audioinstruments_release (Mackie::Button& b) { +#ifndef MIXBUS + set_view_mode (AudioInstr); +#endif return none; } @@ -1365,4 +1368,4 @@ LedState MackieControlProtocol::prog2_marker_release (Button &) { return off; -} \ No newline at end of file +} diff --git a/libs/surfaces/mackie/surface.cc b/libs/surfaces/mackie/surface.cc index 8ff5daf630..e214a1c4d2 100644 --- a/libs/surfaces/mackie/surface.cc +++ b/libs/surfaces/mackie/surface.cc @@ -1354,6 +1354,11 @@ Surface::update_view_mode_display (bool with_helpful_text) id = Button::User; text = _("Selected Tracks"); break; + case MackieControlProtocol::AudioInstr: + show_two_char_display ("IS"); + id = Button::AudioInstruments; + text = _("Instruments"); + break; default: break; }