diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-08-21 21:18:02 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-08-24 21:08:15 +0300 |
commit | a3082da9c7296bb18b7a6bc0424eb2a19d485ff6 (patch) | |
tree | cd07d091f69f5a3000aaddcbc8911d472b9137e7 /src/gui/sdlinput.cpp | |
parent | 84189722a64c0794fbd918b4e6412908be2b7394 (diff) | |
download | manaverse-a3082da9c7296bb18b7a6bc0424eb2a19d485ff6.tar.gz manaverse-a3082da9c7296bb18b7a6bc0424eb2a19d485ff6.tar.bz2 manaverse-a3082da9c7296bb18b7a6bc0424eb2a19d485ff6.tar.xz manaverse-a3082da9c7296bb18b7a6bc0424eb2a19d485ff6.zip |
second part with compilation fixes for SDL2.
Diffstat (limited to 'src/gui/sdlinput.cpp')
-rw-r--r-- | src/gui/sdlinput.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp index bb0ded46f..fd72cb962 100644 --- a/src/gui/sdlinput.cpp +++ b/src/gui/sdlinput.cpp @@ -61,6 +61,9 @@ #include "inputmanager.h" #include "keydata.h" #include "mouseinput.h" +#include "sdlshared.h" + +#include <SDL_keyboard.h> #include <guichan/exception.hpp> @@ -176,11 +179,13 @@ void SDLInput::pushInput(const SDL_Event &event) #endif mouseInput.setButton(convertMouseButton(event.button.button)); +#ifndef USE_SDL2 if (event.button.button == SDL_BUTTON_WHEELDOWN) mouseInput.setType(gcn::MouseInput::WHEEL_MOVED_DOWN); else if (event.button.button == SDL_BUTTON_WHEELUP) mouseInput.setType(gcn::MouseInput::WHEEL_MOVED_UP); else +#endif mouseInput.setType(gcn::MouseInput::PRESSED); mouseInput.setTimeStamp(SDL_GetTicks()); mMouseInputQueue.push(mouseInput); @@ -211,6 +216,7 @@ void SDLInput::pushInput(const SDL_Event &event) mMouseInputQueue.push(mouseInput); break; +#ifndef USE_SDL2 case SDL_ACTIVEEVENT: /* * This occurs when the mouse leaves the window and the Gui-chan @@ -237,7 +243,7 @@ void SDLInput::pushInput(const SDL_Event &event) mMouseInWindow = true; } break; - +#endif default: break; } // end switch @@ -262,7 +268,11 @@ int SDLInput::convertMouseButton(const int button) int SDLInput::convertKeyCharacter(const SDL_Event &event) { const SDL_keysym keysym = event.key.keysym; +#ifdef USE_SDL2 + int value = keysym.scancode; +#else int value = keysym.unicode; +#endif switch (keysym.sym) { @@ -298,7 +308,9 @@ int SDLInput::convertKeyCharacter(const SDL_Event &event) // with the keysym.sym SDLK_SPACE which // without this check would be lost. The check // is only valid on key down events in SDL. +#ifndef USE_SDL2 if (event.type == SDL_KEYUP || keysym.unicode == ' ') +#endif { value = Key::SPACE; } @@ -387,12 +399,14 @@ int SDLInput::convertKeyCharacter(const SDL_Event &event) case SDLK_LMETA: value = Key::LEFT_META; break; +#ifndef USE_SDL2 case SDLK_LSUPER: value = Key::LEFT_SUPER; break; case SDLK_RSUPER: value = Key::RIGHT_SUPER; break; +#endif case SDLK_MODE: value = Key::ALT_GR; break; |