]> git.tdb.fi Git - libs/gui.git/blobdiff - source/input/control.h
Generate synthetic key release events for repeated keys on Windows
[libs/gui.git] / source / input / control.h
index a2f002c08557d57807bbaaaafb4171e9400c7923..450b057ce30496b27f20ec251d3310163c45ae72 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef MSP_GBASE_CONTROL_H_
-#define MSP_GBASE_CONTROL_H_
+#ifndef MSP_INPUT_CONTROL_H_
+#define MSP_INPUT_CONTROL_H_
 
 #include <string>
 #include <sigc++/signal.h>
@@ -8,6 +8,7 @@
 namespace Msp {
 namespace Input {
 
+class BinaryControl;
 class Device;
 
 enum ControlSrcType
@@ -41,6 +42,11 @@ A control uses either a button or half of an axis (positive or negative) as its
 source.  How the source values are interpreted depends on the exact type of the
 control.  Controls also support interactive binding by capturing a button press
 or axis motion.
+
+A BinaryControl can be used as an activator, requiring that control to be
+active for any events to be processed.  This can be used to implement shifted
+controls (when used on a BinaryControl) or click-and-drag functionality (when
+used on a SmoothControl).
 */
 class Control: public sigc::trackable
 {
@@ -50,18 +56,22 @@ public:
 protected:
        ControlSource src;
        Device *capture_dev;
+       BinaryControl *activator;
+       float origin;
 
        Control();
        Control(const ControlSource &);
        Control(Device &, ControlSrcType, unsigned);
 public:
-       virtual ~Control() { }
+       virtual ~Control();
 
        void capture(Device &);
        void cancel_capture();
        void set_source(Device &, ControlSrcType, unsigned);
        void set_source(const ControlSource &);
        const ControlSource &get_source() const { return src; }
+       void set_activator(BinaryControl *);
+       BinaryControl *get_activator() const { return activator; }
 protected:
        virtual void on_press() = 0;
        virtual void on_release() = 0;
@@ -72,6 +82,7 @@ private:
        void button_press(unsigned);
        void button_release(unsigned);
        void axis_motion(unsigned, float, float);
+       void deactivate();
 
        Control(const Control &);
        Control &operator=(const Control &);