From 4b8425c64bb1fb486dae1acbcf7773792e40c6cf Mon Sep 17 00:00:00 2001 From: shenlei Date: Mon, 12 Oct 2026 18:55:51 +0900 Subject: [PATCH] Show the on-screen keyboard only while an edit line has focus SDL_StartTextInput was called once for the whole session, which keeps the Android soft keyboard over the game. Where SDL reports on-screen keyboard support, the frame loop now starts/stops text input with the original EditLine focus (ime.EnableCaptureInput/DisableCaptureInput in ui.py), the in-game chat and the dev login view. Desktop keeps text input always on. Co-Authored-By: Claude Opus 5.5 --- src/app/main.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/app/main.cpp b/src/app/main.cpp index 3837e8ff..62151291 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -386,7 +386,10 @@ int main(int argc, char** argv) { SDL_SetRenderLogicalPresentation(renderer.get(), screen_width, screen_height, SDL_LOGICAL_PRESENTATION_LETTERBOX); // One pacing source: software caps must not also wait on the display refresh. SDL_SetRenderVSync(renderer.get(), fps_cap > 0 ? 0 : 1); - SDL_StartTextInput(window.get()); + // Desktop: text input stays on for the whole session, as on Windows. Phones would keep the + // on-screen keyboard covering the game, so the frame loop toggles it with edit focus instead. + [[maybe_unused]] const bool screen_keyboard = SDL_HasScreenKeyboardSupport(); + if (!screen_keyboard) SDL_StartTextInput(window.get()); float dpi_scale = SDL_GetWindowPixelDensity(window.get()); SDL_Log("AVA2 host started: platform=%s GPU=%s Retina_DPI=%.2fx FPS_Cap=%d RenderScale=%.2f", SDL_GetPlatform(), SDL_GetGPUDeviceDriver(gpu.get()), dpi_scale, fps_cap, render_scale); @@ -1211,6 +1214,16 @@ const auto profileActiveStart = std::chrono::steady_clock::now(); active_map_objects = ava2::CPythonBackground::Instance().GetMapObjects(); } } +#endif +#ifdef AVA2_HAS_PYTHON + // On-screen keyboards appear only while an edit line captures text (ime.EnableCaptureInput + // from the original ui.py), the in-game chat is open or the dev login view is editing. + if (screen_keyboard) { + const bool want = ava2::IME_IsCaptureInput() || chat_input_active + || (!view_script.empty() && snapshot.phase == "login"); + if (want != SDL_TextInputActive(window.get())) + want ? SDL_StartTextInput(window.get()) : SDL_StopTextInput(window.get()); + } #endif SDL_Event event; while (SDL_PollEvent(&event)) {