2 #include <sigc++/bind.h>
3 #include <sigc++/bind_return.h>
4 #include <msp/core/hash.h>
5 #include <msp/core/maputils.h>
18 void Hub::attach(Device &dev)
20 unsigned tag = hash32(dev.get_name(), 20);
21 while(devices.count(tag))
25 dev.signal_button_press.connect(sigc::bind_return(sigc::bind(sigc::mem_fun(this, &Hub::button_press), tag), false));
26 dev.signal_button_release.connect(sigc::bind_return(sigc::bind(sigc::mem_fun(this, &Hub::button_release), tag), false));
27 dev.signal_axis_motion.connect(sigc::bind_return(sigc::bind(sigc::mem_fun(this, &Hub::axis_motion), tag), false));
30 std::string Hub::get_button_name(unsigned btn) const
32 const Device &dev = *get_item(devices, btn>>12);
33 return dev.get_name()+": "+dev.get_button_name(btn&0xFFF);
36 std::string Hub::get_axis_name(unsigned axis) const
38 const Device &dev = *get_item(devices, axis>>12);
39 return dev.get_name()+": "+dev.get_axis_name(axis&0xFFF);
42 void Hub::button_press(unsigned btn, unsigned tag)
44 set_button_state((tag<<12) | (btn&0xFFF), true, true);
47 void Hub::button_release(unsigned btn, unsigned tag)
49 set_button_state((tag<<12) | (btn&0xFFF), false, true);
52 void Hub::axis_motion(unsigned axis, float value, float, unsigned tag)
54 set_axis_value((tag<<12) | (axis&0xFFF), value, true);