]> git.tdb.fi Git - libs/gui.git/blobdiff - source/input/binarycontrol.cpp
Normalize device axis ranges to [-1, 1]
[libs/gui.git] / source / input / binarycontrol.cpp
index 9bf24083850630981ca75656a91af319df84827f..371de3c19f1a518afae93e7d329c3968c8c7a175 100644 (file)
@@ -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();