X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Finput%2Fcontrol.cpp;h=ffa02932f7db9c3b3159c45ab589d2c2f434ae1e;hb=daf317db7a79a4c92880042125814ca942c3a6fa;hp=8ddcdd772cf2af96cc7e7f51f42e978edebe87cd;hpb=999ca92aa9ee10585c0b2094d84364159253982f;p=libs%2Fgui.git diff --git a/source/input/control.cpp b/source/input/control.cpp index 8ddcdd7..ffa0293 100644 --- a/source/input/control.cpp +++ b/source/input/control.cpp @@ -29,8 +29,10 @@ std::string ControlSource::str() const { if(type==BUTTON) return dev->get_button_name(index); - else if(type==AXIS_POS || type==AXIS_NEG) - return dev->get_axis_name(index); + else if(type==AXIS_POS) + return dev->get_axis_name(index)+" +"; + else if(type==AXIS_NEG) + return dev->get_axis_name(index)+" -"; else if(type==NONE) return "None"; @@ -54,36 +56,30 @@ Control::Control(Device &d, ControlSrcType t, unsigned i): connect_signals(); } -Control::Control(const Control &c): - trackable(c), - src(c.src), - capture_dev(0) +void Control::capture(Device &d) { - connect_signals(); + notify_callbacks(); + capture_dev=&d; + capture_dev->signal_button_press.connect(sigc::mem_fun(this, &Control::button_press)); + capture_dev->signal_axis_motion.connect(sigc::mem_fun(this, &Control::axis_motion)); } -Control &Control::operator=(const Control &c) +void Control::cancel_capture() { notify_callbacks(); - src=c.src; capture_dev=0; connect_signals(); - - return *this; } -void Control::capture(Device &d) +void Control::set_source(Device &d, ControlSrcType t, unsigned i) { - notify_callbacks(); - capture_dev=&d; - capture_dev->signal_button_press.connect(sigc::mem_fun(this, &Control::button_press)); - capture_dev->signal_axis_motion.connect(sigc::mem_fun(this, &Control::axis_motion)); + set_source(ControlSource(d, t, i)); } -void Control::cancel_capture() +void Control::set_source(const ControlSource &s) { notify_callbacks(); - capture_dev=0; + src=s; connect_signals(); } @@ -134,9 +130,9 @@ void Control::axis_motion(unsigned i, float v, float r) if(capture_dev) { ControlSrcType type=NONE; - if(v<-src.dev->get_axis_threshold()) + if(v<-0.9) type=AXIS_NEG; - else if(v>src.dev->get_axis_threshold()) + else if(v>0.9) type=AXIS_POS; if(type!=NONE)