#include <sstream>
#include <algorithm>
+#include <glibmm/fileutils.h>
#include <glibmm/miscutils.h>
#include "pbd/controllable_descriptor.h"
GenericMidiControlProtocol::GenericMidiControlProtocol (Session& s)
: ControlProtocol (s, _("Generic MIDI"))
, _motorised (false)
+ , _threshold (10)
, gui (0)
{
_input_port = MIDI::Manager::instance()->midi_input_port ();
static const char* const midi_map_dir_name = "midi_maps";
static const char* const midi_map_suffix = ".map";
-static sys::path
+static std::string
system_midi_map_search_path ()
{
bool midimap_path_defined = false;
- sys::path spath_env (Glib::getenv (midimap_env_variable_name, midimap_path_defined));
+ std::string spath_env (Glib::getenv (midimap_env_variable_name, midimap_path_defined));
if (midimap_path_defined) {
return spath_env;
}
- SearchPath spath (system_data_search_path());
+ SearchPath spath (ardour_data_search_path());
spath.add_subdirectory_to_paths(midi_map_dir_name);
// just return the first directory in the search path that exists
- SearchPath::const_iterator i = std::find_if(spath.begin(), spath.end(), sys::exists);
-
- if (i == spath.end()) return sys::path();
-
- return *i;
+ for (SearchPath::const_iterator i = spath.begin(); i != spath.end(); ++i) {
+ if (Glib::file_test (*i, Glib::FILE_TEST_EXISTS)) {
+ return *i;
+ }
+ }
+ return std::string();
}
-static sys::path
+static std::string
user_midi_map_directory ()
{
- sys::path p(user_config_directory());
- p /= midi_map_dir_name;
-
- return p;
+ return Glib::build_filename (user_config_directory(), midi_map_dir_name);
}
static bool
if ((prop = (*niter)->property ("id")) != 0) {
- cerr << "Looking for MIDI Controllable with ID " << prop->value() << endl;
-
ID id = prop->value ();
Controllable* c = Controllable::by_id (id);
- cerr << "\tresult = " << c << endl;
-
if (c) {
MIDIControllable* mc = new MIDIControllable (this, *_input_port, *c, false);
} else {
_motorised = false;
}
+
+ if ((prop = (*citer)->property ("threshold")) != 0) {
+ _threshold = atoi (prop->value ());
+ } else {
+ _threshold = 10;
+ }
+
}
if ((*citer)->name() == "Binding") {
{
_motorised = m;
}
+
+void
+GenericMidiControlProtocol::set_threshold (int t)
+{
+ _threshold = t;
+}