mackie support should use BasicUI::loop_toggle()
[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         if (main_modifier_state() & MODIFIER_SHIFT) {
428                 access_action ("Common/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 ("Common/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 ("Common/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 ("Common/set-loop-from-edit-range");
569                 return off;
570         } else {
571                 loop_toggle ();
572         }
573 }
574
575 LedState
576 MackieControlProtocol::loop_release (Button &)
577 {
578         return none;
579 }
580
581 LedState
582 MackieControlProtocol::enter_press (Button &)
583 {
584         if (main_modifier_state() & MODIFIER_SHIFT) {
585                 access_action ("Transport/ToggleFollowEdits");
586         } else {
587                 access_action ("Editor/select-all-tracks");
588         }
589         return none;
590 }
591
592 LedState
593 MackieControlProtocol::enter_release (Button &)
594 {
595         return none;
596 }
597
598 LedState
599 MackieControlProtocol::bank_release (Button& b, uint32_t basic_bank_num)
600 {
601         if (_subview_mode != None) {
602                 return none;
603         }
604
605         uint32_t bank_num = basic_bank_num;
606
607         if (b.long_press_count() > 0) {
608                 bank_num = 8 + basic_bank_num;
609         }
610
611         (void) switch_banks (n_strips() * bank_num);
612
613         return on;
614 }
615
616 LedState
617 MackieControlProtocol::F1_press (Button &b)
618 {
619         return off;
620 }
621 LedState
622 MackieControlProtocol::F1_release (Button &b)
623 {
624         return bank_release (b, 0);
625 }
626 LedState
627 MackieControlProtocol::F2_press (Button &)
628 {
629         return off;
630 }
631 LedState
632 MackieControlProtocol::F2_release (Button &b)
633 {
634         return bank_release (b, 1);
635 }
636 LedState
637 MackieControlProtocol::F3_press (Button &)
638 {
639         return off;
640 }
641 LedState
642 MackieControlProtocol::F3_release (Button &b)
643 {
644         return bank_release (b, 2);
645 }
646 LedState
647 MackieControlProtocol::F4_press (Button &)
648 {
649         return off;
650 }
651 LedState
652 MackieControlProtocol::F4_release (Button &b)
653 {
654         return bank_release (b, 3);
655 }
656 LedState
657 MackieControlProtocol::F5_press (Button &)
658 {
659         return off;
660 }
661 LedState
662 MackieControlProtocol::F5_release (Button &)
663 {
664         return off;
665 }
666 LedState
667 MackieControlProtocol::F6_press (Button &)
668 {
669         return off;
670 }
671 LedState
672 MackieControlProtocol::F6_release (Button &)
673 {
674         return off;
675 }
676 LedState
677 MackieControlProtocol::F7_press (Button &)
678 {
679         return off;
680 }
681 LedState
682 MackieControlProtocol::F7_release (Button &)
683 {
684         return off;
685 }
686 LedState
687 MackieControlProtocol::F8_press (Button &)
688 {
689         CloseDialog (); /* EMIT SIGNAL */
690         return off;
691 }
692 LedState
693 MackieControlProtocol::F8_release (Button &)
694 {
695         return off;
696 }
697
698 /* UNIMPLEMENTED */
699
700 LedState
701 MackieControlProtocol::pan_press (Button &)
702 {
703         /* XXX eventually pan may have its own subview mode */
704         set_subview_mode (MackieControlProtocol::None, boost::shared_ptr<Stripable>());
705         return none;
706 }
707 LedState
708 MackieControlProtocol::pan_release (Button &)
709 {
710         return none;
711 }
712 LedState
713 MackieControlProtocol::plugin_press (Button &)
714 {
715         return off;
716 }
717 LedState
718 MackieControlProtocol::plugin_release (Button &)
719 {
720         // Do not do this yet, since it does nothing
721         // set_view_mode (Plugins);
722         return none; /* LED state set by set_view_mode */
723 }
724 LedState
725 MackieControlProtocol::eq_press (Button &)
726 {
727         set_subview_mode (EQ, first_selected_stripable ());
728         return none; /* led state handled by set_subview_mode() */
729
730 }
731 LedState
732 MackieControlProtocol::eq_release (Button &)
733 {
734         return none;
735 }
736 LedState
737 MackieControlProtocol::dyn_press (Button &)
738 {
739         set_subview_mode (Dynamics, first_selected_stripable ());
740         return none; /* led state handled by set_subview_mode() */
741 }
742
743 LedState
744 MackieControlProtocol::dyn_release (Button &)
745 {
746         return none;
747 }
748 LedState
749 MackieControlProtocol::flip_press (Button &)
750 {
751         if (subview_mode() == MackieControlProtocol::Sends) {
752                 if (_flip_mode != Normal) {
753                         set_flip_mode (Normal);
754                 } else {
755                         set_flip_mode (Mirror);
756                 }
757                 return ((_flip_mode != Normal) ? on : off);
758         }
759
760         return none;
761 }
762
763 LedState
764 MackieControlProtocol::flip_release (Button &)
765 {
766         return none;
767 }
768 LedState
769 MackieControlProtocol::name_value_press (Button &)
770 {
771         return off;
772 }
773 LedState
774 MackieControlProtocol::name_value_release (Button &)
775 {
776         return off;
777 }
778 LedState
779 MackieControlProtocol::touch_press (Button &)
780 {
781         return none;
782 }
783 LedState
784 MackieControlProtocol::touch_release (Button &)
785 {
786         set_automation_state (ARDOUR::Touch);
787         return none;
788 }
789 LedState
790 MackieControlProtocol::cancel_press (Button &)
791 {
792         if (main_modifier_state() & MODIFIER_SHIFT) {
793                 access_action ("Transport/ToggleExternalSync");
794         } else {
795                 access_action ("Main/Escape");
796         }
797         return none;
798 }
799 LedState
800 MackieControlProtocol::cancel_release (Button &)
801 {
802         return none;
803 }
804 LedState
805 MackieControlProtocol::user_a_press (Button &)
806 {
807         transport_play (session->transport_speed() == 1.0);
808         return off;
809 }
810 LedState
811 MackieControlProtocol::user_a_release (Button &)
812 {
813         return off;
814 }
815 LedState
816 MackieControlProtocol::user_b_press (Button &)
817 {
818         transport_stop();
819         return off;
820 }
821 LedState
822 MackieControlProtocol::user_b_release (Button &)
823 {
824         return off;
825 }
826
827 LedState
828 MackieControlProtocol::master_fader_touch_press (Mackie::Button &)
829 {
830         DEBUG_TRACE (DEBUG::MackieControl, "MackieControlProtocol::master_fader_touch_press\n");
831
832         Fader* master_fader = _master_surface->master_fader();
833
834         boost::shared_ptr<AutomationControl> ac = master_fader->control ();
835
836         master_fader->set_in_use (true);
837         master_fader->start_touch (transport_frame());
838
839         return none;
840 }
841 LedState
842 MackieControlProtocol::master_fader_touch_release (Mackie::Button &)
843 {
844         DEBUG_TRACE (DEBUG::MackieControl, "MackieControlProtocol::master_fader_touch_release\n");
845
846         Fader* master_fader = _master_surface->master_fader();
847
848         master_fader->set_in_use (false);
849         master_fader->stop_touch (transport_frame(), true);
850
851         return none;
852 }
853
854 Mackie::LedState
855 MackieControlProtocol::read_press (Mackie::Button&)
856 {
857         return none;
858 }
859
860 Mackie::LedState
861 MackieControlProtocol::read_release (Mackie::Button&)
862 {
863         set_automation_state (ARDOUR::Play);
864         return none;
865 }
866 Mackie::LedState
867 MackieControlProtocol::write_press (Mackie::Button&)
868 {
869         return none;
870 }
871 Mackie::LedState
872 MackieControlProtocol::write_release (Mackie::Button&)
873 {
874         set_automation_state (ARDOUR::Write);
875         return none;
876 }
877
878 Mackie::LedState
879 MackieControlProtocol::clearsolo_press (Mackie::Button&)
880 {
881         // clears all solos and listens (pfl/afl)
882
883         if (main_modifier_state() & MODIFIER_SHIFT) {
884                 access_action ("Common/set-session-from-edit-range");
885                 return none;
886         }
887
888         cancel_all_solo ();
889         return none;
890 }
891
892 Mackie::LedState
893 MackieControlProtocol::clearsolo_release (Mackie::Button&)
894 {
895         //return session->soloing();
896         return none;
897 }
898
899 Mackie::LedState
900 MackieControlProtocol::track_press (Mackie::Button&)
901 {
902         set_subview_mode (TrackView, first_selected_stripable());
903         return none;
904 }
905 Mackie::LedState
906 MackieControlProtocol::track_release (Mackie::Button&)
907 {
908         return none;
909 }
910 Mackie::LedState
911 MackieControlProtocol::send_press (Mackie::Button&)
912 {
913         set_subview_mode (Sends, first_selected_stripable());
914         return none; /* led state handled by set_subview_mode() */
915 }
916 Mackie::LedState
917 MackieControlProtocol::send_release (Mackie::Button&)
918 {
919         return none;
920 }
921 Mackie::LedState
922 MackieControlProtocol::miditracks_press (Mackie::Button&)
923 {
924         return none;
925 }
926 Mackie::LedState
927 MackieControlProtocol::miditracks_release (Mackie::Button&)
928 {
929         set_view_mode (MidiTracks);
930         return none;
931 }
932 Mackie::LedState
933 MackieControlProtocol::inputs_press (Mackie::Button&)
934 {
935 #ifdef MIXBUS
936         set_view_mode (Mixer);  //in Mixbus, this is the same as Global View (avoid dead buttons)
937 #endif
938         return none;
939 }
940 Mackie::LedState
941 MackieControlProtocol::inputs_release (Mackie::Button&)
942 {
943         return none;
944 }
945 Mackie::LedState
946 MackieControlProtocol::audiotracks_press (Mackie::Button&)
947 {
948         return none;
949 }
950 Mackie::LedState
951 MackieControlProtocol::audiotracks_release (Mackie::Button&)
952 {
953         set_view_mode (AudioTracks);
954         return none;
955 }
956 Mackie::LedState
957 MackieControlProtocol::audioinstruments_press (Mackie::Button& b)
958 {
959 #ifdef MIXBUS
960         set_view_mode (MidiTracks);  //in Mixbus, we do the same thing as MIDI Tracks ( aviod dead buttons )
961 #endif
962         return none;
963 }
964
965 Mackie::LedState
966 MackieControlProtocol::audioinstruments_release (Mackie::Button& b)
967 {
968         return none;
969
970 }
971 Mackie::LedState
972 MackieControlProtocol::aux_press (Mackie::Button&)
973 {
974         return none;
975 }
976 Mackie::LedState
977 MackieControlProtocol::aux_release (Mackie::Button&)
978 {
979         set_view_mode (Auxes);
980         return none;
981 }
982 Mackie::LedState
983 MackieControlProtocol::busses_press (Mackie::Button&)
984 {
985         return none;
986 }
987 Mackie::LedState
988 MackieControlProtocol::busses_release (Mackie::Button&)
989 {
990         set_view_mode (Busses);
991         return none;
992 }
993 Mackie::LedState
994 MackieControlProtocol::outputs_press (Mackie::Button&)
995 {
996         return none;
997 }
998 Mackie::LedState
999 MackieControlProtocol::outputs_release (Mackie::Button&)
1000 {
1001         set_view_mode (Hidden);
1002         return none;
1003 }
1004 Mackie::LedState
1005 MackieControlProtocol::user_press (Mackie::Button&)
1006 {
1007         return none;
1008 }
1009 Mackie::LedState
1010 MackieControlProtocol::user_release (Mackie::Button&)
1011 {
1012         set_view_mode (Selected);
1013         return none;
1014 }
1015 Mackie::LedState
1016 MackieControlProtocol::trim_press (Mackie::Button&)
1017 {
1018         return none;
1019 }
1020 Mackie::LedState
1021 MackieControlProtocol::trim_release (Mackie::Button&)
1022 {
1023         return none;
1024 }
1025 Mackie::LedState
1026 MackieControlProtocol::latch_press (Mackie::Button&)
1027 {
1028         return none;
1029 }
1030 Mackie::LedState
1031 MackieControlProtocol::latch_release (Mackie::Button&)
1032 {
1033         return none;
1034 }
1035 Mackie::LedState
1036 MackieControlProtocol::grp_press (Mackie::Button&)
1037 {
1038         return none;
1039 }
1040 Mackie::LedState
1041 MackieControlProtocol::grp_release (Mackie::Button&)
1042 {
1043         /* There is no "Off" button for automation,
1044            so we use Group for this purpose.
1045         */
1046         set_automation_state (Off);
1047         return none;
1048 }
1049 Mackie::LedState
1050 MackieControlProtocol::nudge_press (Mackie::Button&)
1051 {
1052         _modifier_state |= MODIFIER_NUDGE;
1053         nudge_modifier_consumed_by_button = false;
1054         return on;
1055 }
1056 Mackie::LedState
1057 MackieControlProtocol::nudge_release (Mackie::Button&)
1058 {
1059         _modifier_state &= ~MODIFIER_NUDGE;
1060
1061         /* XXX these action names are stupid, because the action can affect
1062          * regions, markers or the playhead depending on selection state.
1063          */
1064
1065         if (main_modifier_state() & MODIFIER_SHIFT) {
1066                 access_action ("Region/nudge-backward");
1067         } else {
1068                 access_action ("Region/nudge-forward");
1069         }
1070
1071         return off;
1072 }
1073 Mackie::LedState
1074 MackieControlProtocol::replace_press (Mackie::Button&)
1075 {
1076         if (main_modifier_state() == MODIFIER_SHIFT) {
1077                 toggle_punch_out();
1078                 return none;
1079         } else {
1080                 access_action ("Common/finish-range-from-playhead");
1081         }
1082         return none;
1083 }
1084 Mackie::LedState
1085 MackieControlProtocol::replace_release (Mackie::Button&)
1086 {
1087         return none;
1088 }
1089 Mackie::LedState
1090 MackieControlProtocol::click_press (Mackie::Button&)
1091 {
1092         if (main_modifier_state() & MODIFIER_SHIFT) {
1093                 access_action ("Common/set-punch-from-edit-range");
1094                 return off;
1095         } else {
1096                 bool state = !Config->get_clicking();
1097                 Config->set_clicking (state);
1098                 return state;
1099         }
1100 }
1101 Mackie::LedState
1102 MackieControlProtocol::click_release (Mackie::Button&)
1103 {
1104         return none;
1105 }
1106 Mackie::LedState
1107 MackieControlProtocol::view_press (Mackie::Button&)
1108 {
1109         set_view_mode (Mixer);
1110         return none;
1111 }
1112 Mackie::LedState
1113 MackieControlProtocol::view_release (Mackie::Button&)
1114 {
1115         return none;
1116 }