ctlrscript: refactoring and cleanup, adding API

This commit is contained in:
Harry van Haaren 2016-12-03 14:40:08 +00:00
parent 6da76a4f03
commit d664bb010a
3 changed files with 51 additions and 7 deletions

View file

@ -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");

View file

@ -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;

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
#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 */