#include "midi_byte_array.h"
#include "mackie_control_exception.h"
+#include "device_profile.h"
#include "surface_port.h"
#include "surface.h"
#include "strip.h"
const int MackieControlProtocol::MODIFIER_OPTION = 0x1;
const int MackieControlProtocol::MODIFIER_CONTROL = 0x2;
-const int MackieControlProtocol::MODIFIER_SHIFT = 0x3;
-const int MackieControlProtocol::MODIFIER_CMDALT = 0x4;
+const int MackieControlProtocol::MODIFIER_SHIFT = 0x4;
+const int MackieControlProtocol::MODIFIER_CMDALT = 0x8;
MackieControlProtocol* MackieControlProtocol::_instance = 0;
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),
}
}
+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)
{
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());