summaryrefslogtreecommitdiff
path: root/libs/surfaces/generic_midi/midicontrollable.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libs/surfaces/generic_midi/midicontrollable.cc')
-rw-r--r--libs/surfaces/generic_midi/midicontrollable.cc12
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;
+ }
}
}