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
This commit is contained in:
parent
ddfc37e42a
commit
224295266f
@ -314,16 +314,16 @@ bool
|
|||||||
FaderPort::button_long_press_timeout (ButtonID id)
|
FaderPort::button_long_press_timeout (ButtonID id)
|
||||||
{
|
{
|
||||||
if (buttons_down.find (id) != buttons_down.end()) {
|
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 {
|
} else {
|
||||||
/* release happened and somehow we were not cancelled */
|
/* 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 */
|
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);
|
set<ButtonID>::iterator c = consumed.find (id);
|
||||||
|
|
||||||
if (c == consumed.end()) {
|
if (c == consumed.end()) {
|
||||||
button.invoke (button_state, tb->value ? true : false);
|
(void) button.invoke (button_state, tb->value ? true : false);
|
||||||
} else {
|
} else {
|
||||||
DEBUG_TRACE (DEBUG::FaderPort, "button was consumed, ignored\n");
|
DEBUG_TRACE (DEBUG::FaderPort, "button was consumed, ignored\n");
|
||||||
consumed.erase (c);
|
consumed.erase (c);
|
||||||
@ -918,7 +918,7 @@ FaderPort::connected ()
|
|||||||
_output_port->write (buf, 6, 0);
|
_output_port->write (buf, 6, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
bool
|
||||||
FaderPort::Button::invoke (FaderPort::ButtonState bs, bool press)
|
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));
|
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 (press) {
|
||||||
if ((x = on_press.find (bs)) == on_press.end()) {
|
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));
|
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 {
|
} else {
|
||||||
if ((x = on_release.find (bs)) == on_release.end()) {
|
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));
|
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:
|
case NamedAction:
|
||||||
if (!x->second.action_name.empty()) {
|
if (!x->second.action_name.empty()) {
|
||||||
fp.access_action (x->second.action_name);
|
fp.access_action (x->second.action_name);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case InternalFunction:
|
case InternalFunction:
|
||||||
if (x->second.function) {
|
if (x->second.function) {
|
||||||
x->second.function ();
|
x->second.function ();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -232,7 +232,7 @@ class FaderPort : public ARDOUR::ControlProtocol, public AbstractUI<FaderPortReq
|
|||||||
std::string get_action (bool press, FaderPort::ButtonState bs = ButtonState (0));
|
std::string get_action (bool press, FaderPort::ButtonState bs = ButtonState (0));
|
||||||
|
|
||||||
void set_led_state (boost::shared_ptr<MIDI::Port>, bool onoff);
|
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; }
|
bool uses_flash () const { return flash; }
|
||||||
void set_flash (bool yn) { flash = yn; }
|
void set_flash (bool yn) { flash = yn; }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user