1 #include <sigc++/bind_return.h>
2 #include <msp/strings/lexicalcast.h>
11 ControlSource::ControlSource():
17 ControlSource::ControlSource(Device &d, ControlSrcType t, unsigned i):
23 std::string ControlSource::str() const
26 return dev->get_button_name(index);
27 else if(type==AXIS_POS)
28 return dev->get_axis_name(index)+" +";
29 else if(type==AXIS_NEG)
30 return dev->get_axis_name(index)+" -";
34 return lexical_cast<string>(index);
42 Control::Control(const ControlSource &s):
47 Control::Control(Device &d, ControlSrcType t, unsigned i):
54 void Control::capture(Device &d)
58 capture_dev->signal_button_press.connect(sigc::bind_return(sigc::mem_fun(this, &Control::button_press), false));
59 capture_dev->signal_axis_motion.connect(sigc::bind_return(sigc::mem_fun(this, &Control::axis_motion), false));
62 void Control::cancel_capture()
69 void Control::set_source(Device &d, ControlSrcType t, unsigned i)
71 set_source(ControlSource(d, t, i));
74 void Control::set_source(const ControlSource &s)
81 void Control::connect_signals()
88 src.dev->signal_button_press.connect(sigc::bind_return(sigc::mem_fun(this, &Control::button_press), false));
89 src.dev->signal_button_release.connect(sigc::bind_return(sigc::mem_fun(this, &Control::button_release), false));
93 src.dev->signal_axis_motion.connect(sigc::bind_return(sigc::mem_fun(this, &Control::axis_motion), false));
98 void Control::button_press(unsigned i)
102 src.dev = capture_dev;
109 signal_capture_complete.emit();
111 else if(src.type==BUTTON && i==src.index)
115 void Control::button_release(unsigned i)
117 if(src.type==BUTTON && i==src.index)
121 void Control::axis_motion(unsigned i, float v, float r)
125 ControlSrcType type = NONE;
133 src.dev = capture_dev;
140 signal_capture_complete.emit();
143 else if(src.type==AXIS_POS && i==src.index && v>=0)
145 else if(src.type==AXIS_NEG && i==src.index && v<=0)