]> git.tdb.fi Git - libs/gui.git/blobdiff - source/control.cpp
Add names for input devices
[libs/gui.git] / source / control.cpp
index ef1170cc84b66b42bb8ac0659e97adf1a8f978b6..823202d3e11544ea2c45d1c0a54c8ce807f85d6a 100644 (file)
@@ -6,6 +6,7 @@ Distributed under the LGPL
 */
 
 #include <msp/core/except.h>
+#include <msp/strings/lexicalcast.h>
 #include "control.h"
 #include "inputdevice.h"
 
@@ -24,6 +25,18 @@ ControlSource::ControlSource(Device &d, ControlSrcType t, unsigned i):
        index(i)
 { }
 
+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==NONE)
+               return "None";
+
+       return lexical_cast(index);
+}
+
 
 Control::Control():
        capture_dev(0)