]> git.tdb.fi Git - libs/gui.git/blob - source/input/hub.h
Inherit input devices using Window::signal_input_event from sigc::trackable
[libs/gui.git] / source / input / hub.h
1 #ifndef MSP_INPUT_INPUTHUB_H_
2 #define MSP_INPUT_INPUTHUB_H_
3
4 #include <map>
5 #include <sigc++/trackable.h>
6 #include "device.h"
7
8 namespace Msp {
9 namespace Input {
10
11 /**
12 The Hub device collects events from multiple input devices and presents an
13 aggregate of them.  Button and axis numbers are mapped to unique values.
14 */
15 class Hub: public Device, public sigc::trackable
16 {
17 protected:
18         std::map<unsigned, Device *> devices;
19
20 public:
21         Hub();
22
23         /// Attaches an input device to the hub.
24         void attach(Device &dev);
25
26         virtual std::string get_button_name(unsigned) const;
27         virtual std::string get_axis_name(unsigned) const;
28 protected:
29         void button_press(unsigned, unsigned);
30         void button_release(unsigned, unsigned);
31         void axis_motion(unsigned, float, float, unsigned);
32 };
33
34 } // namespace Input
35 } // namespace Msp
36
37 #endif