2 #include <sigc++/bind.h>
3 #include <msp/core/hash.h>
4 #include <msp/core/maputils.h>
17 void Hub::attach(Device &dev)
19 unsigned tag = hash32(dev.get_name(), 20);
20 while(devices.count(tag))
24 dev.signal_button_press.connect(sigc::bind(sigc::mem_fun(this, &Hub::button_press), tag));
25 dev.signal_button_release.connect(sigc::bind(sigc::mem_fun(this, &Hub::button_release), tag));
26 dev.signal_axis_motion.connect(sigc::bind(sigc::mem_fun(this, &Hub::axis_motion), tag));
29 std::string Hub::get_button_name(unsigned btn) const
31 const Device &dev = *get_item(devices, btn>>12);
32 return dev.get_name()+": "+dev.get_button_name(btn&0xFFF);
35 std::string Hub::get_axis_name(unsigned axis) const
37 const Device &dev = *get_item(devices, axis>>12);
38 return dev.get_name()+": "+dev.get_axis_name(axis&0xFFF);
41 void Hub::button_press(unsigned btn, unsigned tag)
43 set_button_state((tag<<12) | (btn&0xFFF), true, true);
46 void Hub::button_release(unsigned btn, unsigned tag)
48 set_button_state((tag<<12) | (btn&0xFFF), false, true);
51 void Hub::axis_motion(unsigned axis, float value, float, unsigned tag)
53 set_axis_value((tag<<12) | (axis&0xFFF), value, true);