fix missing negation from previous MCP commit
[ardour.git] / libs / surfaces / mackie / surface.cc
index 4d9ab3f87724a567ab36f1dcaad2aef5893f617f..0cc0f02a77fb8ab18dba52181d5ba46056e7b9fc 100644 (file)
@@ -299,9 +299,14 @@ Surface::handle_midi_pitchbend_message (MIDI::Parser&, MIDI::pitchbend_t pb, uin
         * when we connected to the per-channel pitchbend events.
         */
 
+
        DEBUG_TRACE (DEBUG::MackieControl, string_compose ("handle_midi pitchbend on port %3, fader = %1 value = %2\n", 
                                                           fader_id, pb, _number));
        
+       if (_mcp.device_info().no_handshake()) {
+               turn_it_on ();
+       }
+
        Fader* fader = faders[fader_id];
 
        if (fader) {
@@ -324,6 +329,10 @@ Surface::handle_midi_note_on_message (MIDI::Parser &, MIDI::EventTwoBytes* ev)
 {
        DEBUG_TRACE (DEBUG::MackieControl, string_compose ("SurfacePort::handle_note_on %1 = %2\n", (int) ev->note_number, (int) ev->velocity));
        
+       if (_mcp.device_info().no_handshake()) {
+               turn_it_on ();
+       }
+
        Button* button = buttons[ev->note_number];
 
        if (button) {
@@ -348,6 +357,10 @@ Surface::handle_midi_controller_message (MIDI::Parser &, MIDI::EventTwoBytes* ev
 {
        DEBUG_TRACE (DEBUG::MackieControl, string_compose ("SurfacePort::handle_midi_controller %1 = %2\n", (int) ev->controller_number, (int) ev->value));
 
+       if (_mcp.device_info().no_handshake()) {
+               turn_it_on ();
+       }
+
        Pot* pot = pots[ev->controller_number];
 
        // bit 6 gives the sign
@@ -387,6 +400,10 @@ Surface::handle_midi_sysex (MIDI::Parser &, MIDI::byte * raw_bytes, size_t count
 
        DEBUG_TRACE (DEBUG::MackieControl, string_compose ("handle_midi_sysex: %1\n", bytes));
 
+       if (_mcp.device_info().no_handshake()) {
+               turn_it_on ();
+       }
+
        /* always save the device type ID so that our outgoing sysex messages
         * are correct 
         */
@@ -406,12 +423,7 @@ Surface::handle_midi_sysex (MIDI::Parser &, MIDI::byte * raw_bytes, size_t count
                        write_sysex (host_connection_query (bytes));
                } else {
                        if (!_active) {
-                               _active = true;
-                               zero_controls ();
-                               for (Strips::iterator s = strips.begin(); s != strips.end(); ++s) {
-                                       (*s)->notify_all ();
-                               }
-                               update_view_mode_display ();
+                               turn_it_on ();
                        }
                }
                break;
@@ -493,6 +505,19 @@ Surface::host_connection_confirmation (const MidiByteArray & bytes)
        return MidiByteArray (2, 0x13, 0x00);
 }
 
+void
+Surface::turn_it_on ()
+{
+       if (!_active) {
+               _active = true;
+               zero_controls ();
+               for (Strips::iterator s = strips.begin(); s != strips.end(); ++s) {
+                       (*s)->notify_all ();
+               }
+               update_view_mode_display ();
+       }
+}
+
 void 
 Surface::handle_port_inactive (SurfacePort*)
 {
@@ -667,19 +692,14 @@ Surface::show_two_char_display (unsigned int value, const std::string & /*dots*/
        show_two_char_display (os.str());
 }
 
-void 
-Surface::display_timecode (const std::string & timecode, const std::string & timecode_last)
+void
+Surface::display_timecode (const std::string & timecode, const std::string & last_timecode)
 {
-       if (_active && _mcp.device_info().has_timecode_display()) {
-               _port->write (timecode_display (timecode, timecode_last));
+       if (!_active || !_mcp.device_info().has_timecode_display()) {
+               return;
        }
-}
-
-MidiByteArray 
-Surface::timecode_display (const std::string & timecode, const std::string & last_timecode)
-{
        // if there's no change, send nothing, not even sysex header
-       if  (timecode == last_timecode) return MidiByteArray();
+       if  (timecode == last_timecode) return;
        
        // length sanity checking
        string local_timecode = timecode;
@@ -697,25 +717,16 @@ Surface::timecode_display (const std::string & timecode, const std::string & las
        // find the suffix of local_timecode that differs from last_timecode
        std::pair<string::const_iterator,string::iterator> pp = mismatch (last_timecode.begin(), last_timecode.end(), local_timecode.begin());
        
-       MidiByteArray retval;
-       
-       // sysex header
-       retval << sysex_hdr();
-       
-       // code for timecode display
-       retval << 0x10;
-       
+       int position = 0x40;
+
        // translate characters. These are sent in reverse order of display
        // hence the reverse iterators
        string::reverse_iterator rend = reverse_iterator<string::iterator> (pp.second);
        for  (string::reverse_iterator it = local_timecode.rbegin(); it != rend; ++it) {
+               MidiByteArray retval (2, 0xb0, position++);
                retval << translate_seven_segment (*it);
+               _port->write (retval);
        }
-       
-       // sysex trailer
-       retval << MIDI::eox;
-       
-       return retval;
 }
 
 void