X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Finput%2Fcontrol.cpp;h=6ff80883f8d39d8df19892b9fd2cf114aac7cc4a;hb=c9626e6953c16efc66575eff80c4c0de2f739041;hp=8ddcdd772cf2af96cc7e7f51f42e978edebe87cd;hpb=999ca92aa9ee10585c0b2094d84364159253982f;p=libs%2Fgui.git diff --git a/source/input/control.cpp b/source/input/control.cpp index 8ddcdd7..6ff8088 100644 --- a/source/input/control.cpp +++ b/source/input/control.cpp @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of libmspgbase -Copyright © 2007 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #include #include #include "control.h" @@ -29,8 +22,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 +49,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 +123,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)