]> git.tdb.fi Git - libs/gui.git/blobdiff - source/control.cpp
Add names for input devices
[libs/gui.git] / source / control.cpp
index 9b9223fd9a5105d7854f0b81a45e7ee7133a3198..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)
@@ -104,7 +117,7 @@ void Control::button_press(unsigned i)
                notify_callbacks();
                capture_dev=0;
                connect_signals();
-               capture_complete.emit();
+               signal_capture_complete.emit();
        }
        else if(src.type==BUTTON && i==src.index)
                on_press();
@@ -131,9 +144,11 @@ void Control::axis_motion(unsigned i, float v, float r)
                        src.dev=capture_dev;
                        src.type=type;
                        src.index=i;
+
                        notify_callbacks();
+                       capture_dev=0;
                        connect_signals();
-                       capture_complete.emit();
+                       signal_capture_complete.emit();
                }
        }
        else if(src.type==AXIS_POS && i==src.index && v>=0)