Add boilerplate for event handling

This commit is contained in:
Robbert van der Helm
2020-02-07 17:16:09 +01:00
parent 7a68654fa2
commit 65996f856a
4 changed files with 27 additions and 15 deletions
+21 -12
View File
@@ -1,6 +1,9 @@
#include "bridge.h"
#include <iostream>
#include <msgpack.hpp>
#include "../common/events.h"
// TODO: I should track down the VST2 SDK for clarification on some of the
// implementation details, such as the use of intptr_t isntead of void*
@@ -12,10 +15,24 @@
*/
intptr_t Bridge::dispatch(AEffect* /*plugin*/,
int32_t opcode,
int32_t /*parameter*/,
intptr_t /*value*/,
int32_t parameter,
intptr_t value,
void* result,
float /*option*/) {
float option) {
// TODO: Send to the Wine process
Event event{opcode, parameter, value, option};
msgpack::sbuffer buffer;
msgpack::pack(buffer, event);
// TODO: Read the response
EventResult response;
if (response.result) {
std::copy(response.result->begin(), response.result->end(),
static_cast<char*>(result));
}
// Some events need some extra handling
// TODO: Handle other things such as GUI itneraction
switch (opcode) {
case effClose:
// TODO: Gracefully close the editor?
@@ -27,17 +44,9 @@ intptr_t Bridge::dispatch(AEffect* /*plugin*/,
return 0;
break;
case effGetEffectName:
const std::string plugin_name("Hello, world!");
std::copy(plugin_name.begin(), plugin_name.end(),
static_cast<char*>(result));
return 1; // TODO: Why?
break;
}
// TODO: Unimplmemented
return 0;
return response.return_value;
}
void Bridge::process(AEffect* /*plugin*/,