X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Finput%2Fbinarycontrol.cpp;h=371de3c19f1a518afae93e7d329c3968c8c7a175;hb=8f8480438244fd04058049ace22071a8e2e0b85c;hp=9bf24083850630981ca75656a91af319df84827f;hpb=999ca92aa9ee10585c0b2094d84364159253982f;p=libs%2Fgui.git diff --git a/source/input/binarycontrol.cpp b/source/input/binarycontrol.cpp index 9bf2408..371de3c 100644 --- a/source/input/binarycontrol.cpp +++ b/source/input/binarycontrol.cpp @@ -12,19 +12,27 @@ namespace Msp { namespace Input { BinaryControl::BinaryControl(): - state(false) + state(false), + threshold(0.5) { } BinaryControl::BinaryControl(const ControlSource &s): Control(s), - state(false) + state(false), + threshold(0.5) { } BinaryControl::BinaryControl(Device &d, ControlSrcType t, unsigned i): Control(d, t, i), - state(false) + state(false), + threshold(0.5) { } +void BinaryControl::set_threshold(float t) +{ + threshold=t; +} + void BinaryControl::on_press() { if(!state) @@ -45,7 +53,7 @@ void BinaryControl::on_release() void BinaryControl::on_motion(float value, float) { - if(value>src.dev->get_axis_threshold()) + if(value>threshold) on_press(); else on_release();