X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Finputhub.cpp;h=1fa95d0fc3f41a3dfbf5c75b7636881dd4e1239e;hb=77d8b98374ab07be0d14c9c88502c6a803041040;hp=27a340a134015433e19cace7ed65824f784558ef;hpb=61eeb96535d1575ca0cf698d833c0ddfc7ae0f50;p=libs%2Fgui.git diff --git a/source/inputhub.cpp b/source/inputhub.cpp index 27a340a..1fa95d0 100644 --- a/source/inputhub.cpp +++ b/source/inputhub.cpp @@ -6,11 +6,17 @@ Distributed under the LGPL */ #include +#include #include "inputhub.h" namespace Msp { namespace Input { +Hub::Hub() +{ + name="Hub"; +} + unsigned Hub::attach(Device &dev) { unsigned index=devices.size(); @@ -21,19 +27,29 @@ unsigned Hub::attach(Device &dev) return index; } +std::string Hub::get_button_name(unsigned btn) const +{ + unsigned dev_index=btn>>12; + 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); +} + void Hub::button_press(unsigned btn, unsigned index) { - set_button_state(index<<8 | btn&0xFF, true, true); + set_button_state(index<<12 | btn&0xFFF, true, true); } void Hub::button_release(unsigned btn, unsigned index) { - set_button_state(index<<8 | btn&0xFF, 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<<8 | axis&0xFF, value, true); + set_axis_value(index<<12 | axis&0xFFF, value, true); } } // namespace Input