1 #ifndef MSP_INPUT_INPUTDEVICE_H_
2 #define MSP_INPUT_INPUTDEVICE_H_
6 #include <sigc++/signal.h>
12 Base class for input devices. Input devices have two types of controls:
13 buttons and axes. Buttons are either on or off. Axes have a floating point
14 value in the range [-1, 1].
16 Event handlers return a boolean indicating whether the event is considered
17 processed. If a handler returns true, no further handlers are invoked.
22 struct EventAccumulator
24 typedef void result_type;
26 template<typename Iter>
27 result_type operator()(Iter begin, Iter end) const
29 for(Iter i=begin; i!=end; ++i)
36 sigc::signal<bool, unsigned>::accumulated<EventAccumulator> signal_button_press;
37 sigc::signal<bool, unsigned>::accumulated<EventAccumulator> signal_button_release;
38 sigc::signal<bool, unsigned, float, float>::accumulated<EventAccumulator> signal_axis_motion;
42 std::vector<char> buttons;
43 std::vector<float> axes;
48 const std::string &get_name() const { return name; }
49 bool get_button_state(unsigned) const;
50 float get_axis_value(unsigned) const;
52 virtual std::string get_button_name(unsigned) const;
53 virtual std::string get_axis_name(unsigned) const;
55 void set_button_state(unsigned, bool, bool);
56 void set_axis_value(unsigned, float, bool);