1 #ifndef MSP_INPUT_SMOOTHCONTROL_H_
2 #define MSP_INPUT_SMOOTHCONTROL_H_
10 A control with a continuous range of values. A button is treated as either 1
11 or 0. Axis values are mapped to absolute value.
13 Two smooth controls can also be paired to each other. Motion on one control of
14 the pair will cause negative motion on the other. This works best when the
15 controls are bound to the opposite sides of the same axis.
17 class SmoothControl: public Control
20 sigc::signal<void, float> signal_motion;
24 SmoothControl *paired_ctrl = nullptr;
25 float dead_zone = 0.1f;
26 float threshold = 0.9f;
29 SmoothControl() = default;
30 SmoothControl(const ControlSource &);
31 SmoothControl(Device &, ControlSrcType, unsigned);
34 /// Sets the dead zone value. Any value below this will be treated as 0.
35 void set_dead_zone(float);
37 /** Sets the max-out threshold. Any value above this will be treated as 1.
38 A negative value can be used to disable the threshold entirely. */
39 void set_threshold(float);
41 /// Sets dead zone and threshold in a single function call.
42 void set_range(float, float);
44 void pair(SmoothControl *ctrl);
45 float get_value() const { return value; }
48 void on_press() override;
49 void on_release() override;
50 void on_motion(float, float) override;