summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/gui.h6
-rw-r--r--src/gui/sdlinput.cpp27
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