X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Finput%2Fdevice.h;h=7df388b18c34f5f0d2dc1001ac61e27ae5b9afa8;hb=917222bae696465f99024e0e15f73ba1058add44;hp=49d858ba2a3eed92dbfb1fb6f9c83dabe474e06a;hpb=1023b38fa278cea71fba3d2881e1bfde930cd025;p=libs%2Fgui.git diff --git a/source/input/device.h b/source/input/device.h index 49d858b..7df388b 100644 --- a/source/input/device.h +++ b/source/input/device.h @@ -11,25 +11,43 @@ 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]. +value nominally 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 + result_type operator()(Iter begin, Iter end) const + { + for(Iter i=begin; i!=end; ++i) + if(*i) + return; + } + }; + public: - sigc::signal signal_button_press; - sigc::signal signal_button_release; - sigc::signal signal_axis_motion; + sigc::signal::accumulated signal_button_press; + sigc::signal::accumulated signal_button_release; + sigc::signal::accumulated signal_axis_motion; protected: std::string name; - std::vector buttons; + std::vector buttons; std::vector axes; - Device() { } + Device(); public: - virtual ~Device() { } + virtual ~Device(); + const std::string &get_name() const { return name; } - bool get_button_state(unsigned) const; + bool get_button_state(unsigned) const; float get_axis_value(unsigned) const; virtual std::string get_button_name(unsigned) const;