summaryrefslogtreecommitdiff
path: root/src/gui/sdlinput.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-08-24 23:00:27 +0300
committerAndrei Karas <akaras@inbox.ru>2013-08-24 23:00:27 +0300
commitc4e3b6cb2c4d8dceb45ee2da549ec42daabc053d (patch)
tree8a0c6d02cc7d7bd8994c2ac26bc14efbbd677b75 /src/gui/sdlinput.cpp
parentf3f5a316ca62e9d17776d4a49aab728aee65a5b5 (diff)
downloadplus-c4e3b6cb2c4d8dceb45ee2da549ec42daabc053d.tar.gz
plus-c4e3b6cb2c4d8dceb45ee2da549ec42daabc053d.tar.bz2
plus-c4e3b6cb2c4d8dceb45ee2da549ec42daabc053d.tar.xz
plus-c4e3b6cb2c4d8dceb45ee2da549ec42daabc053d.zip
fix mouse wheel usage in SDL2.
Diffstat (limited to 'src/gui/sdlinput.cpp')
-rw-r--r--src/gui/sdlinput.cpp27
1 files changed, 27 insertions, 0 deletions
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