MCP: various work on the button binding GUI

git-svn-id: svn://localhost/ardour2/branches/3.0@11997 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2012-04-17 20:41:31 +00:00
parent a382da4918
commit b9ff443085
20 changed files with 857 additions and 165 deletions

View file

@ -57,6 +57,7 @@
#include "midi_byte_array.h"
#include "mackie_control_exception.h"
#include "device_profile.h"
#include "surface_port.h"
#include "surface.h"
#include "strip.h"
@ -108,7 +109,10 @@ MackieControlProtocol::MackieControlProtocol (Session& session)
DEBUG_TRACE (DEBUG::MackieControl, "MackieControlProtocol::MackieControlProtocol\n");
DeviceInfo::reload_device_info ();
DeviceProfile::reload_device_profiles ();
set_device (Config->get_mackie_device_name());
set_profile (Config->get_mackie_device_profile());
AudioEngine::instance()->PortConnectedOrDisconnected.connect (
audio_engine_connections, MISSING_INVALIDATOR, ui_bind (&MackieControlProtocol::port_connected_or_disconnected, this, _2, _4, _5),
@ -506,6 +510,23 @@ MackieControlProtocol::connect_session_signals()
}
}
void
MackieControlProtocol::set_profile (const string& profile_name)
{
if (profile_name == "default") {
/* reset to default */
_device_profile = DeviceProfile (profile_name);
}
map<string,DeviceProfile>::iterator d = DeviceProfile::device_profiles.find (profile_name);
if (d == DeviceProfile::device_profiles.end()) {
return;
}
_device_profile = d->second;
}
void
MackieControlProtocol::set_device (const string& device_name)
{
@ -1016,6 +1037,22 @@ MackieControlProtocol::handle_button_event (Surface& surface, Button& button, Bu
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Handling %1 for button %2\n", (bs == press ? "press" : "release"), button.id()));
/* check profile first */
string action = _device_profile.get_button_action (button.bid(), _modifier_state);
if (!action.empty()) {
/* if there is a bound action for this button, and this is a press event,
carry out the action. If its a release event, do nothing since we
don't bind to them at all but don't want any other handling to
occur either.
*/
if (bs == press) {
access_action (action);
}
return;
}
/* lookup using the device-INDEPENDENT button ID */
ButtonMap::iterator b = button_map.find (button.bid());