summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2018-03-26 18:26:39 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2018-03-26 18:26:39 -0400
commit224295266f2942974095b66d74b70c7c000bc470 (patch)
tree7e067ac0d1a1ad2f08169d9069be7a3468206cc0
parentddfc37e42a27e31f6916100c5bbc3f04ba104522 (diff)
faderport: make ::invoke() tell us whether or not something was actually invoked for a button event
Only put the button into "consumed" if it actually invoked something. This helps to get reverse-polarity footswitches to work as expected
-rw-r--r--libs/surfaces/faderport/faderport.cc24
-rw-r--r--libs/surfaces/faderport/faderport.h2
2 files changed, 15 insertions, 11 deletions
diff --git a/libs/surfaces/faderport/faderport.cc b/libs/surfaces/faderport/faderport.cc
index 9896997640..ec4ceebb93 100644
--- a/libs/surfaces/faderport/faderport.cc
+++ b/libs/surfaces/faderport/faderport.cc
@@ -314,16 +314,16 @@ bool
FaderPort::button_long_press_timeout (ButtonID id)
{
if (buttons_down.find (id) != buttons_down.end()) {
- get_button (id).invoke (ButtonState (LongPress|button_state), false);
+ if (get_button (id).invoke (ButtonState (LongPress|button_state), false)) {
+ /* whichever button this was, we've used it ... don't invoke the
+ release action.
+ */
+ consumed.insert (id);
+ }
} else {
/* 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 */
}
@@ -401,7 +401,7 @@ FaderPort::button_handler (MIDI::Parser &, MIDI::EventTwoBytes* tb)
set<ButtonID>::iterator c = consumed.find (id);
if (c == consumed.end()) {
- button.invoke (button_state, tb->value ? true : false);
+ (void) button.invoke (button_state, tb->value ? true : false);
} else {
DEBUG_TRACE (DEBUG::FaderPort, "button was consumed, ignored\n");
consumed.erase (c);
@@ -918,7 +918,7 @@ FaderPort::connected ()
_output_port->write (buf, 6, 0);
}
-void
+bool
FaderPort::Button::invoke (FaderPort::ButtonState bs, bool press)
{
DEBUG_TRACE (DEBUG::FaderPort, string_compose ("invoke button %1 for %2 state %3%4%5\n", id, (press ? "press":"release"), hex, bs, dec));
@@ -928,12 +928,12 @@ FaderPort::Button::invoke (FaderPort::ButtonState bs, bool press)
if (press) {
if ((x = on_press.find (bs)) == on_press.end()) {
DEBUG_TRACE (DEBUG::FaderPort, string_compose ("no press action for button %1 state %2 @ %3 in %4\n", id, bs, this, &on_press));
- return;
+ return false;
}
} else {
if ((x = on_release.find (bs)) == on_release.end()) {
DEBUG_TRACE (DEBUG::FaderPort, string_compose ("no release action for button %1 state %2 @%3 in %4\n", id, bs, this, &on_release));
- return;
+ return false;
}
}
@@ -941,13 +941,17 @@ FaderPort::Button::invoke (FaderPort::ButtonState bs, bool press)
case NamedAction:
if (!x->second.action_name.empty()) {
fp.access_action (x->second.action_name);
+ return true;
}
break;
case InternalFunction:
if (x->second.function) {
x->second.function ();
+ return true;
}
}
+
+ return false;
}
void
diff --git a/libs/surfaces/faderport/faderport.h b/libs/surfaces/faderport/faderport.h
index 56b8ebfbfd..b174996e67 100644
--- a/libs/surfaces/faderport/faderport.h
+++ b/libs/surfaces/faderport/faderport.h
@@ -232,7 +232,7 @@ class FaderPort : public ARDOUR::ControlProtocol, public AbstractUI<FaderPortReq
std::string get_action (bool press, FaderPort::ButtonState bs = ButtonState (0));
void set_led_state (boost::shared_ptr<MIDI::Port>, bool onoff);
- void invoke (ButtonState bs, bool press);
+ bool invoke (ButtonState bs, bool press);
bool uses_flash () const { return flash; }
void set_flash (bool yn) { flash = yn; }