commit 5db1094d3542d3fd434f28ac531f4aedc09ba2df
parent 882ee94ac67ad601afe50311418f6d377f72ec7f
Author: fundamental <mark.d.mccurry@gmail.com>
Date: Fri, 29 Jul 2016 18:11:21 -0400
Add Connection To Hardcoded Zest Library
Diffstat:
1 file changed, 77 insertions(+), 1 deletion(-)
diff --git a/src/Plugin/ZynAddSubFX/ZynAddSubFX-UI-Zest.cpp b/src/Plugin/ZynAddSubFX/ZynAddSubFX-UI-Zest.cpp
@@ -13,6 +13,22 @@
// DPF includes
#include "DistrhoUI.hpp"
+#include <dlfcn.h>
+
+typedef void *zest_t;
+struct zest_handles {
+ zest_t *(*zest_open)(const char *);
+ void (*zest_close)(zest_t*);
+ void (*zest_setup)(zest_t*);
+ void (*zest_draw)(zest_t*);
+ void (*zest_motion)(zest_t*, int x, int y);
+ void (*zest_scroll)(zest_t*, int x, int y, int dx, int dy);
+ void (*zest_mouse)(zest_t *z, int button, int action, int x, int y);
+ void (*zest_key)();
+ void (*zest_resize)();
+ int (*zest_tick)(zest_t*);
+ zest_t *zest;
+};
/* ------------------------------------------------------------------------------------------------------------
* ZynAddSubFX UI class */
@@ -21,13 +37,33 @@ class ZynAddSubFXUI : public UI
{
public:
ZynAddSubFXUI()
- : UI(390, 525)
+ : UI(1181, 659)
{
printf("[INFO] Opened the zynaddsubfx UI...\n");
+ handle = dlopen("/home/mark/code/mruby-zest-build/libzest.so", RTLD_LAZY);
+ if(!handle) {
+ printf("[ERROR] Cannot Open libzest.so\n");
+ printf("[ERROR] '%s'\n", dlerror());
+ }
+ memset(&z, 0, sizeof(z));
+#define get_sym(x) z.zest_##x = (decltype(z.zest_##x))dlsym(handle, "zest_"#x)
+ get_sym(open);
+ get_sym(setup);
+ get_sym(close);
+ get_sym(draw);
+ get_sym(tick);
+ get_sym(motion);
+ get_sym(scroll);
+ get_sym(mouse);
+ printf("[INFO] Ready to run\n");
}
~ZynAddSubFXUI() override
{
+ printf("[INFO:Zyn] zest_close()\n");
+ if(z.zest)
+ z.zest_close(z.zest);
+ dlclose(handle);
}
protected:
@@ -72,15 +108,55 @@ protected:
/* --------------------------------------------------------------------------------------------------------
* UI Callbacks */
+ bool onMouse(const MouseEvent &m) override
+ {
+ if(z.zest)
+ z.zest_mouse(z.zest, m.button, m.press, m.pos.getX(), m.pos.getY());
+ return false;
+ }
+
+ bool onMotion(const MotionEvent &m) override
+ {
+ if(z.zest)
+ z.zest_motion(z.zest, m.pos.getX(), m.pos.getY());
+ return false;
+ }
+
/**
A function called to draw the view contents with OpenGL.
*/
void onDisplay() override
{
+ if(!z.zest) {
+ if(!z.zest_open)
+ return;
+ printf("[INFO:Zyn] zest_open()\n");
+ char address[1024];
+ snprintf(address, sizeof(address), "osc.udp://127.0.0.1:%d",oscPort);
+
+ z.zest = z.zest_open(address);
+ printf("[INFO:Zyn] zest_setup()\n");
+ z.zest_setup(z.zest);
+ }
+
+ z.zest_draw(z.zest);
+ repaint();
+ }
+
+ void uiIdle(void) override
+ {
+ if(z.zest)
+ z.zest_tick(z.zest);
+ }
+
+ void uiReshape(uint width, uint height)
+ {
}
private:
int oscPort;
+ zest_handles z;
+ void *handle;
DISTRHO_DECLARE_NON_COPY_CLASS(ZynAddSubFXUI)