FP8: use separate bank offsets per MixMode
[ardour.git] / libs / surfaces / faderport8 / fp8_controls.h
1 /*
2  * Copyright (C) 2017 Robin Gareus <robin@gareus.org>
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17  */
18
19 #ifndef _ardour_surfaces_fp8controls_h_
20 #define _ardour_surfaces_fp8controls_h_
21
22 #include <map>
23
24 #include "fp8_base.h"
25 #include "fp8_button.h"
26 #include "fp8_strip.h"
27
28 namespace ArdourSurface {
29
30 class FP8Controls
31 {
32 public:
33         FP8Controls (FP8Base&);
34         virtual ~FP8Controls ();
35
36         enum ButtonId {
37                 BtnPlay,
38                 BtnStop,
39                 BtnRecord,
40                 BtnLoop,
41                 BtnRewind,
42                 BtnFastForward,
43
44                 BtnALatch,
45                 BtnATrim,
46                 BtnAOff,
47                 BtnATouch,
48                 BtnAWrite,
49                 BtnARead,
50
51                 // Automation
52                 BtnSave,
53                 BtnRedo,
54                 BtnUndo,
55                 BtnUser1,
56                 BtnUser2,
57                 BtnUser3,
58
59                 BtnFootswitch,
60
61                 // Pan/Param encoder press
62                 BtnParam,
63
64                 // Navigation
65                 BtnPrev,
66                 BtnNext,
67                 BtnEncoder,
68
69                 BtnChannel,
70                 BtnZoom,
71                 BtnScroll,
72                 BtnBank,
73                 BtnMaster,
74                 BtnClick,
75                 BtnSection,
76                 BtnMarker,
77
78                 BtnF1, BtnF2, BtnF3, BtnF4,
79                 BtnF5, BtnF6, BtnF7, BtnF8,
80
81                 // FaderMode
82                 BtnTrack,
83                 BtnPlugins,
84                 BtnSend,
85                 BtnPan,
86
87                 BtnTimecode,
88
89                 // Mix Management
90                 BtnMAudio,
91                 BtnMVI,
92                 BtnMBus,
93                 BtnMVCA,
94                 BtnMAll,
95
96                 BtnMInputs,
97                 BtnMMIDI,
98                 BtnMOutputs,
99                 BtnMFX,
100                 BtnMUser,
101
102                 // General Controls
103                 BtnArm,
104                 BtnArmAll,
105                 BtnSoloClear,
106                 BtnMuteClear,
107
108                 BtnBypass,
109                 BtnBypassAll,
110                 BtnMacro,
111                 BtnOpen,
112                 BtnLink,
113                 BtnLock,
114
115         };
116
117         typedef std::map <ButtonId, std::string> UserButtonMap;
118
119         UserButtonMap const& user_buttons () const {
120                 return _user_buttons;
121         }
122
123         bool button_name_to_enum (std::string const&, ButtonId&) const;
124         bool button_enum_to_name (ButtonId, std::string&) const;
125
126         PBD::Signal0<void> FaderModeChanged;
127         PBD::Signal0<void> MixModeChanged;
128
129         FP8Types::FaderMode fader_mode () const { return _fadermode; }
130         FP8Types::NavigationMode nav_mode () const { return _navmode; }
131         FP8Types::MixMode mix_mode () const { return _mixmode; }
132         bool display_timecode () const { return _display_timecode; }
133
134         FP8ButtonInterface& button (ButtonId id);
135         FP8Strip& strip (uint8_t id);
136
137         bool midi_event (uint8_t id, uint8_t val);
138         bool midi_touch (uint8_t id, uint8_t val);
139         bool midi_fader (uint8_t id, unsigned short val);
140
141         void initialize ();
142         void all_lights_off () const;
143
144         void set_fader_mode (FP8Types::FaderMode);
145 protected:
146         typedef std::map <uint8_t, FP8ButtonInterface*> MidiButtonMap;
147         typedef std::map <ButtonId, FP8ButtonInterface*> CtrlButtonMap;
148
149         void set_nav_mode (FP8Types::NavigationMode);
150         void set_mix_mode (FP8Types::MixMode);
151         void toggle_timecode ();
152
153         MidiButtonMap _midimap;
154         CtrlButtonMap _ctrlmap;
155         MidiButtonMap _midimap_strip;
156
157         FP8Strip* chanstrip[8];
158
159         FP8Types::FaderMode      _fadermode;
160         FP8Types::NavigationMode _navmode;
161         FP8Types::MixMode        _mixmode;
162         bool                     _display_timecode;
163
164         UserButtonMap  _user_buttons;
165         FP8DummyButton _dummy_button;
166
167         std::map<std::string, ButtonId> _user_str_to_enum;
168         std::map<ButtonId, std::string> _user_enum_to_str;
169
170         PBD::ScopedConnectionList button_connections;
171 };
172
173 } /* namespace */
174 #endif /* _ardour_surfaces_fp8controls_h_ */