// JNI helpers used by modules/platform/android.sx. Kept in the library // so consumers don't need to vendor an identically-named copy. The sx // compiler resolves `#source "vendors/..."` against the stdlib search // paths in addition to the consumer's project root. // // The safe-insets JNI chain that used to live here was migrated to // sx in Phase 1D of the FFI plan (see `library/modules/platform/ // android.sx::sx_query_safe_insets_jni` and the JavaVM helpers // alongside it). What remains is the input-handler installer, which // is a plain C struct-field assignment rather than JNI dispatch and // has no sx equivalent yet. #ifdef __ANDROID__ #include // Mirror of struct android_app (NDK 29 / arm64) up to the fields we touch. // Avoids depending on the glue header in the sx library compile path. struct sx_android_app_min { void* userData; void (*onAppCmd)(struct sx_android_app_min* app, int cmd); int (*onInputEvent)(struct sx_android_app_min* app, AInputEvent* event); // ...rest of struct ignored; we only assign onInputEvent. }; // Install an sx-side handler as `app->onInputEvent`. native_app_glue's // process_input loop calls this for every AInputEvent it pulls off the // input queue. Returning 1 marks the event as consumed. void sx_android_install_input_handler(void* app, int (*handler)(void* app, void* event)) { if (app == 0) return; struct sx_android_app_min* a = (struct sx_android_app_min*)app; a->onInputEvent = (int (*)(struct sx_android_app_min*, AInputEvent*))handler; } #endif