Fix for opening screen keyboard with gamepad on login screen

This commit is contained in:
Deve 2018-10-25 22:42:45 +02:00
parent 571d3d3ba0
commit be137155af
6 changed files with 28 additions and 22 deletions

View File

@ -27,6 +27,10 @@
#include "states_screens/state_manager.hpp"
#include "utils/log.hpp"
#ifdef ANDROID
#include "../../../lib/irrlicht/source/Irrlicht/CIrrDeviceAndroid.h"
#endif
#include <algorithm>
#include <string>
@ -407,3 +411,21 @@ bool ScreenKeyboard::onEscapePressed()
} // onEscapePressed
// ----------------------------------------------------------------------------
/** A function that determines if screen keyboard should be activated
*/
bool ScreenKeyboard::shouldUseScreenKeyboard()
{
bool use_screen_keyboard = UserConfigParams::m_screen_keyboard > 1;
#ifdef ANDROID
if (UserConfigParams::m_screen_keyboard == 1)
{
int32_t keyboard = AConfiguration_getKeyboard(
global_android_app->config);
use_screen_keyboard = (keyboard != ACONFIGURATION_KEYBOARD_QWERTY);
}
#endif
return use_screen_keyboard;
}

View File

@ -118,6 +118,8 @@ namespace GUIEngine
/** Returns true if keyboard is created */
static bool isActive() {return m_screen_keyboard != NULL;}
static bool shouldUseScreenKeyboard();
/** Override to be notified of updates */
virtual void onUpdate(float dt);

View File

@ -1291,7 +1291,7 @@ bool CGUIEditBox::processMouse(const SEvent& event)
{
return false;
}
else if (shouldUseScreenKeyboard())
else if (GUIEngine::ScreenKeyboard::shouldUseScreenKeyboard())
{
openScreenKeyboard();
return true;
@ -1754,24 +1754,6 @@ void CGUIEditBox::deserializeAttributes(io::IAttributes* in, io::SAttributeReadW
// setOverrideFont(in->getAttributeAsFont("OverrideFont"));
}
bool CGUIEditBox::shouldUseScreenKeyboard()
{
bool use_screen_keyboard = UserConfigParams::m_screen_keyboard > 1;
#ifdef ANDROID
if (UserConfigParams::m_screen_keyboard == 1)
{
int32_t keyboard = AConfiguration_getKeyboard(
global_android_app->config);
use_screen_keyboard = (keyboard != ACONFIGURATION_KEYBOARD_QWERTY);
}
#endif
return use_screen_keyboard;
}
void CGUIEditBox::openScreenKeyboard()
{
if (GUIEngine::ScreenKeyboard::getCurrent() != NULL)

View File

@ -119,7 +119,6 @@ using namespace gui;
virtual irr::gui::IGUIFont* getActiveFont() const { return NULL; }
virtual void setDrawBackground(bool) { }
bool shouldUseScreenKeyboard();
void openScreenKeyboard();
protected:

View File

@ -200,7 +200,7 @@ void TextBoxWidget::setActive(bool active)
EventPropagation TextBoxWidget::onActivationInput(const int playerID)
{
if (((MyCGUIEditBox*)m_element)->shouldUseScreenKeyboard())
if (GUIEngine::ScreenKeyboard::shouldUseScreenKeyboard())
{
((MyCGUIEditBox*)m_element)->openScreenKeyboard();
}

View File

@ -22,6 +22,7 @@
#include "challenges/unlock_manager.hpp"
#include "config/player_manager.hpp"
#include "config/user_config.hpp"
#include "guiengine/screen_keyboard.hpp"
#include "guiengine/widgets/check_box_widget.hpp"
#include "guiengine/widgets/dynamic_ribbon_widget.hpp"
#include "guiengine/widgets/label_widget.hpp"
@ -192,7 +193,7 @@ EventPropagation BaseUserScreen::filterActions(PlayerAction action,
Input::InputType type,
int playerId)
{
if (action == PA_MENU_SELECT)
if (action == PA_MENU_SELECT && !ScreenKeyboard::shouldUseScreenKeyboard())
{
if ((m_username_tb != NULL && m_username_tb->isFocusedForPlayer(PLAYER_ID_GAME_MASTER))
|| (m_password_tb != NULL && m_password_tb->isFocusedForPlayer(PLAYER_ID_GAME_MASTER)))