X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Finput%2Fbinarycontrol.cpp;h=df07fb9eaf47c430d1a204f1dab7ad394d4e1491;hb=11ab96ba152e389814543a6398e2cd6f17a31092;hp=9bf24083850630981ca75656a91af319df84827f;hpb=999ca92aa9ee10585c0b2094d84364159253982f;p=libs%2Fgui.git diff --git a/source/input/binarycontrol.cpp b/source/input/binarycontrol.cpp index 9bf2408..df07fb9 100644 --- a/source/input/binarycontrol.cpp +++ b/source/input/binarycontrol.cpp @@ -1,35 +1,31 @@ -/* $Id$ - -This file is part of libmspgbase -Copyright © 2007 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #include "binarycontrol.h" #include "device.h" namespace Msp { namespace Input { -BinaryControl::BinaryControl(): - state(false) -{ } - BinaryControl::BinaryControl(const ControlSource &s): - Control(s), - state(false) + Control(s) { } BinaryControl::BinaryControl(Device &d, ControlSrcType t, unsigned i): - Control(d, t, i), - state(false) + Control(d, t, i) { } +BinaryControl::~BinaryControl() +{ } + +void BinaryControl::set_threshold(float t) +{ + threshold = t; +} + void BinaryControl::on_press() { if(!state) { - state=true; + state = true; + rising_edge = true; signal_press.emit(); } } @@ -38,14 +34,15 @@ void BinaryControl::on_release() { if(state) { - state=false; + state = false; + falling_edge = true; signal_release.emit(); } } void BinaryControl::on_motion(float value, float) { - if(value>src.dev->get_axis_threshold()) + if(value>threshold) on_press(); else on_release();