diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-01-28 00:30:51 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-01-28 23:35:20 +0300 |
commit | a0b2deb4192bddad4d061f5d5df86411a437f01f (patch) | |
tree | 4739472959d83045eac4d7f7ddf3dc265d37b45c /src/gui/sdlinput.cpp | |
parent | 226202ff807dc860991af0d6665ef9e9b48c1bed (diff) | |
download | manaplus-a0b2deb4192bddad4d061f5d5df86411a437f01f.tar.gz manaplus-a0b2deb4192bddad4d061f5d5df86411a437f01f.tar.bz2 manaplus-a0b2deb4192bddad4d061f5d5df86411a437f01f.tar.xz manaplus-a0b2deb4192bddad4d061f5d5df86411a437f01f.zip |
add support for screen scale in OpenGL modes.
Diffstat (limited to 'src/gui/sdlinput.cpp')
-rw-r--r-- | src/gui/sdlinput.cpp | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp index 653806491..193a35dfe 100644 --- a/src/gui/sdlinput.cpp +++ b/src/gui/sdlinput.cpp @@ -81,6 +81,8 @@ #include "input/inputmanager.h" +#include "render/graphics.h" + #ifdef USE_SDL2 #include "gui/gui.h" #endif @@ -210,14 +212,19 @@ void SDLInput::pushInput(const SDL_Event &event) #endif case SDL_MOUSEBUTTONDOWN: + { mMouseDown = true; - mouseInput.setX(event.button.x); - mouseInput.setY(event.button.y); + const int scale = mainGraphics->getScale(); + const int x = event.button.x / scale; + const int y = event.button.y / scale; + mouseInput.setX(x); + mouseInput.setY(y); #ifdef ANDROID #ifdef USE_SDL2 - mouseInput.setReal(event.button.x, event.button.y); + mouseInput.setReal(x, y); #else - mouseInput.setReal(event.button.realx, event.button.realy); + mouseInput.setReal(event.button.realx / scale, + event.button.realy / scale); #endif #endif mouseInput.setButton(convertMouseButton(event.button.button)); @@ -233,16 +240,21 @@ void SDLInput::pushInput(const SDL_Event &event) mouseInput.setTimeStamp(SDL_GetTicks()); mMouseInputQueue.push(mouseInput); break; - + } case SDL_MOUSEBUTTONUP: + { mMouseDown = false; - mouseInput.setX(event.button.x); - mouseInput.setY(event.button.y); + const int scale = mainGraphics->getScale(); + const int x = event.button.x / scale; + const int y = event.button.y / scale; + mouseInput.setX(x); + mouseInput.setY(y); #ifdef ANDROID #ifdef USE_SDL2 - mouseInput.setReal(event.button.x, event.button.y); + mouseInput.setReal(x, y); #else - mouseInput.setReal(event.button.realx, event.button.realy); + mouseInput.setReal(event.button.realx / scale, + event.button.realy / scale); #endif #endif mouseInput.setButton(convertMouseButton(event.button.button)); @@ -250,15 +262,20 @@ void SDLInput::pushInput(const SDL_Event &event) mouseInput.setTimeStamp(SDL_GetTicks()); mMouseInputQueue.push(mouseInput); break; - + } case SDL_MOUSEMOTION: - mouseInput.setX(event.motion.x); - mouseInput.setY(event.motion.y); + { + const int scale = mainGraphics->getScale(); + const int x = event.motion.x / scale; + const int y = event.motion.y / scale; + mouseInput.setX(x); + mouseInput.setY(y); #ifdef ANDROID #ifdef USE_SDL2 - mouseInput.setReal(event.motion.x, event.motion.y); + mouseInput.setReal(x, y); #else - mouseInput.setReal(event.motion.realx, event.motion.realy); + mouseInput.setReal(event.motion.realx / scale, + event.motion.realy / scale); #endif #endif mouseInput.setButton(gcn::MouseInput::EMPTY); @@ -266,7 +283,7 @@ void SDLInput::pushInput(const SDL_Event &event) mouseInput.setTimeStamp(SDL_GetTicks()); mMouseInputQueue.push(mouseInput); break; - + } #ifndef USE_SDL2 case SDL_ACTIVEEVENT: /* |