ctlrscript: initial stub implementation

This commit adds a framework for TCC based scripting
of controllers. Given that TCC only compiles C, it is needed to translate
the C++ Event class instances to a plain C interface, which can then be
sent to the controller.
This commit is contained in:
Harry van Haaren 2016-11-30 16:07:39 +00:00
parent cd1565d073
commit 4657b4b135
2 changed files with 95 additions and 0 deletions

View file

@ -0,0 +1,42 @@
/*
* 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/>.
*/
#include "ctlrscript.hxx"
#include <iostream>
#include "../jack.hxx"
#include "../event.hxx"
#include "../gridlogic.hxx"
#include "../eventhandler.hxx"
extern Jack* jack;
CtlrScript::CtlrScript(std::string filename) :
Controller()
{
printf("%s, attempting to compile %s\n", __func__, filename.c_str());
#warning WIP HERE, add TCC libs, and attempt to load/compile filename
}
void CtlrScript::bpm(int bpm)
{
printf("%s : %d\n", __func__, bpm);
}

View file

@ -0,0 +1,53 @@
/*
* Author: Harry van Haaren 2013
* 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
#include "controller.hxx"
#include "../observer/midi.hxx"
/** This is a controller using TCC as a backend, which reads .c files
* as "scripts", but compiles them on the fly and then hooks in the
* poll / handle event loop into the controller itself.
*
* It is designed to be a flexible way of prototyping support for any
* MIDI/HID devices. Once a controller file is concidered "finished",
* it may be sent as a pull request for inclusion in vanilla Luppp.
*
* As TCC is only a C compiler (as opposed to C++) this layer translates
* Luppps internal events (which are C++ classes) to native C structs,
* which can then be passed to the TCC compiled C backend. Ideally the
* Luppp internal event handling system would be ported to plain C,
* however this would also require significant effort, which does not
* seem worth the time at the moment.
*/
class CtlrScript : public Controller
{
public:
CtlrScript(std::string filename);
std::string getName(){return "CtlrScript";}
void bpm(int bpm);
};
#endif // LUPPP_CONTROLLER_SCRIPT_H