1 #ifndef MSP_INPUT_INPUTDEVICE_H_
2 #define MSP_INPUT_INPUTDEVICE_H_
7 #include <sigc++/signal.h>
12 class device_not_available: public std::runtime_error
15 device_not_available(const std::string &w): std::runtime_error(w) { }
16 virtual ~device_not_available() throw() { }
21 Base class for input devices. Input devices have two types of controls:
22 buttons and axes. Buttons are either on or off. Axes have a floating point
23 value nominally in the range [-1, 1].
25 Event handlers return a boolean indicating whether the event is considered
26 processed. If a handler returns true, no further handlers are invoked.
31 struct EventAccumulator
33 typedef void result_type;
35 template<typename Iter>
36 result_type operator()(Iter begin, Iter end) const
38 for(Iter i=begin; i!=end; ++i)
45 sigc::signal<bool, unsigned>::accumulated<EventAccumulator> signal_button_press;
46 sigc::signal<bool, unsigned>::accumulated<EventAccumulator> signal_button_release;
47 sigc::signal<bool, unsigned, float, float>::accumulated<EventAccumulator> signal_axis_motion;
51 std::vector<char> buttons;
52 std::vector<float> axes;
58 const std::string &get_name() const { return name; }
59 bool get_button_state(unsigned) const;
60 float get_axis_value(unsigned) const;
62 virtual std::string get_button_name(unsigned) const;
63 virtual std::string get_axis_name(unsigned) const;
65 void set_button_state(unsigned, bool, bool);
66 void set_axis_value(unsigned, float, bool);