X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Fcontroller.cpp;fp=source%2Flibr2c2%2Fcontroller.cpp;h=480abc2691ede5cc734e3cce301d04e2b3617563;hb=1ff06c5bc46a677fa389ef86c6b26664368f1653;hp=0000000000000000000000000000000000000000;hpb=9b05c573a38639827697fe393d55b7c76f5bde45;p=r2c2.git diff --git a/source/libr2c2/controller.cpp b/source/libr2c2/controller.cpp new file mode 100644 index 0000000..480abc2 --- /dev/null +++ b/source/libr2c2/controller.cpp @@ -0,0 +1,76 @@ +/* $Id$ + +This file is part of R²C² +Copyright © 2010 Mikkosoft Productions, Mikko Rasa +Distributed under the GPL +*/ + +#include +#include +#include "controller.h" + +using namespace std; +using namespace Msp; + +namespace R2C2 { + +void Controller::Control::set(float v) +{ + if(vmax_value) + v = max_value; + else if(type==BINARY) + value = v ? 1 : 0; + else if(type==DISCRETE) + value = min_value+floor((v-min_value)/step)*step; + else if(type==CONTINUOUS) + value = v; +} + +Controller::Control Controller::Control::binary(const string &n) +{ + Controller::Control tc; + tc.name = n; + tc.type = BINARY; + tc.min_value = 0; + tc.max_value = 1; + tc.step = 1; + tc.value = 0; + + return tc; +} + +Controller::Control Controller::Control::discrete(const string &n, float m, float x, float s) +{ + if(x