summaryrefslogtreecommitdiff
path: root/libs/surfaces/generic_midi
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2016-02-02 22:22:20 -0500
committerPaul Davis <paul@linuxaudiosystems.com>2016-02-02 22:28:36 -0500
commit0ddbf665d8a152437d7e813b19caec253a615b52 (patch)
tree2eb6432b33540f7d44ac02df3ff77467445958ea /libs/surfaces/generic_midi
parentb4a9bf5878f6b124629fe724f80b2b124298d2da (diff)
generic MIDI: if a CC is bound to a toggled controllable, toggle the controllable only when the incoming CC value > 0x40
See comment in code for more details
Diffstat (limited to 'libs/surfaces/generic_midi')
-rw-r--r--libs/surfaces/generic_midi/midicontrollable.cc24
1 files changed, 19 insertions, 5 deletions
diff --git a/libs/surfaces/generic_midi/midicontrollable.cc b/libs/surfaces/generic_midi/midicontrollable.cc
index b036a9d30f..3a1aea592f 100644
--- a/libs/surfaces/generic_midi/midicontrollable.cc
+++ b/libs/surfaces/generic_midi/midicontrollable.cc
@@ -374,12 +374,26 @@ MIDIControllable::midi_sense_controller (Parser &, EventTwoBytes *msg)
}
} else {
- if ( msg->value > 0x40 ) {
- controllable->set_value (1, Controllable::NoGroup);
+
+ /* toggle control: make the toggle flip only if the
+ * incoming control value exceeds 0.5 (0x40), so that
+ * the typical button which sends "CC N=0x7f" on press
+ * and "CC N=0x0" on release can be used to drive
+ * toggles on press.
+ *
+ * No other arrangement really makes sense for a toggle
+ * controllable. Acting on the press+release makes the
+ * action momentary, which is almost never
+ * desirable. If the physical button only sends a
+ * message on press (or release), then it will be
+ * expected to send a controller value >= 0.5
+ * (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::NoGroup);
DEBUG_TRACE (DEBUG::GenericMidi, string_compose ("Midi CC %1 value 1 %2\n", (int) msg->controller_number, current_uri()));
- } else {
- controllable->set_value (0, Controllable::NoGroup);
- DEBUG_TRACE (DEBUG::GenericMidi, string_compose ("Midi CC %1 value 0 %2\n", (int) msg->controller_number, current_uri()));
}
}