From a9ce37b7ac268f5ef6972a8f8a18fa0d280d88ab Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 3 Dec 2015 18:38:09 -0500 Subject: [PATCH] faderport: fix long press behaviour, and fix ardour-only behaviour with user button when used as a modifier --- libs/surfaces/faderport/faderport.cc | 34 ++++++++++++++++++++++++---- libs/surfaces/faderport/faderport.h | 1 + 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/libs/surfaces/faderport/faderport.cc b/libs/surfaces/faderport/faderport.cc index f7d15e17c4..4812f55420 100644 --- a/libs/surfaces/faderport/faderport.cc +++ b/libs/surfaces/faderport/faderport.cc @@ -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::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 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 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 diff --git a/libs/surfaces/faderport/faderport.h b/libs/surfaces/faderport/faderport.h index 00259a58f9..326bde6db1 100644 --- a/libs/surfaces/faderport/faderport.h +++ b/libs/surfaces/faderport/faderport.h @@ -268,6 +268,7 @@ class FaderPort : public ARDOUR::ControlProtocol, public AbstractUI buttons_down; + std::set consumed; bool button_long_press_timeout (ButtonID id); void start_press_timeout (Button&, ButtonID);