X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Finput%2Fbinarycontrol.cpp;h=b0148ccf5332f023d22c1a9dfe436ba94fe93783;hb=2438c3cdd14087bfc3375ed1f5521ad5c0c09bbc;hp=9bf24083850630981ca75656a91af319df84827f;hpb=999ca92aa9ee10585c0b2094d84364159253982f;p=libs%2Fgui.git diff --git a/source/input/binarycontrol.cpp b/source/input/binarycontrol.cpp index 9bf2408..b0148cc 100644 --- a/source/input/binarycontrol.cpp +++ b/source/input/binarycontrol.cpp @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of libmspgbase -Copyright © 2007 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #include "binarycontrol.h" #include "device.h" @@ -12,24 +5,35 @@ 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) +{ } + +BinaryControl::~BinaryControl() { } +void BinaryControl::set_threshold(float t) +{ + threshold = t; +} + void BinaryControl::on_press() { if(!state) { - state=true; + state = true; signal_press.emit(); } } @@ -38,14 +42,14 @@ void BinaryControl::on_release() { if(state) { - state=false; + state = false; 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();