]> git.tdb.fi Git - libs/gui.git/blobdiff - source/input/smoothcontrol.h
Reorganize files to separate gbase and input
[libs/gui.git] / source / input / smoothcontrol.h
diff --git a/source/input/smoothcontrol.h b/source/input/smoothcontrol.h
new file mode 100644 (file)
index 0000000..26484a9
--- /dev/null
@@ -0,0 +1,52 @@
+/* $Id$
+
+This file is part of libmspgbase
+Copyright © 2007 Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#ifndef MSP_GBASE_SMOOTHCONTROL_H_
+#define MSP_GBASE_SMOOTHCONTROL_H_
+
+#include "control.h"
+
+namespace Msp {
+namespace Input {
+
+/**
+A control with a continuous range of values.  A button is treated as either 1
+or 0.  Axis values are mapped to absolute value.
+
+Two smooth controls can also be paired to each other.  Motion on one control of
+the pair will cause negative motion on the other.  This works best when the
+controls are bound to the opposite sides of the same joystick axis.
+*/
+class SmoothControl: public Control
+{
+public:
+       sigc::signal<void, float> signal_motion;
+
+private:
+       float value;
+       SmoothControl *paired_ctrl;
+
+public:
+       SmoothControl();
+       SmoothControl(const ControlSource &);
+       SmoothControl(Device &, ControlSrcType, unsigned);
+       SmoothControl &operator=(const SmoothControl &);
+       virtual ~SmoothControl();
+
+       void pair(SmoothControl *ctrl);
+       float get_value() const { return value; }
+
+private:
+       virtual void on_press();
+       virtual void on_release();
+       virtual void on_motion(float, float);
+};
+
+} // namespace Input
+} // namespace Msp
+
+#endif