Mackie protocol: set-session-from-edit-range moved to shift+marker
[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         } else {
366                 access_action ("Editor/start-range-from-playhead");
367         }
368         return none;
369 }
370
371 LedState
372 MackieControlProtocol::drop_release (Button &)
373 {
374         return none;
375 }
376
377 LedState
378 MackieControlProtocol::save_press (Button &)
379 {
380         if (main_modifier_state() == MODIFIER_SHIFT) {
381                 quick_snapshot_switch();
382         } else {
383                 save_state ();
384         }
385         
386         return none;
387 }
388
389 LedState
390 MackieControlProtocol::save_release (Button &)
391 {
392         return none;
393 }
394
395 LedState
396 MackieControlProtocol::timecode_beats_press (Button &)
397 {
398         switch (_timecode_type) {
399         case ARDOUR::AnyTime::BBT:
400                 _timecode_type = ARDOUR::AnyTime::Timecode;
401                 break;
402         case ARDOUR::AnyTime::Timecode:
403                 _timecode_type = ARDOUR::AnyTime::BBT;
404                 break;
405         default:
406                 return off;
407         }
408
409         update_timecode_beats_led();
410
411         return on;
412 }
413
414 LedState
415 MackieControlProtocol::timecode_beats_release (Button &)
416 {
417         return off;
418 }
419
420 /////////////////////////////////////
421 // Functions
422 /////////////////////////////////////
423 LedState
424 MackieControlProtocol::marker_press (Button &)
425 {
426         if (main_modifier_state() & MODIFIER_SHIFT) {
427                 access_action ("Editor/set-session-from-edit-range");
428                 return off;
429         } else {
430                 _modifier_state |= MODIFIER_MARKER;
431                 marker_modifier_consumed_by_button = false;
432                 return on;
433         }
434 }
435
436 LedState
437 MackieControlProtocol::marker_release (Button &)
438 {
439         _modifier_state &= ~MODIFIER_MARKER;
440
441         if (marker_modifier_consumed_by_button) {
442                 /* marker was used a modifier for some other button(s), so do
443                    nothing
444                 */
445                 return off;
446         }
447
448         string markername;
449
450         /* Don't add another mark if one exists within 1/100th of a second of
451          * the current position and we're not rolling.
452          */
453
454         framepos_t where = session->audible_frame();
455
456         if (session->transport_stopped() && session->locations()->mark_at (where, session->frame_rate() / 100.0)) {
457                 return off;
458         }
459
460         session->locations()->next_available_name (markername,"marker");
461         add_marker (markername);
462
463         return off;
464 }
465
466 /////////////////////////////////////
467 // Transport Buttons
468 /////////////////////////////////////
469
470 LedState
471 MackieControlProtocol::stop_press (Button &)
472 {
473         transport_stop ();
474
475         if (main_modifier_state() == MODIFIER_SHIFT) {
476                 session->midi_panic();
477         }
478
479         return on;
480 }
481
482 LedState
483 MackieControlProtocol::stop_release (Button &)
484 {
485         return session->transport_stopped();
486 }
487
488 LedState
489 MackieControlProtocol::play_press (Button &)
490 {
491         /* if we're already rolling at normal speed, and we're pressed
492            again, jump back to where we started last time
493         */
494
495         transport_play (session->transport_speed() == 1.0);
496         return none;
497 }
498
499 LedState
500 MackieControlProtocol::play_release (Button &)
501 {
502         return none;
503 }
504
505 LedState
506 MackieControlProtocol::record_press (Button &)
507 {
508         rec_enable_toggle ();
509         return none;
510 }
511
512 LedState
513 MackieControlProtocol::record_release (Button &)
514 {
515         return none;
516 }
517
518 LedState
519 MackieControlProtocol::rewind_press (Button &)
520 {
521         if (modifier_state() & MODIFIER_MARKER) {
522                 prev_marker ();
523         } else if (modifier_state() & MODIFIER_NUDGE) {
524                 access_action ("Editor/nudge-playhead-backward");
525         } else if (main_modifier_state() & MODIFIER_SHIFT) {
526                 goto_start ();
527         } else {
528                 rewind ();
529         }
530         return none;
531 }
532
533 LedState
534 MackieControlProtocol::rewind_release (Button &)
535 {
536         return none;
537 }
538
539 LedState
540 MackieControlProtocol::ffwd_press (Button &)
541 {
542         if (modifier_state() & MODIFIER_MARKER) {
543                 next_marker ();
544         } else if (modifier_state() & MODIFIER_NUDGE) {
545                 access_action ("Editor/nudge-playhead-forward");
546         } else if (main_modifier_state() & MODIFIER_SHIFT) {
547                 goto_end();
548         } else {
549                 ffwd ();
550         }
551         return none;
552 }
553
554 LedState
555 MackieControlProtocol::ffwd_release (Button &)
556 {
557         return none;
558 }
559
560 LedState
561 MackieControlProtocol::loop_press (Button &)
562 {
563         if (main_modifier_state() & MODIFIER_SHIFT) {
564                 access_action ("Editor/set-loop-from-edit-range");
565                 return off;
566         } else {
567                 bool was_on = session->get_play_loop();
568                 session->request_play_loop (!was_on);
569                 return was_on ? off : on;
570         }
571 }
572
573 LedState
574 MackieControlProtocol::loop_release (Button &)
575 {
576         return none;
577 }
578
579 LedState
580 MackieControlProtocol::enter_press (Button &)
581 {
582         if (main_modifier_state() & MODIFIER_SHIFT) {
583                 access_action ("Transport/ToggleFollowEdits");
584         } else {
585                 access_action ("Editor/select-all-tracks");
586         }
587         return none;
588 }
589
590 LedState
591 MackieControlProtocol::enter_release (Button &)
592 {
593         return none;
594 }
595
596 LedState
597 MackieControlProtocol::bank_release (Button& b, uint32_t basic_bank_num)
598 {
599         if (_subview_mode != None) {
600                 return none;
601         }
602
603         uint32_t bank_num = basic_bank_num;
604
605         if (b.long_press_count() > 0) {
606                 bank_num = 8 + basic_bank_num;
607         }
608
609         (void) switch_banks (n_strips() * bank_num);
610
611         return on;
612 }
613
614 LedState
615 MackieControlProtocol::F1_press (Button &b)
616 {
617         return off;
618 }
619 LedState
620 MackieControlProtocol::F1_release (Button &b)
621 {
622         return bank_release (b, 0);
623 }
624 LedState
625 MackieControlProtocol::F2_press (Button &)
626 {
627         return off;
628 }
629 LedState
630 MackieControlProtocol::F2_release (Button &b)
631 {
632         return bank_release (b, 1);
633 }
634 LedState
635 MackieControlProtocol::F3_press (Button &)
636 {
637         return off;
638 }
639 LedState
640 MackieControlProtocol::F3_release (Button &b)
641 {
642         return bank_release (b, 2);
643 }
644 LedState
645 MackieControlProtocol::F4_press (Button &)
646 {
647         return off;
648 }
649 LedState
650 MackieControlProtocol::F4_release (Button &b)
651 {
652         return bank_release (b, 3);
653 }
654 LedState
655 MackieControlProtocol::F5_press (Button &)
656 {
657         return off;
658 }
659 LedState
660 MackieControlProtocol::F5_release (Button &)
661 {
662         return off;
663 }
664 LedState
665 MackieControlProtocol::F6_press (Button &)
666 {
667         return off;
668 }
669 LedState
670 MackieControlProtocol::F6_release (Button &)
671 {
672         return off;
673 }
674 LedState
675 MackieControlProtocol::F7_press (Button &)
676 {
677         return off;
678 }
679 LedState
680 MackieControlProtocol::F7_release (Button &)
681 {
682         return off;
683 }
684 LedState
685 MackieControlProtocol::F8_press (Button &)
686 {
687         CloseDialog (); /* EMIT SIGNAL */
688         return off;
689 }
690 LedState
691 MackieControlProtocol::F8_release (Button &)
692 {
693         return off;
694 }
695
696 /* UNIMPLEMENTED */
697
698 LedState
699 MackieControlProtocol::pan_press (Button &)
700 {
701         /* XXX eventually pan may have its own subview mode */
702         set_subview_mode (MackieControlProtocol::None, boost::shared_ptr<Route>());
703         return none;
704 }
705 LedState
706 MackieControlProtocol::pan_release (Button &)
707 {
708         return none;
709 }
710 LedState
711 MackieControlProtocol::plugin_press (Button &)
712 {
713         return off;
714 }
715 LedState
716 MackieControlProtocol::plugin_release (Button &)
717 {
718         // Do not do this yet, since it does nothing
719         // set_view_mode (Plugins);
720         return none; /* LED state set by set_view_mode */
721 }
722 LedState
723 MackieControlProtocol::eq_press (Button &)
724 {
725         boost::shared_ptr<Route> r = first_selected_route ();
726         set_subview_mode (EQ, r);
727         return none; /* led state handled by set_subview_mode() */
728
729 }
730 LedState
731 MackieControlProtocol::eq_release (Button &)
732 {
733         return none;
734 }
735 LedState
736 MackieControlProtocol::dyn_press (Button &)
737 {
738         boost::shared_ptr<Route> r = first_selected_route ();
739         set_subview_mode (Dynamics, r);
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 ("Editor/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 (session) {
884                 if (session->soloing()) {
885                         session->set_solo (session->get_routes(), false);
886                 } else if (session->listening()) {
887                         session->set_listen (session->get_routes(), false);
888                 }
889
890                 session->clear_all_solo_state (session->get_routes()); // safeguard, ideally this won't do anything, check the log-window
891         }
892         return none;
893 }
894
895 Mackie::LedState
896 MackieControlProtocol::clearsolo_release (Mackie::Button&)
897 {
898         //return session->soloing();
899         return none;
900 }
901
902 Mackie::LedState
903 MackieControlProtocol::track_press (Mackie::Button&)
904 {
905         set_subview_mode (TrackView, first_selected_route());
906         return none;
907 }
908 Mackie::LedState
909 MackieControlProtocol::track_release (Mackie::Button&)
910 {
911         return none;
912 }
913 Mackie::LedState
914 MackieControlProtocol::send_press (Mackie::Button&)
915 {
916         boost::shared_ptr<Route> r = first_selected_route ();
917         set_subview_mode (Sends, r);
918         return none; /* led state handled by set_subview_mode() */
919 }
920 Mackie::LedState
921 MackieControlProtocol::send_release (Mackie::Button&)
922 {
923         return none;
924 }
925 Mackie::LedState
926 MackieControlProtocol::miditracks_press (Mackie::Button&)
927 {
928         return none;
929 }
930 Mackie::LedState
931 MackieControlProtocol::miditracks_release (Mackie::Button&)
932 {
933         set_view_mode (MidiTracks);
934         return none;
935 }
936 Mackie::LedState
937 MackieControlProtocol::inputs_press (Mackie::Button&)
938 {
939         return none;
940 }
941 Mackie::LedState
942 MackieControlProtocol::inputs_release (Mackie::Button&)
943 {
944         return none;
945 }
946 Mackie::LedState
947 MackieControlProtocol::audiotracks_press (Mackie::Button&)
948 {
949         return none;
950 }
951 Mackie::LedState
952 MackieControlProtocol::audiotracks_release (Mackie::Button&)
953 {
954         set_view_mode (AudioTracks);
955         return none;
956 }
957 Mackie::LedState
958 MackieControlProtocol::audioinstruments_press (Mackie::Button& b)
959 {
960         return none;
961 }
962
963 Mackie::LedState
964 MackieControlProtocol::audioinstruments_release (Mackie::Button& b)
965 {
966         return none;
967
968 }
969 Mackie::LedState
970 MackieControlProtocol::aux_press (Mackie::Button&)
971 {
972         return none;
973 }
974 Mackie::LedState
975 MackieControlProtocol::aux_release (Mackie::Button&)
976 {
977         set_view_mode (Auxes);
978         return none;
979 }
980 Mackie::LedState
981 MackieControlProtocol::busses_press (Mackie::Button&)
982 {
983         return none;
984 }
985 Mackie::LedState
986 MackieControlProtocol::busses_release (Mackie::Button&)
987 {
988         set_view_mode (Busses);
989         return none;
990 }
991 Mackie::LedState
992 MackieControlProtocol::outputs_press (Mackie::Button&)
993 {
994         return none;
995 }
996 Mackie::LedState
997 MackieControlProtocol::outputs_release (Mackie::Button&)
998 {
999         set_view_mode (Hidden);
1000         return none;
1001 }
1002 Mackie::LedState
1003 MackieControlProtocol::user_press (Mackie::Button&)
1004 {
1005         return none;
1006 }
1007 Mackie::LedState
1008 MackieControlProtocol::user_release (Mackie::Button&)
1009 {
1010         set_view_mode (Selected);
1011         return none;
1012 }
1013 Mackie::LedState
1014 MackieControlProtocol::trim_press (Mackie::Button&)
1015 {
1016         return none;
1017 }
1018 Mackie::LedState
1019 MackieControlProtocol::trim_release (Mackie::Button&)
1020 {
1021         return none;
1022 }
1023 Mackie::LedState
1024 MackieControlProtocol::latch_press (Mackie::Button&)
1025 {
1026         return none;
1027 }
1028 Mackie::LedState
1029 MackieControlProtocol::latch_release (Mackie::Button&)
1030 {
1031         return none;
1032 }
1033 Mackie::LedState
1034 MackieControlProtocol::grp_press (Mackie::Button&)
1035 {
1036         return none;
1037 }
1038 Mackie::LedState
1039 MackieControlProtocol::grp_release (Mackie::Button&)
1040 {
1041         /* There is no "Off" button for automation,
1042            so we use Group for this purpose.
1043         */
1044         set_automation_state (Off);
1045         return none;
1046 }
1047 Mackie::LedState
1048 MackieControlProtocol::nudge_press (Mackie::Button&)
1049 {
1050         _modifier_state |= MODIFIER_NUDGE;
1051         nudge_modifier_consumed_by_button = false;
1052         return on;
1053 }
1054 Mackie::LedState
1055 MackieControlProtocol::nudge_release (Mackie::Button&)
1056 {
1057         _modifier_state &= ~MODIFIER_NUDGE;
1058
1059         /* XXX these action names are stupid, because the action can affect
1060          * regions, markers or the playhead depending on selection state. 
1061          */
1062
1063         if (main_modifier_state() & MODIFIER_SHIFT) {
1064                 access_action ("Region/nudge-backward");
1065         } else {
1066                 access_action ("Region/nudge-forward");
1067         }
1068
1069         return off;
1070 }
1071 Mackie::LedState
1072 MackieControlProtocol::replace_press (Mackie::Button&)
1073 {
1074         if (main_modifier_state() == MODIFIER_SHIFT) {
1075                 toggle_punch_out();
1076         } else {
1077                 access_action ("Editor/finish-range-from-playhead");
1078         }
1079         return off;
1080 }
1081 Mackie::LedState
1082 MackieControlProtocol::replace_release (Mackie::Button&)
1083 {
1084         return none;
1085 }
1086 Mackie::LedState
1087 MackieControlProtocol::click_press (Mackie::Button&)
1088 {
1089         if (main_modifier_state() & MODIFIER_SHIFT) {
1090                 access_action ("Editor/set-punch-from-edit-range");
1091                 return off;
1092         } else {
1093                 bool state = !Config->get_clicking();
1094                 Config->set_clicking (state);
1095                 return state;
1096         }
1097 }
1098 Mackie::LedState
1099 MackieControlProtocol::click_release (Mackie::Button&)
1100 {
1101         return none;
1102 }
1103 Mackie::LedState
1104 MackieControlProtocol::view_press (Mackie::Button&)
1105 {
1106         set_view_mode (Mixer);
1107         return none;
1108 }
1109 Mackie::LedState
1110 MackieControlProtocol::view_release (Mackie::Button&)
1111 {
1112         return none;
1113 }