mackie: more debug tracing for remapped buttons
[ardour.git] / libs / surfaces / mackie / mcp_buttons.cc
index bff011668fdb64314cefb23adb761ac2be4ca846..dcbaa5c34bc94b00613d024ca28009fb82aa6836 100644 (file)
@@ -32,7 +32,7 @@
 #include "surface.h"
 #include "fader.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 /* handlers for all buttons, broken into a separate file to avoid clutter in
  * mackie_control_protocol.cc
@@ -60,7 +60,6 @@ LedState
 MackieControlProtocol::option_press (Button &)
 {
        _modifier_state |= MODIFIER_OPTION;
-       access_action ("Editor/set-loop-from-edit-range");
        return on;
 }
 LedState
@@ -74,7 +73,6 @@ MackieControlProtocol::control_press (Button &)
 {
        _modifier_state |= MODIFIER_CONTROL;
        DEBUG_TRACE (DEBUG::MackieControl, string_compose ("CONTROL Press: modifier state now set to %1\n", _modifier_state));
-       access_action ("Editor/set-punch-from-edit-range");
        return on;
 }
 LedState
@@ -88,7 +86,6 @@ LedState
 MackieControlProtocol::cmd_alt_press (Button &)
 {
        _modifier_state |= MODIFIER_CMDALT;
-       access_action ("Editor/set-session-from-edit-range");
        return on;
 }
 LedState
@@ -105,7 +102,7 @@ MackieControlProtocol::left_press (Button &)
                return none;
        }
 
-       Sorted sorted = get_sorted_routes();
+       Sorted sorted = get_sorted_stripables();
        uint32_t strip_cnt = n_strips ();
 
        DEBUG_TRACE (DEBUG::MackieControl, string_compose ("bank left with current initial = %1 nstrips = %2 tracks/busses = %3\n",
@@ -133,7 +130,7 @@ MackieControlProtocol::right_press (Button &)
                return none;
        }
 
-       Sorted sorted = get_sorted_routes();
+       Sorted sorted = get_sorted_stripables();
        uint32_t strip_cnt = n_strips();
        uint32_t route_cnt = sorted.size();
        uint32_t max_bank = route_cnt / strip_cnt * strip_cnt;
@@ -235,7 +232,7 @@ MackieControlProtocol::cursor_up_press (Button&)
                        VerticalZoomInAll (); /* EMIT SIGNAL */
                }
        } else {
-               StepTracksUp (); /* EMIT SIGNAL */
+               access_action ("Editor/select-prev-route");
        }
        return off;
 }
@@ -256,7 +253,7 @@ MackieControlProtocol::cursor_down_press (Button&)
                        VerticalZoomOutAll (); /* EMIT SIGNAL */
                }
        } else {
-               StepTracksDown (); /* EMIT SIGNAL */
+               access_action ("Editor/select-next-route");
        }
        return off;
 }
@@ -273,7 +270,7 @@ MackieControlProtocol::channel_left_press (Button &)
        if (_subview_mode != None) {
                return none;
        }
-       Sorted sorted = get_sorted_routes();
+       Sorted sorted = get_sorted_stripables();
        if (sorted.size() > n_strips()) {
                prev_track();
                return on;
@@ -294,7 +291,7 @@ MackieControlProtocol::channel_right_press (Button &)
        if (_subview_mode != None) {
                return none;
        }
-       Sorted sorted = get_sorted_routes();
+       Sorted sorted = get_sorted_stripables();
        if (sorted.size() > n_strips()) {
                next_track();
                return on;
@@ -346,7 +343,11 @@ MackieControlProtocol::scrub_release (Mackie::Button &)
 LedState
 MackieControlProtocol::undo_press (Button&)
 {
-       toggle_punch_out ();
+       if (main_modifier_state() == MODIFIER_SHIFT) {
+               redo();
+       } else {
+               undo ();
+       }
        return none;
 }
 
@@ -359,7 +360,12 @@ MackieControlProtocol::undo_release (Button&)
 LedState
 MackieControlProtocol::drop_press (Button &)
 {
-       access_action ("Editor/start-range-from-playhead");
+       if (main_modifier_state() == MODIFIER_SHIFT) {
+               toggle_punch_in();
+               return none;
+       } else {
+               access_action ("Common/start-range-from-playhead");
+       }
        return none;
 }
 
@@ -372,7 +378,12 @@ MackieControlProtocol::drop_release (Button &)
 LedState
 MackieControlProtocol::save_press (Button &)
 {
-       toggle_punch_in ();
+       if (main_modifier_state() == MODIFIER_SHIFT) {
+               quick_snapshot_switch();
+       } else {
+               save_state ();
+       }
+
        return none;
 }
 
@@ -413,16 +424,28 @@ MackieControlProtocol::timecode_beats_release (Button &)
 LedState
 MackieControlProtocol::marker_press (Button &)
 {
-       _modifier_state |= MODIFIER_MARKER;
-       marker_modifier_consumed_by_button = false;
-       return on;
+       DEBUG_TRACE (DEBUG::MackieControl, "marker press\n");
+
+       if (main_modifier_state() & MODIFIER_SHIFT) {
+               access_action ("Common/remove-location-from-playhead");
+               return off;
+       } else {
+               _modifier_state |= MODIFIER_MARKER;
+               marker_modifier_consumed_by_button = false;
+               return on;
+       }
 }
 
 LedState
 MackieControlProtocol::marker_release (Button &)
 {
+       DEBUG_TRACE (DEBUG::MackieControl, "marker release\n");
+
        _modifier_state &= ~MODIFIER_MARKER;
 
+       if (main_modifier_state() & MODIFIER_SHIFT)
+               return off;   //if shift was held, we already did the action
+
        if (marker_modifier_consumed_by_button) {
                /* marker was used a modifier for some other button(s), so do
                   nothing
@@ -506,7 +529,7 @@ MackieControlProtocol::rewind_press (Button &)
        if (modifier_state() & MODIFIER_MARKER) {
                prev_marker ();
        } else if (modifier_state() & MODIFIER_NUDGE) {
-               access_action ("Editor/nudge-playhead-backward");
+               access_action ("Common/nudge-playhead-backward");
        } else if (main_modifier_state() & MODIFIER_SHIFT) {
                goto_start ();
        } else {
@@ -527,7 +550,7 @@ MackieControlProtocol::ffwd_press (Button &)
        if (modifier_state() & MODIFIER_MARKER) {
                next_marker ();
        } else if (modifier_state() & MODIFIER_NUDGE) {
-               access_action ("Editor/nudge-playhead-forward");
+               access_action ("Common/nudge-playhead-forward");
        } else if (main_modifier_state() & MODIFIER_SHIFT) {
                goto_end();
        } else {
@@ -545,9 +568,14 @@ MackieControlProtocol::ffwd_release (Button &)
 LedState
 MackieControlProtocol::loop_press (Button &)
 {
-       bool was_on = session->get_play_loop();
-       session->request_play_loop (!was_on);
-       return was_on ? off : on;
+       if (main_modifier_state() & MODIFIER_SHIFT) {
+               access_action ("Common/set-loop-from-edit-range");
+               return off;
+       } else {
+               bool was_on = session->get_play_loop();
+               loop_toggle ();
+               return was_on ? off : on;
+       }
 }
 
 LedState
@@ -556,24 +584,14 @@ MackieControlProtocol::loop_release (Button &)
        return none;
 }
 
-LedState
-MackieControlProtocol::clicking_press (Button &)
-{
-       bool state = !Config->get_clicking();
-       Config->set_clicking (state);
-       return state;
-}
-
-LedState
-MackieControlProtocol::clicking_release (Button &)
-{
-       return Config->get_clicking();
-}
-
 LedState
 MackieControlProtocol::enter_press (Button &)
 {
-       access_action ("Transport/ToggleFollowEdits");
+       if (main_modifier_state() & MODIFIER_SHIFT) {
+               access_action ("Transport/ToggleFollowEdits");
+       } else {
+               access_action ("Editor/select-all-tracks");
+       }
        return none;
 }
 
@@ -689,7 +707,7 @@ LedState
 MackieControlProtocol::pan_press (Button &)
 {
        /* XXX eventually pan may have its own subview mode */
-       set_subview_mode (MackieControlProtocol::None, boost::shared_ptr<Route>());
+       set_subview_mode (MackieControlProtocol::None, boost::shared_ptr<Stripable>());
        return none;
 }
 LedState
@@ -712,8 +730,7 @@ MackieControlProtocol::plugin_release (Button &)
 LedState
 MackieControlProtocol::eq_press (Button &)
 {
-       boost::shared_ptr<Route> r = first_selected_route ();
-       set_subview_mode (EQ, r);
+       set_subview_mode (EQ, first_selected_stripable ());
        return none; /* led state handled by set_subview_mode() */
 
 }
@@ -725,8 +742,7 @@ MackieControlProtocol::eq_release (Button &)
 LedState
 MackieControlProtocol::dyn_press (Button &)
 {
-       boost::shared_ptr<Route> r = first_selected_route ();
-       set_subview_mode (Dynamics, r);
+       set_subview_mode (Dynamics, first_selected_stripable ());
        return none; /* led state handled by set_subview_mode() */
 }
 
@@ -779,7 +795,11 @@ MackieControlProtocol::touch_release (Button &)
 LedState
 MackieControlProtocol::cancel_press (Button &)
 {
-       access_action ("Transport/ToggleExternalSync");
+       if (main_modifier_state() & MODIFIER_SHIFT) {
+               access_action ("Transport/ToggleExternalSync");
+       } else {
+               access_action ("Main/Escape");
+       }
        return none;
 }
 LedState
@@ -866,15 +886,12 @@ MackieControlProtocol::clearsolo_press (Mackie::Button&)
 {
        // clears all solos and listens (pfl/afl)
 
-       if (session) {
-               if (session->soloing()) {
-                       session->set_solo (session->get_routes(), false);
-               } else if (session->listening()) {
-                       session->set_listen (session->get_routes(), false);
-               }
-
-               session->clear_all_solo_state (session->get_routes()); // safeguard, ideally this won't do anything, check the log-window
+       if (main_modifier_state() & MODIFIER_SHIFT) {
+               access_action ("Common/set-session-from-edit-range");
+               return none;
        }
+
+       cancel_all_solo ();
        return none;
 }
 
@@ -888,7 +905,7 @@ MackieControlProtocol::clearsolo_release (Mackie::Button&)
 Mackie::LedState
 MackieControlProtocol::track_press (Mackie::Button&)
 {
-       set_subview_mode (TrackView, first_selected_route());
+       set_subview_mode (TrackView, first_selected_stripable());
        return none;
 }
 Mackie::LedState
@@ -899,8 +916,7 @@ MackieControlProtocol::track_release (Mackie::Button&)
 Mackie::LedState
 MackieControlProtocol::send_press (Mackie::Button&)
 {
-       boost::shared_ptr<Route> r = first_selected_route ();
-       set_subview_mode (Sends, r);
+       set_subview_mode (Sends, first_selected_stripable());
        return none; /* led state handled by set_subview_mode() */
 }
 Mackie::LedState
@@ -922,6 +938,9 @@ MackieControlProtocol::miditracks_release (Mackie::Button&)
 Mackie::LedState
 MackieControlProtocol::inputs_press (Mackie::Button&)
 {
+#ifdef MIXBUS
+       set_view_mode (Mixer);  //in Mixbus, this is the same as Global View (avoid dead buttons)
+#endif
        return none;
 }
 Mackie::LedState
@@ -943,6 +962,9 @@ MackieControlProtocol::audiotracks_release (Mackie::Button&)
 Mackie::LedState
 MackieControlProtocol::audioinstruments_press (Mackie::Button& b)
 {
+#ifdef MIXBUS
+       set_view_mode (MidiTracks);  //in Mixbus, we do the same thing as MIDI Tracks ( aviod dead buttons )
+#endif
        return none;
 }
 
@@ -1043,7 +1065,7 @@ MackieControlProtocol::nudge_release (Mackie::Button&)
        _modifier_state &= ~MODIFIER_NUDGE;
 
        /* XXX these action names are stupid, because the action can affect
-        * regions, markers or the playhead depending on selection state. 
+        * regions, markers or the playhead depending on selection state.
         */
 
        if (main_modifier_state() & MODIFIER_SHIFT) {
@@ -1057,8 +1079,13 @@ MackieControlProtocol::nudge_release (Mackie::Button&)
 Mackie::LedState
 MackieControlProtocol::replace_press (Mackie::Button&)
 {
-       access_action ("Editor/finish-range-from-playhead");
-       return off;
+       if (main_modifier_state() == MODIFIER_SHIFT) {
+               toggle_punch_out();
+               return none;
+       } else {
+               access_action ("Common/finish-range-from-playhead");
+       }
+       return none;
 }
 Mackie::LedState
 MackieControlProtocol::replace_release (Mackie::Button&)
@@ -1068,7 +1095,14 @@ MackieControlProtocol::replace_release (Mackie::Button&)
 Mackie::LedState
 MackieControlProtocol::click_press (Mackie::Button&)
 {
-       return none;
+       if (main_modifier_state() & MODIFIER_SHIFT) {
+               access_action ("Common/set-punch-from-edit-range");
+               return off;
+       } else {
+               bool state = !Config->get_clicking();
+               Config->set_clicking (state);
+               return state;
+       }
 }
 Mackie::LedState
 MackieControlProtocol::click_release (Mackie::Button&)