]> git.tdb.fi Git - libs/gui.git/blobdiff - source/input/smoothcontrol.h
Improve SmoothControl range API
[libs/gui.git] / source / input / smoothcontrol.h
index 26484a912c4a2b0615a47bc45d0b6376a919d4db..f16177b2b2ea0076dc176ab9b0f7da76ec747506 100644 (file)
@@ -1,12 +1,5 @@
-/* $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_
+#ifndef MSP_INPUT_SMOOTHCONTROL_H_
+#define MSP_INPUT_SMOOTHCONTROL_H_
 
 #include "control.h"
 
@@ -19,7 +12,7 @@ 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.
+controls are bound to the opposite sides of the same axis.
 */
 class SmoothControl: public Control
 {
@@ -29,14 +22,25 @@ public:
 private:
        float value;
        SmoothControl *paired_ctrl;
+       float dead_zone;
+       float threshold;
 
 public:
        SmoothControl();
        SmoothControl(const ControlSource &);
        SmoothControl(Device &, ControlSrcType, unsigned);
-       SmoothControl &operator=(const SmoothControl &);
        virtual ~SmoothControl();
 
+       /// Sets the dead zone value.  Any value below this will be treated as 0.
+       void set_dead_zone(float);
+
+       /** Sets the max-out threshold.  Any value above this will be treated as 1.
+       A negative value can be used to disable the threshold entirely. */
+       void set_threshold(float);
+
+       /// Sets dead zone and threshold in a single function call.
+       void set_range(float, float);
+
        void pair(SmoothControl *ctrl);
        float get_value() const { return value; }