Skip to content

[Android] Handle Android IME text sequences#3692

Open
winsvega wants to merge 3 commits into
SFML:masterfrom
winsvega:ime_input
Open

[Android] Handle Android IME text sequences#3692
winsvega wants to merge 3 commits into
SFML:masterfrom
winsvega:ime_input

Conversation

@winsvega

@winsvega winsvega commented Mar 31, 2026

Copy link
Copy Markdown

Intro

I tried to vibecode this issue out. And found a solution that works for me. Please review and comment if it can be merged to android example or if it breaks any logic, I tried to make it as minimum as possible to the original src code.

Motivation

This PR is related to the issue #3102

Android IME input (especially non-Latin/composed text such as Chinese or Russian) is not reliably represented through raw native key Unicode APIs. This change adds a Java-to-native text path so committed IME text can still be delivered as sf::Event::TextEntered.
5359588834716358692

Description

  • Added a native JNI text callback in Android main glue:

    • nativeOnTextInput(JNIEnv*, jobject, jstring) decodes UTF-16 Java text to Unicode codepoints and appends them to shared activity state.

    • registerTextInputCallback(ANativeActivity*) registers nativeOnTextInput(String) on the activity class and logs errors if registration fails.

    • Callback registration is invoked during ANativeActivity_onCreate.

  • Added textEvents queue storage to ActivityStates for cross-module transfer of IME codepoints.

  • Updated Android window event processing to flush queued codepoints as Event::TextEntered and clear the queue each frame.

  • Updated Android example to extend NativeActivity and intercept IME text input into hidden text input. Call new callback from there into SFML

  • Added free font unifont-17.0.04.otf that supports many languages


Codex Task

Tasks

  • Tested on Linux
  • Tested on Windows
  • Tested on macOS
  • Tested on iOS
  • Tested on Android

How to test this PR?

Compile and run updated android example

@winsvega winsvega changed the title Handle Android IME text sequences [Android] Handle Android IME text sequences Apr 2, 2026
@eXpl0it3r eXpl0it3r linked an issue Apr 22, 2026 that may be closed by this pull request
3 tasks
@github-project-automation github-project-automation Bot moved this to Planned in SFML 3.2.0 Apr 22, 2026
@eXpl0it3r eXpl0it3r added this to the 3.2 milestone Apr 22, 2026
@winsvega

Copy link
Copy Markdown
Author

Hmm, shall add backward compatibility as now it requires to override activity class

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Planned

Development

Successfully merging this pull request may close these issues.

Virtual keyboard on Android not issuing TextEntered events

2 participants