]> git.tdb.fi Git - libs/gui.git/blobdiff - source/input/controlscheme.cpp
Add classes for storing and applying bindings to controls
[libs/gui.git] / source / input / controlscheme.cpp
diff --git a/source/input/controlscheme.cpp b/source/input/controlscheme.cpp
new file mode 100644 (file)
index 0000000..fe1c0eb
--- /dev/null
@@ -0,0 +1,33 @@
+#include <msp/core/maputils.h>
+#include "control.h"
+#include "controlscheme.h"
+
+using namespace std;
+
+namespace Msp {
+namespace Input {
+
+void ControlScheme::add(const string &name, Control &ctrl)
+{
+       insert_unique(controls, name, &ctrl);
+}
+
+Control &ControlScheme::get(const string &name) const
+{
+       return *get_item(controls, name);
+}
+
+Control *ControlScheme::find(const string &name) const
+{
+       map<string, Control *>::const_iterator i = controls.find(name);
+       return (i!=controls.end() ? i->second : 0);
+}
+
+void ControlScheme::reset_edges()
+{
+       for(map<string, Control *>::const_iterator i=controls.begin(); i!=controls.end(); ++i)
+               i->second->reset_edges();
+}
+
+} // namespace Input
+} // namespace Msp