1919//! ```
2020//!
2121//! and implement a `#[no_mangle]` `android_main` entry point like this:
22- //! ```
22+ //! ```no_run
2323//! #[no_mangle]
2424//! fn android_main(app: android_activity::AndroidApp) {
2525//!
@@ -132,7 +132,7 @@ use ndk::native_window::NativeWindow;
132132pub use ndk;
133133pub use ndk_sys;
134134
135- #[ cfg( all ( not( target_os = "android" ) , not ( feature = "test" ) ) ) ]
135+ #[ cfg( not( target_os = "android" ) ) ]
136136compile_error ! ( "android-activity only supports compiling for Android" ) ;
137137
138138#[ cfg( all( feature = "game-activity" , feature = "native-activity" ) ) ]
@@ -560,7 +560,7 @@ impl AndroidApp {
560560 /// ```no_run
561561 /// # use jni::JavaVM;
562562 /// # let app: android_activity::AndroidApp = todo!();
563- /// let vm = unsafe { JavaVM::from_raw(app.vm_as_ptr().ast ()) };
563+ /// let vm = unsafe { JavaVM::from_raw(app.vm_as_ptr().cast ()) };
564564 /// ```
565565 ///
566566 /// [`jni`]: https://crates.io/crates/jni
@@ -732,20 +732,23 @@ impl AndroidApp {
732732 /// # Example
733733 /// Code to iterate all pending input events would look something like this:
734734 ///
735- /// ```
735+ /// ```no_run
736+ /// # use android_activity::{AndroidApp, InputStatus, input::InputEvent};
737+ /// # let app: AndroidApp = todo!();
736738 /// match app.input_events_iter() {
737739 /// Ok(mut iter) => {
738740 /// loop {
739741 /// let read_input = iter.next(|event| {
740742 /// let handled = match event {
741743 /// InputEvent::KeyEvent(key_event) => {
742744 /// // Snip
745+ /// InputStatus::Handled
743746 /// }
744747 /// InputEvent::MotionEvent(motion_event) => {
745- /// // Snip
748+ /// InputStatus::Unhandled
746749 /// }
747750 /// event => {
748- /// // Snip
751+ /// InputStatus::Unhandled
749752 /// }
750753 /// };
751754 ///
@@ -767,7 +770,7 @@ impl AndroidApp {
767770 ///
768771 /// This must only be called from your `android_main()` thread and it may panic if called
769772 /// from another thread.
770- pub fn input_events_iter ( & self ) -> Result < input:: InputIterator > {
773+ pub fn input_events_iter ( & self ) -> Result < input:: InputIterator < ' _ > > {
771774 let receiver = {
772775 let guard = self . inner . read ( ) . unwrap ( ) ;
773776 guard. input_events_receiver ( ) ?
@@ -787,44 +790,47 @@ impl AndroidApp {
787790 ///
788791 /// Code to handle unicode character mapping as well as combining dead keys could look some thing like:
789792 ///
790- /// ```
793+ /// ```no_run
794+ /// # use android_activity::{AndroidApp, input::{InputEvent, KeyEvent, KeyMapChar}};
795+ /// # let app: AndroidApp = todo!();
796+ /// # let key_event: KeyEvent = todo!();
791797 /// let mut combining_accent = None;
792798 /// // Snip
793799 ///
794- /// let combined_key_char = if let Ok(map) = app.device_key_character_map(device_id) {
800+ /// let combined_key_char = if let Ok(map) = app.device_key_character_map(key_event. device_id() ) {
795801 /// match map.get(key_event.key_code(), key_event.meta_state()) {
796802 /// Ok(KeyMapChar::Unicode(unicode)) => {
797803 /// let combined_unicode = if let Some(accent) = combining_accent {
798804 /// match map.get_dead_char(accent, unicode) {
799805 /// Ok(Some(key)) => {
800- /// info !("KeyEvent: Combined '{unicode}' with accent '{accent}' to give '{key}'");
806+ /// println !("KeyEvent: Combined '{unicode}' with accent '{accent}' to give '{key}'");
801807 /// Some(key)
802808 /// }
803809 /// Ok(None) => None,
804810 /// Err(err) => {
805- /// log::error !("KeyEvent: Failed to combine 'dead key' accent '{accent}' with '{unicode}': {err:?}");
811+ /// eprintln !("KeyEvent: Failed to combine 'dead key' accent '{accent}' with '{unicode}': {err:?}");
806812 /// None
807813 /// }
808814 /// }
809815 /// } else {
810- /// info !("KeyEvent: Pressed '{unicode}'");
816+ /// println !("KeyEvent: Pressed '{unicode}'");
811817 /// Some(unicode)
812818 /// };
813819 /// combining_accent = None;
814820 /// combined_unicode.map(|unicode| KeyMapChar::Unicode(unicode))
815821 /// }
816822 /// Ok(KeyMapChar::CombiningAccent(accent)) => {
817- /// info !("KeyEvent: Pressed 'dead key' combining accent '{accent}'");
823+ /// println !("KeyEvent: Pressed 'dead key' combining accent '{accent}'");
818824 /// combining_accent = Some(accent);
819825 /// Some(KeyMapChar::CombiningAccent(accent))
820826 /// }
821827 /// Ok(KeyMapChar::None) => {
822- /// info !("KeyEvent: Pressed non-unicode key");
828+ /// println !("KeyEvent: Pressed non-unicode key");
823829 /// combining_accent = None;
824830 /// None
825831 /// }
826832 /// Err(err) => {
827- /// log::error !("KeyEvent: Failed to get key map character: {err:?}");
833+ /// eprintln !("KeyEvent: Failed to get key map character: {err:?}");
828834 /// combining_accent = None;
829835 /// None
830836 /// }
0 commit comments