summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2016-08-25 19:57:02 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2016-09-27 14:59:31 -0500
commitb822d8be366f39663b2fc50e128557b4d3f18f42 (patch)
treea07fe8fafd9a4f6f47fa5ebdb7714252a0e04fa3
parent6946bdc0830c9f0971d2cd0d54b27e343c54d96a (diff)
basic code to get/set pressure mode to/from the push2
-rw-r--r--libs/surfaces/push2/push2.cc48
-rw-r--r--libs/surfaces/push2/push2.h13
2 files changed, 60 insertions, 1 deletions
diff --git a/libs/surfaces/push2/push2.cc b/libs/surfaces/push2/push2.cc
index 0544446a31..d91cf5cfe8 100644
--- a/libs/surfaces/push2/push2.cc
+++ b/libs/surfaces/push2/push2.cc
@@ -141,6 +141,7 @@ Push2::Push2 (ARDOUR::Session& s)
, _in_key (true)
, octave_shift (0)
, percussion (false)
+ , _pressure_mode (AfterTouch)
{
context = Cairo::Context::create (frame_buffer);
@@ -709,6 +710,19 @@ void
Push2::handle_midi_sysex (MIDI::Parser&, MIDI::byte* raw_bytes, size_t sz)
{
DEBUG_TRACE (DEBUG::Push2, string_compose ("Sysex, %1 bytes\n", sz));
+ MidiByteArray msg (sz, raw_bytes);
+ MidiByteArray aftertouch_mode_response (9, 0xF0, 0x00, 0x21, 0x1D, 0x01, 0x01, 0x1F, 0x0, 0xF7);
+ MidiByteArray polypress_mode_response (9, 0xF0, 0x00, 0x21, 0x1D, 0x01, 0x01, 0x1F, 0x1, 0xF7);
+
+ if (msg == aftertouch_mode_response) {
+ _pressure_mode = AfterTouch;
+ PressureModeChange (AfterTouch);
+ cerr << "Pressure mod eis after\n";
+ } else if (msg == polypress_mode_response) {
+ _pressure_mode = PolyPressure;
+ PressureModeChange (PolyPressure);
+ cerr << "Pressure mod eis poly\n";
+ }
}
void
@@ -1336,7 +1350,7 @@ Push2::connection_handler (boost::weak_ptr<ARDOUR::Port>, std::string name1, boo
g_usleep (100000);
DEBUG_TRACE (DEBUG::FaderPort, "device now connected for both input and output\n");
- // connected ();
+ connected ();
} else {
DEBUG_TRACE (DEBUG::FaderPort, "Device disconnected (input or output or both) or not yet fully connected\n");
@@ -1349,6 +1363,12 @@ Push2::connection_handler (boost::weak_ptr<ARDOUR::Port>, std::string name1, boo
return true; /* connection status changed */
}
+void
+Push2::connected ()
+{
+ request_pressure_mode ();
+}
+
boost::shared_ptr<Port>
Push2::output_port()
{
@@ -1735,3 +1755,29 @@ Push2::set_current_layout (Push2Layout* layout)
_current_layout->on_show ();
}
}
+
+void
+Push2::request_pressure_mode ()
+{
+ MidiByteArray msg (8, 0xF0, 0x00, 0x21, 0x1D, 0x01, 0x01, 0x1F, 0xF7);
+ write (msg);
+}
+
+void
+Push2::set_pressure_mode (PressureMode pm)
+{
+ MidiByteArray msg (9, 0xF0, 0x00, 0x21, 0x1D, 0x01, 0x01, 0x1E, 0x0, 0xF7);
+
+ switch (pm) {
+ case AfterTouch:
+ /* nothing to do, message is correct */
+ break;
+ case PolyPressure:
+ msg[7] = 0x1;
+ break;
+ default:
+ return;
+ }
+
+ write (msg);
+}
diff --git a/libs/surfaces/push2/push2.h b/libs/surfaces/push2/push2.h
index d30f89fabe..be4c116895 100644
--- a/libs/surfaces/push2/push2.h
+++ b/libs/surfaces/push2/push2.h
@@ -303,6 +303,11 @@ class Push2 : public ARDOUR::ControlProtocol
KnobBorder,
};
+ enum PressureMode {
+ AfterTouch,
+ PolyPressure,
+ };
+
public:
Push2 (ARDOUR::Session&);
~Push2 ();
@@ -355,6 +360,10 @@ class Push2 : public ARDOUR::ControlProtocol
static const int cols;
static const int rows;
+ PressureMode pressure_mode () const { return _pressure_mode; }
+ void set_pressure_mode (PressureMode);
+ PBD::Signal1<void,PressureMode> PressureModeChange;
+
private:
libusb_device_handle *handle;
uint8_t frame_header[16];
@@ -540,6 +549,7 @@ class Push2 : public ARDOUR::ControlProtocol
int connection_state;
bool connection_handler (boost::weak_ptr<ARDOUR::Port>, std::string name1, boost::weak_ptr<ARDOUR::Port>, std::string name2, bool yn);
PBD::ScopedConnection port_connection;
+ void connected ();
/* GUI */
@@ -574,6 +584,9 @@ class Push2 : public ARDOUR::ControlProtocol
typedef std::map<ColorName,uint32_t> Colors;
Colors colors;
void fill_color_table ();
+
+ PressureMode _pressure_mode;
+ void request_pressure_mode ();
};
} /* namespace */