Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android IME support #82

Closed
wants to merge 4 commits into from
Closed

Conversation

miscvariables
Copy link

based on checkout of sokol and sokol-samples on 2021/02/11
Android ImGui IME support. Simple Information:

No Java. Pure c/c++ android native activity.

Using JNI to call JavaVM functions, show/hide soft keyboard, create Android EditText widget in top view DecorView

Update the content between EditText and ImGui::InputText

I use 4 states to update the content: previous text in EditText(atext_prev), current text in EditText(atext), previous text in ImGui::InputText(vtext_prev), current text in ImGui::InputText(vtext). "atext" means Android-Text, "vtext" means Virtual-Text. The state machine is in sokol_app.h

Android main UI thread and sokol gl&imgui thread use Android looper to communicate. All JNI calls are done in Android main UI thread. It can avoid crash

sokol_imgui.h should pass ImGui::InputText state of current focus to sokol_app.h

sokol android seems only using c interface(no c++), so I only implement JNI c interface in sokol_app.h, JNI c++ interface has only empty functions for compiling complains.

Pure c/c++ Android app must use many tricks, the the code looks a bit dirty. There are many commented out codes in sokol_app.h, show the sucessful and unsucessful tries I ever made.

Patched files:
sokol/sokol_app.h
sokol/util/sokol_imgui.h
sokol-samples/sapp/imgui-highdpi-sapp.cc
sokol-samples/sapp/CMakeLists.txt (stripped. Contains only imgui-highdpi-sapp.cc Not necessary)
sokol-samples/libs/dbgui/dbgui.cc (only add #include imgui_internal.h, for compiling complains)
sokol-samples/tests/cpp-compile-test.cc (only add #include imgui_internal.h, for compiling complains)

@floooh
Copy link
Owner

floooh commented Feb 11, 2021

Please see my comment here: floooh/sokol#475 (comment)

@floooh floooh marked this pull request as draft February 11, 2021 17:03
@floooh
Copy link
Owner

floooh commented Feb 11, 2021

I've set this PR to "Draft" state too for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants