X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Fsimplecontroller.cpp;fp=source%2Flibr2c2%2Fsimplecontroller.cpp;h=e7d9352ca048bd8377570476662860d1662d5fd3;hb=bd174b180d22a68bfa2caa35fb31d8b50fa3a750;hp=7f8b3362087ed0cee7a37eb03c55875cc31a4f20;hpb=f4e02a59008181013e57cdf2a8cf1695e89b24bb;p=r2c2.git diff --git a/source/libr2c2/simplecontroller.cpp b/source/libr2c2/simplecontroller.cpp index 7f8b336..e7d9352 100644 --- a/source/libr2c2/simplecontroller.cpp +++ b/source/libr2c2/simplecontroller.cpp @@ -23,14 +23,24 @@ SimpleController::SimpleController(): target_speed.set(0); } +const char *SimpleController::enumerate_controls(unsigned index) const +{ + if(index==0) + return target_speed.name.c_str(); + else if(index==1) + return reverse.name.c_str(); + else + return 0; +} + void SimpleController::set_control(const string &name, float v) { - if(name=="speed") + if(name==target_speed.name) { target_speed.set(v); signal_control_changed.emit(target_speed); } - else if(name=="reverse") + else if(name==reverse.name) { if(target_speed.value || speed) throw InvalidState("Must be stopped to change reverse"); @@ -41,9 +51,9 @@ void SimpleController::set_control(const string &name, float v) const Controller::Control &SimpleController::get_control(const string &name) const { - if(name=="speed") + if(name==target_speed.name) return target_speed; - else if(name=="reverse") + else if(name==reverse.name) return reverse; else throw KeyError("Unknown control", name);