]> git.tdb.fi Git - libs/gui.git/blobdiff - source/input/device.h
Allow event handling to be interrupted
[libs/gui.git] / source / input / device.h
index 3338137eb51e46e50528cf51af02c73beb31ce50..6a436ab2d8a62f0318b893aefca0ac0b068592b1 100644 (file)
@@ -12,13 +12,30 @@ namespace Input {
 Base class for input devices.  Input devices have two types of controls:
 buttons and axes.  Buttons are either on or off.  Axes have a floating point
 value in the range [-1, 1].
+
+Event handlers return a boolean indicating whether the event is considered
+processed.  If a handler returns true, no further handlers are invoked.
 */
 class Device
 {
+protected:
+       struct EventAccumulator
+       {
+               typedef void result_type;
+
+               template<typename Iter>
+               result_type operator()(Iter begin, Iter end) const
+               {
+                       for(Iter i=begin; i!=end; ++i)
+                               if(*i)
+                                       return;
+               }
+       };
+
 public:
-       sigc::signal<void, unsigned> signal_button_press;
-       sigc::signal<void, unsigned> signal_button_release;
-       sigc::signal<void, unsigned, float, float> signal_axis_motion;
+       sigc::signal<bool, unsigned>::accumulated<EventAccumulator> signal_button_press;
+       sigc::signal<bool, unsigned>::accumulated<EventAccumulator> signal_button_release;
+       sigc::signal<bool, unsigned, float, float>::accumulated<EventAccumulator> signal_axis_motion;
 
 protected:
        std::string name;