Skip to content

Android IME support#82

Closed
miscvariables wants to merge 4 commits into
floooh:masterfrom
miscvariables:master
Closed

Android IME support#82
miscvariables wants to merge 4 commits into
floooh:masterfrom
miscvariables:master

Conversation

@miscvariables

Copy link
Copy Markdown

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

floooh commented Feb 11, 2021

Copy link
Copy Markdown
Owner

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

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

floooh commented Feb 11, 2021

Copy link
Copy Markdown
Owner

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.

2 participants