X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Finput%2Fmouse.cpp;h=e379576363a3d29bff734fcf341036334e89c035;hb=27356249e3607c78f5da9823c88703a6f4f7bed1;hp=0fbc940f144b23537495cf99825db4b3e09fbc8b;hpb=daf317db7a79a4c92880042125814ca942c3a6fa;p=libs%2Fgui.git diff --git a/source/input/mouse.cpp b/source/input/mouse.cpp index 0fbc940..e379576 100644 --- a/source/input/mouse.cpp +++ b/source/input/mouse.cpp @@ -1,45 +1,38 @@ -/* $Id$ - -This file is part of libmspgbase -Copyright © 2007 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - -#include #include "mouse.h" +#include +#include "keys.h" namespace Msp { namespace Input { Mouse::Mouse(Graphics::Window &w): + Device(MOUSE), window(w) { - name="Mouse"; + name = "Mouse"; buttons.resize(3); axes.resize(2); - window.signal_button_press.connect(sigc::mem_fun(this, &Mouse::button_press)); - window.signal_button_release.connect(sigc::mem_fun(this, &Mouse::button_release)); - window.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 { switch(btn) { - case 1: + case MOUSE_LEFT: return "Left"; - case 2: + case MOUSE_MIDDLE: return "Middle"; - case 3: + case MOUSE_RIGHT: return "Right"; - case 4: + case MOUSE_WHEEL_UP: return "Wheel Up"; - case 5: + case MOUSE_WHEEL_DOWN: return "Wheel Down"; default: - return format("Button %d", btn); + return Device::get_button_name(btn); } } @@ -47,30 +40,14 @@ std::string Mouse::get_axis_name(unsigned axis) const { switch(axis) { - case 0: + case MOUSE_X_AXIS: return "X axis"; - case 1: + case MOUSE_Y_AXIS: 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/window.get_width()-1.0f, true); - set_axis_value(1, 1.0f-y*2.0f/window.get_height(), true); -} - } // namespace Input } // namespace Msp