]> git.tdb.fi Git - libs/gui.git/blobdiff - source/mouse.cpp
Add names for input devices
[libs/gui.git] / source / mouse.cpp
index dc361252bc988150c97c7aed5c1b8fb71699d70e..931b204f8a2655805f18509259ffc5c3781587ea 100644 (file)
@@ -5,6 +5,7 @@ Copyright © 2007 Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
+#include <msp/strings/formatter.h>
 #include "mouse.h"
 
 namespace Msp {
@@ -14,6 +15,8 @@ Mouse::Mouse(Graphics::Window &w):
        window(w),
        axis_scale(0.01)
 {
+       name="Mouse";
+
        buttons.resize(3);
        axes.resize(2);
 
@@ -22,6 +25,25 @@ Mouse::Mouse(Graphics::Window &w):
        window.signal_pointer_motion.connect(sigc::mem_fun(this, &Mouse::pointer_motion));
 }
 
+std::string Mouse::get_button_name(unsigned btn) const
+{
+       switch(btn)
+       {
+       case 1:
+               return "Left";
+       case 2:
+               return "Middle";
+       case 3:
+               return "Right";
+       case 4:
+               return "Wheel Up";
+       case 5:
+               return "Wheel Down";
+       default:
+               return format("Button %d", btn);
+       }
+}
+
 void Mouse::button_press(int, int, unsigned btn, unsigned)
 {
        set_button_state(btn, true, true);