remove cruft
[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 "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_routes();
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_routes();
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_routes();
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_routes();
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 ("Editor/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         if (main_modifier_state() & MODIFIER_SHIFT) {
428                 access_action ("Editor/remove-location-from-playhead");
429                 return off;
430         } else {
431                 _modifier_state |= MODIFIER_MARKER;
432                 marker_modifier_consumed_by_button = false;
433                 return on;
434         }
435 }
436
437 LedState
438 MackieControlProtocol::marker_release (Button &)
439 {
440         _modifier_state &= ~MODIFIER_MARKER;
441
442         if (main_modifier_state() & MODIFIER_SHIFT)
443                 return off;   //if shift was held, we already did the action
444
445         if (marker_modifier_consumed_by_button) {
446                 /* marker was used a modifier for some other button(s), so do
447                    nothing
448                 */
449                 return off;
450         }
451
452         string markername;
453
454         /* Don't add another mark if one exists within 1/100th of a second of
455          * the current position and we're not rolling.
456          */
457
458         framepos_t where = session->audible_frame();
459
460         if (session->transport_stopped() && session->locations()->mark_at (where, session->frame_rate() / 100.0)) {
461                 return off;
462         }
463
464         session->locations()->next_available_name (markername,"marker");
465         add_marker (markername);
466
467         return off;
468 }
469
470 /////////////////////////////////////
471 // Transport Buttons
472 /////////////////////////////////////
473
474 LedState
475 MackieControlProtocol::stop_press (Button &)
476 {
477         transport_stop ();
478
479         if (main_modifier_state() == MODIFIER_SHIFT) {
480                 session->midi_panic();
481         }
482
483         return on;
484 }
485
486 LedState
487 MackieControlProtocol::stop_release (Button &)
488 {
489         return session->transport_stopped();
490 }
491
492 LedState
493 MackieControlProtocol::play_press (Button &)
494 {
495         /* if we're already rolling at normal speed, and we're pressed
496            again, jump back to where we started last time
497         */
498
499         transport_play (session->transport_speed() == 1.0);
500         return none;
501 }
502
503 LedState
504 MackieControlProtocol::play_release (Button &)
505 {
506         return none;
507 }
508
509 LedState
510 MackieControlProtocol::record_press (Button &)
511 {
512         rec_enable_toggle ();
513         return none;
514 }
515
516 LedState
517 MackieControlProtocol::record_release (Button &)
518 {
519         return none;
520 }
521
522 LedState
523 MackieControlProtocol::rewind_press (Button &)
524 {
525         if (modifier_state() & MODIFIER_MARKER) {
526                 prev_marker ();
527         } else if (modifier_state() & MODIFIER_NUDGE) {
528                 access_action ("Editor/nudge-playhead-backward");
529         } else if (main_modifier_state() & MODIFIER_SHIFT) {
530                 goto_start ();
531         } else {
532                 rewind ();
533         }
534         return none;
535 }
536
537 LedState
538 MackieControlProtocol::rewind_release (Button &)
539 {
540         return none;
541 }
542
543 LedState
544 MackieControlProtocol::ffwd_press (Button &)
545 {
546         if (modifier_state() & MODIFIER_MARKER) {
547                 next_marker ();
548         } else if (modifier_state() & MODIFIER_NUDGE) {
549                 access_action ("Editor/nudge-playhead-forward");
550         } else if (main_modifier_state() & MODIFIER_SHIFT) {
551                 goto_end();
552         } else {
553                 ffwd ();
554         }
555         return none;
556 }
557
558 LedState
559 MackieControlProtocol::ffwd_release (Button &)
560 {
561         return none;
562 }
563
564 LedState
565 MackieControlProtocol::loop_press (Button &)
566 {
567         if (main_modifier_state() & MODIFIER_SHIFT) {
568                 access_action ("Editor/set-loop-from-edit-range");
569                 return off;
570         } else {
571                 bool was_on = session->get_play_loop();
572                 session->request_play_loop (!was_on);
573                 return was_on ? off : on;
574         }
575 }
576
577 LedState
578 MackieControlProtocol::loop_release (Button &)
579 {
580         return none;
581 }
582
583 LedState
584 MackieControlProtocol::enter_press (Button &)
585 {
586         if (main_modifier_state() & MODIFIER_SHIFT) {
587                 access_action ("Transport/ToggleFollowEdits");
588         } else {
589                 access_action ("Editor/select-all-tracks");
590         }
591         return none;
592 }
593
594 LedState
595 MackieControlProtocol::enter_release (Button &)
596 {
597         return none;
598 }
599
600 LedState
601 MackieControlProtocol::bank_release (Button& b, uint32_t basic_bank_num)
602 {
603         if (_subview_mode != None) {
604                 return none;
605         }
606
607         uint32_t bank_num = basic_bank_num;
608
609         if (b.long_press_count() > 0) {
610                 bank_num = 8 + basic_bank_num;
611         }
612
613         (void) switch_banks (n_strips() * bank_num);
614
615         return on;
616 }
617
618 LedState
619 MackieControlProtocol::F1_press (Button &b)
620 {
621         return off;
622 }
623 LedState
624 MackieControlProtocol::F1_release (Button &b)
625 {
626         return bank_release (b, 0);
627 }
628 LedState
629 MackieControlProtocol::F2_press (Button &)
630 {
631         return off;
632 }
633 LedState
634 MackieControlProtocol::F2_release (Button &b)
635 {
636         return bank_release (b, 1);
637 }
638 LedState
639 MackieControlProtocol::F3_press (Button &)
640 {
641         return off;
642 }
643 LedState
644 MackieControlProtocol::F3_release (Button &b)
645 {
646         return bank_release (b, 2);
647 }
648 LedState
649 MackieControlProtocol::F4_press (Button &)
650 {
651         return off;
652 }
653 LedState
654 MackieControlProtocol::F4_release (Button &b)
655 {
656         return bank_release (b, 3);
657 }
658 LedState
659 MackieControlProtocol::F5_press (Button &)
660 {
661         return off;
662 }
663 LedState
664 MackieControlProtocol::F5_release (Button &)
665 {
666         return off;
667 }
668 LedState
669 MackieControlProtocol::F6_press (Button &)
670 {
671         return off;
672 }
673 LedState
674 MackieControlProtocol::F6_release (Button &)
675 {
676         return off;
677 }
678 LedState
679 MackieControlProtocol::F7_press (Button &)
680 {
681         return off;
682 }
683 LedState
684 MackieControlProtocol::F7_release (Button &)
685 {
686         return off;
687 }
688 LedState
689 MackieControlProtocol::F8_press (Button &)
690 {
691         CloseDialog (); /* EMIT SIGNAL */
692         return off;
693 }
694 LedState
695 MackieControlProtocol::F8_release (Button &)
696 {
697         return off;
698 }
699
700 /* UNIMPLEMENTED */
701
702 LedState
703 MackieControlProtocol::pan_press (Button &)
704 {
705         /* XXX eventually pan may have its own subview mode */
706         set_subview_mode (MackieControlProtocol::None, boost::shared_ptr<Route>());
707         return none;
708 }
709 LedState
710 MackieControlProtocol::pan_release (Button &)
711 {
712         return none;
713 }
714 LedState
715 MackieControlProtocol::plugin_press (Button &)
716 {
717         return off;
718 }
719 LedState
720 MackieControlProtocol::plugin_release (Button &)
721 {
722         // Do not do this yet, since it does nothing
723         // set_view_mode (Plugins);
724         return none; /* LED state set by set_view_mode */
725 }
726 LedState
727 MackieControlProtocol::eq_press (Button &)
728 {
729         boost::shared_ptr<Route> r = first_selected_route ();
730         set_subview_mode (EQ, r);
731         return none; /* led state handled by set_subview_mode() */
732
733 }
734 LedState
735 MackieControlProtocol::eq_release (Button &)
736 {
737         return none;
738 }
739 LedState
740 MackieControlProtocol::dyn_press (Button &)
741 {
742         boost::shared_ptr<Route> r = first_selected_route ();
743         set_subview_mode (Dynamics, r);
744         return none; /* led state handled by set_subview_mode() */
745 }
746
747 LedState
748 MackieControlProtocol::dyn_release (Button &)
749 {
750         return none;
751 }
752 LedState
753 MackieControlProtocol::flip_press (Button &)
754 {
755         if (subview_mode() == MackieControlProtocol::Sends) {
756                 if (_flip_mode != Normal) {
757                         set_flip_mode (Normal);
758                 } else {
759                         set_flip_mode (Mirror);
760                 }
761                 return ((_flip_mode != Normal) ? on : off);
762         }
763
764         return none;
765 }
766
767 LedState
768 MackieControlProtocol::flip_release (Button &)
769 {
770         return none;
771 }
772 LedState
773 MackieControlProtocol::name_value_press (Button &)
774 {
775         return off;
776 }
777 LedState
778 MackieControlProtocol::name_value_release (Button &)
779 {
780         return off;
781 }
782 LedState
783 MackieControlProtocol::touch_press (Button &)
784 {
785         return none;
786 }
787 LedState
788 MackieControlProtocol::touch_release (Button &)
789 {
790         set_automation_state (ARDOUR::Touch);
791         return none;
792 }
793 LedState
794 MackieControlProtocol::cancel_press (Button &)
795 {
796         if (main_modifier_state() & MODIFIER_SHIFT) {
797                 access_action ("Transport/ToggleExternalSync");
798         } else {
799                 access_action ("Editor/escape");
800         }
801         return none;
802 }
803 LedState
804 MackieControlProtocol::cancel_release (Button &)
805 {
806         return none;
807 }
808 LedState
809 MackieControlProtocol::user_a_press (Button &)
810 {
811         transport_play (session->transport_speed() == 1.0);
812         return off;
813 }
814 LedState
815 MackieControlProtocol::user_a_release (Button &)
816 {
817         return off;
818 }
819 LedState
820 MackieControlProtocol::user_b_press (Button &)
821 {
822         transport_stop();
823         return off;
824 }
825 LedState
826 MackieControlProtocol::user_b_release (Button &)
827 {
828         return off;
829 }
830
831 LedState
832 MackieControlProtocol::master_fader_touch_press (Mackie::Button &)
833 {
834         DEBUG_TRACE (DEBUG::MackieControl, "MackieControlProtocol::master_fader_touch_press\n");
835
836         Fader* master_fader = _master_surface->master_fader();
837
838         boost::shared_ptr<AutomationControl> ac = master_fader->control ();
839
840         master_fader->set_in_use (true);
841         master_fader->start_touch (transport_frame());
842
843         return none;
844 }
845 LedState
846 MackieControlProtocol::master_fader_touch_release (Mackie::Button &)
847 {
848         DEBUG_TRACE (DEBUG::MackieControl, "MackieControlProtocol::master_fader_touch_release\n");
849
850         Fader* master_fader = _master_surface->master_fader();
851
852         master_fader->set_in_use (false);
853         master_fader->stop_touch (transport_frame(), true);
854
855         return none;
856 }
857
858 Mackie::LedState
859 MackieControlProtocol::read_press (Mackie::Button&)
860 {
861         return none;
862 }
863
864 Mackie::LedState
865 MackieControlProtocol::read_release (Mackie::Button&)
866 {
867         set_automation_state (ARDOUR::Play);
868         return none;
869 }
870 Mackie::LedState
871 MackieControlProtocol::write_press (Mackie::Button&)
872 {
873         return none;
874 }
875 Mackie::LedState
876 MackieControlProtocol::write_release (Mackie::Button&)
877 {
878         set_automation_state (ARDOUR::Write);
879         return none;
880 }
881
882 Mackie::LedState
883 MackieControlProtocol::clearsolo_press (Mackie::Button&)
884 {
885         // clears all solos and listens (pfl/afl)
886
887         if (main_modifier_state() & MODIFIER_SHIFT) {
888                 access_action ("Editor/set-session-from-edit-range");
889                 return none;
890         }
891         
892         if (session) {
893                 if (session->soloing()) {
894                         session->set_solo (session->get_routes(), false);
895                 } else if (session->listening()) {
896                         session->set_listen (session->get_routes(), false);
897                 }
898
899                 session->clear_all_solo_state (session->get_routes()); // safeguard, ideally this won't do anything, check the log-window
900         }
901         return none;
902 }
903
904 Mackie::LedState
905 MackieControlProtocol::clearsolo_release (Mackie::Button&)
906 {
907         //return session->soloing();
908         return none;
909 }
910
911 Mackie::LedState
912 MackieControlProtocol::track_press (Mackie::Button&)
913 {
914         set_subview_mode (TrackView, first_selected_route());
915         return none;
916 }
917 Mackie::LedState
918 MackieControlProtocol::track_release (Mackie::Button&)
919 {
920         return none;
921 }
922 Mackie::LedState
923 MackieControlProtocol::send_press (Mackie::Button&)
924 {
925         boost::shared_ptr<Route> r = first_selected_route ();
926         set_subview_mode (Sends, r);
927         return none; /* led state handled by set_subview_mode() */
928 }
929 Mackie::LedState
930 MackieControlProtocol::send_release (Mackie::Button&)
931 {
932         return none;
933 }
934 Mackie::LedState
935 MackieControlProtocol::miditracks_press (Mackie::Button&)
936 {
937         return none;
938 }
939 Mackie::LedState
940 MackieControlProtocol::miditracks_release (Mackie::Button&)
941 {
942         set_view_mode (MidiTracks);
943         return none;
944 }
945 Mackie::LedState
946 MackieControlProtocol::inputs_press (Mackie::Button&)
947 {
948         return none;
949 }
950 Mackie::LedState
951 MackieControlProtocol::inputs_release (Mackie::Button&)
952 {
953         return none;
954 }
955 Mackie::LedState
956 MackieControlProtocol::audiotracks_press (Mackie::Button&)
957 {
958         return none;
959 }
960 Mackie::LedState
961 MackieControlProtocol::audiotracks_release (Mackie::Button&)
962 {
963         set_view_mode (AudioTracks);
964         return none;
965 }
966 Mackie::LedState
967 MackieControlProtocol::audioinstruments_press (Mackie::Button& b)
968 {
969         return none;
970 }
971
972 Mackie::LedState
973 MackieControlProtocol::audioinstruments_release (Mackie::Button& b)
974 {
975         return none;
976
977 }
978 Mackie::LedState
979 MackieControlProtocol::aux_press (Mackie::Button&)
980 {
981         return none;
982 }
983 Mackie::LedState
984 MackieControlProtocol::aux_release (Mackie::Button&)
985 {
986         set_view_mode (Auxes);
987         return none;
988 }
989 Mackie::LedState
990 MackieControlProtocol::busses_press (Mackie::Button&)
991 {
992         return none;
993 }
994 Mackie::LedState
995 MackieControlProtocol::busses_release (Mackie::Button&)
996 {
997         set_view_mode (Busses);
998         return none;
999 }
1000 Mackie::LedState
1001 MackieControlProtocol::outputs_press (Mackie::Button&)
1002 {
1003         return none;
1004 }
1005 Mackie::LedState
1006 MackieControlProtocol::outputs_release (Mackie::Button&)
1007 {
1008         set_view_mode (Hidden);
1009         return none;
1010 }
1011 Mackie::LedState
1012 MackieControlProtocol::user_press (Mackie::Button&)
1013 {
1014         return none;
1015 }
1016 Mackie::LedState
1017 MackieControlProtocol::user_release (Mackie::Button&)
1018 {
1019         set_view_mode (Selected);
1020         return none;
1021 }
1022 Mackie::LedState
1023 MackieControlProtocol::trim_press (Mackie::Button&)
1024 {
1025         return none;
1026 }
1027 Mackie::LedState
1028 MackieControlProtocol::trim_release (Mackie::Button&)
1029 {
1030         return none;
1031 }
1032 Mackie::LedState
1033 MackieControlProtocol::latch_press (Mackie::Button&)
1034 {
1035         return none;
1036 }
1037 Mackie::LedState
1038 MackieControlProtocol::latch_release (Mackie::Button&)
1039 {
1040         return none;
1041 }
1042 Mackie::LedState
1043 MackieControlProtocol::grp_press (Mackie::Button&)
1044 {
1045         return none;
1046 }
1047 Mackie::LedState
1048 MackieControlProtocol::grp_release (Mackie::Button&)
1049 {
1050         /* There is no "Off" button for automation,
1051            so we use Group for this purpose.
1052         */
1053         set_automation_state (Off);
1054         return none;
1055 }
1056 Mackie::LedState
1057 MackieControlProtocol::nudge_press (Mackie::Button&)
1058 {
1059         _modifier_state |= MODIFIER_NUDGE;
1060         nudge_modifier_consumed_by_button = false;
1061         return on;
1062 }
1063 Mackie::LedState
1064 MackieControlProtocol::nudge_release (Mackie::Button&)
1065 {
1066         _modifier_state &= ~MODIFIER_NUDGE;
1067
1068         /* XXX these action names are stupid, because the action can affect
1069          * regions, markers or the playhead depending on selection state. 
1070          */
1071
1072         if (main_modifier_state() & MODIFIER_SHIFT) {
1073                 access_action ("Region/nudge-backward");
1074         } else {
1075                 access_action ("Region/nudge-forward");
1076         }
1077
1078         return off;
1079 }
1080 Mackie::LedState
1081 MackieControlProtocol::replace_press (Mackie::Button&)
1082 {
1083         if (main_modifier_state() == MODIFIER_SHIFT) {
1084                 toggle_punch_out();
1085                 return none;
1086         } else {
1087                 access_action ("Editor/finish-range-from-playhead");
1088         }
1089         return none;
1090 }
1091 Mackie::LedState
1092 MackieControlProtocol::replace_release (Mackie::Button&)
1093 {
1094         return none;
1095 }
1096 Mackie::LedState
1097 MackieControlProtocol::click_press (Mackie::Button&)
1098 {
1099         if (main_modifier_state() & MODIFIER_SHIFT) {
1100                 access_action ("Editor/set-punch-from-edit-range");
1101                 return off;
1102         } else {
1103                 bool state = !Config->get_clicking();
1104                 Config->set_clicking (state);
1105                 return state;
1106         }
1107 }
1108 Mackie::LedState
1109 MackieControlProtocol::click_release (Mackie::Button&)
1110 {
1111         return none;
1112 }
1113 Mackie::LedState
1114 MackieControlProtocol::view_press (Mackie::Button&)
1115 {
1116         set_view_mode (Mixer);
1117         return none;
1118 }
1119 Mackie::LedState
1120 MackieControlProtocol::view_release (Mackie::Button&)
1121 {
1122         return none;
1123 }