]> git.tdb.fi Git - libs/gui.git/blob - source/input/device.h
Style update: remove alignment
[libs/gui.git] / source / input / device.h
1 #ifndef MSP_INPUT_INPUTDEVICE_H_
2 #define MSP_INPUT_INPUTDEVICE_H_
3
4 #include <string>
5 #include <vector>
6 #include <sigc++/signal.h>
7
8 namespace Msp {
9 namespace Input {
10
11 /**
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].
15 */
16 class Device
17 {
18 public:
19         sigc::signal<void, unsigned> signal_button_press;
20         sigc::signal<void, unsigned> signal_button_release;
21         sigc::signal<void, unsigned, float, float> signal_axis_motion;
22
23 protected:
24         std::string name;
25         std::vector<char> buttons;
26         std::vector<float> axes;
27
28         Device() { }
29 public:
30         virtual ~Device() { }
31         const std::string &get_name() const { return name; }
32         bool get_button_state(unsigned) const;
33         float get_axis_value(unsigned) const;
34
35         virtual std::string get_button_name(unsigned) const;
36         virtual std::string get_axis_name(unsigned) const;
37 protected:
38         void set_button_state(unsigned, bool, bool);
39         void set_axis_value(unsigned, float, bool);
40 };
41
42 } // namespace Input
43 } // namespace Msp
44
45 #endif