summaryrefslogtreecommitdiff
path: root/libs/surfaces/push2/push2.cc
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 /libs/surfaces/push2/push2.cc
parent6946bdc0830c9f0971d2cd0d54b27e343c54d96a (diff)
basic code to get/set pressure mode to/from the push2
Diffstat (limited to 'libs/surfaces/push2/push2.cc')
-rw-r--r--libs/surfaces/push2/push2.cc48
1 files changed, 47 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);
+}