]> git.tdb.fi Git - libs/gui.git/blob - source/input/binarycontrol.h
Drop Id tags and copyright notices from files
[libs/gui.git] / source / input / binarycontrol.h
1 #ifndef MSP_GBASE_BINARYCONTROL_H_
2 #define MSP_GBASE_BINARYCONTROL_H_
3
4 #include "control.h"
5
6 namespace Msp {
7 namespace Input {
8
9 /**
10 A control with two possible states.  Button state is mapped directly.  An axis
11 is considered to be active when its value is within 10% of the end of the axis.
12 */
13 class BinaryControl: public Control
14 {
15 public:
16         sigc::signal<void> signal_press;
17         sigc::signal<void> signal_release;
18
19 private:
20         bool state;
21         float threshold;
22
23 public:
24         BinaryControl();
25         BinaryControl(const ControlSource &);
26         BinaryControl(Device &, ControlSrcType, unsigned);
27
28         /**
29         Sets the threshold between states for axis sources.  No effect on button
30         sources
31         */
32         void set_threshold(float);
33
34         bool get_state() const { return state; }
35
36 private:
37         virtual void on_press();
38         virtual void on_release();
39         virtual void on_motion(float, float);
40 };
41
42 } // namespace Input
43 } // namespace Msp
44
45 #endif