035d7b2e5f0eca16f0e4f2d1ccfd09fc066bf8f0
[ardour.git] / libs / surfaces / push2 / buttons.cc
1 /*
2   Copyright (C) 2016 Paul Davis
3
4   This program is free software; you can redistribute it and/or modify
5   it under the terms of the GNU General Public License as published by
6   the Free Software Foundation; either version 2 of the License, or
7   (at your option) any later version.
8
9   This program is distributed in the hope that it will be useful,
10   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12   GNU General Public License for more details.
13
14   You should have received a copy of the GNU General Public License
15   along with this program; if not, write to the Free Software
16   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18
19 #include <algorithm>
20
21 #include "ardour/debug.h"
22 #include "ardour/mute_control.h"
23 #include "ardour/session.h"
24 #include "ardour/solo_control.h"
25
26 #include "layout.h"
27 #include "push2.h"
28 #include "track_mix.h"
29
30 using namespace ArdourSurface;
31 using namespace ARDOUR;
32 using namespace PBD;
33 using std::cerr;
34
35 void
36 Push2::build_maps ()
37 {
38         /* Pads */
39
40         Pad* pad;
41
42 #define MAKE_PAD(x,y,nn) \
43         pad = new Pad ((x), (y), (nn)); \
44         nn_pad_map.insert (std::make_pair (pad->extra(), pad));
45
46         MAKE_PAD (0, 0, 92);
47         MAKE_PAD (0, 1, 93);
48         MAKE_PAD (0, 2, 94);
49         MAKE_PAD (0, 3, 95);
50         MAKE_PAD (0, 4, 96);
51         MAKE_PAD (0, 5, 97);
52         MAKE_PAD (0, 6, 98);
53         MAKE_PAD (0, 7, 99);
54         MAKE_PAD (1, 0, 84);
55         MAKE_PAD (1, 1, 85);
56         MAKE_PAD (1, 2, 86);
57         MAKE_PAD (1, 3, 87);
58         MAKE_PAD (1, 4, 88);
59         MAKE_PAD (1, 5, 89);
60         MAKE_PAD (1, 6, 90);
61         MAKE_PAD (1, 7, 91);
62         MAKE_PAD (2, 0, 76);
63         MAKE_PAD (2, 1, 77);
64         MAKE_PAD (2, 2, 78);
65         MAKE_PAD (2, 3, 79);
66         MAKE_PAD (2, 4, 80);
67         MAKE_PAD (2, 5, 81);
68         MAKE_PAD (2, 6, 82);
69         MAKE_PAD (2, 7, 83);
70         MAKE_PAD (3, 0, 68);
71         MAKE_PAD (3, 1, 69);
72         MAKE_PAD (3, 2, 70);
73         MAKE_PAD (3, 3, 71);
74         MAKE_PAD (3, 4, 72);
75         MAKE_PAD (3, 5, 73);
76         MAKE_PAD (3, 6, 74);
77         MAKE_PAD (3, 7, 75);
78         MAKE_PAD (4, 0, 60);
79         MAKE_PAD (4, 1, 61);
80         MAKE_PAD (4, 2, 62);
81         MAKE_PAD (4, 3, 63);
82         MAKE_PAD (4, 4, 64);
83         MAKE_PAD (4, 5, 65);
84         MAKE_PAD (4, 6, 66);
85         MAKE_PAD (4, 7, 67);
86         MAKE_PAD (5, 0, 52);
87         MAKE_PAD (5, 1, 53);
88         MAKE_PAD (5, 2, 54);
89         MAKE_PAD (5, 3, 55);
90         MAKE_PAD (5, 4, 56);
91         MAKE_PAD (5, 5, 57);
92         MAKE_PAD (5, 6, 58);
93         MAKE_PAD (5, 7, 59);
94         MAKE_PAD (6, 0, 44);
95         MAKE_PAD (6, 1, 45);
96         MAKE_PAD (6, 2, 46);
97         MAKE_PAD (6, 3, 47);
98         MAKE_PAD (6, 4, 48);
99         MAKE_PAD (6, 5, 49);
100         MAKE_PAD (6, 6, 50);
101         MAKE_PAD (6, 7, 51);
102         MAKE_PAD (7, 0, 36);
103         MAKE_PAD (7, 1, 37);
104         MAKE_PAD (7, 2, 38);
105         MAKE_PAD (7, 3, 39);
106         MAKE_PAD (7, 4, 40);
107         MAKE_PAD (7, 5, 41);
108         MAKE_PAD (7, 6, 42);
109         MAKE_PAD (7, 7, 43);
110
111         /* Now color buttons */
112
113         Button *button;
114
115 #define MAKE_COLOR_BUTTON(i,cc) \
116         button = new ColorButton ((i), (cc)); \
117         cc_button_map.insert (std::make_pair (button->controller_number(), button)); \
118         id_button_map.insert (std::make_pair (button->id, button));
119 #define MAKE_COLOR_BUTTON_PRESS(i,cc,p)\
120         button = new ColorButton ((i), (cc), (p)); \
121         cc_button_map.insert (std::make_pair (button->controller_number(), button)); \
122         id_button_map.insert (std::make_pair (button->id, button))
123 #define MAKE_COLOR_BUTTON_PRESS_RELEASE_LONG(i,cc,p,r,l)                      \
124         button = new ColorButton ((i), (cc), (p), (r), (l)); \
125         cc_button_map.insert (std::make_pair (button->controller_number(), button)); \
126         id_button_map.insert (std::make_pair (button->id, button))
127
128         MAKE_COLOR_BUTTON_PRESS (Upper1, 102, &Push2::button_upper_1);
129         MAKE_COLOR_BUTTON_PRESS (Upper2, 103, &Push2::button_upper_2);
130         MAKE_COLOR_BUTTON_PRESS (Upper3, 104, &Push2::button_upper_3);
131         MAKE_COLOR_BUTTON_PRESS (Upper4, 105, &Push2::button_upper_4);
132         MAKE_COLOR_BUTTON_PRESS (Upper5, 106, &Push2::button_upper_5);
133         MAKE_COLOR_BUTTON_PRESS (Upper6, 107, &Push2::button_upper_6);
134         MAKE_COLOR_BUTTON_PRESS (Upper7, 108, &Push2::button_upper_7);
135         MAKE_COLOR_BUTTON_PRESS (Upper8, 109, &Push2::button_upper_8);
136         MAKE_COLOR_BUTTON_PRESS (Lower1, 20, &Push2::button_lower_1);
137         MAKE_COLOR_BUTTON_PRESS (Lower2, 21, &Push2::button_lower_2);
138         MAKE_COLOR_BUTTON_PRESS (Lower3, 22, &Push2::button_lower_3);
139         MAKE_COLOR_BUTTON_PRESS (Lower4, 23, &Push2::button_lower_4);
140         MAKE_COLOR_BUTTON_PRESS (Lower5, 24, &Push2::button_lower_5);
141         MAKE_COLOR_BUTTON_PRESS (Lower6, 25, &Push2::button_lower_6);
142         MAKE_COLOR_BUTTON_PRESS (Lower7, 26, &Push2::button_lower_7);
143         MAKE_COLOR_BUTTON_PRESS (Lower8, 27, &Push2::button_lower_8);
144         MAKE_COLOR_BUTTON_PRESS (Master, 28, &Push2::button_master);
145         MAKE_COLOR_BUTTON_PRESS (Mute, 60, &Push2::button_mute);
146         MAKE_COLOR_BUTTON_PRESS_RELEASE_LONG (Solo, 61, &Push2::relax, &Push2::button_solo, &Push2::button_solo_long_press);
147         MAKE_COLOR_BUTTON_PRESS (Stop, 29, &Push2::button_stop);
148         MAKE_COLOR_BUTTON_PRESS (Fwd32ndT, 43, &Push2::button_fwd32t);
149         MAKE_COLOR_BUTTON_PRESS (Fwd32nd,42 , &Push2::button_fwd32);
150         MAKE_COLOR_BUTTON_PRESS (Fwd16thT, 41, &Push2::button_fwd16t);
151         MAKE_COLOR_BUTTON_PRESS (Fwd16th, 40, &Push2::button_fwd16);
152         MAKE_COLOR_BUTTON_PRESS (Fwd8thT, 39 , &Push2::button_fwd8t);
153         MAKE_COLOR_BUTTON_PRESS (Fwd8th, 38, &Push2::button_fwd8);
154         MAKE_COLOR_BUTTON_PRESS (Fwd4trT, 37, &Push2::button_fwd4t);
155         MAKE_COLOR_BUTTON_PRESS (Fwd4tr, 36, &Push2::button_fwd4);
156         MAKE_COLOR_BUTTON (Automate, 89);
157         MAKE_COLOR_BUTTON_PRESS (RecordEnable, 86, &Push2::button_recenable);
158         MAKE_COLOR_BUTTON_PRESS (Play, 85, &Push2::button_play);
159
160 #define MAKE_WHITE_BUTTON(i,cc)\
161         button = new WhiteButton ((i), (cc)); \
162         cc_button_map.insert (std::make_pair (button->controller_number(), button)); \
163         id_button_map.insert (std::make_pair (button->id, button))
164 #define MAKE_WHITE_BUTTON_PRESS(i,cc,p)\
165         button = new WhiteButton ((i), (cc), (p)); \
166         cc_button_map.insert (std::make_pair (button->controller_number(), button)); \
167         id_button_map.insert (std::make_pair (button->id, button))
168 #define MAKE_WHITE_BUTTON_PRESS_RELEASE(i,cc,p,r)                                \
169         button = new WhiteButton ((i), (cc), (p), (r)); \
170         cc_button_map.insert (std::make_pair (button->controller_number(), button)); \
171         id_button_map.insert (std::make_pair (button->id, button))
172 #define MAKE_WHITE_BUTTON_PRESS_RELEASE_LONG(i,cc,p,r,l)                      \
173         button = new WhiteButton ((i), (cc), (p), (r), (l)); \
174         cc_button_map.insert (std::make_pair (button->controller_number(), button)); \
175         id_button_map.insert (std::make_pair (button->id, button))
176
177         MAKE_WHITE_BUTTON (TapTempo, 3);
178         MAKE_WHITE_BUTTON_PRESS (Metronome, 9, &Push2::button_metronome);
179         MAKE_WHITE_BUTTON (Setup, 30);
180         MAKE_WHITE_BUTTON (User, 59);
181         MAKE_WHITE_BUTTON (Delete, 118);
182         MAKE_WHITE_BUTTON (AddDevice, 52);
183         MAKE_WHITE_BUTTON (Device, 110);
184         MAKE_WHITE_BUTTON_PRESS (Mix, 112, &Push2::button_mix_press);
185         MAKE_WHITE_BUTTON_PRESS (Undo, 119, &Push2::button_undo);
186         MAKE_WHITE_BUTTON_PRESS (AddTrack, 53, &Push2::button_add_track);
187         MAKE_WHITE_BUTTON_PRESS (Browse, 111, &Push2::button_browse);
188         MAKE_WHITE_BUTTON_PRESS (Clip, 113, &Push2::button_clip);
189         MAKE_WHITE_BUTTON (Convert, 35);
190         MAKE_WHITE_BUTTON (DoubleLoop, 117);
191         MAKE_WHITE_BUTTON (Quantize, 116);
192         MAKE_WHITE_BUTTON (Duplicate, 88);
193         MAKE_WHITE_BUTTON_PRESS (New, 87, &Push2::button_new);
194         MAKE_WHITE_BUTTON_PRESS (FixedLength, 90, &Push2::button_fixed_length);
195         MAKE_WHITE_BUTTON_PRESS (Up, 46, &Push2::button_up);
196         MAKE_WHITE_BUTTON_PRESS (Right, 45, &Push2::button_right);
197         MAKE_WHITE_BUTTON_PRESS (Down, 47, &Push2::button_down);
198         MAKE_WHITE_BUTTON_PRESS (Left, 44, &Push2::button_left);
199         MAKE_WHITE_BUTTON_PRESS (Repeat, 56, &Push2::button_repeat);
200         MAKE_WHITE_BUTTON (Accent, 57);
201         MAKE_WHITE_BUTTON_PRESS (Scale, 58, &Push2::button_scale_press);
202         MAKE_WHITE_BUTTON_PRESS (Layout, 31, &Push2::button_layout_press);
203         MAKE_WHITE_BUTTON (Note, 50);
204         MAKE_WHITE_BUTTON (Session, 51);
205         MAKE_WHITE_BUTTON (Layout, 31);
206         MAKE_WHITE_BUTTON_PRESS (OctaveUp, 55, &Push2::button_octave_up);
207         MAKE_WHITE_BUTTON_PRESS (PageRight, 63, &Push2::button_page_right);
208         MAKE_WHITE_BUTTON_PRESS (OctaveDown, 54, &Push2::button_octave_down);
209         MAKE_WHITE_BUTTON_PRESS (PageLeft, 62, &Push2::button_page_left);
210         MAKE_WHITE_BUTTON_PRESS_RELEASE_LONG (Shift, 49, &Push2::button_shift_press, &Push2::button_shift_release, &Push2::button_shift_long_press);
211         MAKE_WHITE_BUTTON_PRESS_RELEASE_LONG (Select, 48, &Push2::button_select_press, &Push2::button_select_release, &Push2::button_select_long_press);
212 }
213
214 void
215 Push2::button_play ()
216 {
217         if (!session) {
218                 return;
219         }
220
221         if (_modifier_state & ModShift) {
222                 goto_start (session->transport_rolling());
223                 return;
224         }
225
226         if (session->transport_rolling ()) {
227                 transport_stop ();
228         } else {
229                 transport_play ();
230         }
231 }
232
233 void
234 Push2::button_recenable ()
235 {
236         rec_enable_toggle ();
237 }
238
239 void
240 Push2::button_up ()
241 {
242         _current_layout->button_up ();
243 }
244
245 void
246 Push2::button_down ()
247 {
248         _current_layout->button_down ();
249 }
250
251 void
252 Push2::button_page_right ()
253 {
254         ScrollTimeline (0.75);
255 }
256
257 void
258 Push2::button_page_left ()
259 {
260         ScrollTimeline (-0.75);
261 }
262
263 void
264 Push2::button_right ()
265 {
266         _current_layout->button_right ();
267 }
268
269 void
270 Push2::button_left ()
271 {
272         _current_layout->button_left ();
273 }
274
275 void
276 Push2::button_repeat ()
277 {
278         loop_toggle ();
279 }
280
281 void
282 Push2::button_metronome ()
283 {
284         toggle_click ();
285 }
286
287 void
288 Push2::button_solo_long_press ()
289 {
290         cancel_all_solo ();
291 }
292
293 void
294 Push2::button_mute ()
295 {
296         if (_current_layout) {
297                 _current_layout->button_mute ();
298         }
299 }
300
301 void
302 Push2::button_solo ()
303 {
304         if (_current_layout) {
305                 _current_layout->button_solo ();
306         }
307 }
308
309 void
310 Push2::button_new ()
311 {
312         access_action ("Editor/start-range-from-playhead");
313
314         id_button_map[New]->set_color (LED::White);
315         id_button_map[New]->set_state (LED::NoTransition);
316         write (id_button_map[New]->state_msg());
317
318         /* blink the button for the other half of this operation */
319
320         id_button_map[FixedLength]->set_color (LED::White);
321         id_button_map[FixedLength]->set_state (LED::Blinking4th);
322         write (id_button_map[FixedLength]->state_msg());
323 }
324
325
326 void
327 Push2::button_fixed_length ()
328 {
329         access_action ("Editor/finish-range-from-playhead");
330
331         /* turn off both buttons for this operation */
332
333         id_button_map[New]->set_color (LED::Black);
334         id_button_map[New]->set_state (LED::NoTransition);
335         write (id_button_map[New]->state_msg());
336         id_button_map[FixedLength]->set_color (LED::Black);
337         id_button_map[FixedLength]->set_state (LED::NoTransition);
338         write (id_button_map[FixedLength]->state_msg());
339 }
340
341 void
342 Push2::button_browse ()
343 {
344         access_action ("Editor/addExistingAudioFiles");
345 }
346
347 void
348 Push2::button_clip ()
349 {
350 }
351
352 void
353 Push2::button_upper (uint32_t n)
354 {
355         _current_layout->button_upper (n);
356 }
357
358 void
359 Push2::button_lower (uint32_t n)
360 {
361         _current_layout->button_lower (n);
362 }
363
364 void
365 Push2::button_undo ()
366 {
367         if (_modifier_state & ModShift) {
368                 ControlProtocol::Redo ();
369         } else {
370                 ControlProtocol::Undo ();
371         }
372 }
373
374 void
375 Push2::button_fwd32t ()
376 {
377         const int n = (_modifier_state & ModShift) ? 8 : 0;
378         goto_nth_marker (0+n);
379 }
380
381 void
382 Push2::button_fwd32 ()
383 {
384         const int n = (_modifier_state & ModShift) ? 8 : 0;
385         goto_nth_marker (1+n);
386 }
387
388 void
389 Push2::button_fwd16t ()
390 {
391         const int n = (_modifier_state & ModShift) ? 8 : 0;
392         goto_nth_marker (2+n);
393 }
394
395 void
396 Push2::button_fwd16 ()
397 {
398         const int n = (_modifier_state & ModShift) ? 8 : 0;
399         goto_nth_marker (3+n);
400 }
401
402 void
403 Push2::button_fwd8t ()
404 {
405         const int n = (_modifier_state & ModShift) ? 8 : 0;
406         goto_nth_marker (4+n);
407 }
408
409 void
410 Push2::button_fwd8 ()
411 {
412         const int n = (_modifier_state & ModShift) ? 8 : 0;
413         goto_nth_marker (5+n);
414 }
415
416 void
417 Push2::button_fwd4t ()
418 {
419         const int n = (_modifier_state & ModShift) ? 8 : 0;
420         goto_nth_marker (6+n);
421 }
422
423 void
424 Push2::button_fwd4 ()
425 {
426         const int n = (_modifier_state & ModShift) ? 8 : 0;
427         goto_nth_marker (7+n);
428 }
429
430 void
431 Push2::button_add_track ()
432 {
433         access_action ("Main/AddTrackBus");
434 }
435
436 void
437 Push2::button_stop ()
438 {
439         /* close current window */
440         access_action ("Main/close-current-dialog");
441 }
442
443 void
444 Push2::button_shift_press ()
445 {
446         start_shift ();
447 }
448
449 void
450 Push2::button_shift_release ()
451 {
452         end_shift ();
453 }
454
455 void
456 Push2::button_shift_long_press ()
457 {
458         access_action ("Main/close-current-dialog");
459 }
460
461 void
462 Push2::button_select_press ()
463 {
464         cerr << "start select\n";
465         _modifier_state = ModifierState (_modifier_state | ModSelect);
466         Button* b = id_button_map[Select];
467         b->set_color (Push2::LED::White);
468         b->set_state (Push2::LED::Blinking16th);
469         write (b->state_msg());
470
471         _current_layout->button_select_press ();
472 }
473
474 void
475 Push2::button_select_release ()
476 {
477         if (_modifier_state & ModSelect) {
478                 cerr << "end select\n";
479                 _modifier_state = ModifierState (_modifier_state & ~(ModSelect));
480                 Button* b = id_button_map[Select];
481                 b->timeout_connection.disconnect ();
482                 b->set_color (Push2::LED::White);
483                 b->set_state (Push2::LED::OneShot24th);
484                 write (b->state_msg());
485         }
486
487         _current_layout->button_select_release ();
488 }
489
490 void
491 Push2::button_select_long_press ()
492 {
493         access_action ("Main/Escape");
494 }
495
496 bool
497 Push2::button_long_press_timeout (ButtonID id)
498 {
499         if (buttons_down.find (id) != buttons_down.end()) {
500                 DEBUG_TRACE (DEBUG::Push2, string_compose ("long press timeout for %1, invoking method\n", id));
501                 Button* button = id_button_map[id];
502                 (this->*button->long_press_method) ();
503         } else {
504                 DEBUG_TRACE (DEBUG::Push2, string_compose ("long press timeout for %1, expired/cancelled\n", id));
505                 /* release happened and somehow we were not cancelled */
506         }
507
508         /* whichever button this was, we've used it ... don't invoke the
509            release action.
510         */
511         consumed.insert (id);
512
513         return false; /* don't get called again */
514 }
515
516 void
517 Push2::start_press_timeout (Button& button, ButtonID id)
518 {
519         Glib::RefPtr<Glib::TimeoutSource> timeout = Glib::TimeoutSource::create (500); // milliseconds
520         button.timeout_connection = timeout->connect (sigc::bind (sigc::mem_fun (*this, &Push2::button_long_press_timeout), id));
521         timeout->attach (main_loop()->get_context());
522 }
523
524 void
525 Push2::button_octave_down ()
526 {
527         if (_modifier_state & ModShift) {
528                 octave_shift = 0;
529                 return;
530         }
531
532         int os = (max (-4, octave_shift - 1));
533         if (os != octave_shift) {
534                 octave_shift = os;
535         }
536 }
537
538 void
539 Push2::button_octave_up ()
540 {
541         if (_modifier_state & ModShift) {
542                 octave_shift = 0;
543                 return;
544         }
545
546         int os = (min (4, octave_shift + 1));
547         if (os != octave_shift) {
548                 octave_shift = os;
549         }
550 }
551
552 void
553 Push2::button_layout_press ()
554 {
555         if (percussion) {
556                 set_percussive_mode (false);
557         } else {
558                 set_percussive_mode (true);
559         }
560 }
561
562 void
563 Push2::button_scale_press ()
564 {
565         if (_current_layout != scale_layout) {
566                 set_current_layout (scale_layout);
567         } else {
568                 if (ControlProtocol::first_selected_stripable()) {
569                         set_current_layout (mix_layout);
570                 }
571         }
572 }
573
574 void
575 Push2::button_mix_press ()
576 {
577         if (_current_layout == track_mix_layout) {
578                 set_current_layout (mix_layout);
579         } else {
580                 if (ControlProtocol::first_selected_stripable()) {
581                         set_current_layout (track_mix_layout);
582                 }
583         }
584 }
585
586 void
587 Push2::button_master ()
588 {
589         boost::shared_ptr<Stripable> master = session->master_out();
590
591         if (!master) {
592                 return;
593         }
594
595         ControlProtocol::SetStripableSelection (master);
596
597         if (_current_layout != track_mix_layout) {
598                 set_current_layout (track_mix_layout);
599         }
600 }
601
602 std::string
603 Push2::button_name_by_id (ButtonID id)
604 {
605         switch (id) {
606         case TapTempo:
607                 return "TapTempo";
608         case Metronome:
609                 return "Metronome";
610         case Upper1:
611                 return "Upper1";
612         case Upper2:
613                 return "Upper2";
614         case Upper3:
615                 return "Upper3";
616         case Upper4:
617                 return "Upper4";
618         case Upper5:
619                 return "Upper5";
620         case Upper6:
621                 return "Upper6";
622         case Upper7:
623                 return "Upper7";
624         case Upper8:
625                 return "Upper8";
626         case Setup:
627                 return "Setup";
628         case User:
629                 return "User";
630         case Delete:
631                 return "Delete";
632         case AddDevice:
633                 return "AddDevice";
634         case Device:
635                 return "Device";
636         case Mix:
637                 return "Mix";
638         case Undo:
639                 return "Undo";
640         case AddTrack:
641                 return "AddTrack";
642         case Browse:
643                 return "Browse";
644         case Clip:
645                 return "Clip";
646         case Mute:
647                 return "Mute";
648         case Solo:
649                 return "Solo";
650         case Stop:
651                 return "Stop";
652         case Lower1:
653                 return "Lower1";
654         case Lower2:
655                 return "Lower2";
656         case Lower3:
657                 return "Lower3";
658         case Lower4:
659                 return "Lower4";
660         case Lower5:
661                 return "Lower5";
662         case Lower6:
663                 return "Lower6";
664         case Lower7:
665                 return "Lower7";
666         case Lower8:
667                 return "Lower8";
668         case Master:
669                 return "Master";
670         case Convert:
671                 return "Convert";
672         case DoubleLoop:
673                 return "DoubleLoop";
674         case Quantize:
675                 return "Quantize";
676         case Duplicate:
677                 return "Duplicate";
678         case New:
679                 return "New";
680         case FixedLength:
681                 return "FixedLength";
682         case Automate:
683                 return "Automate";
684         case RecordEnable:
685                 return "RecordEnable";
686         case Play:
687                 return "Play";
688         case Fwd32ndT:
689                 return "Fwd32ndT";
690         case Fwd32nd:
691                 return "Fwd32nd";
692         case Fwd16thT:
693                 return "Fwd16thT";
694         case Fwd16th:
695                 return "Fwd16th";
696         case Fwd8thT:
697                 return "Fwd8thT";
698         case Fwd8th:
699                 return "Fwd8th";
700         case Fwd4trT:
701                 return "Fwd4trT";
702         case Fwd4tr:
703                 return "Fwd4tr";
704         case Up:
705                 return "Up";
706         case Right:
707                 return "Right";
708         case Down:
709                 return "Down";
710         case Left:
711                 return "Left";
712         case Repeat:
713                 return "Repeat";
714         case Accent:
715                 return "Accent";
716         case Scale:
717                 return "Scale";
718         case Layout:
719                 return "Layout";
720         case Note:
721                 return "Note";
722         case Session:
723                 return "Session";
724         case OctaveUp:
725                 return "OctaveUp";
726         case PageRight:
727                 return "PageRight";
728         case OctaveDown:
729                 return "OctaveDown";
730         case PageLeft:
731                 return "PageLeft";
732         case Shift:
733                 return "Shift";
734         case Select:
735                 return "Select";
736         default:
737                 break;
738         }
739
740         return "???";
741 }