2023-10-20 00:18:34 -04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2016 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
2023-11-03 23:00:57 -04:00
|
|
|
o * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2023-10-20 00:18:34 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdexcept>
|
|
|
|
|
|
|
|
#include "pbd/error.h"
|
|
|
|
|
|
|
|
#include "ardour/rc_configuration.h"
|
|
|
|
|
|
|
|
#include "control_protocol/control_protocol.h"
|
|
|
|
#include "lpx.h"
|
|
|
|
|
2023-11-04 11:29:53 -04:00
|
|
|
#ifdef LAUNCHPAD_MINI
|
|
|
|
#define LAUNCHPAD_NAMESPACE LP_MINI
|
|
|
|
#else
|
|
|
|
#define LAUNCHPAD_NAMESPACE LP_X
|
|
|
|
#endif
|
|
|
|
|
2023-10-20 00:18:34 -04:00
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace PBD;
|
|
|
|
using namespace ArdourSurface;
|
2023-11-04 11:29:53 -04:00
|
|
|
using namespace ArdourSurface::LAUNCHPAD_NAMESPACE;
|
2023-10-20 00:18:34 -04:00
|
|
|
|
|
|
|
static ControlProtocol*
|
2023-11-03 23:00:57 -04:00
|
|
|
new_lpmini (Session* s)
|
2023-10-20 00:18:34 -04:00
|
|
|
{
|
2023-11-03 23:00:57 -04:00
|
|
|
LaunchPadX * lpm = nullptr;
|
2023-10-20 00:18:34 -04:00
|
|
|
|
|
|
|
try {
|
2023-11-03 23:00:57 -04:00
|
|
|
lpm = new LaunchPadX (*s);
|
2023-10-20 00:18:34 -04:00
|
|
|
/* do not set active here - wait for set_state() */
|
|
|
|
}
|
|
|
|
catch (std::exception & e) {
|
2023-11-03 23:00:57 -04:00
|
|
|
error << "Error instantiating LaunchPad Mini support: " << e.what() << endmsg;
|
|
|
|
delete lpm;
|
|
|
|
lpm = nullptr;
|
2023-10-20 00:18:34 -04:00
|
|
|
}
|
|
|
|
|
2023-11-03 23:00:57 -04:00
|
|
|
return lpm;
|
2023-10-20 00:18:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2023-11-03 23:00:57 -04:00
|
|
|
delete_lpmini (ControlProtocol* cp)
|
2023-10-20 00:18:34 -04:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
delete cp;
|
|
|
|
}
|
|
|
|
catch ( std::exception & e )
|
|
|
|
{
|
2023-11-03 23:00:57 -04:00
|
|
|
std::cout << "Exception caught trying to finalize LaunchPad Mini support: " << e.what() << std::endl;
|
2023-10-20 00:18:34 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
2023-11-03 23:00:57 -04:00
|
|
|
probe_lpmini_midi_protocol ()
|
2023-10-20 00:18:34 -04:00
|
|
|
{
|
|
|
|
std::string i, o;
|
|
|
|
return LaunchPadX::probe (i, o);
|
|
|
|
}
|
|
|
|
|
2023-11-03 23:00:57 -04:00
|
|
|
static ControlProtocolDescriptor lpmini_descriptor = {
|
|
|
|
/* name */ "Novation LaunchPad Mini",
|
|
|
|
/* id */ "uri://ardour.org/surfaces/lpmini:0",
|
2023-10-20 00:18:34 -04:00
|
|
|
/* module */ 0,
|
2023-11-03 23:00:57 -04:00
|
|
|
/* available */ 0,
|
|
|
|
/* probe_port */ probe_lpmini_midi_protocol,
|
2023-10-20 00:18:34 -04:00
|
|
|
/* match usb */ 0, // LaunchPadX::match_usb,
|
2023-11-03 23:00:57 -04:00
|
|
|
/* initialize */ new_lpmini,
|
|
|
|
/* destroy */ delete_lpmini,
|
2023-10-20 00:18:34 -04:00
|
|
|
};
|
|
|
|
|
2023-11-03 23:00:57 -04:00
|
|
|
extern "C" ARDOURSURFACE_API ControlProtocolDescriptor* protocol_descriptor () { return &lpmini_descriptor; }
|