Toggle Android text input when invoking console

This commit is contained in:
Sergii Pylypenko
2014-05-27 22:43:31 +03:00
parent 7748f7cbf1
commit 617d04eccd

View File

@@ -28,6 +28,10 @@
#include "table/strings.h"
#ifdef __ANDROID__
#include <SDL_screenkeyboard.h>
#endif
static const uint ICON_HISTORY_SIZE = 20;
static const uint ICON_LINE_SPACING = 2;
static const uint ICON_RIGHT_BORDERWIDTH = 10;
@@ -447,9 +451,25 @@ void IConsoleSwitch()
{
switch (_iconsole_mode) {
case ICONSOLE_CLOSED:
new IConsoleWindow();
#ifdef __ANDROID__
{
char buf[1024] = "";
for (const IConsoleLine *print = IConsoleLine::Get(0); print != NULL; print = print->previous) {
if (print->buffer && print->buffer[0]) {
strncat(buf, print->buffer, sizeof(buf)-strlen(buf)-1);
strncat(buf, "\n", sizeof(buf)-strlen(buf)-1);
}
}
strncat(buf, "\n\n\n\n\n\n\n\n", sizeof(buf)-strlen(buf)-1); // Move all text to top
SDL_ANDROID_SetScreenKeyboardHintMesage(buf);
char text[512] = "";
SDL_ANDROID_GetScreenKeyboardTextInput(text, sizeof(text) - 1); /* Invoke Android built-in screen keyboard */
IConsoleCmdExec(text);
}
#else
new IConsoleWindow();
#endif
break;
case ICONSOLE_OPENED: case ICONSOLE_FULL:
DeleteWindowById(WC_CONSOLE, 0);
break;