13
0

MCP: slightly cleaner code for button map definition

git-svn-id: svn://localhost/ardour2/branches/3.0@11883 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2012-04-11 03:18:35 +00:00
parent 72719ba1b6
commit 0b69a2d3e1

View File

@ -884,70 +884,72 @@ MackieControlProtocol::update_led (Surface& surface, Button& button, Mackie::Led
void
MackieControlProtocol::build_button_map ()
{
button_map.insert (pair<int,ButtonHandlers> (Button::Io, ButtonHandlers (&MackieControlProtocol::io_press, &MackieControlProtocol::io_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::Sends, ButtonHandlers (&MackieControlProtocol::sends_press, &MackieControlProtocol::sends_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::Pan, ButtonHandlers (&MackieControlProtocol::pan_press, &MackieControlProtocol::pan_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::Plugin, ButtonHandlers (&MackieControlProtocol::plugin_press, &MackieControlProtocol::plugin_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::Eq, ButtonHandlers (&MackieControlProtocol::eq_press, &MackieControlProtocol::eq_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::Dyn, ButtonHandlers (&MackieControlProtocol::dyn_press, &MackieControlProtocol::dyn_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::Left, ButtonHandlers (&MackieControlProtocol::left_press, &MackieControlProtocol::left_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::Right, ButtonHandlers (&MackieControlProtocol::right_press, &MackieControlProtocol::right_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::ChannelLeft, ButtonHandlers (&MackieControlProtocol::channel_left_press, &MackieControlProtocol::channel_left_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::ChannelRight, ButtonHandlers (&MackieControlProtocol::channel_right_press, &MackieControlProtocol::channel_right_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::Flip, ButtonHandlers (&MackieControlProtocol::flip_press, &MackieControlProtocol::flip_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::Edit, ButtonHandlers (&MackieControlProtocol::edit_press, &MackieControlProtocol::edit_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::NameValue, ButtonHandlers (&MackieControlProtocol::name_value_press, &MackieControlProtocol::name_value_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::TimecodeBeats, ButtonHandlers (&MackieControlProtocol::timecode_beats_press, &MackieControlProtocol::timecode_beats_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::F1, ButtonHandlers (&MackieControlProtocol::F1_press, &MackieControlProtocol::F1_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::F2, ButtonHandlers (&MackieControlProtocol::F2_press, &MackieControlProtocol::F2_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::F3, ButtonHandlers (&MackieControlProtocol::F3_press, &MackieControlProtocol::F3_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::F4, ButtonHandlers (&MackieControlProtocol::F4_press, &MackieControlProtocol::F4_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::F5, ButtonHandlers (&MackieControlProtocol::F5_press, &MackieControlProtocol::F5_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::F6, ButtonHandlers (&MackieControlProtocol::F6_press, &MackieControlProtocol::F6_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::F7, ButtonHandlers (&MackieControlProtocol::F7_press, &MackieControlProtocol::F7_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::F8, ButtonHandlers (&MackieControlProtocol::F8_press, &MackieControlProtocol::F8_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::F9, ButtonHandlers (&MackieControlProtocol::F9_press, &MackieControlProtocol::F9_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::F10, ButtonHandlers (&MackieControlProtocol::F10_press, &MackieControlProtocol::F10_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::F11, ButtonHandlers (&MackieControlProtocol::F11_press, &MackieControlProtocol::F11_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::F12, ButtonHandlers (&MackieControlProtocol::F12_press, &MackieControlProtocol::F12_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::F13, ButtonHandlers (&MackieControlProtocol::F13_press, &MackieControlProtocol::F13_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::F14, ButtonHandlers (&MackieControlProtocol::F14_press, &MackieControlProtocol::F14_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::F15, ButtonHandlers (&MackieControlProtocol::F15_press, &MackieControlProtocol::F15_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::F16, ButtonHandlers (&MackieControlProtocol::F16_press, &MackieControlProtocol::F16_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::Shift, ButtonHandlers (&MackieControlProtocol::shift_press, &MackieControlProtocol::shift_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::Option, ButtonHandlers (&MackieControlProtocol::option_press, &MackieControlProtocol::option_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::Ctrl, ButtonHandlers (&MackieControlProtocol::control_press, &MackieControlProtocol::control_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::CmdAlt, ButtonHandlers (&MackieControlProtocol::cmd_alt_press, &MackieControlProtocol::cmd_alt_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::On, ButtonHandlers (&MackieControlProtocol::on_press, &MackieControlProtocol::on_release)));
//button_map.insert (pair<int,ButtonHandlers> (Button::Rec, ButtonHandlers (&MackieControlProtocol::rec_press, &MackieControlProtocol::rec_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::Undo, ButtonHandlers (&MackieControlProtocol::undo_press, &MackieControlProtocol::undo_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::Save, ButtonHandlers (&MackieControlProtocol::save_press, &MackieControlProtocol::save_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::Touch, ButtonHandlers (&MackieControlProtocol::touch_press, &MackieControlProtocol::touch_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::Redo, ButtonHandlers (&MackieControlProtocol::redo_press, &MackieControlProtocol::redo_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::Marker, ButtonHandlers (&MackieControlProtocol::marker_press, &MackieControlProtocol::marker_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::Enter, ButtonHandlers (&MackieControlProtocol::enter_press, &MackieControlProtocol::enter_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::Cancel, ButtonHandlers (&MackieControlProtocol::cancel_press, &MackieControlProtocol::cancel_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::Mixer, ButtonHandlers (&MackieControlProtocol::mixer_press, &MackieControlProtocol::mixer_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::FrmLeft, ButtonHandlers (&MackieControlProtocol::frm_left_press, &MackieControlProtocol::frm_left_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::FrmRight, ButtonHandlers (&MackieControlProtocol::frm_right_press, &MackieControlProtocol::frm_right_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::Loop, ButtonHandlers (&MackieControlProtocol::loop_press, &MackieControlProtocol::loop_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::PunchIn, ButtonHandlers (&MackieControlProtocol::punch_in_press, &MackieControlProtocol::punch_in_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::PunchOut, ButtonHandlers (&MackieControlProtocol::punch_out_press, &MackieControlProtocol::punch_out_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::Home, ButtonHandlers (&MackieControlProtocol::home_press, &MackieControlProtocol::home_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::End, ButtonHandlers (&MackieControlProtocol::end_press, &MackieControlProtocol::end_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::Rewind, ButtonHandlers (&MackieControlProtocol::rewind_press, &MackieControlProtocol::rewind_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::Ffwd, ButtonHandlers (&MackieControlProtocol::ffwd_press, &MackieControlProtocol::ffwd_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::Stop, ButtonHandlers (&MackieControlProtocol::stop_press, &MackieControlProtocol::stop_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::Play, ButtonHandlers (&MackieControlProtocol::play_press, &MackieControlProtocol::play_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::Record, ButtonHandlers (&MackieControlProtocol::record_press, &MackieControlProtocol::record_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::CursorUp, ButtonHandlers (&MackieControlProtocol::cursor_up_press, &MackieControlProtocol::cursor_up_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::CursorDown, ButtonHandlers (&MackieControlProtocol::cursor_down_press, &MackieControlProtocol::cursor_down_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::CursorLeft, ButtonHandlers (&MackieControlProtocol::cursor_left_press, &MackieControlProtocol::cursor_left_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::CursorRight, ButtonHandlers (&MackieControlProtocol::cursor_right_press, &MackieControlProtocol::cursor_right_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::Zoom, ButtonHandlers (&MackieControlProtocol::zoom_press, &MackieControlProtocol::zoom_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::Scrub, ButtonHandlers (&MackieControlProtocol::scrub_press, &MackieControlProtocol::scrub_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::UserA, ButtonHandlers (&MackieControlProtocol::user_a_press, &MackieControlProtocol::user_a_release)));
button_map.insert (pair<int,ButtonHandlers> (Button::UserB, ButtonHandlers (&MackieControlProtocol::user_b_press, &MackieControlProtocol::user_b_release)));
#define DEFINE_BUTTON_HANDLER(b,p,r) button_map.insert (pair<int,ButtonHandlers> ((b), ButtonHandlers ((p),(r))));
DEFINE_BUTTON_HANDLER (Button::Io, &MackieControlProtocol::io_press, &MackieControlProtocol::io_release);
DEFINE_BUTTON_HANDLER (Button::Sends, &MackieControlProtocol::sends_press, &MackieControlProtocol::sends_release);
DEFINE_BUTTON_HANDLER (Button::Pan, &MackieControlProtocol::pan_press, &MackieControlProtocol::pan_release);
DEFINE_BUTTON_HANDLER (Button::Plugin, &MackieControlProtocol::plugin_press, &MackieControlProtocol::plugin_release);
DEFINE_BUTTON_HANDLER (Button::Eq, &MackieControlProtocol::eq_press, &MackieControlProtocol::eq_release);
DEFINE_BUTTON_HANDLER (Button::Dyn, &MackieControlProtocol::dyn_press, &MackieControlProtocol::dyn_release);
DEFINE_BUTTON_HANDLER (Button::Left, &MackieControlProtocol::left_press, &MackieControlProtocol::left_release);
DEFINE_BUTTON_HANDLER (Button::Right, &MackieControlProtocol::right_press, &MackieControlProtocol::right_release);
DEFINE_BUTTON_HANDLER (Button::ChannelLeft, &MackieControlProtocol::channel_left_press, &MackieControlProtocol::channel_left_release);
DEFINE_BUTTON_HANDLER (Button::ChannelRight, &MackieControlProtocol::channel_right_press, &MackieControlProtocol::channel_right_release);
DEFINE_BUTTON_HANDLER (Button::Flip, &MackieControlProtocol::flip_press, &MackieControlProtocol::flip_release);
DEFINE_BUTTON_HANDLER (Button::Edit, &MackieControlProtocol::edit_press, &MackieControlProtocol::edit_release);
DEFINE_BUTTON_HANDLER (Button::NameValue, &MackieControlProtocol::name_value_press, &MackieControlProtocol::name_value_release);
DEFINE_BUTTON_HANDLER (Button::TimecodeBeats, &MackieControlProtocol::timecode_beats_press, &MackieControlProtocol::timecode_beats_release);
DEFINE_BUTTON_HANDLER (Button::F1, &MackieControlProtocol::F1_press, &MackieControlProtocol::F1_release);
DEFINE_BUTTON_HANDLER (Button::F2, &MackieControlProtocol::F2_press, &MackieControlProtocol::F2_release);
DEFINE_BUTTON_HANDLER (Button::F3, &MackieControlProtocol::F3_press, &MackieControlProtocol::F3_release);
DEFINE_BUTTON_HANDLER (Button::F4, &MackieControlProtocol::F4_press, &MackieControlProtocol::F4_release);
DEFINE_BUTTON_HANDLER (Button::F5, &MackieControlProtocol::F5_press, &MackieControlProtocol::F5_release);
DEFINE_BUTTON_HANDLER (Button::F6, &MackieControlProtocol::F6_press, &MackieControlProtocol::F6_release);
DEFINE_BUTTON_HANDLER (Button::F7, &MackieControlProtocol::F7_press, &MackieControlProtocol::F7_release);
DEFINE_BUTTON_HANDLER (Button::F8, &MackieControlProtocol::F8_press, &MackieControlProtocol::F8_release);
DEFINE_BUTTON_HANDLER (Button::F9, &MackieControlProtocol::F9_press, &MackieControlProtocol::F9_release);
DEFINE_BUTTON_HANDLER (Button::F10, &MackieControlProtocol::F10_press, &MackieControlProtocol::F10_release);
DEFINE_BUTTON_HANDLER (Button::F11, &MackieControlProtocol::F11_press, &MackieControlProtocol::F11_release);
DEFINE_BUTTON_HANDLER (Button::F12, &MackieControlProtocol::F12_press, &MackieControlProtocol::F12_release);
DEFINE_BUTTON_HANDLER (Button::F13, &MackieControlProtocol::F13_press, &MackieControlProtocol::F13_release);
DEFINE_BUTTON_HANDLER (Button::F14, &MackieControlProtocol::F14_press, &MackieControlProtocol::F14_release);
DEFINE_BUTTON_HANDLER (Button::F15, &MackieControlProtocol::F15_press, &MackieControlProtocol::F15_release);
DEFINE_BUTTON_HANDLER (Button::F16, &MackieControlProtocol::F16_press, &MackieControlProtocol::F16_release);
DEFINE_BUTTON_HANDLER (Button::Shift, &MackieControlProtocol::shift_press, &MackieControlProtocol::shift_release);
DEFINE_BUTTON_HANDLER (Button::Option, &MackieControlProtocol::option_press, &MackieControlProtocol::option_release);
DEFINE_BUTTON_HANDLER (Button::Ctrl, &MackieControlProtocol::control_press, &MackieControlProtocol::control_release);
DEFINE_BUTTON_HANDLER (Button::CmdAlt, &MackieControlProtocol::cmd_alt_press, &MackieControlProtocol::cmd_alt_release);
DEFINE_BUTTON_HANDLER (Button::On, &MackieControlProtocol::on_press, &MackieControlProtocol::on_release);
DEFINE_BUTTON_HANDLER (Button::RecReady, &MackieControlProtocol::rec_ready_press, &MackieControlProtocol::rec_ready_release);
DEFINE_BUTTON_HANDLER (Button::Undo, &MackieControlProtocol::undo_press, &MackieControlProtocol::undo_release);
DEFINE_BUTTON_HANDLER (Button::Save, &MackieControlProtocol::save_press, &MackieControlProtocol::save_release);
DEFINE_BUTTON_HANDLER (Button::Touch, &MackieControlProtocol::touch_press, &MackieControlProtocol::touch_release);
DEFINE_BUTTON_HANDLER (Button::Redo, &MackieControlProtocol::redo_press, &MackieControlProtocol::redo_release);
DEFINE_BUTTON_HANDLER (Button::Marker, &MackieControlProtocol::marker_press, &MackieControlProtocol::marker_release);
DEFINE_BUTTON_HANDLER (Button::Enter, &MackieControlProtocol::enter_press, &MackieControlProtocol::enter_release);
DEFINE_BUTTON_HANDLER (Button::Cancel, &MackieControlProtocol::cancel_press, &MackieControlProtocol::cancel_release);
DEFINE_BUTTON_HANDLER (Button::Mixer, &MackieControlProtocol::mixer_press, &MackieControlProtocol::mixer_release);
DEFINE_BUTTON_HANDLER (Button::FrmLeft, &MackieControlProtocol::frm_left_press, &MackieControlProtocol::frm_left_release);
DEFINE_BUTTON_HANDLER (Button::FrmRight, &MackieControlProtocol::frm_right_press, &MackieControlProtocol::frm_right_release);
DEFINE_BUTTON_HANDLER (Button::Loop, &MackieControlProtocol::loop_press, &MackieControlProtocol::loop_release);
DEFINE_BUTTON_HANDLER (Button::PunchIn, &MackieControlProtocol::punch_in_press, &MackieControlProtocol::punch_in_release);
DEFINE_BUTTON_HANDLER (Button::PunchOut, &MackieControlProtocol::punch_out_press, &MackieControlProtocol::punch_out_release);
DEFINE_BUTTON_HANDLER (Button::Home, &MackieControlProtocol::home_press, &MackieControlProtocol::home_release);
DEFINE_BUTTON_HANDLER (Button::End, &MackieControlProtocol::end_press, &MackieControlProtocol::end_release);
DEFINE_BUTTON_HANDLER (Button::Rewind, &MackieControlProtocol::rewind_press, &MackieControlProtocol::rewind_release);
DEFINE_BUTTON_HANDLER (Button::Ffwd, &MackieControlProtocol::ffwd_press, &MackieControlProtocol::ffwd_release);
DEFINE_BUTTON_HANDLER (Button::Stop, &MackieControlProtocol::stop_press, &MackieControlProtocol::stop_release);
DEFINE_BUTTON_HANDLER (Button::Play, &MackieControlProtocol::play_press, &MackieControlProtocol::play_release);
DEFINE_BUTTON_HANDLER (Button::Record, &MackieControlProtocol::record_press, &MackieControlProtocol::record_release);
DEFINE_BUTTON_HANDLER (Button::CursorUp, &MackieControlProtocol::cursor_up_press, &MackieControlProtocol::cursor_up_release);
DEFINE_BUTTON_HANDLER (Button::CursorDown, &MackieControlProtocol::cursor_down_press, &MackieControlProtocol::cursor_down_release);
DEFINE_BUTTON_HANDLER (Button::CursorLeft, &MackieControlProtocol::cursor_left_press, &MackieControlProtocol::cursor_left_release);
DEFINE_BUTTON_HANDLER (Button::CursorRight, &MackieControlProtocol::cursor_right_press, &MackieControlProtocol::cursor_right_release);
DEFINE_BUTTON_HANDLER (Button::Zoom, &MackieControlProtocol::zoom_press, &MackieControlProtocol::zoom_release);
DEFINE_BUTTON_HANDLER (Button::Scrub, &MackieControlProtocol::scrub_press, &MackieControlProtocol::scrub_release);
DEFINE_BUTTON_HANDLER (Button::UserA, &MackieControlProtocol::user_a_press, &MackieControlProtocol::user_a_release);
DEFINE_BUTTON_HANDLER (Button::UserB, &MackieControlProtocol::user_b_press, &MackieControlProtocol::user_b_release);
}
void