faderport: fix long press behaviour, and fix ardour-only behaviour with user button...
authorPaul Davis <paul@linuxaudiosystems.com>
Thu, 3 Dec 2015 23:38:09 +0000 (18:38 -0500)
committerPaul Davis <paul@linuxaudiosystems.com>
Thu, 3 Dec 2015 23:38:09 +0000 (18:38 -0500)
libs/surfaces/faderport/faderport.cc
libs/surfaces/faderport/faderport.h

index f7d15e17c42a3f5ead6f255c6bb449ce55eb8254..4812f5542059baea5d258451645506e52b25edba 100644 (file)
@@ -302,6 +302,11 @@ FaderPort::button_long_press_timeout (ButtonID id)
                /* release happened and somehow we were not cancelled */
        }
 
+       /* whichever button this was, we've used it ... don't invoke the
+          release action.
+       */
+       consumed.insert (id);
+
        return false; /* don't get called again */
 }
 
@@ -374,13 +379,24 @@ FaderPort::button_handler (MIDI::Parser &, MIDI::EventTwoBytes* tb)
                button.set_led_state (_output_port, (int)tb->value);
        }
 
-       button.invoke (button_state, tb->value ? true : false);
+       set<ButtonID>::iterator c = consumed.find (id);
+
+       if (c == consumed.end()) {
+               button.invoke (button_state, tb->value ? true : false);
+       } else {
+               consumed.erase (c);
+       }
 
        if (!tb->value && (id != Shift)) {
                /* non-shift key was released, clear shift modifier */
                button_state = ButtonState (button_state&~ShiftDown);
                DEBUG_TRACE (DEBUG::FaderPort, "clear shift modifier\n");
        }
+
+       if (!tb->value && (id != User)) {
+               consumed.insert (User);
+               DEBUG_TRACE (DEBUG::FaderPort, "clear user modifier\n");
+       }
 }
 
 void
@@ -430,11 +446,11 @@ FaderPort::encoder_handler (MIDI::Parser &, MIDI::pitchbend_t pb)
                }
 
                if ((button_state & trim_modifier) == trim_modifier ) {    // mod+encoder = input trim
-                       boost::shared_ptr<AutomationControl> gain = _current_route->trim()->gain_control ();
-                       if (gain) {
-                               float val = gain->get_user();  //for gain elements, the "user" value is in dB
+                       boost::shared_ptr<AutomationControl> trim = _current_route->trim()->gain_control ();
+                       if (trim) {
+                               float val = trim->get_user();  //for gain elements, the "user" value is in dB
                                val += delta;
-                               gain->set_user(val);
+                               trim->set_user(val);
                        }
                } else if (width_modifier && ((button_state & width_modifier) == width_modifier)) {
                        ardour_pan_width (delta);
@@ -447,6 +463,14 @@ FaderPort::encoder_handler (MIDI::Parser &, MIDI::pitchbend_t pb)
                        }
                }
        }
+
+       /* if the user button was pressed, mark it as consumed so that its
+        * release action has no effect.
+        */
+
+       if (!Profile->get_mixbus() && (button_state & UserDown)) {
+               consumed.insert (User);
+       }
 }
 
 void
index 00259a58f93a3065a391031cd0dec6784259b574..326bde6db10bce2ed21893599d61b0a11ae7e959 100644 (file)
@@ -268,6 +268,7 @@ class FaderPort : public ARDOUR::ControlProtocol, public AbstractUI<FaderPortReq
        Button& get_button (ButtonID) const;
 
        std::set<ButtonID> buttons_down;
+       std::set<ButtonID> consumed;
 
        bool button_long_press_timeout (ButtonID id);
        void start_press_timeout (Button&, ButtonID);