summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorDaveHodder67 <dave.hodder@focusrite.com>2015-08-13 14:09:07 +0100
committerDaveHodder67 <dave.hodder@focusrite.com>2015-08-13 14:09:07 +0100
commit7c6fbef9abe3d75099f36e174a6f4dfd67eeaccc (patch)
treedbe93ae857a365b6af5f93542e16c336d6369ffe /tools
parentbd1f984b05ed156fc5c64fea5416b4fe48c3d491 (diff)
downloadlaunchpad-polymaker-7c6fbef9abe3d75099f36e174a6f4dfd67eeaccc.tar.gz
launchpad-polymaker-7c6fbef9abe3d75099f36e174a6f4dfd67eeaccc.zip
MIDI input to sim working
Diffstat (limited to 'tools')
-rw-r--r--tools/osx/simulator-osx.c45
1 files changed, 42 insertions, 3 deletions
diff --git a/tools/osx/simulator-osx.c b/tools/osx/simulator-osx.c
index 2c0909b..046fdf8 100644
--- a/tools/osx/simulator-osx.c
+++ b/tools/osx/simulator-osx.c
@@ -89,13 +89,28 @@ static void sim_app_timer_event()
89 app_timer_event(); 89 app_timer_event();
90} 90}
91 91
92//////////////////////////////////////////////////////////////////////////
93static void processPacket(const unsigned char *data, int length)
94{
95 while (length > 0)
96 {
97 printf("%2.2x ", *data++);
98 --length;
99 }
100 printf("\n");
101
102 // recieve a pad or button press!
103}
104
105
92static void readProc(const MIDIPacketList *pktlist, void *readProcRefCon, void *srcConnRefCon) 106static void readProc(const MIDIPacketList *pktlist, void *readProcRefCon, void *srcConnRefCon)
93{ 107{
94 // farm out the packet list entries 108 // farm out the packet list entries
95 const MIDIPacket *packet = &pktlist->packet[0]; 109 const MIDIPacket *packet = &pktlist->packet[0];
96 for (int i=0; i < pktlist->numPackets; ++i) 110 for (int i=0; i < pktlist->numPackets; ++i)
97 { 111 {
98 // process the packet 112 // process the packet - in our case, receive a surface message
113 processPacket(packet->data, packet->length);
99 114
100 // next 115 // next
101 packet = MIDIPacketNext(packet); 116 packet = MIDIPacketNext(packet);
@@ -124,6 +139,12 @@ static int findLaunchapdPro()
124 { 139 {
125 return -1; 140 return -1;
126 } 141 }
142
143
144 if (noErr != MIDIPortConnectSource(g_inDevPort, endpoint, NULL))
145 {
146 return -1;
147 }
127 } 148 }
128 } 149 }
129 } 150 }
@@ -152,7 +173,13 @@ static int findLaunchapdPro()
152 } 173 }
153 } 174 }
154 175
155 return (g_inDevPort && g_outDevPort); 176 return !(g_inDevPort && g_outDevPort);
177}
178
179static int createVirtualPorts()
180{
181 // create local virtual Launchpad Pro ports
182 return 0;
156} 183}
157 184
158// ____________________________________________________________________________ 185// ____________________________________________________________________________
@@ -167,21 +194,33 @@ int main(int argc, char * argv[])
167 } 194 }
168 else 195 else
169 { 196 {
197 // failed to open MIDI client
170 return -1; 198 return -1;
171 } 199 }
172 200
173 if (findLaunchapdPro()) 201 if (findLaunchapdPro())
174 { 202 {
203 // no Launchpad Pro connected
175 return -2; 204 return -2;
176 } 205 }
177 206
207 if (createVirtualPorts())
208 {
209 // unable to open virtual MIDI ports
210 return -3;
211 }
212
178 // init the app 213 // init the app
179 sim_app_init(); 214 sim_app_init();
180 215
181 // start the terrible busywaiting timer loop 216 // start the terrible busywaiting timer loop
182 for (;;) 217 for (;;)
183 { 218 {
184 break; 219 usleep(1000);
220 app_timer_event();
221
222 // tickle the runloop so we can recieve events
223 while (kCFRunLoopRunHandledSource == CFRunLoopRunInMode(kCFRunLoopCommonModes, 0, true));
185 } 224 }
186 225
187 return 0; 226 return 0;