mirror of
https://github.com/ocornut/imgui.git
synced 2026-11-07 06:55:53 +01:00
Backend improvements (imgui_impl_android.h/.cpp): - Moved JNI soft-keyboard and Unicode char polling from the example into the backend. The backend automatically shows/hides the soft keyboard based on io.WantTextInput during NewFrame(). - Moved JNI Unicode character polling from the example into the backend. Characters are polled and fed to io.AddInputCharacter() automatically. - Added clipboard support via JNI to Android ClipboardManager. io.SetClipboardTextFn / io.GetClipboardTextFn are now set by the backend. - Added ImGui_ImplAndroid_ShowSoftKeyboard() / HideSoftKeyboard() public API. - Init() now accepts optional asset_manager and native_activity params. When native_activity is provided, JNI features are enabled automatically. When nullptr, the backend degrades gracefully (no keyboard/clipboard). - Added sensor support via NDK ASensor API (no JNI needed): Accelerometer, Gyroscope, Magnetometer, Light, Proximity, Pressure, Humidity, Ambient Temperature. API: EnableSensor(), DisableSensor(), GetSensorData(), IsSensorAvailable(). Sensor events are drained non-blocking in NewFrame(). - Added display metrics via JNI: DPI, density, xdpi/ydpi, refresh rate, orientation, resolution. API: GetDisplayMetrics(). Used to auto-scale ImGui style to the device's actual density. Example cleanup (main.cpp): - Removed ~120 lines of JNI boilerplate (ShowSoftKeyboardInput, PollUnicodeChars, GetAssetData). The example is now a clean Init -> Loop -> Render -> Shutdown. - Single ImGui_ImplAndroid_Init() call passes the activity object; the backend handles the rest. - Added sensor window: live accelerometer, gyroscope, magnetometer, light, proximity readouts with visual progress bars. - Added display window: resolution, DPI, density, refresh rate, orientation. - Uses actual device density for style scaling instead of hardcoded 2.0f. CMakeLists.txt: added 'sensor' to target_link_libraries for ASensor API. Kotlin activity (MainActivity.kt): - Kept the three JNI-bridge methods (showSoftInput/hideSoftInput/pollUnicodeChar) since Android's native API does not provide these. Cleaned up and documented that they are called by the backend, not by app code.
New to Dear ImGui? - Check out the Getting Started guide: https://github.com/ocornut/imgui/wiki/Getting-Started - About Backends: docs/BACKENDS.md file, or on the web: https://github.com/ocornut/imgui/blob/master/docs/BACKENDS.md - About Examples: docs/EXAMPLES.md file, or on the web: https://github.com/ocornut/imgui/blob/master/docs/EXAMPLES.md Backends = Helper code to facilitate integration with platforms/graphics api (used by Examples + should be used by your app). Examples = Standalone applications showcasing integration with platforms/graphics api. A few Examples have extra README files in their respective directory, please check them too! Once Dear ImGui is running (in either examples or your own application/game/engine), run and refer to ImGui::ShowDemoWindow() in imgui_demo.cpp for the end-user API.