3 This file is part of libmspgbase
4 Copyright © 2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
8 #ifndef MSP_GBASE_CONTROL_H_
9 #define MSP_GBASE_CONTROL_H_
12 #include <sigc++/signal.h>
13 #include <sigc++/trackable.h>
29 Specifies the source of a control. This provides a way for setting sources for
30 different types of controls in a uniform way.
39 ControlSource(Device &, ControlSrcType, unsigned);
40 std::string str() const;
44 Provides further abstraction on top of input devices. There are two types of
45 controls currently defined: BinaryControl and SmoothControl.
47 A control uses either a button or half of an axis (positive or negative) as its
48 source. How the source values are interpreted depends on the exact type of the
49 control. Controls also support interactive binding by capturing a button press
52 class Control: public sigc::trackable
55 sigc::signal<void> signal_capture_complete;
62 Control(const ControlSource &);
63 Control(Device &, ControlSrcType, unsigned);
64 Control(const Control &);
66 Control &operator=(const Control &);
67 virtual ~Control() { }
69 void capture(Device &);
70 void cancel_capture();
71 void set_source(Device &, ControlSrcType, unsigned);
72 void set_source(const ControlSource &);
73 const ControlSource &get_source() const { return src; }
75 virtual void on_press() =0;
76 virtual void on_release() =0;
77 virtual void on_motion(float, float) =0;
80 void connect_signals();
81 void button_press(unsigned);
82 void button_release(unsigned);
83 void axis_motion(unsigned, float, float);