X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Finput%2Fhub.cpp;h=1916126c9ff3f3be420de975bb3b93ea03ad9f55;hb=b99a9eb342d0f6ba5509c6d9f8ab0b0b5d5d2979;hp=635ea8a6c935fe9485fee30c87dc55386a3f56ed;hpb=f01fa56a13100ed04c94c9d8b17fbdcf0f0a8bad;p=libs%2Fgui.git diff --git a/source/input/hub.cpp b/source/input/hub.cpp index 635ea8a..1916126 100644 --- a/source/input/hub.cpp +++ b/source/input/hub.cpp @@ -1,16 +1,17 @@ +#include "hub.h" #include #include #include #include #include -#include "hub.h" using namespace std; namespace Msp { namespace Input { -Hub::Hub() +Hub::Hub(): + Device(UNSPECIFIED) { name = "Hub"; } @@ -24,7 +25,29 @@ void Hub::attach(Device &dev) dev.signal_axis_motion.connect(sigc::bind_return(sigc::bind(sigc::mem_fun(this, &Hub::axis_motion), index), false)); } -std::string Hub::get_button_name(unsigned btn) const +Device *Hub::find_subdevice(DeviceType t, unsigned n) +{ + for(Device *d: devices) + if(Device *dev = d->find_subdevice(t, 0)) + { + if(!n) + return dev; + --n; + } + return nullptr; +} + +Device *Hub::find_subdevice(const string &n) +{ + if(n==name) + return this; + for(Device *d: devices) + if(Device *dev = d->find_subdevice(n)) + return dev; + return nullptr; +} + +string Hub::get_button_name(unsigned btn) const { unsigned dev_index = btn>>8; if(dev_index>=devices.size()) @@ -34,7 +57,7 @@ std::string Hub::get_button_name(unsigned btn) const return dev.get_name()+": "+dev.get_button_name(btn&0xFF); } -std::string Hub::get_axis_name(unsigned axis) const +string Hub::get_axis_name(unsigned axis) const { unsigned dev_index = axis>>8; if(dev_index>=devices.size())