diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-08-24 23:00:27 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-08-24 23:00:27 +0300 |
commit | c4e3b6cb2c4d8dceb45ee2da549ec42daabc053d (patch) | |
tree | 8a0c6d02cc7d7bd8994c2ac26bc14efbbd677b75 /src/gui | |
parent | f3f5a316ca62e9d17776d4a49aab728aee65a5b5 (diff) | |
download | mv-c4e3b6cb2c4d8dceb45ee2da549ec42daabc053d.tar.gz mv-c4e3b6cb2c4d8dceb45ee2da549ec42daabc053d.tar.bz2 mv-c4e3b6cb2c4d8dceb45ee2da549ec42daabc053d.tar.xz mv-c4e3b6cb2c4d8dceb45ee2da549ec42daabc053d.zip |
fix mouse wheel usage in SDL2.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/gui.h | 6 | ||||
-rw-r--r-- | src/gui/sdlinput.cpp | 27 |
2 files changed, 33 insertions, 0 deletions
diff --git a/src/gui/gui.h b/src/gui/gui.h index 0b4b4a292..3cdab558d 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -157,6 +157,12 @@ class Gui final : public gcn::Gui void removeDragged(gcn::Widget *widget); + int getLastMouseX() + { return mLastMouseX; } + + int getLastMouseY() + { return mLastMouseY; } + protected: void handleMouseMoved(const gcn::MouseInput &mouseInput); diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp index 884ce25dd..ae8c6d7d4 100644 --- a/src/gui/sdlinput.cpp +++ b/src/gui/sdlinput.cpp @@ -64,6 +64,10 @@ #include "mouseinput.h" #include "sdlshared.h" +#ifdef USE_SDL2 +#include "gui/gui.h" +#endif + #include <SDL_keyboard.h> #include <guichan/exception.hpp> @@ -155,6 +159,29 @@ void SDLInput::pushInput(const SDL_Event &event) keyInput.setText(event.text.text); mKeyInputQueue.push(keyInput); break; + + case SDL_MOUSEWHEEL: + { + const int x = event.wheel.x; + const int y = event.wheel.y; + if (y) + { + mouseInput.setX(gui->getLastMouseX()); + mouseInput.setY(gui->getLastMouseY()); +#ifdef ANDROID + mouseInput.setReal(0, 0); +#endif + mouseInput.setButton(-1); + if (y > 0) + mouseInput.setType(gcn::MouseInput::WHEEL_MOVED_UP); + else + mouseInput.setType(gcn::MouseInput::WHEEL_MOVED_DOWN); + mouseInput.setTimeStamp(SDL_GetTicks()); + mMouseInputQueue.push(mouseInput); + } + + break; + } #endif #ifdef ANDROID |