X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Finput%2Fbinarycontrol.h;h=0d71bdc3349e0dc4afedf3a5a9423528ca82977a;hb=3c5bbaeadb33d288c0f9e487b52904b7ed7e4319;hp=4331f05aa94371b8337ce3ffc1b97fc748c7805c;hpb=daf317db7a79a4c92880042125814ca942c3a6fa;p=libs%2Fgui.git diff --git a/source/input/binarycontrol.h b/source/input/binarycontrol.h index 4331f05..0d71bdc 100644 --- a/source/input/binarycontrol.h +++ b/source/input/binarycontrol.h @@ -1,12 +1,5 @@ -/* $Id$ - -This file is part of libmspgbase -Copyright © 2007 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - -#ifndef MSP_GBASE_BINARYCONTROL_H_ -#define MSP_GBASE_BINARYCONTROL_H_ +#ifndef MSP_INPUT_BINARYCONTROL_H_ +#define MSP_INPUT_BINARYCONTROL_H_ #include "control.h" @@ -15,7 +8,8 @@ namespace Input { /** A control with two possible states. Button state is mapped directly. An axis -is considered to be active when its value is within 10% of the end of the axis. +is considered to be active when its value is above a threshold (0.5 by +default). */ class BinaryControl: public Control { @@ -24,26 +18,27 @@ public: sigc::signal signal_release; private: - bool state; - float threshold; + bool state = false; + float threshold = 0.5f; public: - BinaryControl(); + BinaryControl() = default; BinaryControl(const ControlSource &); BinaryControl(Device &, ControlSrcType, unsigned); + ~BinaryControl(); - /** - Sets the threshold between states for axis sources. No effect on button - sources - */ + /** Sets the threshold between states for axis sources. No effect on button + sources */ void set_threshold(float); bool get_state() const { return state; } + bool was_pressed() const { return rising_edge; } + bool was_released() const { return falling_edge; } private: - virtual void on_press(); - virtual void on_release(); - virtual void on_motion(float, float); + void on_press() override; + void on_release() override; + void on_motion(float, float) override; }; } // namespace Input