diff options
author | Jan Lentfer <jan.lentfer@web.de> | 2018-03-03 14:04:12 +0100 |
---|---|---|
committer | Jan Lentfer <jan.lentfer@web.de> | 2018-03-03 14:04:12 +0100 |
commit | a2af019c95243fb8ee738e7cdd240885ce4ee103 (patch) | |
tree | 672e0d2dd3854d8f3a4477b02b14f794685a524d /libs/surfaces/generic_midi/midicontrollable.cc | |
parent | 7e5a488d811dda42a13363599dbbdddc31128b71 (diff) |
generic_midi: add proper handling of midi controll toggles
Diffstat (limited to 'libs/surfaces/generic_midi/midicontrollable.cc')
-rw-r--r-- | libs/surfaces/generic_midi/midicontrollable.cc | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/libs/surfaces/generic_midi/midicontrollable.cc b/libs/surfaces/generic_midi/midicontrollable.cc index 92c86d665c..fe592965ee 100644 --- a/libs/surfaces/generic_midi/midicontrollable.cc +++ b/libs/surfaces/generic_midi/midicontrollable.cc @@ -54,6 +54,7 @@ MIDIControllable::MIDIControllable (GenericMidiControlProtocol* s, MIDI::Parser& , _momentary (m) { _learned = false; /* from URI */ + _ctltype = Ctl_Momentary; _encoder = No_enc; setting = false; last_value = 0; // got a better idea ? @@ -74,6 +75,7 @@ MIDIControllable::MIDIControllable (GenericMidiControlProtocol* s, MIDI::Parser& set_controllable (&c); _learned = true; /* from controllable */ + _ctltype = Ctl_Momentary; _encoder = No_enc; setting = false; last_value = 0; // got a better idea ? @@ -392,10 +394,18 @@ MIDIControllable::midi_sense_controller (Parser &, EventTwoBytes *msg) * (0x40). It is hard to imagine why anyone would make * a MIDI controller button that sent 0x0 when pressed. */ - if (msg->value >= 0x40) { controllable->set_value (controllable->get_value() >= 0.5 ? 0.0 : 1.0, Controllable::UseGroup); DEBUG_TRACE (DEBUG::GenericMidi, string_compose ("Midi CC %1 value 1 %2\n", (int) msg->controller_number, current_uri())); + } else { + switch (get_ctltype()) { + case Ctl_Momentary: + break; + case Ctl_Toggle: + controllable->set_value (0.0, Controllable::NoGroup); + DEBUG_TRACE (DEBUG::GenericMidi, string_compose ("Midi CC %1 value 0 %2\n", (int) msg->controller_number, current_uri())); + break; + } } } |