merge (w/fix) with master
[ardour.git] / libs / surfaces / mackie / fader.cc
index 9a44f8ef9bbe0607d6b81b68868dd5bd7b7a6e95..4b9da7226a335ef62bbf64f8953a774cd639a7f7 100644 (file)
        Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
+#include <cmath>
+
 #include "fader.h"
 #include "surface.h"
 #include "control_group.h"
+#include "mackie_control_protocol.h"
 
 using namespace Mackie;
 
@@ -44,6 +47,12 @@ Fader::set_position (float normalized)
 MidiByteArray
 Fader::update_message ()
 {
-       int posi = int (0x3fff * position);
-       return MidiByteArray  (3, 0xe0 | raw_id(), posi & 0x7f, posi >> 7);
+       MackieControlProtocol* mcp = MackieControlProtocol::instance ();
+       if (mcp && mcp->flip_mode() == MackieControlProtocol::Zero) {
+               /* do not send messages to move the faders when in this mode */
+               return MidiByteArray();
+       }
+
+       int posi = lrintf (0x3fff * position);
+       return MidiByteArray  (3, 0xe0 + id(), posi & 0x7f, posi >> 7);
 }