]> git.tdb.fi Git - libs/gui.git/blob - source/smoothcontrol.h
26484a912c4a2b0615a47bc45d0b6376a919d4db
[libs/gui.git] / source / smoothcontrol.h
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 #ifndef MSP_GBASE_SMOOTHCONTROL_H_
9 #define MSP_GBASE_SMOOTHCONTROL_H_
10
11 #include "control.h"
12
13 namespace Msp {
14 namespace Input {
15
16 /**
17 A control with a continuous range of values.  A button is treated as either 1
18 or 0.  Axis values are mapped to absolute value.
19
20 Two smooth controls can also be paired to each other.  Motion on one control of
21 the pair will cause negative motion on the other.  This works best when the
22 controls are bound to the opposite sides of the same joystick axis.
23 */
24 class SmoothControl: public Control
25 {
26 public:
27         sigc::signal<void, float> signal_motion;
28
29 private:
30         float value;
31         SmoothControl *paired_ctrl;
32
33 public:
34         SmoothControl();
35         SmoothControl(const ControlSource &);
36         SmoothControl(Device &, ControlSrcType, unsigned);
37         SmoothControl &operator=(const SmoothControl &);
38         virtual ~SmoothControl();
39
40         void pair(SmoothControl *ctrl);
41         float get_value() const { return value; }
42
43 private:
44         virtual void on_press();
45         virtual void on_release();
46         virtual void on_motion(float, float);
47 };
48
49 } // namespace Input
50 } // namespace Msp
51
52 #endif