X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Finput%2Fhub.cpp;h=0bc818f1adac6e28fdda21a9afdfd639dc8dada3;hb=8f8480438244fd04058049ace22071a8e2e0b85c;hp=51b971748170c60599a09c65afe687c2238e2645;hpb=999ca92aa9ee10585c0b2094d84364159253982f;p=libs%2Fgui.git diff --git a/source/input/hub.cpp b/source/input/hub.cpp index 51b9717..0bc818f 100644 --- a/source/input/hub.cpp +++ b/source/input/hub.cpp @@ -30,26 +30,36 @@ unsigned Hub::attach(Device &dev) std::string Hub::get_button_name(unsigned btn) const { unsigned dev_index=btn>>12; - if(dev_index>devices.size()) + if(dev_index>=devices.size()) throw InvalidParameterValue("Button does not exist"); 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; + if(dev_index>=devices.size()) + throw InvalidParameterValue("Axis does not exist"); + + const Device &dev=*devices[dev_index]; + return dev.get_name()+": "+dev.get_axis_name(axis&0xFFF); +} + void Hub::button_press(unsigned btn, unsigned index) { - set_button_state(index<<12 | btn&0xFFF, true, true); + set_button_state((index<<12) | (btn&0xFFF), true, true); } void Hub::button_release(unsigned btn, unsigned index) { - set_button_state(index<<12 | btn&0xFFF, false, true); + set_button_state((index<<12) | (btn&0xFFF), false, true); } void Hub::axis_motion(unsigned axis, float value, float, unsigned index) { - set_axis_value(index<<12 | axis&0xFFF, value, true); + set_axis_value((index<<12) | (axis&0xFFF), value, true); } } // namespace Input