]> git.tdb.fi Git - libs/gui.git/blob - source/inputhub.cpp
Add input hub
[libs/gui.git] / source / inputhub.cpp
1 #include <sigc++/bind.h>
2 #include "inputhub.h"
3
4 namespace Msp {
5 namespace Input {
6
7 unsigned Hub::attach(Device &dev)
8 {
9         unsigned index=devices.size();
10         devices.push_back(&dev);
11         dev.signal_button_press.connect(sigc::bind(sigc::mem_fun(this, &Hub::button_press), index));
12         dev.signal_button_release.connect(sigc::bind(sigc::mem_fun(this, &Hub::button_release), index));
13         dev.signal_axis_motion.connect(sigc::bind(sigc::mem_fun(this, &Hub::axis_motion), index));
14         return index;
15 }
16
17 void Hub::button_press(unsigned btn, unsigned index)
18 {
19         set_button_state(index<<8 | btn&0xFF, true, true);
20 }
21
22 void Hub::button_release(unsigned btn, unsigned index)
23 {
24         set_button_state(index<<8 | btn&0xFF, false, true);
25 }
26
27 void Hub::axis_motion(unsigned axis, float value, float, unsigned index)
28 {
29         set_axis_value(index<<8 | axis&0xFF, value, true);
30 }
31
32 } // namespace Input
33 } // namespace Msp