change Controllable::set_value() API to include grouped control consideration.
[ardour.git] / libs / surfaces / mackie / controls.cc
index 6c9fb559f486d3a5a64342d09fb6c156037a44a3..8ed0bad3114f1463a929b096d2c70939395eca19 100644 (file)
 #include <iomanip>
 #include <sstream>
 
+#include "ardour/automation_control.h"
+
 #include "controls.h"
 #include "types.h"
 #include "surface.h"
 #include "control_group.h"
-
 #include "button.h"
 #include "led.h"
 #include "pot.h"
 #include "meter.h"
 
 
-using namespace Mackie;
 using namespace std;
+using namespace ArdourSurface;
+using namespace Mackie;
+
+using ARDOUR::AutomationControl;
 
 void Group::add (Control& control)
 {
@@ -67,27 +71,56 @@ Control::set_in_use (bool in_use)
        _in_use = in_use;
 }
 
-ostream & Mackie::operator <<  (ostream & os, const Mackie::Control & control)
+void
+Control::set_control (boost::shared_ptr<AutomationControl> ac)
+{
+       normal_ac = ac;
+}
+
+void
+Control::set_value (float val)
+{
+       if (normal_ac) {
+               normal_ac->set_value (normal_ac->interface_to_internal (val), PBD::Controllable::NoGroup);
+       }
+}
+
+float
+Control::get_value ()
+{
+       if (!normal_ac) {
+               return 0.0f;
+       }
+       return normal_ac->internal_to_interface (normal_ac->get_value());
+}
+
+void
+Control::start_touch (double when)
+{
+       if (normal_ac) {
+               return normal_ac->start_touch (when);
+       }
+}
+
+void
+Control::stop_touch (bool mark, double when)
+{
+       if (normal_ac) {
+               return normal_ac->stop_touch (mark, when);
+       }
+}
+
+ostream & operator <<  (ostream & os, const ArdourSurface::Mackie::Control & control)
 {
        os << typeid (control).name();
        os << " { ";
        os << "name: " << control.name();
        os << ", ";
-       os << "raw_id: " << "0x" << setw(2) << setfill('0') << hex << control.raw_id() << setfill(' ');
+       os << "id: " << "0x" << setw(2) << setfill('0') << hex << control.id() << setfill(' ');
        os << ", ";
        os << "group: " << control.group().name();
        os << " }";
-       
-       return os;
-}
 
-Control*
-Jog::factory (Surface& surface, int id, const char* name, Group& group)
-{
-       Jog* j = new Jog (id, name, group);
-       surface.controls.push_back (j);
-       surface.controls_by_name["jog"] = j;
-       group.add (*j);
-       return j;
+       return os;
 }