From d664bb010a48dd53ccd9ea1f4d01946b63c189e9 Mon Sep 17 00:00:00 2001 From: Harry van Haaren Date: Sat, 3 Dec 2016 14:40:08 +0000 Subject: [PATCH] ctlrscript: refactoring and cleanup, adding API --- src/controller/ctlrscript.cxx | 4 +-- src/controller/ctlrscript.hxx | 10 ++++---- src/controller/ctlrscript_api.h | 44 +++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 src/controller/ctlrscript_api.h diff --git a/src/controller/ctlrscript.cxx b/src/controller/ctlrscript.cxx index 04fd65b..b686b80 100644 --- a/src/controller/ctlrscript.cxx +++ b/src/controller/ctlrscript.cxx @@ -92,14 +92,14 @@ int CtlrScript::compile() return -EINVAL; } - poll = (ctlr_poll)tcc_get_symbol(s, "d2_poll"); + poll = (ctlr_handle_midi)tcc_get_symbol(s, "d2_poll"); if(!poll) { error("failed to get de poll\n"); return -EINVAL; } /* handles events from Luppp */ - handle = (void (*)(void*))tcc_get_symbol(s, "d2_handle"); + handle = (ctlr_handle_event)tcc_get_symbol(s, "d2_handle"); if(!handle) error("failed to get d2 handle\n"); diff --git a/src/controller/ctlrscript.hxx b/src/controller/ctlrscript.hxx index e6c0890..644e4db 100644 --- a/src/controller/ctlrscript.hxx +++ b/src/controller/ctlrscript.hxx @@ -1,5 +1,5 @@ /* - * Author: Harry van Haaren 2013 + * Author: Harry van Haaren 2016 * harryhaaren@gmail.com * * This program is free software: you can redistribute it and/or modify @@ -42,8 +42,8 @@ /* These typedefs are for the poll and handle events of the scripted * controller, to receieve and send events as needed */ -typedef int (*ctlr_poll)(unsigned char *midi); -typedef void (*ctlr_handle)(void *); +typedef int (*ctlr_handle_midi)(unsigned char *midi); +typedef void (*ctlr_handle_event)(void *); class CtlrScript : public Controller, public MidiIO { @@ -67,8 +67,8 @@ public: private: void *program; - ctlr_poll poll; - ctlr_handle handle; + ctlr_handle_midi poll; + ctlr_handle_event handle; std::string filename; diff --git a/src/controller/ctlrscript_api.h b/src/controller/ctlrscript_api.h new file mode 100644 index 0000000..c15610b --- /dev/null +++ b/src/controller/ctlrscript_api.h @@ -0,0 +1,44 @@ +/* + * Author: Harry van Haaren 2016 + * harryhaaren@gmail.com + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + +#ifndef LUPPP_CONTROLLER_SCRIPT_H +#define LUPPP_CONTROLLER_SCRIPT_H + +/** + * This file is the API for the Controller Scripts, allowing them to + * understand the events that have occurred in Luppp, and should be shown + * on the hardware device. Similarly, this API provides functions to send + * events to Luppp, which allow controlling of Luppp from the hardware. + */ + +enum EVENT_ID { + EVENT_NOP = 0, + EVENT_TRACK_SEND_ACTIVE, +}; + +struct event_track_send_active { + int track; + int send; + int active; +}; + +static void luppp_do(enum EVENT_ID id, void* event_struct); + +#endif /* LUPPP_CONTROLLER_SCRIPT_H */ +