add a hack to deal with device discovery race, in which the devices were not actually...
[ardour.git] / libs / surfaces / mackie / device_profile.h
1 /*
2         Copyright (C) 2012 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 #ifndef __ardour_mackie_control_protocol_device_profile_h__
20 #define __ardour_mackie_control_protocol_device_profile_h__
21
22 #include <iostream>
23 #include <stdint.h>
24 #include <string>
25 #include <map>
26
27 #include "button.h"
28
29 class XMLNode;
30
31 namespace Mackie {
32
33 class DeviceProfile
34 {
35   public:
36         DeviceProfile (const std::string& name = "");
37         ~DeviceProfile();
38         
39         std::string get_button_action (Button::ID, int modifier_state) const;
40         void set_button_action (Button::ID, int modifier_state, const std::string&);
41         
42         const std::string& name() const;
43         void set_path (const std::string&);
44
45         static void reload_device_profiles ();
46         static std::map<std::string,DeviceProfile> device_profiles;
47         
48   private:
49         struct ButtonActions {
50             std::string plain;
51             std::string control;
52             std::string shift;
53             std::string option;
54             std::string cmdalt;
55             std::string shiftcontrol;
56         };
57         
58         typedef std::map<Button::ID,ButtonActions> ButtonActionMap;
59         
60         std::string _name;
61         std::string _path;
62         ButtonActionMap _button_map;
63         
64         int set_state (const XMLNode&, int version);
65         XMLNode& get_state () const;
66
67         void save ();
68 };
69
70 }
71
72 #endif /* __ardour_mackie_control_protocol_device_profile_h__ */