From 533e703a2c394b9c4a0c0e2d7367dd5cc48c1502 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 23 Jan 2013 19:51:38 +0300 Subject: Add support for handling event for show/hide on screen keyboard. --- src/client.cpp | 23 ++++++++++++++++++++--- src/client.h | 2 ++ src/game.cpp | 34 +++++++++++++++++++++------------- 3 files changed, 43 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/client.cpp b/src/client.cpp index 3a2a5f493..871b5c873 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -115,6 +115,10 @@ #include #endif +#ifdef ANDROID +#include +#endif + #include #include @@ -685,8 +689,11 @@ void Client::gameInit() start_time = static_cast(time(nullptr)); - // Initialize PlayerInfo PlayerInfo::init(); + +#ifdef ANDROID + updateScreenKeyboard(SDL_GetScreenKeyboardHeight(nullptr)); +#endif } Client::~Client() @@ -958,6 +965,9 @@ int Client::gameExec() inputManager.handleAssignKey(event, INPUT_JOYSTICK); break; + case SDL_MOUSEMOTION: + break; + #ifdef ANDROID case SDL_ACTIVEEVENT: if ((event.active.state & SDL_APPACTIVE) @@ -967,9 +977,11 @@ int Client::gameExec() logger->log("exit on lost focus"); } break; -#endif - case SDL_MOUSEMOTION: + + case SDL_KEYBOARDSHOW: + updateScreenKeyboard(event.user.code); break; +#endif default: // logger->log("unknown event: %d", event.type); @@ -2882,3 +2894,8 @@ void Client::windowRemoved(const Window *const window) if (instance()->mCurrentDialog == window) instance()->mCurrentDialog = nullptr; } + +void Client::updateScreenKeyboard(int height) +{ +// logger->log("keyboard height: %d", height); +} diff --git a/src/client.h b/src/client.h index a448678d0..956ee9b85 100644 --- a/src/client.h +++ b/src/client.h @@ -321,6 +321,8 @@ public: static void windowRemoved(const Window *const window); + static void updateScreenKeyboard(int height); + private: void initRootDir(); diff --git a/src/game.cpp b/src/game.cpp index fe279868e..7b5413692 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -942,20 +942,28 @@ void Game::handleInput() if (inputManager.handleEvent(event)) return; - if (event.type == SDL_VIDEORESIZE) + switch (event.type) { - // Let the client deal with this one (it'll pass down from there) - Client::resize(event.resize.w, event.resize.h); - } - // Active event - else if (event.type == SDL_ACTIVEEVENT) - { - handleActive(event); - } - // Quit event - else if (event.type == SDL_QUIT) - { - Client::setState(STATE_EXIT); + case SDL_VIDEORESIZE: + // Let the client deal with this one (it'll + // pass down from there) + Client::resize(event.resize.w, event.resize.h); + break; + // Active event + case SDL_ACTIVEEVENT: + handleActive(event); + break; + // Quit event + case SDL_QUIT: + Client::setState(STATE_EXIT); + break; +#ifdef ANDROID + case SDL_KEYBOARDSHOW: + Client::updateScreenKeyboard(event.user.code); + break; +#endif + default: + break; } BLOCK_END("Game::handleInput 2") } // End while -- cgit v1.2.3-70-g09d2