summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2016-06-17 09:32:18 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2016-09-27 14:59:29 -0500
commitf699773490ffc4b7380eede4e529c66416f965ac (patch)
tree62326a4ebca1aeae139f88e547b3a928afd08ad2
parent2afb7f1a309b3fc46f6f29dbfe8dc65da4b7d0e4 (diff)
clear button states at startup *and* shutdown
-rw-r--r--libs/surfaces/push2/push2.cc28
-rw-r--r--libs/surfaces/push2/push2.h2
2 files changed, 26 insertions, 4 deletions
diff --git a/libs/surfaces/push2/push2.cc b/libs/surfaces/push2/push2.cc
index ddefee3f56..5be31c2f12 100644
--- a/libs/surfaces/push2/push2.cc
+++ b/libs/surfaces/push2/push2.cc
@@ -149,6 +149,13 @@ Push2::open ()
int
Push2::close ()
{
+ init_buttons (false);
+
+ /* wait for button data to be flushed */
+ AsyncMIDIPort* asp;
+ asp = dynamic_cast<AsyncMIDIPort*> (_output_port);
+ asp->drain (10000, 500000);
+
AudioEngine::instance()->unregister_port (_async_in);
AudioEngine::instance()->unregister_port (_async_out);
@@ -179,7 +186,7 @@ Push2::close ()
}
void
-Push2::init_buttons ()
+Push2::init_buttons (bool startup)
{
ButtonID buttons[] = { Mute, Solo, Master, Up, Right, Left, Down, Note, Session, Mix, AddTrack, Delete, Undo,
Metronome, Shift, Select, Play, RecordEnable, Automate, Repeat, Note, Session, DoubleLoop,
@@ -189,7 +196,22 @@ Push2::init_buttons ()
for (size_t n = 0; n < sizeof (buttons) / sizeof (buttons[0]); ++n) {
Button* b = id_button_map[buttons[n]];
- b->set_color (LED::White);
+ if (startup) {
+ b->set_color (LED::White);
+ } else {
+ b->set_color (LED::Black);
+ }
+ b->set_state (LED::OneShot24th);
+ write (b->state_msg());
+ }
+
+ ButtonID strip_buttons[] = { Upper1, Upper2, Upper3, Upper4, Upper5, Upper6, Upper7, Upper8,
+ Lower1, Lower2, Lower3, Lower4, Lower5, Lower6, Lower7, Lower8 };
+
+ for (size_t n = 0; n < sizeof (strip_buttons) / sizeof (strip_buttons[0]); ++n) {
+ Button* b = id_button_map[strip_buttons[n]];
+
+ b->set_color (LED::Black);
b->set_state (LED::OneShot24th);
write (b->state_msg());
}
@@ -464,7 +486,7 @@ Push2::set_active (bool yn)
periodic_connection = periodic_timeout->connect (sigc::mem_fun (*this, &Push2::periodic));
periodic_timeout->attach (main_loop()->get_context());
- init_buttons ();
+ init_buttons (true);
init_touch_strip ();
switch_bank (0);
diff --git a/libs/surfaces/push2/push2.h b/libs/surfaces/push2/push2.h
index 62bebdd2ea..1763750817 100644
--- a/libs/surfaces/push2/push2.h
+++ b/libs/surfaces/push2/push2.h
@@ -285,7 +285,7 @@ class Push2 : public ARDOUR::ControlProtocol
typedef std::map<ButtonID,Button*> IDButtonMap;
IDButtonMap id_button_map;
- void init_buttons ();
+ void init_buttons (bool startup);
void init_touch_strip ();
/* map of Pads by note number */