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):
57 void Control::capture(Device &d)
61 capture_dev->signal_button_press.connect(sigc::bind_return(sigc::mem_fun(this, &Control::button_press), false));
62 capture_dev->signal_axis_motion.connect(sigc::bind_return(sigc::mem_fun(this, &Control::axis_motion), false));
65 void Control::cancel_capture()
72 void Control::set_source(Device &d, ControlSrcType t, unsigned i)
74 set_source(ControlSource(d, t, i));
77 void Control::set_source(const ControlSource &s)
84 void Control::connect_signals()
91 src.dev->signal_button_press.connect(sigc::bind_return(sigc::mem_fun(this, &Control::button_press), false));
92 src.dev->signal_button_release.connect(sigc::bind_return(sigc::mem_fun(this, &Control::button_release), false));
96 src.dev->signal_axis_motion.connect(sigc::bind_return(sigc::mem_fun(this, &Control::axis_motion), false));
101 void Control::button_press(unsigned i)
105 src.dev = capture_dev;
112 signal_capture_complete.emit();
114 else if(src.type==BUTTON && i==src.index)
118 void Control::button_release(unsigned i)
120 if(src.type==BUTTON && i==src.index)
124 void Control::axis_motion(unsigned i, float v, float r)
128 ControlSrcType type = NONE;
136 src.dev = capture_dev;
143 signal_capture_complete.emit();
146 else if(src.type==AXIS_POS && i==src.index && v>=0)
148 else if(src.type==AXIS_NEG && i==src.index && v<=0)