Made master fader touch and jog go to _master_surface instead of first surface.
[ardour.git] / libs / surfaces / mackie / mackie_control_protocol.cc
index 5d6e55e74259e418f073f89d995a27f3bdf48329..be1144e6ac57b3d9bb078ca22c44c8ace821769f 100644 (file)
@@ -110,6 +110,7 @@ MackieControlProtocol::MackieControlProtocol (Session& session)
        , _initialized (false)
        , _surfaces_state (0)
        , _surfaces_version (0)
+       , _session_load (true)
 {
        DEBUG_TRACE (DEBUG::MackieControl, "MackieControlProtocol::MackieControlProtocol\n");
 
@@ -271,7 +272,10 @@ MackieControlProtocol::get_sorted_routes()
                if (route_is_locked_to_strip(route)) {
                        continue;
                }
-
+               /* This next section which is not used yet, looks wrong to me
+                       The first four belong here but the bottom five are not a selection
+                       of routes and belong elsewhere as they are v-pot modes.
+               */
                switch (_view_mode) {
                case Mixer:
                        break;
@@ -490,8 +494,8 @@ MackieControlProtocol::update_global_button (int id, LedState ls)
        if (!_device_info.has_global_controls()) {
                return;
        }
-
-       boost::shared_ptr<Surface> surface = surfaces.front();
+       // surface needs to be master surface
+       boost::shared_ptr<Surface> surface = _master_surface;
 
        map<int,Control*>::iterator x = surface->controls_by_device_independent_id.find (id);
        if (x != surface->controls_by_device_independent_id.end()) {
@@ -510,8 +514,7 @@ MackieControlProtocol::update_global_led (int id, LedState ls)
        if (!_device_info.has_global_controls()) {
                return;
        }
-
-       boost::shared_ptr<Surface> surface = surfaces.front();
+       boost::shared_ptr<Surface> surface = _master_surface;
 
        map<int,Control*>::iterator x = surface->controls_by_device_independent_id.find (id);
 
@@ -562,13 +565,13 @@ MackieControlProtocol::initialize()
                        return;
                }
                
-               if (!surfaces.front()->active ()) {
+               if (!_master_surface->active ()) {
                        return;
                }
                
                // sometimes the jog wheel is a pot
                if (_device_info.has_jog_wheel()) {
-                       surfaces.front()->blank_jog_ring ();
+                       _master_surface->blank_jog_ring ();
                }
        }
 
@@ -668,7 +671,7 @@ int
 MackieControlProtocol::create_surfaces ()
 {
        string device_name;
-       surface_type_t stype = mcu;
+       surface_type_t stype = mcu; // type not yet determined
        char buf[128];
 
        if (_device_info.extenders() == 0) {
@@ -683,12 +686,21 @@ MackieControlProtocol::create_surfaces ()
 
                boost::shared_ptr<Surface> surface;
 
+               if (n == _device_info.master_position()) {
+                       stype = mcu;
+               } else {
+                       stype = ext;
+               }
                try {
                        surface.reset (new Surface (*this, device_name, n, stype));
                } catch (...) {
                        return -1;
                }
 
+               if (n == _device_info.master_position()) {
+                       _master_surface = surface;
+               }
+
                if (_surfaces_state) {
                        surface->set_state (*_surfaces_state, _surfaces_version);
                }
@@ -697,8 +709,6 @@ MackieControlProtocol::create_surfaces ()
                        Glib::Threads::Mutex::Lock lm (surfaces_lock);
                        surfaces.push_back (surface);
                }
-
-               /* next device will be an extender */
                
                if (_device_info.extenders() < 2) {
                        device_name = X_("mackie control #2");
@@ -706,7 +716,6 @@ MackieControlProtocol::create_surfaces ()
                        snprintf (buf, sizeof (buf), X_("mackie control #%d"), n+2);
                        device_name = buf;
                }
-               stype = ext;
 
                if (!_device_info.uses_ipmidi()) {
 
@@ -921,7 +930,7 @@ MackieControlProtocol::update_timecode_display()
                return;
        }
 
-       boost::shared_ptr<Surface> surface = surfaces.front();
+       boost::shared_ptr<Surface> surface = _master_surface;
 
        if (surface->type() != mcu || !_device_info.has_timecode_display() || !surface->active ()) {
                return;
@@ -995,7 +1004,7 @@ MackieControlProtocol::notify_solo_active_changed (bool active)
 
        {
                Glib::Threads::Mutex::Lock lm (surfaces_lock);
-               surface = surfaces.front ();
+               surface = _master_surface;
        }
        
        map<int,Control*>::iterator x = surface->controls_by_device_independent_id.find (Led::RudeSolo);
@@ -1073,7 +1082,7 @@ MackieControlProtocol::notify_record_state_changed ()
 
        {
                Glib::Threads::Mutex::Lock lm (surfaces_lock);
-               surface = surfaces.front();
+               surface = _master_surface;
        }
                
        /* rec is a tristate */