]> git.tdb.fi Git - libs/gui.git/blob - source/input/hub.h
1abff37a18cc52cc10b6fa20db170f79a91c3a3b
[libs/gui.git] / source / input / hub.h
1 #ifndef MSP_INPUT_INPUTHUB_H_
2 #define MSP_INPUT_INPUTHUB_H_
3
4 #include <vector>
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::vector<Device *> devices;
19
20 public:
21         Hub();
22
23         /// Attaches an input device to the hub.
24         void attach(Device &dev);
25
26         Device *find_subdevice(DeviceType, unsigned = 0) override;
27         Device *find_subdevice(const std::string &) override;
28
29         std::string get_button_name(unsigned) const override;
30         std::string get_axis_name(unsigned) const override;
31 protected:
32         void button_press(unsigned, unsigned);
33         void button_release(unsigned, unsigned);
34         void axis_motion(unsigned, float, float, unsigned);
35 };
36
37 } // namespace Input
38 } // namespace Msp
39
40 #endif