remove redundant MackieButtonHandler class, implement initial zoom support for cursor...
[ardour.git] / libs / surfaces / mackie / controls.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 __mackie_controls_h__
21 #define __mackie_controls_h__
22
23 #include <map>
24 #include <vector>
25 #include <string>
26 #include <stdint.h>
27
28 #include "pbd/signals.h"
29
30 #include "mackie_control_exception.h"
31
32 namespace Mackie
33 {
34
35 class Strip;
36 class Group;
37 class Led;
38 class Surface;
39
40 class Control
41 {
42 public:
43         enum type_t { 
44                 type_led, 
45                 type_led_ring, 
46                 type_fader = 0xe0, 
47                 type_button = 0x90, 
48                 type_pot = 0xb0,
49                 type_meter = 0xd0
50         };
51
52         enum base_id_t {
53                 fader_base_id = 0x0,
54                 pot_base_id = 0x10,
55                 jog_base_id = 0x3c,
56                 fader_touch_button_base_id = 0x68,
57                 vselect_button_base_id = 0x20,
58                 select_button_base_id = 0x18,
59                 mute_button_base_id = 0x10,
60                 solo_button_base_id = 0x08,
61                 recenable_button_base_id = 0x0,
62                 meter_base_id = 0xd0,
63         };
64         
65         Control (int id, int ordinal, std::string name, Group& group);
66         virtual ~Control() {}
67         
68         virtual const Led & led() const { throw MackieControlException ("no led available"); }
69
70         /// type() << 8 + midi id of the control. This
71         /// provides a unique id for any control on the surface.
72         int id() const { return (type() << 8) + _id; }
73         
74         /// the value of the second bytes of the message. It's
75         /// the id of the control, but only guaranteed to be
76         /// unique within the control type.
77         int raw_id() const { return _id; }
78         
79         /// The 1-based number of the control
80         int ordinal() const { return _ordinal; }
81         
82         const std::string & name() const  { return _name; }
83         const Group & group() const { return _group; }
84         virtual bool accepts_feedback() const  { return true; }
85         
86         virtual type_t type() const = 0;
87         
88         /// Return true if this control is the one and only Jog Wheel
89         virtual bool is_jog() const { return false; }
90
91         bool in_use () const;
92         void set_in_use (bool);
93         
94         /// Keep track of the timeout so it can be updated with more incoming events
95         sigc::connection in_use_connection;
96
97         /** If we are doing an in_use timeout for a fader without touch, this
98          *  is its touch button control; otherwise 0.
99          */
100         Control* in_use_touch_control;
101
102 private:
103         int _id;
104         int _ordinal;
105         std::string _name;
106         Group& _group;
107         bool _in_use;
108 };
109
110 std::ostream & operator <<  (std::ostream & os, const Control & control);
111
112 }
113
114 #endif /* __mackie_controls_h__ */