track changes to config parameters for MMC device id's correctly (from roy vegard)
[ardour.git] / libs / surfaces / generic_midi / midifunction.cc
index 757c1aeffe3095fbcdbb5178e9fe4ff31480e59b..186858550f7c4790e6438bdca483bbd2aa843ce6 100644 (file)
@@ -35,10 +35,12 @@ MIDIFunction::~MIDIFunction ()
 }
 
 int
-MIDIFunction::init (GenericMidiControlProtocol& ui, const std::string& invokable_name, MIDI::byte* msg_data, size_t data_sz)
+MIDIFunction::setup (GenericMidiControlProtocol& ui, const std::string& invokable_name, const std::string& arg, MIDI::byte* msg_data, size_t data_sz)
 {
         MIDIInvokable::init (ui, invokable_name, msg_data, data_sz);
 
+       _argument = arg;
+
        if (strcasecmp (_invokable_name.c_str(), "transport-stop") == 0) {
                _function = TransportStop;
        } else if (strcasecmp (_invokable_name.c_str(), "transport-roll") == 0) {
@@ -59,6 +61,11 @@ MIDIFunction::init (GenericMidiControlProtocol& ui, const std::string& invokable
                _function = NextBank;
        } else if (strcasecmp (_invokable_name.c_str(), "prev-bank") == 0) {
                _function = PrevBank;
+       } else if (strcasecmp (_invokable_name.c_str(), "select") == 0) {
+               if (_argument.empty()) {
+                       return -1;
+               }
+               _function = Select;
        } else {
                return -1;
        }
@@ -109,6 +116,13 @@ MIDIFunction::execute ()
        case TransportRecordDisable:
                _ui->set_record_enable (false);
                break;
+
+       case Select:
+               if (!_argument.empty()) {
+                       uint32_t rid;
+                       sscanf (_argument.c_str(), "%d", &rid);
+                       _ui->SelectByRID (rid);
+               }
        }
 }