From c6faede00c211b60a894ec0614cb90d363d17a12 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 17 Jun 2016 00:32:06 -0400 Subject: [PATCH] add shift modifier support --- libs/surfaces/push2/buttons.cc | 13 +++++++++++++ libs/surfaces/push2/push2.cc | 7 ++++++- libs/surfaces/push2/push2.h | 9 +++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/libs/surfaces/push2/buttons.cc b/libs/surfaces/push2/buttons.cc index 016cd78a17..b2312c4052 100644 --- a/libs/surfaces/push2/buttons.cc +++ b/libs/surfaces/push2/buttons.cc @@ -93,3 +93,16 @@ Push2::button_fixed_length () id_button_map[FixedLength]->set_state (LED::NoTransition); write (id_button_map[FixedLength]->state_msg()); } + +void +Push2::button_shift_press () +{ + modifier_state = ModifierState (modifier_state | ModShift); +} + +void +Push2::button_shift_release () +{ + modifier_state = ModifierState (modifier_state & ~ModShift); +} + diff --git a/libs/surfaces/push2/push2.cc b/libs/surfaces/push2/push2.cc index e83f393ff5..34a0efcbd0 100644 --- a/libs/surfaces/push2/push2.cc +++ b/libs/surfaces/push2/push2.cc @@ -60,6 +60,7 @@ Push2::Push2 (ARDOUR::Session& s) , handle (0) , device_buffer (0) , frame_buffer (Cairo::ImageSurface::create (Cairo::FORMAT_ARGB32, cols, rows)) + , modifier_state (None) { context = Cairo::Context::create (frame_buffer); tc_clock_layout = Pango::Layout::create (context); @@ -679,6 +680,10 @@ Push2::build_maps () button = new WhiteButton ((i), (cc), (p)); \ cc_button_map.insert (make_pair (button->controller_number(), button)); \ id_button_map.insert (make_pair (button->id, button)) +#define MAKE_WHITE_BUTTON_PRESS_RELEASE(i,cc,p,r) \ + button = new WhiteButton ((i), (cc), (p), (r)); \ + cc_button_map.insert (make_pair (button->controller_number(), button)); \ + id_button_map.insert (make_pair (button->id, button)) MAKE_WHITE_BUTTON (TapTempo, 3); MAKE_WHITE_BUTTON_PRESS (Metronome, 9, &Push2::button_metronome); @@ -712,7 +717,7 @@ Push2::build_maps () MAKE_WHITE_BUTTON (PageRight, 63); MAKE_WHITE_BUTTON (OctaveDown, 54); MAKE_WHITE_BUTTON (PageLeft, 62); - MAKE_WHITE_BUTTON (Shift, 49); + MAKE_WHITE_BUTTON_PRESS_RELEASE (Shift, 49, &Push2::button_shift_press, &Push2::button_shift_release); MAKE_WHITE_BUTTON (Select, 48); } diff --git a/libs/surfaces/push2/push2.h b/libs/surfaces/push2/push2.h index 2ec73779d4..3eac5f8653 100644 --- a/libs/surfaces/push2/push2.h +++ b/libs/surfaces/push2/push2.h @@ -86,6 +86,13 @@ class Push2 : public ARDOUR::ControlProtocol sigc::connection vblank_connection; sigc::connection periodic_connection; + enum ModifierState { + None = 0, + ModShift = 0x1, + }; + + ModifierState modifier_state; + static const int cols; static const int rows; static const int pixels_per_row; @@ -337,6 +344,8 @@ class Push2 : public ARDOUR::ControlProtocol void button_solo (); void button_fixed_length (); void button_new (); + void button_shift_press (); + void button_shift_release (); /* widgets */