summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-12-03 00:00:28 +0300
committerAndrei Karas <akaras@inbox.ru>2012-12-03 00:00:28 +0300
commite9301ddce5a6ddf77dafc1f56f0b1461b2092c6f (patch)
treec9a1ed0ef0d9b15a1b3d617f9a17999bed768ff7 /src/gui
parent0b228c1ed05177a761dce44df31f087c0313dc64 (diff)
downloadplus-e9301ddce5a6ddf77dafc1f56f0b1461b2092c6f.tar.gz
plus-e9301ddce5a6ddf77dafc1f56f0b1461b2092c6f.tar.bz2
plus-e9301ddce5a6ddf77dafc1f56f0b1461b2092c6f.tar.xz
plus-e9301ddce5a6ddf77dafc1f56f0b1461b2092c6f.zip
Add support for relative mouse move in android version.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/gui.cpp5
-rw-r--r--src/gui/sdlinput.cpp30
-rw-r--r--src/gui/sdlinput.h5
3 files changed, 34 insertions, 6 deletions
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 8d26acea8..268f05fc1 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -36,6 +36,7 @@
#include "keydata.h"
#include "keyevent.h"
#include "keyinput.h"
+#include "mouseinput.h"
#include "touchmanager.h"
#include "resources/image.h"
@@ -272,7 +273,7 @@ void Gui::logic()
handleModalFocus();
handleModalMouseInputFocus();
- if (mInput)
+ if (guiInput)
handleMouseInput();
mTop->logic();
@@ -658,7 +659,7 @@ void Gui::handleMouseInput()
BLOCK_START("Gui::handleMouseInput")
while (!mInput->isMouseQueueEmpty())
{
- const gcn::MouseInput mouseInput = mInput->dequeueMouseInput();
+ const MouseInput mouseInput = guiInput->dequeueMouseInput2();
if (touchManager.processEvent(mouseInput))
{
diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp
index a79752cba..32aff02c9 100644
--- a/src/gui/sdlinput.cpp
+++ b/src/gui/sdlinput.cpp
@@ -58,9 +58,9 @@
#include "gui/sdlinput.h"
-#include "keydata.h"
-
#include "inputmanager.h"
+#include "keydata.h"
+#include "mouseinput.h"
#include <guichan/exception.hpp>
@@ -108,10 +108,25 @@ gcn::MouseInput SDLInput::dequeueMouseInput()
return mouseInput;
}
+MouseInput SDLInput::dequeueMouseInput2()
+{
+ MouseInput mouseInput;
+
+ if (mMouseInputQueue.empty())
+ {
+ throw GCN_EXCEPTION("The queue is empty.");
+ }
+
+ mouseInput = mMouseInputQueue.front();
+ mMouseInputQueue.pop();
+
+ return mouseInput;
+}
+
void SDLInput::pushInput(const SDL_Event &event)
{
KeyInput keyInput;
- gcn::MouseInput mouseInput;
+ MouseInput mouseInput;
switch (event.type)
{
@@ -153,6 +168,9 @@ void SDLInput::pushInput(const SDL_Event &event)
mMouseDown = true;
mouseInput.setX(event.button.x);
mouseInput.setY(event.button.y);
+#ifdef ANDROID
+ mouseInput.setReal(event.button.realx, event.button.realy);
+#endif
mouseInput.setButton(convertMouseButton(event.button.button));
if (event.button.button == SDL_BUTTON_WHEELDOWN)
@@ -169,6 +187,9 @@ void SDLInput::pushInput(const SDL_Event &event)
mMouseDown = false;
mouseInput.setX(event.button.x);
mouseInput.setY(event.button.y);
+#ifdef ANDROID
+ mouseInput.setReal(event.button.realx, event.button.realy);
+#endif
mouseInput.setButton(convertMouseButton(event.button.button));
mouseInput.setType(gcn::MouseInput::RELEASED);
mouseInput.setTimeStamp(SDL_GetTicks());
@@ -178,6 +199,9 @@ void SDLInput::pushInput(const SDL_Event &event)
case SDL_MOUSEMOTION:
mouseInput.setX(event.button.x);
mouseInput.setY(event.button.y);
+#ifdef ANDROID
+ mouseInput.setReal(event.button.realx, event.button.realy);
+#endif
mouseInput.setButton(gcn::MouseInput::EMPTY);
mouseInput.setType(gcn::MouseInput::MOVED);
mouseInput.setTimeStamp(SDL_GetTicks());
diff --git a/src/gui/sdlinput.h b/src/gui/sdlinput.h
index c3b0d14e7..dc12789b2 100644
--- a/src/gui/sdlinput.h
+++ b/src/gui/sdlinput.h
@@ -70,6 +70,7 @@
#include <queue>
class KeyInput;
+class MouseInput;
namespace Key
{
@@ -168,6 +169,8 @@ public:
virtual gcn::MouseInput dequeueMouseInput() A_WARN_UNUSED;
+ virtual MouseInput dequeueMouseInput2() A_WARN_UNUSED;
+
protected:
/**
* Converts a mouse button from SDL to a Guichan mouse button
@@ -188,7 +191,7 @@ protected:
static int convertKeyCharacter(const SDL_Event &event) A_WARN_UNUSED;
std::queue<KeyInput> mKeyInputQueue;
- std::queue<gcn::MouseInput> mMouseInputQueue;
+ std::queue<MouseInput> mMouseInputQueue;
bool mMouseDown;
bool mMouseInWindow;