Merge branch 'master' into windows+cc
[ardour.git] / libs / surfaces / mackie / controls.h
index a87dc46cbfff763d8466cc0936b3349726bef8b1..38dad7ef7fa31297fd5d9c54661b30d95601df7c 100644 (file)
 #include <string>
 #include <stdint.h>
 
+#include <boost/smart_ptr.hpp>
+
 #include "pbd/signals.h"
 
 #include "mackie_control_exception.h"
+#include "midi_byte_array.h"
+
+namespace ARDOUR {
+       class AutomationControl;
+}
 
 namespace Mackie
 {
 
 class Strip;
 class Group;
-class Led;
 class Surface;
 
 class Control
 {
 public:
-       enum type_t { 
-               type_led, 
-               type_led_ring, 
-               type_fader = 0xe0, 
-               type_button = 0x90, 
-               type_pot = 0xb0,
-               type_meter = 0xd0
-       };
-
-       enum base_id_t {
-               fader_base_id = 0x0,
-               pot_base_id = 0x10,
-               jog_base_id = 0x3c,
-               fader_touch_button_base_id = 0xe0,
-               vselect_button_base_id = 0x20,
-               select_button_base_id = 0x18,
-               mute_button_base_id = 0x10,
-               solo_button_base_id = 0x08,
-               recenable_button_base_id = 0x0,
-               meter_base_id = 0xd0,
-       };
-       
        Control (int id, std::string name, Group& group);
        virtual ~Control() {}
        
-       virtual const Led & led() const { throw MackieControlException ("no led available"); }
-
-       /// type() << 8 + midi id of the control. This
-       /// provides a unique id for any control on the surface.
-       int id() const { return (type() << 8) + _id; }
-       
-       /// the value of the second bytes of the message. It's
-       /// the id of the control, but only guaranteed to be
-       /// unique within the control type.
-       int raw_id() const { return _id; }
-
+       int id() const { return _id; }
        const std::string & name() const  { return _name; }
        Group & group() const { return _group; }
-       virtual bool accepts_feedback() const  { return true; }
-       
-       virtual type_t type() const = 0;
-       
-       /// Return true if this control is the one and only Jog Wheel
-       virtual bool is_jog() const { return false; }
 
        bool in_use () const;
        void set_in_use (bool);
@@ -91,13 +59,27 @@ public:
        /// Keep track of the timeout so it can be updated with more incoming events
        sigc::connection in_use_connection;
 
+       virtual MidiByteArray zero() = 0;
+
        /** If we are doing an in_use timeout for a fader without touch, this
         *  is its touch button control; otherwise 0.
         */
        Control* in_use_touch_control;
 
-private:
-       int _id;
+       boost::shared_ptr<ARDOUR::AutomationControl> control () const { return normal_ac; }
+       virtual void set_control (boost::shared_ptr<ARDOUR::AutomationControl>);
+
+       float get_value ();
+       void set_value (float val);
+       
+       virtual void start_touch (double when);
+       virtual void stop_touch (double when, bool mark);
+
+  protected:
+       boost::shared_ptr<ARDOUR::AutomationControl> normal_ac;
+
+  private:
+       int _id; /* possibly device-dependent ID */
        std::string _name;
        Group& _group;
        bool _in_use;