provide some support for mackie devices like Steinberg's CMCs that do not do the...
[ardour.git] / libs / surfaces / mackie / device_info.h
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 #ifndef __ardour_mackie_control_protocol_device_info_h__
21 #define __ardour_mackie_control_protocol_device_info_h__
22
23 #include <iostream>
24 #include <stdint.h>
25 #include <string>
26 #include <map>
27
28 #include "button.h"
29
30 class XMLNode;
31
32 namespace Mackie {
33
34 struct GlobalButtonInfo {
35     std::string label; // visible to user
36     std::string group; // in case we want to present in a GUI
37     int32_t id;       // value sent by device
38     
39     GlobalButtonInfo () : id (-1) {}
40     GlobalButtonInfo (const std::string& l, const std::string& g, uint32_t i)
41             : label (l), group (g), id (i) {}
42 };
43         
44 struct StripButtonInfo {
45     int32_t base_id;
46     std::string name;
47     
48     StripButtonInfo () : base_id (-1) {}
49     StripButtonInfo (uint32_t i, const std::string& n)
50             : base_id (i), name (n) {}
51 };
52
53 class DeviceInfo 
54 {
55   public:
56         DeviceInfo();
57         ~DeviceInfo();
58
59         int set_state (const XMLNode&, int version);
60
61         uint32_t strip_cnt () const;
62         uint32_t extenders() const;
63         bool has_two_character_display() const; 
64         bool has_master_fader () const;
65         bool has_timecode_display() const;
66         bool has_global_controls() const;
67         bool has_jog_wheel () const;
68         bool has_touch_sense_faders() const;
69         bool uses_ipmidi() const;
70         bool no_handshake() const;
71         const std::string& name() const;
72
73         static std::map<std::string,DeviceInfo> device_info;
74         static void reload_device_info();
75
76     const std::map<Button::ID,GlobalButtonInfo>& global_buttons() const { return _global_buttons; }
77     const std::map<Button::ID,StripButtonInfo>& strip_buttons() const { return _strip_buttons; }
78         
79   private:
80     uint32_t _strip_cnt;
81     uint32_t _extenders;
82     bool     _has_two_character_display;
83     bool     _has_master_fader;
84     bool     _has_timecode_display;
85     bool     _has_global_controls;
86     bool     _has_jog_wheel;
87     bool     _has_touch_sense_faders;
88     bool     _uses_logic_control_buttons;
89     bool     _uses_ipmidi;
90     bool     _no_handshake;
91     std::string _name;
92
93     std::map<Button::ID,GlobalButtonInfo> _global_buttons;
94     std::map<Button::ID,StripButtonInfo>  _strip_buttons;
95
96     void logic_control_buttons ();
97     void mackie_control_buttons ();
98     void shared_buttons ();
99 };
100
101
102 }
103
104 std::ostream& operator<< (std::ostream& os, const Mackie::DeviceInfo& di);
105
106 #endif /* __ardour_mackie_control_protocol_device_info_h__ */