diff --git a/android-activity/generate-bindings.sh b/android-activity/generate-bindings.sh index d634177..2efcb18 100644 --- a/android-activity/generate-bindings.sh +++ b/android-activity/generate-bindings.sh @@ -8,7 +8,7 @@ fi while read ARCH && read TARGET ; do # --module-raw-line 'use ' - bindgen game-activity-ffi.h -o src/game-activity/ffi_$ARCH.rs \ + bindgen game-activity-ffi.h -o src/game_activity/ffi_$ARCH.rs \ --blocklist-item 'JNI\w+' \ --blocklist-item 'C?_?JNIEnv' \ --blocklist-item '_?JavaVM' \ @@ -30,7 +30,7 @@ while read ARCH && read TARGET ; do -Igame-activity-csrc \ --sysroot="$SYSROOT" --target=$TARGET - bindgen native-activity-ffi.h -o src/native-activity/ffi_$ARCH.rs \ + bindgen native-activity-ffi.h -o src/native_activity/ffi_$ARCH.rs \ --blocklist-item 'JNI\w+' \ --blocklist-item 'C?_?JNIEnv' \ --blocklist-item '_?JavaVM' \ diff --git a/android-activity/src/game_activity/ffi_aarch64.rs b/android-activity/src/game_activity/ffi_aarch64.rs index 6310413..14ab42c 100644 --- a/android-activity/src/game_activity/ffi_aarch64.rs +++ b/android-activity/src/game_activity/ffi_aarch64.rs @@ -22,9 +22,9 @@ pub const __ANDROID_API_P__: u32 = 28; pub const __ANDROID_API_Q__: u32 = 29; pub const __ANDROID_API_R__: u32 = 30; pub const __NDK_MAJOR__: u32 = 21; -pub const __NDK_MINOR__: u32 = 3; +pub const __NDK_MINOR__: u32 = 1; pub const __NDK_BETA__: u32 = 0; -pub const __NDK_BUILD__: u32 = 6528147; +pub const __NDK_BUILD__: u32 = 6352462; pub const __NDK_CANARY__: u32 = 0; pub const WCHAR_MIN: u8 = 0u8; pub const INT8_MIN: i32 = -128; @@ -221,6 +221,7 @@ pub const false_: u32 = 0; pub const __bool_true_false_are_defined: u32 = 1; pub const GAME_ACTIVITY_POINTER_INFO_AXIS_COUNT: u32 = 48; pub const GAMEACTIVITY_MAX_NUM_POINTERS_IN_MOTION_EVENT: u32 = 8; +pub const GAMEACTIVITY_MAX_NUM_HISTORICAL_IN_MOTION_EVENT: u32 = 8; pub const POLLIN: u32 = 1; pub const POLLPRI: u32 = 2; pub const POLLOUT: u32 = 4; @@ -649,6 +650,7 @@ pub const PTHREAD_PROCESS_SHARED: u32 = 1; pub const PTHREAD_SCOPE_SYSTEM: u32 = 0; pub const PTHREAD_SCOPE_PROCESS: u32 = 1; pub const NATIVE_APP_GLUE_MAX_NUM_MOTION_EVENTS: u32 = 16; +pub const NATIVE_APP_GLUE_MAX_HISTORICAL_POINTER_SAMPLES: u32 = 64; pub const NATIVE_APP_GLUE_MAX_NUM_KEY_EVENTS: u32 = 4; pub const NATIVE_APP_GLUE_MAX_INPUT_BUFFERS: u32 = 2; extern "C" { @@ -1469,7 +1471,6 @@ pub struct AInputEvent { } pub const AINPUT_EVENT_TYPE_KEY: ::std::os::raw::c_uint = 1; pub const AINPUT_EVENT_TYPE_MOTION: ::std::os::raw::c_uint = 2; -pub const AINPUT_EVENT_TYPE_FOCUS: ::std::os::raw::c_uint = 3; pub type _bindgen_ty_8 = ::std::os::raw::c_uint; pub const AKEY_EVENT_ACTION_DOWN: ::std::os::raw::c_uint = 0; pub const AKEY_EVENT_ACTION_UP: ::std::os::raw::c_uint = 1; @@ -1570,7 +1571,6 @@ pub const AMOTION_EVENT_TOOL_TYPE_FINGER: ::std::os::raw::c_uint = 1; pub const AMOTION_EVENT_TOOL_TYPE_STYLUS: ::std::os::raw::c_uint = 2; pub const AMOTION_EVENT_TOOL_TYPE_MOUSE: ::std::os::raw::c_uint = 3; pub const AMOTION_EVENT_TOOL_TYPE_ERASER: ::std::os::raw::c_uint = 4; -pub const AMOTION_EVENT_TOOL_TYPE_PALM: ::std::os::raw::c_uint = 5; pub type _bindgen_ty_16 = ::std::os::raw::c_uint; pub const AINPUT_SOURCE_CLASS_MASK: ::std::os::raw::c_uint = 255; pub const AINPUT_SOURCE_CLASS_NONE: ::std::os::raw::c_uint = 0; @@ -1951,11 +1951,6 @@ pub const ADataSpace_ADATASPACE_SRGB: ADataSpace = 142671872; pub const ADataSpace_ADATASPACE_SCRGB: ADataSpace = 411107328; pub const ADataSpace_ADATASPACE_DISPLAY_P3: ADataSpace = 143261696; pub const ADataSpace_ADATASPACE_BT2020_PQ: ADataSpace = 163971072; -pub const ADataSpace_ADATASPACE_ADOBE_RGB: ADataSpace = 151715840; -pub const ADataSpace_ADATASPACE_BT2020: ADataSpace = 147193856; -pub const ADataSpace_ADATASPACE_BT709: ADataSpace = 281083904; -pub const ADataSpace_ADATASPACE_DCI_P3: ADataSpace = 155844608; -pub const ADataSpace_ADATASPACE_SRGB_LINEAR: ADataSpace = 138477568; pub type ADataSpace = ::std::os::raw::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -3080,6 +3075,54 @@ fn bindgen_test_layout_GameActivityPointerAxes() { ) ); } +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct GameActivityHistoricalPointerAxes { + pub eventTime: i64, + pub axisValues: [f32; 48usize], +} +#[test] +fn bindgen_test_layout_GameActivityHistoricalPointerAxes() { + assert_eq!( + ::std::mem::size_of::(), + 200usize, + concat!("Size of: ", stringify!(GameActivityHistoricalPointerAxes)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(GameActivityHistoricalPointerAxes) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).eventTime as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(GameActivityHistoricalPointerAxes), + "::", + stringify!(eventTime) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).axisValues as *const _ + as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(GameActivityHistoricalPointerAxes), + "::", + stringify!(axisValues) + ) + ); +} extern "C" { #[doc = " \\brief Enable the specified axis, so that its value is reported in the"] #[doc = " GameActivityPointerAxes structures stored in a motion event."] @@ -3101,6 +3144,24 @@ extern "C" { #[doc = " If the axis index is out of range, nothing is done."] pub fn GameActivityPointerAxes_disableAxis(axis: i32); } +extern "C" { + #[doc = " \\brief Enable the specified axis, so that its value is reported in the"] + #[doc = " GameActivityHistoricalPointerAxes structures associated with a motion event."] + #[doc = ""] + #[doc = " You must enable any axis that you want to read (no axes are enabled by"] + #[doc = " default)."] + #[doc = ""] + #[doc = " If the axis index is out of range, nothing is done."] + pub fn GameActivityHistoricalPointerAxes_enableAxis(axis: i32); +} +extern "C" { + #[doc = " \\brief Disable the specified axis. Its value won't be reported in the"] + #[doc = " GameActivityHistoricalPointerAxes structures associated with motion events"] + #[doc = " anymore."] + #[doc = ""] + #[doc = " If the axis index is out of range, nothing is done."] + pub fn GameActivityHistoricalPointerAxes_disableAxis(axis: i32); +} #[doc = " \\brief Describe a motion event that happened on the GameActivity SurfaceView."] #[doc = ""] #[doc = " This is 1:1 mapping to the information contained in a Java `MotionEvent`"] @@ -3123,6 +3184,8 @@ pub struct GameActivityMotionEvent { pub pointers: [GameActivityPointerAxes; 8usize], pub precisionX: f32, pub precisionY: f32, + pub historicalStart: i16, + pub historicalCount: i16, } #[test] fn bindgen_test_layout_GameActivityMotionEvent() { @@ -3310,6 +3373,30 @@ fn bindgen_test_layout_GameActivityMotionEvent() { stringify!(precisionY) ) ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).historicalStart as *const _ as usize + }, + 1700usize, + concat!( + "Offset of field: ", + stringify!(GameActivityMotionEvent), + "::", + stringify!(historicalStart) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).historicalCount as *const _ as usize + }, + 1702usize, + concat!( + "Offset of field: ", + stringify!(GameActivityMotionEvent), + "::", + stringify!(historicalCount) + ) + ); } #[doc = " \\brief Describe a key event that happened on the GameActivity SurfaceView."] #[doc = ""] @@ -3549,6 +3636,8 @@ pub struct GameActivityCallbacks { unsafe extern "C" fn( activity: *mut GameActivity, event: *const GameActivityMotionEvent, + historical: *const GameActivityHistoricalPointerAxes, + historicalLen: ::std::os::raw::c_int, ) -> bool, >, #[doc = " Callback called for every key down event on the GameActivity SurfaceView."] @@ -3809,13 +3898,18 @@ extern "C" { #[doc = " This is done automatically by the GameActivity: see `onTouchEvent` to set"] #[doc = " a callback to consume the received events."] #[doc = " This function can be used if you re-implement events handling in your own"] - #[doc = " activity."] + #[doc = " activity. On return, the out_event->historicalStart will be zero, and should"] + #[doc = " be updated to index into whatever buffer out_historical is copied."] + #[doc = " On return the length of out_historical is"] + #[doc = " (out_event->pointerCount x out_event->historicalCount) and is in a"] + #[doc = " pointer-major order (i.e. all axis for a pointer are contiguous)"] #[doc = " Ownership of out_event is maintained by the caller."] pub fn GameActivityMotionEvent_fromJava( env: *mut JNIEnv, motionEvent: jobject, out_event: *mut GameActivityMotionEvent, - ); + out_historical: *mut GameActivityHistoricalPointerAxes, + ) -> ::std::os::raw::c_int; } extern "C" { #[doc = " \\brief Convert a Java `KeyEvent` to a `GameActivityKeyEvent`."] @@ -7914,6 +8008,21 @@ pub struct android_input_buffer { pub motionEvents: [GameActivityMotionEvent; 16usize], #[doc = " The number of valid motion events in `motionEvents`."] pub motionEventsCount: u64, + #[doc = " Pointer to a read-only array of pointers to GameActivityHistoricalPointerAxes."] + #[doc = ""] + #[doc = " Only the first historicalSamplesCount samples are valid."] + #[doc = " Refer to event->historicalStart, event->pointerCount and event->historicalCount"] + #[doc = " to access the specific samples that relate to an event."] + #[doc = ""] + #[doc = " Each slice of samples for one event has a length of"] + #[doc = " (event->pointerCount and event->historicalCount) and is in pointer-major"] + #[doc = " order so the historic samples for each pointer are contiguous."] + #[doc = " E.g. you would access historic sample index 3 for pointer 2 of an event with:"] + #[doc = ""] + #[doc = " historicalAxisSamples[event->historicalStart + (event->historicalCount * 2) + 3];"] + pub historicalAxisSamples: [GameActivityHistoricalPointerAxes; 64usize], + #[doc = " The number of valid historical samples in `historicalAxisSamples`."] + pub historicalSamplesCount: u64, #[doc = " Pointer to a read-only array of pointers to GameActivityKeyEvent."] #[doc = " Only the first keyEventsCount events are valid."] pub keyEvents: [GameActivityKeyEvent; 4usize], @@ -7924,7 +8033,7 @@ pub struct android_input_buffer { fn bindgen_test_layout_android_input_buffer() { assert_eq!( ::std::mem::size_of::(), - 27504usize, + 40312usize, concat!("Size of: ", stringify!(android_input_buffer)) ); assert_eq!( @@ -7957,8 +8066,34 @@ fn bindgen_test_layout_android_input_buffer() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).keyEvents as *const _ as usize }, + unsafe { + &(*(::std::ptr::null::())).historicalAxisSamples as *const _ + as usize + }, 27272usize, + concat!( + "Offset of field: ", + stringify!(android_input_buffer), + "::", + stringify!(historicalAxisSamples) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).historicalSamplesCount as *const _ + as usize + }, + 40072usize, + concat!( + "Offset of field: ", + stringify!(android_input_buffer), + "::", + stringify!(historicalSamplesCount) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).keyEvents as *const _ as usize }, + 40080usize, concat!( "Offset of field: ", stringify!(android_input_buffer), @@ -7970,7 +8105,7 @@ fn bindgen_test_layout_android_input_buffer() { unsafe { &(*(::std::ptr::null::())).keyEventsCount as *const _ as usize }, - 27496usize, + 40304usize, concat!( "Offset of field: ", stringify!(android_input_buffer), @@ -8100,7 +8235,7 @@ pub struct android_app { fn bindgen_test_layout_android_app() { assert_eq!( ::std::mem::size_of::(), - 55288usize, + 80904usize, concat!("Size of: ", stringify!(android_app)) ); assert_eq!( @@ -8230,7 +8365,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).currentInputBuffer as *const _ as usize }, - 55096usize, + 80712usize, concat!( "Offset of field: ", stringify!(android_app), @@ -8240,7 +8375,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).textInputState as *const _ as usize }, - 55100usize, + 80716usize, concat!( "Offset of field: ", stringify!(android_app), @@ -8250,7 +8385,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).mutex as *const _ as usize }, - 55104usize, + 80720usize, concat!( "Offset of field: ", stringify!(android_app), @@ -8260,7 +8395,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).cond as *const _ as usize }, - 55144usize, + 80760usize, concat!( "Offset of field: ", stringify!(android_app), @@ -8270,7 +8405,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).msgread as *const _ as usize }, - 55192usize, + 80808usize, concat!( "Offset of field: ", stringify!(android_app), @@ -8280,7 +8415,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).msgwrite as *const _ as usize }, - 55196usize, + 80812usize, concat!( "Offset of field: ", stringify!(android_app), @@ -8290,7 +8425,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).thread as *const _ as usize }, - 55200usize, + 80816usize, concat!( "Offset of field: ", stringify!(android_app), @@ -8300,7 +8435,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).cmdPollSource as *const _ as usize }, - 55208usize, + 80824usize, concat!( "Offset of field: ", stringify!(android_app), @@ -8310,7 +8445,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).running as *const _ as usize }, - 55232usize, + 80848usize, concat!( "Offset of field: ", stringify!(android_app), @@ -8320,7 +8455,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).stateSaved as *const _ as usize }, - 55236usize, + 80852usize, concat!( "Offset of field: ", stringify!(android_app), @@ -8330,7 +8465,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).destroyed as *const _ as usize }, - 55240usize, + 80856usize, concat!( "Offset of field: ", stringify!(android_app), @@ -8340,7 +8475,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).redrawNeeded as *const _ as usize }, - 55244usize, + 80860usize, concat!( "Offset of field: ", stringify!(android_app), @@ -8350,7 +8485,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).pendingWindow as *const _ as usize }, - 55248usize, + 80864usize, concat!( "Offset of field: ", stringify!(android_app), @@ -8360,7 +8495,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).pendingContentRect as *const _ as usize }, - 55256usize, + 80872usize, concat!( "Offset of field: ", stringify!(android_app), @@ -8370,7 +8505,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).keyEventFilter as *const _ as usize }, - 55272usize, + 80888usize, concat!( "Offset of field: ", stringify!(android_app), @@ -8380,7 +8515,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).motionEventFilter as *const _ as usize }, - 55280usize, + 80896usize, concat!( "Offset of field: ", stringify!(android_app), @@ -8498,6 +8633,11 @@ extern "C" { #[doc = " your game loop. You should handle events at each iteration of your game loop."] pub fn android_app_clear_key_events(inputBuffer: *mut android_input_buffer); } +extern "C" { + #[doc = " This is a springboard into the Rust glue layer that wraps calling the"] + #[doc = " main entry for the app itself."] + pub fn _rust_glue_entry(app: *mut android_app); +} extern "C" { #[doc = " Set the filter to use when processing key events."] #[doc = " Any events for which the filter returns false will be ignored by"] diff --git a/android-activity/src/game_activity/ffi_arm.rs b/android-activity/src/game_activity/ffi_arm.rs index 17a2c3f..6fac456 100644 --- a/android-activity/src/game_activity/ffi_arm.rs +++ b/android-activity/src/game_activity/ffi_arm.rs @@ -102,9 +102,9 @@ pub const __ANDROID_API_P__: u32 = 28; pub const __ANDROID_API_Q__: u32 = 29; pub const __ANDROID_API_R__: u32 = 30; pub const __NDK_MAJOR__: u32 = 21; -pub const __NDK_MINOR__: u32 = 3; +pub const __NDK_MINOR__: u32 = 1; pub const __NDK_BETA__: u32 = 0; -pub const __NDK_BUILD__: u32 = 6528147; +pub const __NDK_BUILD__: u32 = 6352462; pub const __NDK_CANARY__: u32 = 0; pub const WCHAR_MIN: u8 = 0u8; pub const INT8_MIN: i32 = -128; @@ -272,6 +272,7 @@ pub const false_: u32 = 0; pub const __bool_true_false_are_defined: u32 = 1; pub const GAME_ACTIVITY_POINTER_INFO_AXIS_COUNT: u32 = 48; pub const GAMEACTIVITY_MAX_NUM_POINTERS_IN_MOTION_EVENT: u32 = 8; +pub const GAMEACTIVITY_MAX_NUM_HISTORICAL_IN_MOTION_EVENT: u32 = 8; pub const POLLIN: u32 = 1; pub const POLLPRI: u32 = 2; pub const POLLOUT: u32 = 4; @@ -681,6 +682,7 @@ pub const PTHREAD_PROCESS_SHARED: u32 = 1; pub const PTHREAD_SCOPE_SYSTEM: u32 = 0; pub const PTHREAD_SCOPE_PROCESS: u32 = 1; pub const NATIVE_APP_GLUE_MAX_NUM_MOTION_EVENTS: u32 = 16; +pub const NATIVE_APP_GLUE_MAX_HISTORICAL_POINTER_SAMPLES: u32 = 64; pub const NATIVE_APP_GLUE_MAX_NUM_KEY_EVENTS: u32 = 4; pub const NATIVE_APP_GLUE_MAX_INPUT_BUFFERS: u32 = 2; extern "C" { @@ -1488,7 +1490,6 @@ pub struct AInputEvent { } pub const AINPUT_EVENT_TYPE_KEY: ::std::os::raw::c_uint = 1; pub const AINPUT_EVENT_TYPE_MOTION: ::std::os::raw::c_uint = 2; -pub const AINPUT_EVENT_TYPE_FOCUS: ::std::os::raw::c_uint = 3; pub type _bindgen_ty_8 = ::std::os::raw::c_uint; pub const AKEY_EVENT_ACTION_DOWN: ::std::os::raw::c_uint = 0; pub const AKEY_EVENT_ACTION_UP: ::std::os::raw::c_uint = 1; @@ -1589,7 +1590,6 @@ pub const AMOTION_EVENT_TOOL_TYPE_FINGER: ::std::os::raw::c_uint = 1; pub const AMOTION_EVENT_TOOL_TYPE_STYLUS: ::std::os::raw::c_uint = 2; pub const AMOTION_EVENT_TOOL_TYPE_MOUSE: ::std::os::raw::c_uint = 3; pub const AMOTION_EVENT_TOOL_TYPE_ERASER: ::std::os::raw::c_uint = 4; -pub const AMOTION_EVENT_TOOL_TYPE_PALM: ::std::os::raw::c_uint = 5; pub type _bindgen_ty_16 = ::std::os::raw::c_uint; pub const AINPUT_SOURCE_CLASS_MASK: ::std::os::raw::c_uint = 255; pub const AINPUT_SOURCE_CLASS_NONE: ::std::os::raw::c_uint = 0; @@ -1970,11 +1970,6 @@ pub const ADataSpace_ADATASPACE_SRGB: ADataSpace = 142671872; pub const ADataSpace_ADATASPACE_SCRGB: ADataSpace = 411107328; pub const ADataSpace_ADATASPACE_DISPLAY_P3: ADataSpace = 143261696; pub const ADataSpace_ADATASPACE_BT2020_PQ: ADataSpace = 163971072; -pub const ADataSpace_ADATASPACE_ADOBE_RGB: ADataSpace = 151715840; -pub const ADataSpace_ADATASPACE_BT2020: ADataSpace = 147193856; -pub const ADataSpace_ADATASPACE_BT709: ADataSpace = 281083904; -pub const ADataSpace_ADATASPACE_DCI_P3: ADataSpace = 155844608; -pub const ADataSpace_ADATASPACE_SRGB_LINEAR: ADataSpace = 138477568; pub type ADataSpace = ::std::os::raw::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -3099,6 +3094,54 @@ fn bindgen_test_layout_GameActivityPointerAxes() { ) ); } +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct GameActivityHistoricalPointerAxes { + pub eventTime: i64, + pub axisValues: [f32; 48usize], +} +#[test] +fn bindgen_test_layout_GameActivityHistoricalPointerAxes() { + assert_eq!( + ::std::mem::size_of::(), + 200usize, + concat!("Size of: ", stringify!(GameActivityHistoricalPointerAxes)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(GameActivityHistoricalPointerAxes) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).eventTime as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(GameActivityHistoricalPointerAxes), + "::", + stringify!(eventTime) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).axisValues as *const _ + as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(GameActivityHistoricalPointerAxes), + "::", + stringify!(axisValues) + ) + ); +} extern "C" { #[doc = " \\brief Enable the specified axis, so that its value is reported in the"] #[doc = " GameActivityPointerAxes structures stored in a motion event."] @@ -3120,6 +3163,24 @@ extern "C" { #[doc = " If the axis index is out of range, nothing is done."] pub fn GameActivityPointerAxes_disableAxis(axis: i32); } +extern "C" { + #[doc = " \\brief Enable the specified axis, so that its value is reported in the"] + #[doc = " GameActivityHistoricalPointerAxes structures associated with a motion event."] + #[doc = ""] + #[doc = " You must enable any axis that you want to read (no axes are enabled by"] + #[doc = " default)."] + #[doc = ""] + #[doc = " If the axis index is out of range, nothing is done."] + pub fn GameActivityHistoricalPointerAxes_enableAxis(axis: i32); +} +extern "C" { + #[doc = " \\brief Disable the specified axis. Its value won't be reported in the"] + #[doc = " GameActivityHistoricalPointerAxes structures associated with motion events"] + #[doc = " anymore."] + #[doc = ""] + #[doc = " If the axis index is out of range, nothing is done."] + pub fn GameActivityHistoricalPointerAxes_disableAxis(axis: i32); +} #[doc = " \\brief Describe a motion event that happened on the GameActivity SurfaceView."] #[doc = ""] #[doc = " This is 1:1 mapping to the information contained in a Java `MotionEvent`"] @@ -3142,6 +3203,8 @@ pub struct GameActivityMotionEvent { pub pointers: [GameActivityPointerAxes; 8usize], pub precisionX: f32, pub precisionY: f32, + pub historicalStart: i16, + pub historicalCount: i16, } #[test] fn bindgen_test_layout_GameActivityMotionEvent() { @@ -3329,6 +3392,30 @@ fn bindgen_test_layout_GameActivityMotionEvent() { stringify!(precisionY) ) ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).historicalStart as *const _ as usize + }, + 1700usize, + concat!( + "Offset of field: ", + stringify!(GameActivityMotionEvent), + "::", + stringify!(historicalStart) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).historicalCount as *const _ as usize + }, + 1702usize, + concat!( + "Offset of field: ", + stringify!(GameActivityMotionEvent), + "::", + stringify!(historicalCount) + ) + ); } #[doc = " \\brief Describe a key event that happened on the GameActivity SurfaceView."] #[doc = ""] @@ -3568,6 +3655,8 @@ pub struct GameActivityCallbacks { unsafe extern "C" fn( activity: *mut GameActivity, event: *const GameActivityMotionEvent, + historical: *const GameActivityHistoricalPointerAxes, + historicalLen: ::std::os::raw::c_int, ) -> bool, >, #[doc = " Callback called for every key down event on the GameActivity SurfaceView."] @@ -3828,13 +3917,18 @@ extern "C" { #[doc = " This is done automatically by the GameActivity: see `onTouchEvent` to set"] #[doc = " a callback to consume the received events."] #[doc = " This function can be used if you re-implement events handling in your own"] - #[doc = " activity."] + #[doc = " activity. On return, the out_event->historicalStart will be zero, and should"] + #[doc = " be updated to index into whatever buffer out_historical is copied."] + #[doc = " On return the length of out_historical is"] + #[doc = " (out_event->pointerCount x out_event->historicalCount) and is in a"] + #[doc = " pointer-major order (i.e. all axis for a pointer are contiguous)"] #[doc = " Ownership of out_event is maintained by the caller."] pub fn GameActivityMotionEvent_fromJava( env: *mut JNIEnv, motionEvent: jobject, out_event: *mut GameActivityMotionEvent, - ); + out_historical: *mut GameActivityHistoricalPointerAxes, + ) -> ::std::os::raw::c_int; } extern "C" { #[doc = " \\brief Convert a Java `KeyEvent` to a `GameActivityKeyEvent`."] @@ -8383,6 +8477,21 @@ pub struct android_input_buffer { pub motionEvents: [GameActivityMotionEvent; 16usize], #[doc = " The number of valid motion events in `motionEvents`."] pub motionEventsCount: u64, + #[doc = " Pointer to a read-only array of pointers to GameActivityHistoricalPointerAxes."] + #[doc = ""] + #[doc = " Only the first historicalSamplesCount samples are valid."] + #[doc = " Refer to event->historicalStart, event->pointerCount and event->historicalCount"] + #[doc = " to access the specific samples that relate to an event."] + #[doc = ""] + #[doc = " Each slice of samples for one event has a length of"] + #[doc = " (event->pointerCount and event->historicalCount) and is in pointer-major"] + #[doc = " order so the historic samples for each pointer are contiguous."] + #[doc = " E.g. you would access historic sample index 3 for pointer 2 of an event with:"] + #[doc = ""] + #[doc = " historicalAxisSamples[event->historicalStart + (event->historicalCount * 2) + 3];"] + pub historicalAxisSamples: [GameActivityHistoricalPointerAxes; 64usize], + #[doc = " The number of valid historical samples in `historicalAxisSamples`."] + pub historicalSamplesCount: u64, #[doc = " Pointer to a read-only array of pointers to GameActivityKeyEvent."] #[doc = " Only the first keyEventsCount events are valid."] pub keyEvents: [GameActivityKeyEvent; 4usize], @@ -8393,7 +8502,7 @@ pub struct android_input_buffer { fn bindgen_test_layout_android_input_buffer() { assert_eq!( ::std::mem::size_of::(), - 27504usize, + 40312usize, concat!("Size of: ", stringify!(android_input_buffer)) ); assert_eq!( @@ -8426,8 +8535,34 @@ fn bindgen_test_layout_android_input_buffer() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).keyEvents as *const _ as usize }, + unsafe { + &(*(::std::ptr::null::())).historicalAxisSamples as *const _ + as usize + }, 27272usize, + concat!( + "Offset of field: ", + stringify!(android_input_buffer), + "::", + stringify!(historicalAxisSamples) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).historicalSamplesCount as *const _ + as usize + }, + 40072usize, + concat!( + "Offset of field: ", + stringify!(android_input_buffer), + "::", + stringify!(historicalSamplesCount) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).keyEvents as *const _ as usize }, + 40080usize, concat!( "Offset of field: ", stringify!(android_input_buffer), @@ -8439,7 +8574,7 @@ fn bindgen_test_layout_android_input_buffer() { unsafe { &(*(::std::ptr::null::())).keyEventsCount as *const _ as usize }, - 27496usize, + 40304usize, concat!( "Offset of field: ", stringify!(android_input_buffer), @@ -8569,7 +8704,7 @@ pub struct android_app { fn bindgen_test_layout_android_app() { assert_eq!( ::std::mem::size_of::(), - 55152usize, + 80768usize, concat!("Size of: ", stringify!(android_app)) ); assert_eq!( @@ -8699,7 +8834,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).currentInputBuffer as *const _ as usize }, - 55064usize, + 80680usize, concat!( "Offset of field: ", stringify!(android_app), @@ -8709,7 +8844,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).textInputState as *const _ as usize }, - 55068usize, + 80684usize, concat!( "Offset of field: ", stringify!(android_app), @@ -8719,7 +8854,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).mutex as *const _ as usize }, - 55072usize, + 80688usize, concat!( "Offset of field: ", stringify!(android_app), @@ -8729,7 +8864,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).cond as *const _ as usize }, - 55076usize, + 80692usize, concat!( "Offset of field: ", stringify!(android_app), @@ -8739,7 +8874,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).msgread as *const _ as usize }, - 55080usize, + 80696usize, concat!( "Offset of field: ", stringify!(android_app), @@ -8749,7 +8884,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).msgwrite as *const _ as usize }, - 55084usize, + 80700usize, concat!( "Offset of field: ", stringify!(android_app), @@ -8759,7 +8894,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).thread as *const _ as usize }, - 55088usize, + 80704usize, concat!( "Offset of field: ", stringify!(android_app), @@ -8769,7 +8904,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).cmdPollSource as *const _ as usize }, - 55092usize, + 80708usize, concat!( "Offset of field: ", stringify!(android_app), @@ -8779,7 +8914,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).running as *const _ as usize }, - 55104usize, + 80720usize, concat!( "Offset of field: ", stringify!(android_app), @@ -8789,7 +8924,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).stateSaved as *const _ as usize }, - 55108usize, + 80724usize, concat!( "Offset of field: ", stringify!(android_app), @@ -8799,7 +8934,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).destroyed as *const _ as usize }, - 55112usize, + 80728usize, concat!( "Offset of field: ", stringify!(android_app), @@ -8809,7 +8944,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).redrawNeeded as *const _ as usize }, - 55116usize, + 80732usize, concat!( "Offset of field: ", stringify!(android_app), @@ -8819,7 +8954,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).pendingWindow as *const _ as usize }, - 55120usize, + 80736usize, concat!( "Offset of field: ", stringify!(android_app), @@ -8829,7 +8964,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).pendingContentRect as *const _ as usize }, - 55124usize, + 80740usize, concat!( "Offset of field: ", stringify!(android_app), @@ -8839,7 +8974,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).keyEventFilter as *const _ as usize }, - 55140usize, + 80756usize, concat!( "Offset of field: ", stringify!(android_app), @@ -8849,7 +8984,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).motionEventFilter as *const _ as usize }, - 55144usize, + 80760usize, concat!( "Offset of field: ", stringify!(android_app), @@ -8967,6 +9102,11 @@ extern "C" { #[doc = " your game loop. You should handle events at each iteration of your game loop."] pub fn android_app_clear_key_events(inputBuffer: *mut android_input_buffer); } +extern "C" { + #[doc = " This is a springboard into the Rust glue layer that wraps calling the"] + #[doc = " main entry for the app itself."] + pub fn _rust_glue_entry(app: *mut android_app); +} extern "C" { #[doc = " Set the filter to use when processing key events."] #[doc = " Any events for which the filter returns false will be ignored by"] diff --git a/android-activity/src/game_activity/ffi_i686.rs b/android-activity/src/game_activity/ffi_i686.rs index 70ba9c0..c22ede7 100644 --- a/android-activity/src/game_activity/ffi_i686.rs +++ b/android-activity/src/game_activity/ffi_i686.rs @@ -22,9 +22,9 @@ pub const __ANDROID_API_P__: u32 = 28; pub const __ANDROID_API_Q__: u32 = 29; pub const __ANDROID_API_R__: u32 = 30; pub const __NDK_MAJOR__: u32 = 21; -pub const __NDK_MINOR__: u32 = 3; +pub const __NDK_MINOR__: u32 = 1; pub const __NDK_BETA__: u32 = 0; -pub const __NDK_BUILD__: u32 = 6528147; +pub const __NDK_BUILD__: u32 = 6352462; pub const __NDK_CANARY__: u32 = 0; pub const INT8_MIN: i32 = -128; pub const INT8_MAX: u32 = 127; @@ -191,6 +191,7 @@ pub const false_: u32 = 0; pub const __bool_true_false_are_defined: u32 = 1; pub const GAME_ACTIVITY_POINTER_INFO_AXIS_COUNT: u32 = 48; pub const GAMEACTIVITY_MAX_NUM_POINTERS_IN_MOTION_EVENT: u32 = 8; +pub const GAMEACTIVITY_MAX_NUM_HISTORICAL_IN_MOTION_EVENT: u32 = 8; pub const POLLIN: u32 = 1; pub const POLLPRI: u32 = 2; pub const POLLOUT: u32 = 4; @@ -601,6 +602,7 @@ pub const PTHREAD_PROCESS_SHARED: u32 = 1; pub const PTHREAD_SCOPE_SYSTEM: u32 = 0; pub const PTHREAD_SCOPE_PROCESS: u32 = 1; pub const NATIVE_APP_GLUE_MAX_NUM_MOTION_EVENTS: u32 = 16; +pub const NATIVE_APP_GLUE_MAX_HISTORICAL_POINTER_SAMPLES: u32 = 64; pub const NATIVE_APP_GLUE_MAX_NUM_KEY_EVENTS: u32 = 4; pub const NATIVE_APP_GLUE_MAX_INPUT_BUFFERS: u32 = 2; extern "C" { @@ -1409,7 +1411,6 @@ pub struct AInputEvent { } pub const AINPUT_EVENT_TYPE_KEY: ::std::os::raw::c_uint = 1; pub const AINPUT_EVENT_TYPE_MOTION: ::std::os::raw::c_uint = 2; -pub const AINPUT_EVENT_TYPE_FOCUS: ::std::os::raw::c_uint = 3; pub type _bindgen_ty_8 = ::std::os::raw::c_uint; pub const AKEY_EVENT_ACTION_DOWN: ::std::os::raw::c_uint = 0; pub const AKEY_EVENT_ACTION_UP: ::std::os::raw::c_uint = 1; @@ -1510,7 +1511,6 @@ pub const AMOTION_EVENT_TOOL_TYPE_FINGER: ::std::os::raw::c_uint = 1; pub const AMOTION_EVENT_TOOL_TYPE_STYLUS: ::std::os::raw::c_uint = 2; pub const AMOTION_EVENT_TOOL_TYPE_MOUSE: ::std::os::raw::c_uint = 3; pub const AMOTION_EVENT_TOOL_TYPE_ERASER: ::std::os::raw::c_uint = 4; -pub const AMOTION_EVENT_TOOL_TYPE_PALM: ::std::os::raw::c_uint = 5; pub type _bindgen_ty_16 = ::std::os::raw::c_uint; pub const AINPUT_SOURCE_CLASS_MASK: ::std::os::raw::c_uint = 255; pub const AINPUT_SOURCE_CLASS_NONE: ::std::os::raw::c_uint = 0; @@ -1891,11 +1891,6 @@ pub const ADataSpace_ADATASPACE_SRGB: ADataSpace = 142671872; pub const ADataSpace_ADATASPACE_SCRGB: ADataSpace = 411107328; pub const ADataSpace_ADATASPACE_DISPLAY_P3: ADataSpace = 143261696; pub const ADataSpace_ADATASPACE_BT2020_PQ: ADataSpace = 163971072; -pub const ADataSpace_ADATASPACE_ADOBE_RGB: ADataSpace = 151715840; -pub const ADataSpace_ADATASPACE_BT2020: ADataSpace = 147193856; -pub const ADataSpace_ADATASPACE_BT709: ADataSpace = 281083904; -pub const ADataSpace_ADATASPACE_DCI_P3: ADataSpace = 155844608; -pub const ADataSpace_ADATASPACE_SRGB_LINEAR: ADataSpace = 138477568; pub type ADataSpace = ::std::os::raw::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -3020,6 +3015,54 @@ fn bindgen_test_layout_GameActivityPointerAxes() { ) ); } +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct GameActivityHistoricalPointerAxes { + pub eventTime: i64, + pub axisValues: [f32; 48usize], +} +#[test] +fn bindgen_test_layout_GameActivityHistoricalPointerAxes() { + assert_eq!( + ::std::mem::size_of::(), + 200usize, + concat!("Size of: ", stringify!(GameActivityHistoricalPointerAxes)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!( + "Alignment of ", + stringify!(GameActivityHistoricalPointerAxes) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).eventTime as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(GameActivityHistoricalPointerAxes), + "::", + stringify!(eventTime) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).axisValues as *const _ + as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(GameActivityHistoricalPointerAxes), + "::", + stringify!(axisValues) + ) + ); +} extern "C" { #[doc = " \\brief Enable the specified axis, so that its value is reported in the"] #[doc = " GameActivityPointerAxes structures stored in a motion event."] @@ -3041,6 +3084,24 @@ extern "C" { #[doc = " If the axis index is out of range, nothing is done."] pub fn GameActivityPointerAxes_disableAxis(axis: i32); } +extern "C" { + #[doc = " \\brief Enable the specified axis, so that its value is reported in the"] + #[doc = " GameActivityHistoricalPointerAxes structures associated with a motion event."] + #[doc = ""] + #[doc = " You must enable any axis that you want to read (no axes are enabled by"] + #[doc = " default)."] + #[doc = ""] + #[doc = " If the axis index is out of range, nothing is done."] + pub fn GameActivityHistoricalPointerAxes_enableAxis(axis: i32); +} +extern "C" { + #[doc = " \\brief Disable the specified axis. Its value won't be reported in the"] + #[doc = " GameActivityHistoricalPointerAxes structures associated with motion events"] + #[doc = " anymore."] + #[doc = ""] + #[doc = " If the axis index is out of range, nothing is done."] + pub fn GameActivityHistoricalPointerAxes_disableAxis(axis: i32); +} #[doc = " \\brief Describe a motion event that happened on the GameActivity SurfaceView."] #[doc = ""] #[doc = " This is 1:1 mapping to the information contained in a Java `MotionEvent`"] @@ -3063,12 +3124,14 @@ pub struct GameActivityMotionEvent { pub pointers: [GameActivityPointerAxes; 8usize], pub precisionX: f32, pub precisionY: f32, + pub historicalStart: i16, + pub historicalCount: i16, } #[test] fn bindgen_test_layout_GameActivityMotionEvent() { assert_eq!( ::std::mem::size_of::(), - 1696usize, + 1700usize, concat!("Size of: ", stringify!(GameActivityMotionEvent)) ); assert_eq!( @@ -3250,6 +3313,30 @@ fn bindgen_test_layout_GameActivityMotionEvent() { stringify!(precisionY) ) ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).historicalStart as *const _ as usize + }, + 1696usize, + concat!( + "Offset of field: ", + stringify!(GameActivityMotionEvent), + "::", + stringify!(historicalStart) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).historicalCount as *const _ as usize + }, + 1698usize, + concat!( + "Offset of field: ", + stringify!(GameActivityMotionEvent), + "::", + stringify!(historicalCount) + ) + ); } #[doc = " \\brief Describe a key event that happened on the GameActivity SurfaceView."] #[doc = ""] @@ -3489,6 +3576,8 @@ pub struct GameActivityCallbacks { unsafe extern "C" fn( activity: *mut GameActivity, event: *const GameActivityMotionEvent, + historical: *const GameActivityHistoricalPointerAxes, + historicalLen: ::std::os::raw::c_int, ) -> bool, >, #[doc = " Callback called for every key down event on the GameActivity SurfaceView."] @@ -3749,13 +3838,18 @@ extern "C" { #[doc = " This is done automatically by the GameActivity: see `onTouchEvent` to set"] #[doc = " a callback to consume the received events."] #[doc = " This function can be used if you re-implement events handling in your own"] - #[doc = " activity."] + #[doc = " activity. On return, the out_event->historicalStart will be zero, and should"] + #[doc = " be updated to index into whatever buffer out_historical is copied."] + #[doc = " On return the length of out_historical is"] + #[doc = " (out_event->pointerCount x out_event->historicalCount) and is in a"] + #[doc = " pointer-major order (i.e. all axis for a pointer are contiguous)"] #[doc = " Ownership of out_event is maintained by the caller."] pub fn GameActivityMotionEvent_fromJava( env: *mut JNIEnv, motionEvent: jobject, out_event: *mut GameActivityMotionEvent, - ); + out_historical: *mut GameActivityHistoricalPointerAxes, + ) -> ::std::os::raw::c_int; } extern "C" { #[doc = " \\brief Convert a Java `KeyEvent` to a `GameActivityKeyEvent`."] @@ -10128,6 +10222,21 @@ pub struct android_input_buffer { pub motionEvents: [GameActivityMotionEvent; 16usize], #[doc = " The number of valid motion events in `motionEvents`."] pub motionEventsCount: u64, + #[doc = " Pointer to a read-only array of pointers to GameActivityHistoricalPointerAxes."] + #[doc = ""] + #[doc = " Only the first historicalSamplesCount samples are valid."] + #[doc = " Refer to event->historicalStart, event->pointerCount and event->historicalCount"] + #[doc = " to access the specific samples that relate to an event."] + #[doc = ""] + #[doc = " Each slice of samples for one event has a length of"] + #[doc = " (event->pointerCount and event->historicalCount) and is in pointer-major"] + #[doc = " order so the historic samples for each pointer are contiguous."] + #[doc = " E.g. you would access historic sample index 3 for pointer 2 of an event with:"] + #[doc = ""] + #[doc = " historicalAxisSamples[event->historicalStart + (event->historicalCount * 2) + 3];"] + pub historicalAxisSamples: [GameActivityHistoricalPointerAxes; 64usize], + #[doc = " The number of valid historical samples in `historicalAxisSamples`."] + pub historicalSamplesCount: u64, #[doc = " Pointer to a read-only array of pointers to GameActivityKeyEvent."] #[doc = " Only the first keyEventsCount events are valid."] pub keyEvents: [GameActivityKeyEvent; 4usize], @@ -10138,7 +10247,7 @@ pub struct android_input_buffer { fn bindgen_test_layout_android_input_buffer() { assert_eq!( ::std::mem::size_of::(), - 27360usize, + 40232usize, concat!("Size of: ", stringify!(android_input_buffer)) ); assert_eq!( @@ -10162,7 +10271,7 @@ fn bindgen_test_layout_android_input_buffer() { unsafe { &(*(::std::ptr::null::())).motionEventsCount as *const _ as usize }, - 27136usize, + 27200usize, concat!( "Offset of field: ", stringify!(android_input_buffer), @@ -10170,9 +10279,35 @@ fn bindgen_test_layout_android_input_buffer() { stringify!(motionEventsCount) ) ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).historicalAxisSamples as *const _ + as usize + }, + 27208usize, + concat!( + "Offset of field: ", + stringify!(android_input_buffer), + "::", + stringify!(historicalAxisSamples) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).historicalSamplesCount as *const _ + as usize + }, + 40008usize, + concat!( + "Offset of field: ", + stringify!(android_input_buffer), + "::", + stringify!(historicalSamplesCount) + ) + ); assert_eq!( unsafe { &(*(::std::ptr::null::())).keyEvents as *const _ as usize }, - 27144usize, + 40016usize, concat!( "Offset of field: ", stringify!(android_input_buffer), @@ -10184,7 +10319,7 @@ fn bindgen_test_layout_android_input_buffer() { unsafe { &(*(::std::ptr::null::())).keyEventsCount as *const _ as usize }, - 27352usize, + 40224usize, concat!( "Offset of field: ", stringify!(android_input_buffer), @@ -10314,7 +10449,7 @@ pub struct android_app { fn bindgen_test_layout_android_app() { assert_eq!( ::std::mem::size_of::(), - 54860usize, + 80604usize, concat!("Size of: ", stringify!(android_app)) ); assert_eq!( @@ -10444,7 +10579,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).currentInputBuffer as *const _ as usize }, - 54776usize, + 80520usize, concat!( "Offset of field: ", stringify!(android_app), @@ -10454,7 +10589,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).textInputState as *const _ as usize }, - 54780usize, + 80524usize, concat!( "Offset of field: ", stringify!(android_app), @@ -10464,7 +10599,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).mutex as *const _ as usize }, - 54784usize, + 80528usize, concat!( "Offset of field: ", stringify!(android_app), @@ -10474,7 +10609,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).cond as *const _ as usize }, - 54788usize, + 80532usize, concat!( "Offset of field: ", stringify!(android_app), @@ -10484,7 +10619,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).msgread as *const _ as usize }, - 54792usize, + 80536usize, concat!( "Offset of field: ", stringify!(android_app), @@ -10494,7 +10629,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).msgwrite as *const _ as usize }, - 54796usize, + 80540usize, concat!( "Offset of field: ", stringify!(android_app), @@ -10504,7 +10639,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).thread as *const _ as usize }, - 54800usize, + 80544usize, concat!( "Offset of field: ", stringify!(android_app), @@ -10514,7 +10649,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).cmdPollSource as *const _ as usize }, - 54804usize, + 80548usize, concat!( "Offset of field: ", stringify!(android_app), @@ -10524,7 +10659,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).running as *const _ as usize }, - 54816usize, + 80560usize, concat!( "Offset of field: ", stringify!(android_app), @@ -10534,7 +10669,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).stateSaved as *const _ as usize }, - 54820usize, + 80564usize, concat!( "Offset of field: ", stringify!(android_app), @@ -10544,7 +10679,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).destroyed as *const _ as usize }, - 54824usize, + 80568usize, concat!( "Offset of field: ", stringify!(android_app), @@ -10554,7 +10689,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).redrawNeeded as *const _ as usize }, - 54828usize, + 80572usize, concat!( "Offset of field: ", stringify!(android_app), @@ -10564,7 +10699,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).pendingWindow as *const _ as usize }, - 54832usize, + 80576usize, concat!( "Offset of field: ", stringify!(android_app), @@ -10574,7 +10709,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).pendingContentRect as *const _ as usize }, - 54836usize, + 80580usize, concat!( "Offset of field: ", stringify!(android_app), @@ -10584,7 +10719,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).keyEventFilter as *const _ as usize }, - 54852usize, + 80596usize, concat!( "Offset of field: ", stringify!(android_app), @@ -10594,7 +10729,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).motionEventFilter as *const _ as usize }, - 54856usize, + 80600usize, concat!( "Offset of field: ", stringify!(android_app), @@ -10712,6 +10847,11 @@ extern "C" { #[doc = " your game loop. You should handle events at each iteration of your game loop."] pub fn android_app_clear_key_events(inputBuffer: *mut android_input_buffer); } +extern "C" { + #[doc = " This is a springboard into the Rust glue layer that wraps calling the"] + #[doc = " main entry for the app itself."] + pub fn _rust_glue_entry(app: *mut android_app); +} extern "C" { #[doc = " Set the filter to use when processing key events."] #[doc = " Any events for which the filter returns false will be ignored by"] diff --git a/android-activity/src/game_activity/ffi_x86_64.rs b/android-activity/src/game_activity/ffi_x86_64.rs index db4ba7a..56d351a 100644 --- a/android-activity/src/game_activity/ffi_x86_64.rs +++ b/android-activity/src/game_activity/ffi_x86_64.rs @@ -22,9 +22,9 @@ pub const __ANDROID_API_P__: u32 = 28; pub const __ANDROID_API_Q__: u32 = 29; pub const __ANDROID_API_R__: u32 = 30; pub const __NDK_MAJOR__: u32 = 21; -pub const __NDK_MINOR__: u32 = 3; +pub const __NDK_MINOR__: u32 = 1; pub const __NDK_BETA__: u32 = 0; -pub const __NDK_BUILD__: u32 = 6528147; +pub const __NDK_BUILD__: u32 = 6352462; pub const __NDK_CANARY__: u32 = 0; pub const INT8_MIN: i32 = -128; pub const INT8_MAX: u32 = 127; @@ -220,6 +220,7 @@ pub const false_: u32 = 0; pub const __bool_true_false_are_defined: u32 = 1; pub const GAME_ACTIVITY_POINTER_INFO_AXIS_COUNT: u32 = 48; pub const GAMEACTIVITY_MAX_NUM_POINTERS_IN_MOTION_EVENT: u32 = 8; +pub const GAMEACTIVITY_MAX_NUM_HISTORICAL_IN_MOTION_EVENT: u32 = 8; pub const POLLIN: u32 = 1; pub const POLLPRI: u32 = 2; pub const POLLOUT: u32 = 4; @@ -629,6 +630,7 @@ pub const PTHREAD_PROCESS_SHARED: u32 = 1; pub const PTHREAD_SCOPE_SYSTEM: u32 = 0; pub const PTHREAD_SCOPE_PROCESS: u32 = 1; pub const NATIVE_APP_GLUE_MAX_NUM_MOTION_EVENTS: u32 = 16; +pub const NATIVE_APP_GLUE_MAX_HISTORICAL_POINTER_SAMPLES: u32 = 64; pub const NATIVE_APP_GLUE_MAX_NUM_KEY_EVENTS: u32 = 4; pub const NATIVE_APP_GLUE_MAX_INPUT_BUFFERS: u32 = 2; extern "C" { @@ -1449,7 +1451,6 @@ pub struct AInputEvent { } pub const AINPUT_EVENT_TYPE_KEY: ::std::os::raw::c_uint = 1; pub const AINPUT_EVENT_TYPE_MOTION: ::std::os::raw::c_uint = 2; -pub const AINPUT_EVENT_TYPE_FOCUS: ::std::os::raw::c_uint = 3; pub type _bindgen_ty_8 = ::std::os::raw::c_uint; pub const AKEY_EVENT_ACTION_DOWN: ::std::os::raw::c_uint = 0; pub const AKEY_EVENT_ACTION_UP: ::std::os::raw::c_uint = 1; @@ -1550,7 +1551,6 @@ pub const AMOTION_EVENT_TOOL_TYPE_FINGER: ::std::os::raw::c_uint = 1; pub const AMOTION_EVENT_TOOL_TYPE_STYLUS: ::std::os::raw::c_uint = 2; pub const AMOTION_EVENT_TOOL_TYPE_MOUSE: ::std::os::raw::c_uint = 3; pub const AMOTION_EVENT_TOOL_TYPE_ERASER: ::std::os::raw::c_uint = 4; -pub const AMOTION_EVENT_TOOL_TYPE_PALM: ::std::os::raw::c_uint = 5; pub type _bindgen_ty_16 = ::std::os::raw::c_uint; pub const AINPUT_SOURCE_CLASS_MASK: ::std::os::raw::c_uint = 255; pub const AINPUT_SOURCE_CLASS_NONE: ::std::os::raw::c_uint = 0; @@ -1931,11 +1931,6 @@ pub const ADataSpace_ADATASPACE_SRGB: ADataSpace = 142671872; pub const ADataSpace_ADATASPACE_SCRGB: ADataSpace = 411107328; pub const ADataSpace_ADATASPACE_DISPLAY_P3: ADataSpace = 143261696; pub const ADataSpace_ADATASPACE_BT2020_PQ: ADataSpace = 163971072; -pub const ADataSpace_ADATASPACE_ADOBE_RGB: ADataSpace = 151715840; -pub const ADataSpace_ADATASPACE_BT2020: ADataSpace = 147193856; -pub const ADataSpace_ADATASPACE_BT709: ADataSpace = 281083904; -pub const ADataSpace_ADATASPACE_DCI_P3: ADataSpace = 155844608; -pub const ADataSpace_ADATASPACE_SRGB_LINEAR: ADataSpace = 138477568; pub type ADataSpace = ::std::os::raw::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -3060,6 +3055,54 @@ fn bindgen_test_layout_GameActivityPointerAxes() { ) ); } +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct GameActivityHistoricalPointerAxes { + pub eventTime: i64, + pub axisValues: [f32; 48usize], +} +#[test] +fn bindgen_test_layout_GameActivityHistoricalPointerAxes() { + assert_eq!( + ::std::mem::size_of::(), + 200usize, + concat!("Size of: ", stringify!(GameActivityHistoricalPointerAxes)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(GameActivityHistoricalPointerAxes) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).eventTime as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(GameActivityHistoricalPointerAxes), + "::", + stringify!(eventTime) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).axisValues as *const _ + as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(GameActivityHistoricalPointerAxes), + "::", + stringify!(axisValues) + ) + ); +} extern "C" { #[doc = " \\brief Enable the specified axis, so that its value is reported in the"] #[doc = " GameActivityPointerAxes structures stored in a motion event."] @@ -3081,6 +3124,24 @@ extern "C" { #[doc = " If the axis index is out of range, nothing is done."] pub fn GameActivityPointerAxes_disableAxis(axis: i32); } +extern "C" { + #[doc = " \\brief Enable the specified axis, so that its value is reported in the"] + #[doc = " GameActivityHistoricalPointerAxes structures associated with a motion event."] + #[doc = ""] + #[doc = " You must enable any axis that you want to read (no axes are enabled by"] + #[doc = " default)."] + #[doc = ""] + #[doc = " If the axis index is out of range, nothing is done."] + pub fn GameActivityHistoricalPointerAxes_enableAxis(axis: i32); +} +extern "C" { + #[doc = " \\brief Disable the specified axis. Its value won't be reported in the"] + #[doc = " GameActivityHistoricalPointerAxes structures associated with motion events"] + #[doc = " anymore."] + #[doc = ""] + #[doc = " If the axis index is out of range, nothing is done."] + pub fn GameActivityHistoricalPointerAxes_disableAxis(axis: i32); +} #[doc = " \\brief Describe a motion event that happened on the GameActivity SurfaceView."] #[doc = ""] #[doc = " This is 1:1 mapping to the information contained in a Java `MotionEvent`"] @@ -3103,6 +3164,8 @@ pub struct GameActivityMotionEvent { pub pointers: [GameActivityPointerAxes; 8usize], pub precisionX: f32, pub precisionY: f32, + pub historicalStart: i16, + pub historicalCount: i16, } #[test] fn bindgen_test_layout_GameActivityMotionEvent() { @@ -3290,6 +3353,30 @@ fn bindgen_test_layout_GameActivityMotionEvent() { stringify!(precisionY) ) ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).historicalStart as *const _ as usize + }, + 1700usize, + concat!( + "Offset of field: ", + stringify!(GameActivityMotionEvent), + "::", + stringify!(historicalStart) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).historicalCount as *const _ as usize + }, + 1702usize, + concat!( + "Offset of field: ", + stringify!(GameActivityMotionEvent), + "::", + stringify!(historicalCount) + ) + ); } #[doc = " \\brief Describe a key event that happened on the GameActivity SurfaceView."] #[doc = ""] @@ -3529,6 +3616,8 @@ pub struct GameActivityCallbacks { unsafe extern "C" fn( activity: *mut GameActivity, event: *const GameActivityMotionEvent, + historical: *const GameActivityHistoricalPointerAxes, + historicalLen: ::std::os::raw::c_int, ) -> bool, >, #[doc = " Callback called for every key down event on the GameActivity SurfaceView."] @@ -3789,13 +3878,18 @@ extern "C" { #[doc = " This is done automatically by the GameActivity: see `onTouchEvent` to set"] #[doc = " a callback to consume the received events."] #[doc = " This function can be used if you re-implement events handling in your own"] - #[doc = " activity."] + #[doc = " activity. On return, the out_event->historicalStart will be zero, and should"] + #[doc = " be updated to index into whatever buffer out_historical is copied."] + #[doc = " On return the length of out_historical is"] + #[doc = " (out_event->pointerCount x out_event->historicalCount) and is in a"] + #[doc = " pointer-major order (i.e. all axis for a pointer are contiguous)"] #[doc = " Ownership of out_event is maintained by the caller."] pub fn GameActivityMotionEvent_fromJava( env: *mut JNIEnv, motionEvent: jobject, out_event: *mut GameActivityMotionEvent, - ); + out_historical: *mut GameActivityHistoricalPointerAxes, + ) -> ::std::os::raw::c_int; } extern "C" { #[doc = " \\brief Convert a Java `KeyEvent` to a `GameActivityKeyEvent`."] @@ -10157,6 +10251,21 @@ pub struct android_input_buffer { pub motionEvents: [GameActivityMotionEvent; 16usize], #[doc = " The number of valid motion events in `motionEvents`."] pub motionEventsCount: u64, + #[doc = " Pointer to a read-only array of pointers to GameActivityHistoricalPointerAxes."] + #[doc = ""] + #[doc = " Only the first historicalSamplesCount samples are valid."] + #[doc = " Refer to event->historicalStart, event->pointerCount and event->historicalCount"] + #[doc = " to access the specific samples that relate to an event."] + #[doc = ""] + #[doc = " Each slice of samples for one event has a length of"] + #[doc = " (event->pointerCount and event->historicalCount) and is in pointer-major"] + #[doc = " order so the historic samples for each pointer are contiguous."] + #[doc = " E.g. you would access historic sample index 3 for pointer 2 of an event with:"] + #[doc = ""] + #[doc = " historicalAxisSamples[event->historicalStart + (event->historicalCount * 2) + 3];"] + pub historicalAxisSamples: [GameActivityHistoricalPointerAxes; 64usize], + #[doc = " The number of valid historical samples in `historicalAxisSamples`."] + pub historicalSamplesCount: u64, #[doc = " Pointer to a read-only array of pointers to GameActivityKeyEvent."] #[doc = " Only the first keyEventsCount events are valid."] pub keyEvents: [GameActivityKeyEvent; 4usize], @@ -10167,7 +10276,7 @@ pub struct android_input_buffer { fn bindgen_test_layout_android_input_buffer() { assert_eq!( ::std::mem::size_of::(), - 27504usize, + 40312usize, concat!("Size of: ", stringify!(android_input_buffer)) ); assert_eq!( @@ -10200,8 +10309,34 @@ fn bindgen_test_layout_android_input_buffer() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).keyEvents as *const _ as usize }, + unsafe { + &(*(::std::ptr::null::())).historicalAxisSamples as *const _ + as usize + }, 27272usize, + concat!( + "Offset of field: ", + stringify!(android_input_buffer), + "::", + stringify!(historicalAxisSamples) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).historicalSamplesCount as *const _ + as usize + }, + 40072usize, + concat!( + "Offset of field: ", + stringify!(android_input_buffer), + "::", + stringify!(historicalSamplesCount) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).keyEvents as *const _ as usize }, + 40080usize, concat!( "Offset of field: ", stringify!(android_input_buffer), @@ -10213,7 +10348,7 @@ fn bindgen_test_layout_android_input_buffer() { unsafe { &(*(::std::ptr::null::())).keyEventsCount as *const _ as usize }, - 27496usize, + 40304usize, concat!( "Offset of field: ", stringify!(android_input_buffer), @@ -10343,7 +10478,7 @@ pub struct android_app { fn bindgen_test_layout_android_app() { assert_eq!( ::std::mem::size_of::(), - 55288usize, + 80904usize, concat!("Size of: ", stringify!(android_app)) ); assert_eq!( @@ -10473,7 +10608,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).currentInputBuffer as *const _ as usize }, - 55096usize, + 80712usize, concat!( "Offset of field: ", stringify!(android_app), @@ -10483,7 +10618,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).textInputState as *const _ as usize }, - 55100usize, + 80716usize, concat!( "Offset of field: ", stringify!(android_app), @@ -10493,7 +10628,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).mutex as *const _ as usize }, - 55104usize, + 80720usize, concat!( "Offset of field: ", stringify!(android_app), @@ -10503,7 +10638,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).cond as *const _ as usize }, - 55144usize, + 80760usize, concat!( "Offset of field: ", stringify!(android_app), @@ -10513,7 +10648,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).msgread as *const _ as usize }, - 55192usize, + 80808usize, concat!( "Offset of field: ", stringify!(android_app), @@ -10523,7 +10658,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).msgwrite as *const _ as usize }, - 55196usize, + 80812usize, concat!( "Offset of field: ", stringify!(android_app), @@ -10533,7 +10668,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).thread as *const _ as usize }, - 55200usize, + 80816usize, concat!( "Offset of field: ", stringify!(android_app), @@ -10543,7 +10678,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).cmdPollSource as *const _ as usize }, - 55208usize, + 80824usize, concat!( "Offset of field: ", stringify!(android_app), @@ -10553,7 +10688,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).running as *const _ as usize }, - 55232usize, + 80848usize, concat!( "Offset of field: ", stringify!(android_app), @@ -10563,7 +10698,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).stateSaved as *const _ as usize }, - 55236usize, + 80852usize, concat!( "Offset of field: ", stringify!(android_app), @@ -10573,7 +10708,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).destroyed as *const _ as usize }, - 55240usize, + 80856usize, concat!( "Offset of field: ", stringify!(android_app), @@ -10583,7 +10718,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).redrawNeeded as *const _ as usize }, - 55244usize, + 80860usize, concat!( "Offset of field: ", stringify!(android_app), @@ -10593,7 +10728,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).pendingWindow as *const _ as usize }, - 55248usize, + 80864usize, concat!( "Offset of field: ", stringify!(android_app), @@ -10603,7 +10738,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).pendingContentRect as *const _ as usize }, - 55256usize, + 80872usize, concat!( "Offset of field: ", stringify!(android_app), @@ -10613,7 +10748,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).keyEventFilter as *const _ as usize }, - 55272usize, + 80888usize, concat!( "Offset of field: ", stringify!(android_app), @@ -10623,7 +10758,7 @@ fn bindgen_test_layout_android_app() { ); assert_eq!( unsafe { &(*(::std::ptr::null::())).motionEventFilter as *const _ as usize }, - 55280usize, + 80896usize, concat!( "Offset of field: ", stringify!(android_app), @@ -10741,6 +10876,11 @@ extern "C" { #[doc = " your game loop. You should handle events at each iteration of your game loop."] pub fn android_app_clear_key_events(inputBuffer: *mut android_input_buffer); } +extern "C" { + #[doc = " This is a springboard into the Rust glue layer that wraps calling the"] + #[doc = " main entry for the app itself."] + pub fn _rust_glue_entry(app: *mut android_app); +} extern "C" { #[doc = " Set the filter to use when processing key events."] #[doc = " Any events for which the filter returns false will be ignored by"]