summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Noel <joe.noel@focusrite.com>2015-08-19 14:51:44 +0100
committerJoe Noel <joe.noel@focusrite.com>2015-08-19 14:51:44 +0100
commit293e4a638dd55a2c1088bf8c76962a835b5d1296 (patch)
tree9ad51ef9b50c9032164c1f3701ac9621c7183bac
parenteb8bfe510bf438c596e45e7371bbe123bee4123c (diff)
downloadlaunchpad-polymaker-293e4a638dd55a2c1088bf8c76962a835b5d1296.tar.gz
launchpad-polymaker-293e4a638dd55a2c1088bf8c76962a835b5d1296.zip
Added aftertouch support
-rw-r--r--tools/osx/simulator-osx.c75
1 files changed, 38 insertions, 37 deletions
diff --git a/tools/osx/simulator-osx.c b/tools/osx/simulator-osx.c
index 0888533..57b0f38 100644
--- a/tools/osx/simulator-osx.c
+++ b/tools/osx/simulator-osx.c
@@ -76,43 +76,44 @@ void hal_send_sysex(u8 port, const u8* data, u16 length)
76////////////////////////////////////////////////////////////////////////// 76//////////////////////////////////////////////////////////////////////////
77static void processPacket(const unsigned char *data, int length) 77static void processPacket(const unsigned char *data, int length)
78{ 78{
79 // parse MIDI (very naively) 79 // parse MIDI (very naively)
80 unsigned char status = 0; 80 while (length > 0)
81 unsigned char d1 = 0xff; 81 {
82 82 unsigned char status = data[0];
83 while (length > 0) 83
84 { 84 // Wipe out channel (bottom four bits)
85 if (*data & 0x80) 85 status &= 0xF0;
86 { 86
87 status = *data; 87 if (length >= 3)
88 } 88 {
89 else 89 switch (status)
90 { 90 {
91 // data 91 case NOTEON:
92 switch (status) 92 case NOTEOFF:
93 { 93 app_surface_event(TYPEPAD, data[1], data[2]);
94 case 0x90: // pads 94 length -= 3;
95 case 0xB0: // circular buttons 95 break;
96 { 96
97 if (d1> 0x7F) 97 case CC:
98 { 98 app_surface_event(TYPEPAD, data[1], data[2]);
99 // await data 2 byte 99 length -= 3;
100 d1 = *data; 100 break;
101 } 101
102 else 102 case POLYAFTERTOUCH:
103 { 103 app_aftertouch_event(data[1], data[2]);
104 // complete note message - send up to the app 104 length -= 3;
105 app_surface_event(TYPEPAD, d1, *data); 105 break;
106 d1 = 0xff; 106
107 } 107 default:
108 } 108 break;
109 break; 109 }
110 } 110 }
111 } 111 else
112 112 {
113 ++data; 113 // We expected at least three bytes and didn't get them, so bail
114 --length; 114 length = 0;
115 } 115 }
116 }
116} 117}
117 118
118static void readProc(const MIDIPacketList *pktlist, void *readProcRefCon, void *srcConnRefCon) 119static void readProc(const MIDIPacketList *pktlist, void *readProcRefCon, void *srcConnRefCon)