Skip to content

Commit 98f7b45

Browse files
committed
Add a possibility to disable system screen keyboard
1 parent 5e2f75a commit 98f7b45

File tree

6 files changed

+25
-10
lines changed

6 files changed

+25
-10
lines changed

src/graphics/graphics_restrictions.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ namespace GraphicsRestrictions
4444
/** The list of names used in the XML file for the graphics
4545
* restriction types. They must be in the same order as the types. */
4646

47-
std::array<std::string, 31> m_names_of_restrictions =
47+
std::array<std::string, 32> m_names_of_restrictions =
4848
{
4949
{
5050
"UniformBufferObject",
@@ -77,7 +77,8 @@ namespace GraphicsRestrictions
7777
"VertexIdWorking",
7878
"HardwareSkinning",
7979
"NpotTextures",
80-
"TextureBufferObject"
80+
"TextureBufferObject",
81+
"SystemScreenKeyboard"
8182
}
8283
};
8384
} // namespace Private

src/graphics/graphics_restrictions.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ namespace GraphicsRestrictions
6565
GR_HARDWARE_SKINNING,
6666
GR_NPOT_TEXTURES,
6767
GR_TEXTURE_BUFFER_OBJECT,
68+
GR_SYSTEM_SCREEN_KEYBOARD,
6869
GR_COUNT /** MUST be last entry. */
6970
} ;
7071

src/guiengine/screen_keyboard.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1818

1919
#include "config/user_config.hpp"
20+
#include "graphics/graphics_restrictions.hpp"
2021
#include "graphics/irr_driver.hpp"
2122
#include "guiengine/engine.hpp"
2223
#include "guiengine/screen_keyboard.hpp"
@@ -530,3 +531,14 @@ bool ScreenKeyboard::shouldUseScreenKeyboard()
530531

531532
return always_use_screen_keyboard;
532533
}
534+
535+
// ----------------------------------------------------------------------------
536+
/** Returns true if system screen keyboard is available
537+
*/
538+
bool ScreenKeyboard::hasSystemScreenKeyboard()
539+
{
540+
if (GraphicsRestrictions::isDisabled(GraphicsRestrictions::GR_SYSTEM_SCREEN_KEYBOARD))
541+
return false;
542+
543+
return irr_driver->getDevice()->hasOnScreenKeyboard();
544+
}

src/guiengine/screen_keyboard.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ namespace GUIEngine
126126
static bool isActive() {return m_screen_keyboard != NULL;}
127127

128128
static bool shouldUseScreenKeyboard();
129+
static bool hasSystemScreenKeyboard();
129130

130131
/** Override to be notified of updates */
131132
virtual void onUpdate(float dt);

src/guiengine/widgets/CGUIEditBox.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ CGUIEditBox::~CGUIEditBox()
246246
DestroyCaret();
247247
#endif
248248
if (GUIEngine::ScreenKeyboard::shouldUseScreenKeyboard() &&
249-
irr_driver->getDevice()->hasOnScreenKeyboard())
249+
GUIEngine::ScreenKeyboard::hasSystemScreenKeyboard())
250250
irr_driver->getDevice()->toggleOnScreenKeyboard(false);
251251

252252
#endif
@@ -381,7 +381,7 @@ bool CGUIEditBox::OnEvent(const SEvent& event)
381381
calculateScrollPos();
382382
#ifdef ANDROID
383383
if (GUIEngine::ScreenKeyboard::shouldUseScreenKeyboard() &&
384-
irr_driver->getDevice()->hasOnScreenKeyboard() &&
384+
GUIEngine::ScreenKeyboard::hasSystemScreenKeyboard() &&
385385
irr_driver->getDevice()->getType() == irr::EIDT_ANDROID)
386386
{
387387
// If user toggle with hacker keyboard with arrows, keep
@@ -675,7 +675,7 @@ bool CGUIEditBox::processKey(const SEvent& event)
675675
case IRR_KEY_RETURN:
676676
{
677677
if (GUIEngine::ScreenKeyboard::shouldUseScreenKeyboard() &&
678-
irr_driver->getDevice()->hasOnScreenKeyboard())
678+
GUIEngine::ScreenKeyboard::hasSystemScreenKeyboard())
679679
irr_driver->getDevice()->toggleOnScreenKeyboard(false);
680680
sendGuiEvent( EGET_EDITBOX_ENTER );
681681
}
@@ -1021,7 +1021,7 @@ void CGUIEditBox::setText(const core::stringw& text)
10211021
calculateScrollPos();
10221022
#ifdef ANDROID
10231023
if (GUIEngine::ScreenKeyboard::shouldUseScreenKeyboard() &&
1024-
irr_driver->getDevice()->hasOnScreenKeyboard() &&
1024+
GUIEngine::ScreenKeyboard::hasSystemScreenKeyboard() &&
10251025
irr_driver->getDevice()->getType() == irr::EIDT_ANDROID)
10261026
{
10271027
CIrrDeviceAndroid* dl = dynamic_cast<CIrrDeviceAndroid*>(
@@ -1144,7 +1144,7 @@ bool CGUIEditBox::processMouse(const SEvent& event)
11441144

11451145
if (GUIEngine::ScreenKeyboard::shouldUseScreenKeyboard())
11461146
{
1147-
if (irr_driver->getDevice()->hasOnScreenKeyboard())
1147+
if (GUIEngine::ScreenKeyboard::hasSystemScreenKeyboard())
11481148
irr_driver->getDevice()->toggleOnScreenKeyboard(true, m_type);
11491149
else
11501150
openScreenKeyboard();
@@ -1413,7 +1413,7 @@ void CGUIEditBox::setTextMarkers(s32 begin, s32 end)
14131413
sendGuiEvent(EGET_EDITBOX_MARKING_CHANGED);
14141414
#ifdef ANDROID
14151415
if (GUIEngine::ScreenKeyboard::shouldUseScreenKeyboard() &&
1416-
irr_driver->getDevice()->hasOnScreenKeyboard() &&
1416+
GUIEngine::ScreenKeyboard::hasSystemScreenKeyboard() &&
14171417
irr_driver->getDevice()->getType() == irr::EIDT_ANDROID)
14181418
{
14191419
CIrrDeviceAndroid* dl = dynamic_cast<CIrrDeviceAndroid*>(
@@ -1485,7 +1485,7 @@ void CGUIEditBox::deserializeAttributes(io::IAttributes* in, io::SAttributeReadW
14851485
void CGUIEditBox::openScreenKeyboard()
14861486
{
14871487
// If the device has native on screen keyboard, always use it
1488-
if (irr_driver->getDevice()->hasOnScreenKeyboard())
1488+
if (GUIEngine::ScreenKeyboard::hasSystemScreenKeyboard())
14891489
return;
14901490

14911491
if (GUIEngine::ScreenKeyboard::getCurrent() != NULL)

src/states_screens/options/user_screen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ EventPropagation BaseUserScreen::filterActions(PlayerAction action,
209209
{
210210
if (action == PA_MENU_SELECT &&
211211
(!ScreenKeyboard::shouldUseScreenKeyboard() ||
212-
GUIEngine::getDevice()->hasOnScreenKeyboard()))
212+
GUIEngine::ScreenKeyboard::hasSystemScreenKeyboard()))
213213
{
214214
if ((m_username_tb != NULL && m_username_tb->isFocusedForPlayer(PLAYER_ID_GAME_MASTER))
215215
|| (m_password_tb != NULL && m_password_tb->isFocusedForPlayer(PLAYER_ID_GAME_MASTER)))

0 commit comments

Comments
 (0)