X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Finput%2Fmouse.cpp;h=1b41e3654517c2adb12d02e5cb10821df70a5764;hb=69aaca13ae0949acf12056e390cbd1009a8487b2;hp=6717427535b4190f49f3720cef2e29dcc4f6e4b1;hpb=5add89fdd5e5e542ae0e93de2fe9d9b2532c1e07;p=libs%2Fgui.git diff --git a/source/input/mouse.cpp b/source/input/mouse.cpp index 6717427..1b41e36 100644 --- a/source/input/mouse.cpp +++ b/source/input/mouse.cpp @@ -1,27 +1,18 @@ -/* $Id$ - -This file is part of libmspgbase -Copyright © 2007-2008, 2010 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - -#include +#include #include "mouse.h" namespace Msp { namespace Input { -Mouse::Mouse(Graphics::EventSource &s): - source(s) +Mouse::Mouse(Graphics::Window &w): + window(w) { - name="Mouse"; + name = "Mouse"; buttons.resize(3); axes.resize(2); - source.signal_button_press.connect(sigc::mem_fun(this, &Mouse::button_press)); - source.signal_button_release.connect(sigc::mem_fun(this, &Mouse::button_release)); - source.signal_pointer_motion.connect(sigc::mem_fun(this, &Mouse::pointer_motion)); + window.signal_input_event.connect(sigc::mem_fun(this, &Mouse::input_event)); } std::string Mouse::get_button_name(unsigned btn) const @@ -39,7 +30,7 @@ std::string Mouse::get_button_name(unsigned btn) const case 5: return "Wheel Down"; default: - return format("Button %d", btn); + return Device::get_button_name(btn); } } @@ -52,25 +43,9 @@ std::string Mouse::get_axis_name(unsigned axis) const case 1: return "Y axis"; default: - return format("Axis %d", axis); + return Device::get_axis_name(axis); }; } -void Mouse::button_press(int, int, unsigned btn, unsigned) -{ - set_button_state(btn, true, true); -} - -void Mouse::button_release(int, int, unsigned btn, unsigned) -{ - set_button_state(btn, false, true); -} - -void Mouse::pointer_motion(int x, int y) -{ - set_axis_value(0, x*2.0f/source.get_width()-1.0f, true); - set_axis_value(1, 1.0f-y*2.0f/source.get_height(), true); -} - } // namespace Input } // namespace Msp