summaryrefslogtreecommitdiff
path: root/libs/surfaces/push2
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2016-09-23 13:54:29 -0500
committerPaul Davis <paul@linuxaudiosystems.com>2016-09-27 14:59:32 -0500
commita9a3b71807cfb81f30a6f84482c921f1fd1f85a1 (patch)
tree3298c6cb81a88432281c11324e27c484f122350a /libs/surfaces/push2
parent44c0ea209526dcdec70412f88e7a0dfcb5b0527d (diff)
change handling of MIDI sysex incoming to be a little more efficient
Diffstat (limited to 'libs/surfaces/push2')
-rw-r--r--libs/surfaces/push2/push2.cc34
1 files changed, 23 insertions, 11 deletions
diff --git a/libs/surfaces/push2/push2.cc b/libs/surfaces/push2/push2.cc
index 87d4c4d9c5..ccc541296f 100644
--- a/libs/surfaces/push2/push2.cc
+++ b/libs/surfaces/push2/push2.cc
@@ -622,18 +622,30 @@ 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));
+
+ if (sz < 8) {
+ return;
+ }
+
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";
+ MidiByteArray push2_sysex_header (6, 0xF0, 0x00, 0x21, 0x1D, 0x01, 0x01);
+
+ if (!push2_sysex_header.compare_n (msg, 6)) {
+ return;
+ }
+
+ switch (msg[6]) {
+ case 0x1f: /* pressure mode */
+ if (msg[7] == 0x0) {
+ _pressure_mode = AfterTouch;
+ PressureModeChange (AfterTouch);
+ cerr << "Pressure mode is after\n";
+ } else {
+ _pressure_mode = PolyPressure;
+ PressureModeChange (PolyPressure);
+ cerr << "Pressure mode is poly\n";
+ }
+ break;
}
}