X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Finput%2Fdevice.h;h=e356bea86a4639cc5280d0a974eb6af3a8f005ab;hb=051149e5026ff64f3ec477cf19080124b82de619;hp=43d180d50b6595696f1767f490c48d3c0863a178;hpb=c9626e6953c16efc66575eff80c4c0de2f739041;p=libs%2Fgui.git diff --git a/source/input/device.h b/source/input/device.h index 43d180d..e356bea 100644 --- a/source/input/device.h +++ b/source/input/device.h @@ -1,5 +1,5 @@ -#ifndef MSP_GBASE_INPUTDEVICE_H_ -#define MSP_GBASE_INPUTDEVICE_H_ +#ifndef MSP_INPUT_INPUTDEVICE_H_ +#define MSP_INPUT_INPUTDEVICE_H_ #include #include @@ -12,24 +12,42 @@ 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 + 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;