X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=inline;f=source%2Finput%2Fhub.cpp;h=cbf9f78a689e083d79057945ba84eb218aba3685;hb=1023b38fa278cea71fba3d2881e1bfde930cd025;hp=1be5d1382dc34552157ed26c8877d7d31bb7b102;hpb=c9626e6953c16efc66575eff80c4c0de2f739041;p=libs%2Fgui.git diff --git a/source/input/hub.cpp b/source/input/hub.cpp index 1be5d13..cbf9f78 100644 --- a/source/input/hub.cpp +++ b/source/input/hub.cpp @@ -1,18 +1,20 @@ +#include #include -#include #include "hub.h" +using namespace std; + namespace Msp { namespace Input { Hub::Hub() { - name="Hub"; + name = "Hub"; } unsigned Hub::attach(Device &dev) { - unsigned index=devices.size(); + unsigned index = devices.size(); devices.push_back(&dev); dev.signal_button_press.connect(sigc::bind(sigc::mem_fun(this, &Hub::button_press), index)); dev.signal_button_release.connect(sigc::bind(sigc::mem_fun(this, &Hub::button_release), index)); @@ -22,21 +24,21 @@ unsigned Hub::attach(Device &dev) std::string Hub::get_button_name(unsigned btn) const { - unsigned dev_index=btn>>12; + unsigned dev_index = btn>>12; if(dev_index>=devices.size()) - throw InvalidParameterValue("Button does not exist"); + throw invalid_argument("Hub::get_button_name"); - const Device &dev=*devices[dev_index]; + const Device &dev = *devices[dev_index]; return dev.get_name()+": "+dev.get_button_name(btn&0xFFF); } std::string Hub::get_axis_name(unsigned axis) const { - unsigned dev_index=axis>>12; + unsigned dev_index = axis>>12; if(dev_index>=devices.size()) - throw InvalidParameterValue("Axis does not exist"); + throw invalid_argument("Hub::get_axis_name"); - const Device &dev=*devices[dev_index]; + const Device &dev = *devices[dev_index]; return dev.get_name()+": "+dev.get_axis_name(axis&0xFFF); }