]> git.tdb.fi Git - libs/gui.git/blob - source/input/binarycontrol.cpp
Use default member initializers and defaulted default constructors
[libs/gui.git] / source / input / binarycontrol.cpp
1 #include "binarycontrol.h"
2 #include "device.h"
3
4 namespace Msp {
5 namespace Input {
6
7 BinaryControl::BinaryControl(const ControlSource &s):
8         Control(s)
9 { }
10
11 BinaryControl::BinaryControl(Device &d, ControlSrcType t, unsigned i):
12         Control(d, t, i)
13 { }
14
15 BinaryControl::~BinaryControl()
16 { }
17
18 void BinaryControl::set_threshold(float t)
19 {
20         threshold = t;
21 }
22
23 void BinaryControl::on_press()
24 {
25         if(!state)
26         {
27                 state = true;
28                 rising_edge = true;
29                 signal_press.emit();
30         }
31 }
32
33 void BinaryControl::on_release()
34 {
35         if(state)
36         {
37                 state = false;
38                 falling_edge = true;
39                 signal_release.emit();
40         }
41 }
42
43 void BinaryControl::on_motion(float value, float)
44 {
45         if(value>threshold)
46                 on_press();
47         else
48                 on_release();
49 }
50
51 } // namespace Input
52 } // namespace Msp