]> git.tdb.fi Git - libs/gui.git/blob - source/binarycontrol.cpp
Bugfixes
[libs/gui.git] / source / binarycontrol.cpp
1 /* $Id$
2
3 This file is part of libmspgbase
4 Copyright © 2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #include "binarycontrol.h"
9 #include "inputdevice.h"
10
11 namespace Msp {
12 namespace Input {
13
14 BinaryControl::BinaryControl():
15         state(false)
16 { }
17
18 BinaryControl::BinaryControl(const ControlSource &s):
19         Control(s),
20         state(false)
21 { }
22
23 BinaryControl::BinaryControl(Device &d, ControlSrcType t, unsigned i):
24         Control(d, t, i),
25         state(false)
26 { }
27
28 void BinaryControl::on_press()
29 {
30         if(!state)
31         {
32                 state=true;
33                 signal_press.emit();
34         }
35 }
36
37 void BinaryControl::on_release()
38 {
39         if(state)
40         {
41                 state=false;
42                 signal_release.emit();
43         }
44 }
45
46 void BinaryControl::on_motion(float value, float)
47 {
48         if(value>src.dev->get_axis_threshold())
49                 on_press();
50         else
51                 on_release();
52 }
53
54 } // namespace Input
55 } // namespace Msp