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