(Android) Enabled the use of the OS-supplied virtual keyboard if the ES-DE virtual keyboard setting has been disabled

This commit is contained in:
Leon Styhre 2024-02-01 23:25:43 +01:00
parent 9b805949e9
commit 45bcfa9179
4 changed files with 27 additions and 1 deletions

View file

@ -888,6 +888,12 @@ void GuiMenu::openUIOptions()
Settings::getInstance()->setBool("VirtualKeyboard", virtualKeyboard->getState());
s->setNeedsSaving();
s->setInvalidateCachedBackground();
#if defined(__ANDROID__)
if (Settings::getInstance()->getBool("VirtualKeyboard"))
SDL_SetHint(SDL_HINT_ENABLE_SCREEN_KEYBOARD, "0");
else
SDL_SetHint(SDL_HINT_ENABLE_SCREEN_KEYBOARD, "1");
#endif
}
});

View file

@ -988,7 +988,12 @@ int main(int argc, char* argv[])
LOG(LogInfo) << "SDL version: " << std::to_string(version.major) << "."
<< std::to_string(version.minor) << "." << std::to_string(version.patch);
#if !defined(__ANDROID__)
#if defined(__ANDROID__)
if (Settings::getInstance()->getBool("VirtualKeyboard"))
SDL_SetHint(SDL_HINT_ENABLE_SCREEN_KEYBOARD, "0");
else
SDL_SetHint(SDL_HINT_ENABLE_SCREEN_KEYBOARD, "1");
#else
if (version.major > 2 || (version.major == 2 && version.minor >= 28)) {
// This will prevent the popup virtual keyboard of any handheld device from being
// automatically displayed on top of the ES-DE virtual keyboard.

View file

@ -79,8 +79,10 @@ void TextEditComponent::setValue(const std::string& val)
void TextEditComponent::textInput(const std::string& text, const bool pasting)
{
#if !defined(__ANDROID__)
if (mMaskInput && !pasting)
return;
#endif
// Allow pasting up to a reasonable max clipboard size.
if (pasting && text.length() > (isMultiline() ? 16384 : 300))
@ -197,11 +199,13 @@ bool TextEditComponent::input(InputConfig* config, Input input)
}
return true;
}
#if !defined(__ANDROID__)
else if (input.id == SDLK_BACKSPACE) {
mMaskInput = false;
textInput("\b");
return true;
}
#endif
}
if (cursorLeft || cursorRight) {

View file

@ -115,16 +115,27 @@ GuiTextEditPopup::GuiTextEditPopup(const HelpStyle& helpstyle,
setSize(windowWidth, mTitle->getFont()->getHeight() + textHeight +
mButtonGrid->getSize().y + mButtonGrid->getSize().y * 1.85f);
#if defined(__ANDROID__)
setPosition((Renderer::getScreenWidth() - mSize.x) / 2.0f,
Font::get(FONT_SIZE_LARGE_FIXED)->getLetterHeight());
#else
setPosition((Renderer::getScreenWidth() - mSize.x) / 2.0f,
(Renderer::getScreenHeight() - mSize.y) / 2.0f);
#endif
}
else {
float width = glm::clamp(0.54f * aspectValue, 0.20f, 0.70f) * Renderer::getScreenWidth();
setSize(width, mTitle->getFont()->getHeight() + textHeight + mButtonGrid->getSize().y +
mButtonGrid->getSize().y / 2.0f);
#if defined(__ANDROID__)
setPosition((Renderer::getScreenWidth() - mSize.x) / 2.0f,
Font::get(FONT_SIZE_LARGE_FIXED)->getLetterHeight());
#else
setPosition((Renderer::getScreenWidth() - mSize.x) / 2.0f,
(Renderer::getScreenHeight() - mSize.y) / 2.0f);
#endif
}
if (!multiLine)