1 #include <msp/strings/lexicalcast.h>
10 ControlSource::ControlSource():
16 ControlSource::ControlSource(Device &d, ControlSrcType t, unsigned i):
22 std::string ControlSource::str() const
25 return dev->get_button_name(index);
26 else if(type==AXIS_POS)
27 return dev->get_axis_name(index)+" +";
28 else if(type==AXIS_NEG)
29 return dev->get_axis_name(index)+" -";
33 return lexical_cast<string>(index);
41 Control::Control(const ControlSource &s):
46 Control::Control(Device &d, ControlSrcType t, unsigned i):
53 void Control::capture(Device &d)
57 capture_dev->signal_button_press.connect(sigc::mem_fun(this, &Control::button_press));
58 capture_dev->signal_axis_motion.connect(sigc::mem_fun(this, &Control::axis_motion));
61 void Control::cancel_capture()
68 void Control::set_source(Device &d, ControlSrcType t, unsigned i)
70 set_source(ControlSource(d, t, i));
73 void Control::set_source(const ControlSource &s)
80 void Control::connect_signals()
87 src.dev->signal_button_press.connect(sigc::mem_fun(this, &Control::button_press));
88 src.dev->signal_button_release.connect(sigc::mem_fun(this, &Control::button_release));
92 src.dev->signal_axis_motion.connect(sigc::mem_fun(this, &Control::axis_motion));
97 void Control::button_press(unsigned i)
101 src.dev = capture_dev;
108 signal_capture_complete.emit();
110 else if(src.type==BUTTON && i==src.index)
114 void Control::button_release(unsigned i)
116 if(src.type==BUTTON && i==src.index)
120 void Control::axis_motion(unsigned i, float v, float r)
124 ControlSrcType type = NONE;
132 src.dev = capture_dev;
139 signal_capture_complete.emit();
142 else if(src.type==AXIS_POS && i==src.index && v>=0)
144 else if(src.type==AXIS_NEG && i==src.index && v<=0)