3 This file is part of libmspgbase
4 Copyright © 2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
8 #include <msp/strings/formatter.h>
14 Mouse::Mouse(Graphics::Window &w):
22 window.signal_button_press.connect(sigc::mem_fun(this, &Mouse::button_press));
23 window.signal_button_release.connect(sigc::mem_fun(this, &Mouse::button_release));
24 window.signal_pointer_motion.connect(sigc::mem_fun(this, &Mouse::pointer_motion));
27 std::string Mouse::get_button_name(unsigned btn) const
42 return format("Button %d", btn);
46 std::string Mouse::get_axis_name(unsigned axis) const
55 return format("Axis %d", axis);
59 void Mouse::button_press(int, int, unsigned btn, unsigned)
61 set_button_state(btn, true, true);
64 void Mouse::button_release(int, int, unsigned btn, unsigned)
66 set_button_state(btn, false, true);
69 void Mouse::pointer_motion(int x, int y)
71 set_axis_value(0, x*2.0f/window.get_width()-1.0f, true);
72 set_axis_value(1, 1.0f-y*2.0f/window.get_height(), true);