663ff6c0174e8cf0458d4c9c96652c9a35d72ae2
[ardour.git] / libs / surfaces / mackie / mcp_buttons.cc
1 /*
2  * Copyright (C) 2006-2007 John Anderson
3  * Copyright (C) 2012-2018 Paul Davis <paul@linuxaudiosystems.com>
4  * Copyright (C) 2015-2016 Len Ovens <len@ovenwerks.net>
5  * Copyright (C) 2015-2017 Robin Gareus <robin@gareus.org>
6  * Copyright (C) 2016-2019 Ben Loftis <ben@harrisonconsoles.com>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22
23 #include <algorithm>
24
25 #include "pbd/memento_command.h"
26
27 #include "ardour/debug.h"
28 #include "ardour/profile.h"
29 #include "ardour/session.h"
30 #include "ardour/route.h"
31 #include "ardour/location.h"
32 #include "ardour/rc_configuration.h"
33
34 #include "mackie_control_protocol.h"
35 #include "surface.h"
36 #include "fader.h"
37
38 #include "pbd/i18n.h"
39
40 /* handlers for all buttons, broken into a separate file to avoid clutter in
41  * mackie_control_protocol.cc
42  */
43
44 using std::string;
45 using namespace ARDOUR;
46 using namespace PBD;
47 using namespace ArdourSurface;
48 using namespace Mackie;
49
50 LedState
51 MackieControlProtocol::shift_press (Button &)
52 {
53         _modifier_state |= MODIFIER_SHIFT;
54         return on;
55 }
56 LedState
57 MackieControlProtocol::shift_release (Button &)
58 {
59         _modifier_state &= ~MODIFIER_SHIFT;
60         return off;
61 }
62 LedState
63 MackieControlProtocol::option_press (Button &)
64 {
65         _modifier_state |= MODIFIER_OPTION;
66         return on;
67 }
68 LedState
69 MackieControlProtocol::option_release (Button &)
70 {
71         _modifier_state &= ~MODIFIER_OPTION;
72         return off;
73 }
74 LedState
75 MackieControlProtocol::control_press (Button &)
76 {
77         _modifier_state |= MODIFIER_CONTROL;
78         DEBUG_TRACE (DEBUG::MackieControl, string_compose ("CONTROL Press: modifier state now set to %1\n", _modifier_state));
79         return on;
80 }
81 LedState
82 MackieControlProtocol::control_release (Button &)
83 {
84         _modifier_state &= ~MODIFIER_CONTROL;
85         DEBUG_TRACE (DEBUG::MackieControl, string_compose ("CONTROL Release: modifier state now set to %1\n", _modifier_state));
86         return off;
87 }
88 LedState
89 MackieControlProtocol::cmd_alt_press (Button &)
90 {
91         _modifier_state |= MODIFIER_CMDALT;
92         return on;
93 }
94 LedState
95 MackieControlProtocol::cmd_alt_release (Button &)
96 {
97         _modifier_state &= ~MODIFIER_CMDALT;
98         return off;
99 }
100
101 LedState
102 MackieControlProtocol::left_press (Button &)
103 {
104         if (_subview_mode != None) {
105                 return none;
106         }
107
108         Sorted sorted = get_sorted_stripables();
109         uint32_t strip_cnt = n_strips ();
110
111         DEBUG_TRACE (DEBUG::MackieControl, string_compose ("bank left with current initial = %1 nstrips = %2 tracks/busses = %3\n",
112                                                            _current_initial_bank, strip_cnt, sorted.size()));
113         if (_current_initial_bank > 0) {
114                 (void) switch_banks ((_current_initial_bank - 1) / strip_cnt * strip_cnt);
115         } else {
116                 (void) switch_banks (0);
117         }
118
119
120         return on;
121 }
122
123 LedState
124 MackieControlProtocol::left_release (Button &)
125 {
126         return off;
127 }
128
129 LedState
130 MackieControlProtocol::right_press (Button &)
131 {
132         if (_subview_mode != None) {
133                 return none;
134         }
135
136         Sorted sorted = get_sorted_stripables();
137         uint32_t strip_cnt = n_strips();
138         uint32_t route_cnt = sorted.size();
139         uint32_t max_bank = route_cnt / strip_cnt * strip_cnt;
140
141
142         DEBUG_TRACE (DEBUG::MackieControl, string_compose ("bank right with current initial = %1 nstrips = %2 tracks/busses = %3\n",
143                                                            _current_initial_bank, strip_cnt, route_cnt));
144
145         if (_current_initial_bank < max_bank) {
146                 uint32_t new_initial = (_current_initial_bank / strip_cnt * strip_cnt) + strip_cnt;
147                 (void) switch_banks (new_initial);
148         }
149
150         return on;
151 }
152
153 LedState
154 MackieControlProtocol::right_release (Button &)
155 {
156         return off;
157 }
158
159 LedState
160 MackieControlProtocol::cursor_left_press (Button& )
161 {
162         if (zoom_mode()) {
163
164                 if (main_modifier_state() & MODIFIER_OPTION) {
165                         /* reset selected tracks to default vertical zoom */
166                 } else {
167                         ZoomOut (); /* EMIT SIGNAL */
168                 }
169         } else {
170                 float page_fraction;
171                 if (main_modifier_state() == MODIFIER_CONTROL) {
172                         page_fraction = 1.0;
173                 } else if (main_modifier_state() == MODIFIER_OPTION) {
174                         page_fraction = 0.1;
175                 } else if (main_modifier_state() == MODIFIER_SHIFT) {
176                         page_fraction = 2.0;
177                 } else {
178                         page_fraction = 0.25;
179                 }
180
181                 ScrollTimeline (-page_fraction);
182         }
183
184         return off;
185 }
186
187 LedState
188 MackieControlProtocol::cursor_left_release (Button&)
189 {
190         return off;
191 }
192
193 LedState
194 MackieControlProtocol::cursor_right_press (Button& )
195 {
196         if (zoom_mode()) {
197
198                 if (main_modifier_state() & MODIFIER_OPTION) {
199                         /* reset selected tracks to default vertical zoom */
200                 } else {
201                         ZoomIn (); /* EMIT SIGNAL */
202                 }
203         } else {
204                 float page_fraction;
205                 if (main_modifier_state() == MODIFIER_CONTROL) {
206                         page_fraction = 1.0;
207                 } else if (main_modifier_state() == MODIFIER_OPTION) {
208                         page_fraction = 0.1;
209                 } else if (main_modifier_state() == MODIFIER_SHIFT) {
210                         page_fraction = 2.0;
211                 } else {
212                         page_fraction = 0.25;
213                 }
214
215                 ScrollTimeline (page_fraction);
216         }
217
218         return off;
219 }
220
221 LedState
222 MackieControlProtocol::cursor_right_release (Button&)
223 {
224         return off;
225 }
226
227 LedState
228 MackieControlProtocol::cursor_up_press (Button&)
229 {
230         if (zoom_mode()) {
231
232                 if (main_modifier_state() & MODIFIER_CONTROL) {
233                         VerticalZoomInSelected (); /* EMIT SIGNAL */
234                 } else {
235                         VerticalZoomInAll (); /* EMIT SIGNAL */
236                 }
237         } else {
238                 access_action ("Editor/select-prev-route");
239         }
240         return off;
241 }
242
243 LedState
244 MackieControlProtocol::cursor_up_release (Button&)
245 {
246         return off;
247 }
248
249 LedState
250 MackieControlProtocol::cursor_down_press (Button&)
251 {
252         if (zoom_mode()) {
253                 if (main_modifier_state() & MODIFIER_OPTION) {
254                         VerticalZoomOutSelected (); /* EMIT SIGNAL */
255                 } else {
256                         VerticalZoomOutAll (); /* EMIT SIGNAL */
257                 }
258         } else {
259                 access_action ("Editor/select-next-route");
260         }
261         return off;
262 }
263
264 LedState
265 MackieControlProtocol::cursor_down_release (Button&)
266 {
267         return off;
268 }
269
270 LedState
271 MackieControlProtocol::channel_left_press (Button &)
272 {
273         if (_device_info.single_fader_follows_selection()) {
274                 access_action ("Editor/select-prev-route");
275                 return on;
276         }
277
278         if (_subview_mode != None) {
279                 return none;
280         }
281         Sorted sorted = get_sorted_stripables();
282         if (sorted.size() > n_strips()) {
283                 prev_track();
284                 return on;
285         } else {
286                 return flashing;
287         }
288 }
289
290 LedState
291 MackieControlProtocol::channel_left_release (Button &)
292 {
293         return off;
294 }
295
296 LedState
297 MackieControlProtocol::channel_right_press (Button &)
298 {
299         if (_device_info.single_fader_follows_selection()) {
300                 access_action ("Editor/select-next-route");
301                 return on;
302         }
303
304         if (_subview_mode != None) {
305                 return none;
306         }
307         Sorted sorted = get_sorted_stripables();
308         if (sorted.size() > n_strips()) {
309                 next_track();
310                 return on;
311         } else {
312                 return flashing;
313         }
314 }
315
316 LedState
317 MackieControlProtocol::channel_right_release (Button &)
318 {
319         return off;
320 }
321
322 Mackie::LedState
323 MackieControlProtocol::zoom_press (Mackie::Button &)
324 {
325         return none;
326 }
327
328 Mackie::LedState
329 MackieControlProtocol::zoom_release (Mackie::Button &)
330 {
331         if (_modifier_state & MODIFIER_ZOOM) {
332                 _modifier_state &= ~MODIFIER_ZOOM;
333         } else {
334                 _modifier_state |= MODIFIER_ZOOM;
335         }
336
337         return (zoom_mode() ? on : off);
338 }
339
340 Mackie::LedState
341 MackieControlProtocol::scrub_press (Mackie::Button &)
342 {
343         if (!surfaces.empty()) {
344                 // surfaces.front()->next_jog_mode ();
345                 _master_surface->next_jog_mode ();
346         }
347         return none;
348 }
349
350 Mackie::LedState
351 MackieControlProtocol::scrub_release (Mackie::Button &)
352 {
353         return none;
354 }
355
356 LedState
357 MackieControlProtocol::undo_press (Button&)
358 {
359         if (main_modifier_state() == MODIFIER_SHIFT) {
360                 redo();
361         } else {
362                 undo ();
363         }
364         return none;
365 }
366
367 LedState
368 MackieControlProtocol::undo_release (Button&)
369 {
370         return none;
371 }
372
373 LedState
374 MackieControlProtocol::drop_press (Button &)
375 {
376         if (main_modifier_state() == MODIFIER_SHIFT) {
377                 toggle_punch_in();
378                 return none;
379         } else {
380                 access_action ("Common/start-range-from-playhead");
381         }
382         return none;
383 }
384
385 LedState
386 MackieControlProtocol::drop_release (Button &)
387 {
388         return none;
389 }
390
391 LedState
392 MackieControlProtocol::save_press (Button &)
393 {
394         if (main_modifier_state() == MODIFIER_SHIFT) {
395                 quick_snapshot_switch();
396         } else {
397                 save_state ();
398         }
399
400         return none;
401 }
402
403 LedState
404 MackieControlProtocol::save_release (Button &)
405 {
406         return none;
407 }
408
409 LedState
410 MackieControlProtocol::timecode_beats_press (Button &)
411 {
412         switch (_timecode_type) {
413         case ARDOUR::AnyTime::BBT:
414                 _timecode_type = ARDOUR::AnyTime::Timecode;
415                 break;
416         case ARDOUR::AnyTime::Timecode:
417                 _timecode_type = ARDOUR::AnyTime::BBT;
418                 break;
419         default:
420                 return off;
421         }
422
423         update_timecode_beats_led();
424
425         return on;
426 }
427
428 LedState
429 MackieControlProtocol::timecode_beats_release (Button &)
430 {
431         return off;
432 }
433
434 /////////////////////////////////////
435 // Functions
436 /////////////////////////////////////
437 LedState
438 MackieControlProtocol::marker_press (Button &)
439 {
440         if (main_modifier_state() & MODIFIER_SHIFT) {
441                 access_action ("Common/remove-location-from-playhead");
442                 return off;
443         } else {
444                 _modifier_state |= MODIFIER_MARKER;
445                 marker_modifier_consumed_by_button = false;
446                 return on;
447         }
448 }
449
450 LedState
451 MackieControlProtocol::marker_release (Button &)
452 {
453         _modifier_state &= ~MODIFIER_MARKER;
454
455         if (main_modifier_state() & MODIFIER_SHIFT) {
456                 return off;   //if shift was held, we already did the action
457         }
458
459         if (marker_modifier_consumed_by_button) {
460                 DEBUG_TRACE (DEBUG::MackieControl, "marked modifier consumed by button, ignored\n");
461                 /* marker was used a modifier for some other button(s), so do
462                    nothing
463                 */
464                 return off;
465         }
466
467         string markername;
468
469         /* Don't add another mark if one exists within 1/100th of a second of
470          * the current position and we're not rolling.
471          */
472
473         samplepos_t where = session->audible_sample();
474
475         if (session->transport_stopped() && session->locations()->mark_at (where, session->sample_rate() / 100.0)) {
476                 return off;
477         }
478
479         session->locations()->next_available_name (markername,"mark");
480         add_marker (markername);
481
482         return off;
483 }
484
485 /////////////////////////////////////
486 // Transport Buttons
487 /////////////////////////////////////
488
489 LedState
490 MackieControlProtocol::stop_press (Button &)
491 {
492         transport_stop ();
493
494         if (main_modifier_state() == MODIFIER_SHIFT) {
495                 session->midi_panic();
496         }
497
498         return on;
499 }
500
501 LedState
502 MackieControlProtocol::stop_release (Button &)
503 {
504         return session->transport_stopped();
505 }
506
507 LedState
508 MackieControlProtocol::play_press (Button &)
509 {
510         /* if we're already rolling at normal speed, and we're pressed
511            again, jump back to where we started last time
512         */
513
514         transport_play (session->transport_speed() == 1.0);
515         return none;
516 }
517
518 LedState
519 MackieControlProtocol::play_release (Button &)
520 {
521         return none;
522 }
523
524 LedState
525 MackieControlProtocol::record_press (Button &)
526 {
527         rec_enable_toggle ();
528         return none;
529 }
530
531 LedState
532 MackieControlProtocol::record_release (Button &)
533 {
534         return none;
535 }
536
537 LedState
538 MackieControlProtocol::rewind_press (Button &)
539 {
540         if (modifier_state() & MODIFIER_MARKER) {
541                 prev_marker ();
542         } else if (modifier_state() & MODIFIER_NUDGE) {
543                 access_action ("Common/nudge-playhead-backward");
544         } else if (main_modifier_state() & MODIFIER_SHIFT) {
545                 goto_start ();
546         } else {
547                 rewind ();
548         }
549         return none;
550 }
551
552 LedState
553 MackieControlProtocol::rewind_release (Button &)
554 {
555         return none;
556 }
557
558 LedState
559 MackieControlProtocol::ffwd_press (Button &)
560 {
561         if (modifier_state() & MODIFIER_MARKER) {
562                 next_marker ();
563         } else if (modifier_state() & MODIFIER_NUDGE) {
564                 access_action ("Common/nudge-playhead-forward");
565         } else if (main_modifier_state() & MODIFIER_SHIFT) {
566                 goto_end();
567         } else {
568                 ffwd ();
569         }
570         return none;
571 }
572
573 LedState
574 MackieControlProtocol::ffwd_release (Button &)
575 {
576         return none;
577 }
578
579 LedState
580 MackieControlProtocol::loop_press (Button &)
581 {
582         if (main_modifier_state() & MODIFIER_SHIFT) {
583                 access_action ("Editor/set-loop-from-edit-range");
584                 return off;
585         } else {
586                 bool was_on = session->get_play_loop();
587                 loop_toggle ();
588                 return was_on ? off : on;
589         }
590 }
591
592 LedState
593 MackieControlProtocol::loop_release (Button &)
594 {
595         return none;
596 }
597
598 LedState
599 MackieControlProtocol::enter_press (Button &)
600 {
601         if (main_modifier_state() & MODIFIER_SHIFT) {
602                 access_action ("Transport/ToggleFollowEdits");
603         } else {
604                 access_action ("Common/select-all-tracks");
605         }
606         return none;
607 }
608
609 LedState
610 MackieControlProtocol::enter_release (Button &)
611 {
612         return none;
613 }
614
615 LedState
616 MackieControlProtocol::bank_release (Button& b, uint32_t basic_bank_num)
617 {
618         if (_subview_mode != None) {
619                 return none;
620         }
621
622         uint32_t bank_num = basic_bank_num;
623
624         if (b.long_press_count() > 0) {
625                 bank_num = 8 + basic_bank_num;
626         }
627
628         (void) switch_banks (n_strips() * bank_num);
629
630         return on;
631 }
632
633 /*  F-KEYS are only used for actions that are bound from the control panel; no need to address them here
634 LedState
635 MackieControlProtocol::F1_press (Button &b)
636 {
637         return on;
638 }
639 LedState
640 MackieControlProtocol::F1_release (Button &b)
641 {
642         return off;
643 }
644 LedState
645 MackieControlProtocol::F2_press (Button &)
646 {
647         return on;
648 }
649 LedState
650 MackieControlProtocol::F2_release (Button &b)
651 {
652         return off;
653 }
654 LedState
655 MackieControlProtocol::F3_press (Button &)
656 {
657         return on;
658 }
659 LedState
660 MackieControlProtocol::F3_release (Button &b)
661 {
662         return off;
663 }
664 LedState
665 MackieControlProtocol::F4_press (Button &)
666 {
667         return on;
668 }
669 LedState
670 MackieControlProtocol::F4_release (Button &b)
671 {
672         return off;
673 }
674 LedState
675 MackieControlProtocol::F5_press (Button &)
676 {
677         return on;
678 }
679 LedState
680 MackieControlProtocol::F5_release (Button &)
681 {
682         return off;
683 }
684 LedState
685 MackieControlProtocol::F6_press (Button &)
686 {
687         return on;
688 }
689 LedState
690 MackieControlProtocol::F6_release (Button &)
691 {
692         return off;
693 }
694 LedState
695 MackieControlProtocol::F7_press (Button &)
696 {
697         return on;
698 }
699 LedState
700 MackieControlProtocol::F7_release (Button &)
701 {
702         return off;
703 }
704 LedState
705 MackieControlProtocol::F8_press (Button &)
706 {
707         return on;
708 }
709 LedState
710 MackieControlProtocol::F8_release (Button &)
711 {
712         return off;
713 }
714 */
715
716
717 /* UNIMPLEMENTED */
718
719 LedState
720 MackieControlProtocol::pan_press (Button &)
721 {
722         /* XXX eventually pan may have its own subview mode */
723         set_subview_mode (MackieControlProtocol::None, boost::shared_ptr<Stripable>());
724         return none;
725 }
726 LedState
727 MackieControlProtocol::pan_release (Button &)
728 {
729         return none;
730 }
731 LedState
732 MackieControlProtocol::plugin_press (Button &)
733 {
734         return off;
735 }
736 LedState
737 MackieControlProtocol::plugin_release (Button &)
738 {
739         // Do not do this yet, since it does nothing
740         // set_view_mode (Plugins);
741         return none; /* LED state set by set_view_mode */
742 }
743 LedState
744 MackieControlProtocol::eq_press (Button &)
745 {
746         set_subview_mode (EQ, first_selected_stripable ());
747         return none; /* led state handled by set_subview_mode() */
748
749 }
750 LedState
751 MackieControlProtocol::eq_release (Button &)
752 {
753         return none;
754 }
755 LedState
756 MackieControlProtocol::dyn_press (Button &)
757 {
758         set_subview_mode (Dynamics, first_selected_stripable ());
759         return none; /* led state handled by set_subview_mode() */
760 }
761
762 LedState
763 MackieControlProtocol::dyn_release (Button &)
764 {
765         return none;
766 }
767 LedState
768 MackieControlProtocol::flip_press (Button &)
769 {
770         if (subview_mode() == MackieControlProtocol::Sends) {
771                 if (_flip_mode != Normal) {
772                         set_flip_mode (Normal);
773                 } else {
774                         set_flip_mode (Mirror);
775                 }
776                 return ((_flip_mode != Normal) ? on : off);
777         }
778
779         return none;
780 }
781
782 LedState
783 MackieControlProtocol::flip_release (Button &)
784 {
785         return none;
786 }
787 LedState
788 MackieControlProtocol::name_value_press (Button &)
789 {
790         return off;
791 }
792 LedState
793 MackieControlProtocol::name_value_release (Button &)
794 {
795         return off;
796 }
797 LedState
798 MackieControlProtocol::touch_press (Button &)
799 {
800         return none;
801 }
802 LedState
803 MackieControlProtocol::touch_release (Button &)
804 {
805         set_automation_state (ARDOUR::Touch);
806         return none;
807 }
808 LedState
809 MackieControlProtocol::cancel_press (Button &)
810 {
811         if (main_modifier_state() & MODIFIER_SHIFT) {
812                 access_action ("Transport/ToggleExternalSync");
813         } else {
814                 access_action ("Main/Escape");
815         }
816         return none;
817 }
818 LedState
819 MackieControlProtocol::cancel_release (Button &)
820 {
821         return none;
822 }
823 LedState
824 MackieControlProtocol::user_a_press (Button &)
825 {
826         transport_play (session->transport_speed() == 1.0);
827         return off;
828 }
829 LedState
830 MackieControlProtocol::user_a_release (Button &)
831 {
832         return off;
833 }
834 LedState
835 MackieControlProtocol::user_b_press (Button &)
836 {
837         transport_stop();
838         return off;
839 }
840 LedState
841 MackieControlProtocol::user_b_release (Button &)
842 {
843         return off;
844 }
845
846 LedState
847 MackieControlProtocol::master_fader_touch_press (Mackie::Button &)
848 {
849         DEBUG_TRACE (DEBUG::MackieControl, "MackieControlProtocol::master_fader_touch_press\n");
850
851         Fader* master_fader = _master_surface->master_fader();
852
853         boost::shared_ptr<AutomationControl> ac = master_fader->control ();
854
855         master_fader->set_in_use (true);
856         master_fader->start_touch (transport_sample());
857
858         return none;
859 }
860 LedState
861 MackieControlProtocol::master_fader_touch_release (Mackie::Button &)
862 {
863         DEBUG_TRACE (DEBUG::MackieControl, "MackieControlProtocol::master_fader_touch_release\n");
864
865         Fader* master_fader = _master_surface->master_fader();
866
867         master_fader->set_in_use (false);
868         master_fader->stop_touch (transport_sample());
869
870         return none;
871 }
872
873 Mackie::LedState
874 MackieControlProtocol::read_press (Mackie::Button&)
875 {
876         return none;
877 }
878
879 Mackie::LedState
880 MackieControlProtocol::read_release (Mackie::Button&)
881 {
882         set_automation_state (ARDOUR::Play);
883         return none;
884 }
885 Mackie::LedState
886 MackieControlProtocol::write_press (Mackie::Button&)
887 {
888         return none;
889 }
890 Mackie::LedState
891 MackieControlProtocol::write_release (Mackie::Button&)
892 {
893         set_automation_state (ARDOUR::Write);
894         return none;
895 }
896
897 Mackie::LedState
898 MackieControlProtocol::clearsolo_press (Mackie::Button&)
899 {
900         // clears all solos and listens (pfl/afl)
901
902         if (main_modifier_state() & MODIFIER_SHIFT) {
903                 access_action ("Editor/set-session-from-edit-range");
904                 return none;
905         }
906
907         cancel_all_solo ();
908         return none;
909 }
910
911 Mackie::LedState
912 MackieControlProtocol::clearsolo_release (Mackie::Button&)
913 {
914         //return session->soloing();
915         return none;
916 }
917
918 Mackie::LedState
919 MackieControlProtocol::track_press (Mackie::Button&)
920 {
921         set_subview_mode (TrackView, first_selected_stripable());
922         return none;
923 }
924 Mackie::LedState
925 MackieControlProtocol::track_release (Mackie::Button&)
926 {
927         return none;
928 }
929 Mackie::LedState
930 MackieControlProtocol::send_press (Mackie::Button&)
931 {
932         set_subview_mode (Sends, first_selected_stripable());
933         return none; /* led state handled by set_subview_mode() */
934 }
935 Mackie::LedState
936 MackieControlProtocol::send_release (Mackie::Button&)
937 {
938         return none;
939 }
940 Mackie::LedState
941 MackieControlProtocol::miditracks_press (Mackie::Button&)
942 {
943         return none;
944 }
945 Mackie::LedState
946 MackieControlProtocol::miditracks_release (Mackie::Button&)
947 {
948         set_view_mode (MidiTracks);
949         return none;
950 }
951 Mackie::LedState
952 MackieControlProtocol::inputs_press (Mackie::Button&)
953 {
954 #ifdef MIXBUS
955         set_view_mode (Mixer);  //in Mixbus, this is the same as Global View (avoid dead buttons)
956 #endif
957         return none;
958 }
959 Mackie::LedState
960 MackieControlProtocol::inputs_release (Mackie::Button&)
961 {
962         return none;
963 }
964 Mackie::LedState
965 MackieControlProtocol::audiotracks_press (Mackie::Button&)
966 {
967         return none;
968 }
969 Mackie::LedState
970 MackieControlProtocol::audiotracks_release (Mackie::Button&)
971 {
972         set_view_mode (AudioTracks);
973         return none;
974 }
975 Mackie::LedState
976 MackieControlProtocol::audioinstruments_press (Mackie::Button& b)
977 {
978 #ifdef MIXBUS
979         set_view_mode (MidiTracks);  //in Mixbus, we do the same thing as MIDI Tracks ( aviod dead buttons )
980 #endif
981         return none;
982 }
983
984 Mackie::LedState
985 MackieControlProtocol::audioinstruments_release (Mackie::Button& b)
986 {
987         return none;
988
989 }
990 Mackie::LedState
991 MackieControlProtocol::aux_press (Mackie::Button&)
992 {
993         return none;
994 }
995 Mackie::LedState
996 MackieControlProtocol::aux_release (Mackie::Button&)
997 {
998         set_view_mode (Auxes);
999         return none;
1000 }
1001 Mackie::LedState
1002 MackieControlProtocol::busses_press (Mackie::Button&)
1003 {
1004         return none;
1005 }
1006 Mackie::LedState
1007 MackieControlProtocol::busses_release (Mackie::Button&)
1008 {
1009         set_view_mode (Busses);
1010         return none;
1011 }
1012 Mackie::LedState
1013 MackieControlProtocol::outputs_press (Mackie::Button&)
1014 {
1015         return none;
1016 }
1017 Mackie::LedState
1018 MackieControlProtocol::outputs_release (Mackie::Button&)
1019 {
1020         set_view_mode (Hidden);
1021         return none;
1022 }
1023 Mackie::LedState
1024 MackieControlProtocol::user_press (Mackie::Button&)
1025 {
1026         return none;
1027 }
1028 Mackie::LedState
1029 MackieControlProtocol::user_release (Mackie::Button&)
1030 {
1031         set_view_mode (Selected);
1032         return none;
1033 }
1034 Mackie::LedState
1035 MackieControlProtocol::trim_press (Mackie::Button&)
1036 {
1037         return none;
1038 }
1039 Mackie::LedState
1040 MackieControlProtocol::trim_release (Mackie::Button&)
1041 {
1042         return none;
1043 }
1044 Mackie::LedState
1045 MackieControlProtocol::latch_press (Mackie::Button&)
1046 {
1047         return none;
1048 }
1049 Mackie::LedState
1050 MackieControlProtocol::latch_release (Mackie::Button&)
1051 {
1052         return none;
1053 }
1054 Mackie::LedState
1055 MackieControlProtocol::grp_press (Mackie::Button&)
1056 {
1057         return none;
1058 }
1059 Mackie::LedState
1060 MackieControlProtocol::grp_release (Mackie::Button&)
1061 {
1062         /* There is no "Off" button for automation,
1063            so we use Group for this purpose.
1064         */
1065         set_automation_state (Off);
1066         return none;
1067 }
1068 Mackie::LedState
1069 MackieControlProtocol::nudge_press (Mackie::Button&)
1070 {
1071         _modifier_state |= MODIFIER_NUDGE;
1072         nudge_modifier_consumed_by_button = false;
1073         return on;
1074 }
1075 Mackie::LedState
1076 MackieControlProtocol::nudge_release (Mackie::Button&)
1077 {
1078         _modifier_state &= ~MODIFIER_NUDGE;
1079
1080         /* XXX these action names are stupid, because the action can affect
1081          * regions, markers or the playhead depending on selection state.
1082          */
1083
1084         if (main_modifier_state() & MODIFIER_SHIFT) {
1085                 access_action ("Region/nudge-backward");
1086         } else {
1087                 access_action ("Region/nudge-forward");
1088         }
1089
1090         return off;
1091 }
1092 Mackie::LedState
1093 MackieControlProtocol::replace_press (Mackie::Button&)
1094 {
1095         if (main_modifier_state() == MODIFIER_SHIFT) {
1096                 toggle_punch_out();
1097                 return none;
1098         } else {
1099                 access_action ("Common/finish-range-from-playhead");
1100         }
1101         return none;
1102 }
1103 Mackie::LedState
1104 MackieControlProtocol::replace_release (Mackie::Button&)
1105 {
1106         return none;
1107 }
1108 Mackie::LedState
1109 MackieControlProtocol::click_press (Mackie::Button&)
1110 {
1111         if (main_modifier_state() & MODIFIER_SHIFT) {
1112                 access_action ("Editor/set-punch-from-edit-range");
1113                 return off;
1114         } else {
1115                 bool state = !Config->get_clicking();
1116                 Config->set_clicking (state);
1117                 return state;
1118         }
1119 }
1120 Mackie::LedState
1121 MackieControlProtocol::click_release (Mackie::Button&)
1122 {
1123         return none;
1124 }
1125 Mackie::LedState
1126 MackieControlProtocol::view_press (Mackie::Button&)
1127 {
1128         set_view_mode (Mixer);
1129         return none;
1130 }
1131 Mackie::LedState
1132 MackieControlProtocol::view_release (Mackie::Button&)
1133 {
1134         return none;
1135 }