diff --git a/Cargo.lock b/Cargo.lock index f2e01f9..8ac8324 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -95,6 +95,13 @@ dependencies = [ "document-features", ] +[[package]] +name = "ohos-input-sys" +version = "0.1.0" +dependencies = [ + "document-features", +] + [[package]] name = "ohos-rawfile-sys" version = "0.1.0" diff --git a/components/drawing/CHANGELOG.md b/components/drawing/CHANGELOG.md index 022f68c..7c20a09 100644 --- a/components/drawing/CHANGELOG.md +++ b/components/drawing/CHANGELOG.md @@ -1,3 +1,9 @@ +# Changelog + +## unreleased + +- `OH_Drawing_Point2D` and `OH_Drawing_Point3D` now derive Copy, Clone and Debug + ## v0.2.1 (2025-01-08) - Update bindings for API-13 diff --git a/components/drawing/src/text_blob/text_blob_ffi.rs b/components/drawing/src/text_blob/text_blob_ffi.rs index 35ef2d2..2add744 100644 --- a/components/drawing/src/text_blob/text_blob_ffi.rs +++ b/components/drawing/src/text_blob/text_blob_ffi.rs @@ -18,6 +18,7 @@ use crate::error_code::OH_Drawing_ErrorCode; #[cfg(feature = "api-11")] #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))] #[repr(C)] +#[derive(Debug)] pub struct OH_Drawing_RunBuffer { /// storage for glyph indexes in run pub glyphs: *mut u16, diff --git a/components/drawing/src/types/types_ffi.rs b/components/drawing/src/types/types_ffi.rs index e97f545..10c818a 100644 --- a/components/drawing/src/types/types_ffi.rs +++ b/components/drawing/src/types/types_ffi.rs @@ -49,6 +49,7 @@ pub struct OH_Drawing_ColorSpace { #[cfg(feature = "api-12")] #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] #[repr(C)] +#[derive(Debug, Copy, Clone)] pub struct OH_Drawing_Point2D { pub x: f32, pub y: f32, @@ -71,6 +72,7 @@ pub type OH_Drawing_Corner_Radii = OH_Drawing_Point2D; #[cfg(feature = "api-12")] #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] #[repr(C)] +#[derive(Debug, Copy, Clone)] pub struct OH_Drawing_Point3D { pub x: f32, pub y: f32, diff --git a/components/multimodal-input/Cargo.toml b/components/multimodal-input/Cargo.toml new file mode 100644 index 0000000..ca07609 --- /dev/null +++ b/components/multimodal-input/Cargo.toml @@ -0,0 +1,33 @@ +[package] +name = "ohos-input-sys" +version = "0.1.0" +edition = "2021" +description = "Bindings to the multi-modal Input-kit on OpenHarmony" +license = "Apache-2.0" +repository = "https://github.com/openharmony-rs/ohos-sys" +keywords = ["OpenHarmony", "HarmonyOS", "ffi", "inputkit", "input"] +readme = "README.md" + +[dependencies] +document-features = { version = "0.2", optional = true } + +[features] +default = [] + +#! ### OpenHarmony API level +#! The `inputmethod` API was added in API-level 12. +#! Defaults to no bindings at all, to maintain feature composability in `ohos-sys`. +#! Optionally enable one of the `api-*` features to get access to bindings for newer +#! OpenHarmony versions. + +## Enables bindings for OpenHarmony API-level 12. +api-12 = [] +## Enables bindings for OpenHarmony API-level 13 (No changes) +api-13 = ["api-12"] +## Document available features when building the documentation +document-features = ["dep:document-features"] + +[package.metadata.docs.rs] +features = ["document-features"] +targets = ["aarch64-unknown-linux-ohos", "armv7-unknown-linux-ohos", "x86_64-unknown-linux-ohos"] +all-features = true diff --git a/components/multimodal-input/Changelog.md b/components/multimodal-input/Changelog.md new file mode 100644 index 0000000..a1ed544 --- /dev/null +++ b/components/multimodal-input/Changelog.md @@ -0,0 +1,5 @@ +# Changelog + +## v0.1.0 + +- Initial release diff --git a/components/multimodal-input/README.md b/components/multimodal-input/README.md new file mode 100644 index 0000000..a13ed18 --- /dev/null +++ b/components/multimodal-input/README.md @@ -0,0 +1,11 @@ +# OpenHarmony Input-kit bindings + +Raw rust-bindings for the `Input-kit` on OpenHarmony. +Available since OpenHarmony 5.0 (API-level 12). +Please view the [official Documentation] for more details. + +[official Documentation]: https://docs.openharmony.cn/pages/v5.0/en/application-dev/reference/apis-input-kit/input.md + +## License + +Licensed under the Apache-2.0 license, matching the license of OpenHarmony. \ No newline at end of file diff --git a/components/multimodal-input/src/axis_type.rs b/components/multimodal-input/src/axis_type.rs new file mode 100644 index 0000000..d7aa19b --- /dev/null +++ b/components/multimodal-input/src/axis_type.rs @@ -0,0 +1,5 @@ +//! Defines the axis event structures and enumerations. +//! +//! System capability: SystemCapability.MultimodalInput.Input.Core +mod axis_type_ffi; +pub use axis_type_ffi::*; diff --git a/components/multimodal-input/src/axis_type/axis_type_ffi.rs b/components/multimodal-input/src/axis_type/axis_type_ffi.rs new file mode 100644 index 0000000..891fb5f --- /dev/null +++ b/components/multimodal-input/src/axis_type/axis_type_ffi.rs @@ -0,0 +1,159 @@ +// automatically generated by rust-bindgen 0.71.1 + +#![allow(non_upper_case_globals)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] + +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl InputEvent_AxisType { + /// Indicates an unknown axis type. It is generally used as the initial value. + /// + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub const AXIS_TYPE_UNKNOWN: InputEvent_AxisType = InputEvent_AxisType(0); +} +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl InputEvent_AxisType { + /// Indicates the vertical scroll axis. When you scroll the mouse wheel or make certain gestures on the touchpad, + /// the status of the vertical scroll axis changes. + /// + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub const AXIS_TYPE_SCROLL_VERTICAL: InputEvent_AxisType = InputEvent_AxisType(1); +} +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl InputEvent_AxisType { + /// Indicates the horizontal scroll axis. + /// When you scroll the mouse wheel or make certain gestures on the touchpad, + /// the status of the horizontal scroll axis changes. + /// + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub const AXIS_TYPE_SCROLL_HORIZONTAL: InputEvent_AxisType = InputEvent_AxisType(2); +} +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl InputEvent_AxisType { + /// Indicates the pinch axis, which is used to describe a pinch gesture on the touchscreen or touchpad. + /// + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub const AXIS_TYPE_PINCH: InputEvent_AxisType = InputEvent_AxisType(3); +} +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl InputEvent_AxisType { + /// Indicates the rotate axis, which is used to describe a rotate gesture on the touchpad. + /// + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub const AXIS_TYPE_ROTATE: InputEvent_AxisType = InputEvent_AxisType(4); +} +#[repr(transparent)] +/// Enumerates axis types. +/// +/// +/// Available since API-level: 12 +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct InputEvent_AxisType(pub ::core::ffi::c_uint); +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl InputEvent_AxisEventType { + /// Enumerates two-finger pinch events. The axis value can be AXIS_TYPE_PINCH or AXIS_TYPE_ROTATE. + /// + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub const AXIS_EVENT_TYPE_PINCH: InputEvent_AxisEventType = InputEvent_AxisEventType(1); +} +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl InputEvent_AxisEventType { + /// Enumerates scroll axis events. + /// The axis value can be AXIS_TYPE_SCROLL_VERTICAL or AXIS_TYPE_SCROLL_HORIZONTAL. + /// Wherein, the value of AXIS_TYPE_SCROLL_HORIZONTAL is 0 for a mouse wheel event. + /// + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub const AXIS_EVENT_TYPE_SCROLL: InputEvent_AxisEventType = InputEvent_AxisEventType(2); +} +#[repr(transparent)] +/// Enumerates axis event types. +/// +/// +/// Available since API-level: 12 +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct InputEvent_AxisEventType(pub ::core::ffi::c_uint); +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl InputEvent_AxisAction { + /// Cancel action for the axis input event. + /// + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub const AXIS_ACTION_CANCEL: InputEvent_AxisAction = InputEvent_AxisAction(0); +} +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl InputEvent_AxisAction { + /// Start action for the axis input event. + /// + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub const AXIS_ACTION_BEGIN: InputEvent_AxisAction = InputEvent_AxisAction(1); +} +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl InputEvent_AxisAction { + /// Update action for the axis input event. + /// + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub const AXIS_ACTION_UPDATE: InputEvent_AxisAction = InputEvent_AxisAction(2); +} +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl InputEvent_AxisAction { + /// End action for the axis input event. + /// + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub const AXIS_ACTION_END: InputEvent_AxisAction = InputEvent_AxisAction(3); +} +#[repr(transparent)] +/// Enumerates axis event actions. +/// +/// +/// Available since API-level: 12 +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct InputEvent_AxisAction(pub ::core::ffi::c_uint); diff --git a/components/multimodal-input/src/input_manager.rs b/components/multimodal-input/src/input_manager.rs new file mode 100644 index 0000000..1305301 --- /dev/null +++ b/components/multimodal-input/src/input_manager.rs @@ -0,0 +1,6 @@ +//! Provides functions such as event injection and status query. +//! +//! System capability: SystemCapability.MultimodalInput.Input.Core + +mod input_manager_ffi; +pub use input_manager_ffi::*; diff --git a/components/multimodal-input/src/input_manager/input_manager_ffi.rs b/components/multimodal-input/src/input_manager/input_manager_ffi.rs new file mode 100644 index 0000000..0bda405 --- /dev/null +++ b/components/multimodal-input/src/input_manager/input_manager_ffi.rs @@ -0,0 +1,2286 @@ +// automatically generated by rust-bindgen 0.71.1 + +#![allow(non_upper_case_globals)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +use crate::axis_type::{InputEvent_AxisAction, InputEvent_AxisEventType, InputEvent_AxisType}; + +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl Input_KeyStateAction { + /// Default + pub const KEY_DEFAULT: Input_KeyStateAction = Input_KeyStateAction(-1); +} +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl Input_KeyStateAction { + /// Pressing of a key + pub const KEY_PRESSED: Input_KeyStateAction = Input_KeyStateAction(0); +} +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl Input_KeyStateAction { + /// Release of a key + pub const KEY_RELEASED: Input_KeyStateAction = Input_KeyStateAction(1); +} +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl Input_KeyStateAction { + /// Key switch enabled + pub const KEY_SWITCH_ON: Input_KeyStateAction = Input_KeyStateAction(2); +} +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl Input_KeyStateAction { + /// Key switch disabled + pub const KEY_SWITCH_OFF: Input_KeyStateAction = Input_KeyStateAction(3); +} +#[repr(transparent)] +/// Enumerated values of key event action. +/// +/// +/// Available since API-level: 12 +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct Input_KeyStateAction(pub ::core::ffi::c_int); +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl Input_KeyEventAction { + /// Cancellation of a key action. + pub const KEY_ACTION_CANCEL: Input_KeyEventAction = Input_KeyEventAction(0); +} +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl Input_KeyEventAction { + /// Pressing of a key. + pub const KEY_ACTION_DOWN: Input_KeyEventAction = Input_KeyEventAction(1); +} +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl Input_KeyEventAction { + /// Release of a key. + pub const KEY_ACTION_UP: Input_KeyEventAction = Input_KeyEventAction(2); +} +#[repr(transparent)] +/// Enumerates key event types. +/// +/// +/// Available since API-level: 12 +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct Input_KeyEventAction(pub ::core::ffi::c_uint); +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl Input_MouseEventAction { + /// Cancel. + pub const MOUSE_ACTION_CANCEL: Input_MouseEventAction = Input_MouseEventAction(0); +} +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl Input_MouseEventAction { + /// Moving of the mouse pointer. + pub const MOUSE_ACTION_MOVE: Input_MouseEventAction = Input_MouseEventAction(1); +} +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl Input_MouseEventAction { + /// Pressing down of the mouse. + pub const MOUSE_ACTION_BUTTON_DOWN: Input_MouseEventAction = Input_MouseEventAction(2); +} +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl Input_MouseEventAction { + /// Lifting of the mouse button. + pub const MOUSE_ACTION_BUTTON_UP: Input_MouseEventAction = Input_MouseEventAction(3); +} +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl Input_MouseEventAction { + /// Beginning of the mouse axis event + pub const MOUSE_ACTION_AXIS_BEGIN: Input_MouseEventAction = Input_MouseEventAction(4); +} +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl Input_MouseEventAction { + /// Updating of the mouse axis event + pub const MOUSE_ACTION_AXIS_UPDATE: Input_MouseEventAction = Input_MouseEventAction(5); +} +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl Input_MouseEventAction { + /// End of the mouse axis event + pub const MOUSE_ACTION_AXIS_END: Input_MouseEventAction = Input_MouseEventAction(6); +} +#[repr(transparent)] +/// Enumerated values of mouse event action. +/// +/// +/// Available since API-level: 12 +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct Input_MouseEventAction(pub ::core::ffi::c_uint); +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl InputEvent_MouseAxis { + /// Vertical scroll axis + pub const MOUSE_AXIS_SCROLL_VERTICAL: InputEvent_MouseAxis = InputEvent_MouseAxis(0); +} +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl InputEvent_MouseAxis { + /// Horizontal scroll axis + pub const MOUSE_AXIS_SCROLL_HORIZONTAL: InputEvent_MouseAxis = InputEvent_MouseAxis(1); +} +#[repr(transparent)] +/// Mouse axis types. +/// +/// +/// Available since API-level: 12 +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct InputEvent_MouseAxis(pub ::core::ffi::c_uint); +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl Input_MouseEventButton { + /// Invalid button + pub const MOUSE_BUTTON_NONE: Input_MouseEventButton = Input_MouseEventButton(-1); +} +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl Input_MouseEventButton { + /// Left button on the mouse. + pub const MOUSE_BUTTON_LEFT: Input_MouseEventButton = Input_MouseEventButton(0); +} +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl Input_MouseEventButton { + /// Middle button on the mouse. + pub const MOUSE_BUTTON_MIDDLE: Input_MouseEventButton = Input_MouseEventButton(1); +} +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl Input_MouseEventButton { + /// Right button on the mouse. + pub const MOUSE_BUTTON_RIGHT: Input_MouseEventButton = Input_MouseEventButton(2); +} +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl Input_MouseEventButton { + /// Forward button on the mouse. + pub const MOUSE_BUTTON_FORWARD: Input_MouseEventButton = Input_MouseEventButton(3); +} +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl Input_MouseEventButton { + /// Back button on the mouse. + pub const MOUSE_BUTTON_BACK: Input_MouseEventButton = Input_MouseEventButton(4); +} +#[repr(transparent)] +/// Enumerated values of mouse event button. +/// +/// +/// Available since API-level: 12 +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct Input_MouseEventButton(pub ::core::ffi::c_int); +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl Input_TouchEventAction { + /// Touch cancelled. + pub const TOUCH_ACTION_CANCEL: Input_TouchEventAction = Input_TouchEventAction(0); +} +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl Input_TouchEventAction { + /// Touch pressed. + pub const TOUCH_ACTION_DOWN: Input_TouchEventAction = Input_TouchEventAction(1); +} +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl Input_TouchEventAction { + /// Touch moved. + pub const TOUCH_ACTION_MOVE: Input_TouchEventAction = Input_TouchEventAction(2); +} +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl Input_TouchEventAction { + /// Touch lifted. + pub const TOUCH_ACTION_UP: Input_TouchEventAction = Input_TouchEventAction(3); +} +#[repr(transparent)] +/// Enumerated values of touch event action. +/// +/// +/// Available since API-level: 12 +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct Input_TouchEventAction(pub ::core::ffi::c_uint); +#[cfg(feature = "api-13")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))] +impl Input_KeyboardType { + /// Keyboard without keys + pub const KEYBOARD_TYPE_NONE: Input_KeyboardType = Input_KeyboardType(0); +} +#[cfg(feature = "api-13")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))] +impl Input_KeyboardType { + /// Keyboard with unknown keys + pub const KEYBOARD_TYPE_UNKNOWN: Input_KeyboardType = Input_KeyboardType(1); +} +#[cfg(feature = "api-13")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))] +impl Input_KeyboardType { + /// Full keyboard + pub const KEYBOARD_TYPE_ALPHABETIC: Input_KeyboardType = Input_KeyboardType(2); +} +#[cfg(feature = "api-13")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))] +impl Input_KeyboardType { + /// Digital keyboard + pub const KEYBOARD_TYPE_DIGITAL: Input_KeyboardType = Input_KeyboardType(3); +} +#[cfg(feature = "api-13")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))] +impl Input_KeyboardType { + /// Stylus + pub const KEYBOARD_TYPE_STYLUS: Input_KeyboardType = Input_KeyboardType(4); +} +#[cfg(feature = "api-13")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))] +impl Input_KeyboardType { + /// Remote control + pub const KEYBOARD_TYPE_REMOTE_CONTROL: Input_KeyboardType = Input_KeyboardType(5); +} +#[repr(transparent)] +/// Enumerates keyboard types. +/// +/// +/// Available since API-level: 13 +#[cfg(feature = "api-13")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct Input_KeyboardType(pub ::core::ffi::c_uint); +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl InputEvent_SourceType { + /// Indicates that the input source generates events similar to mouse cursor movement, + /// button press and release, and wheel scrolling. + /// + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub const SOURCE_TYPE_MOUSE: InputEvent_SourceType = InputEvent_SourceType(1); +} +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl InputEvent_SourceType { + /// Indicates that the input source generates a touchscreen multi-touch event. + /// + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub const SOURCE_TYPE_TOUCHSCREEN: InputEvent_SourceType = InputEvent_SourceType(2); +} +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl InputEvent_SourceType { + /// Indicates that the input source generates a touchpad multi-touch event. + /// + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub const SOURCE_TYPE_TOUCHPAD: InputEvent_SourceType = InputEvent_SourceType(3); +} +#[repr(transparent)] +/// Enumerates event source types. +/// +/// +/// Available since API-level: 12 +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct InputEvent_SourceType(pub ::core::ffi::c_uint); +#[repr(C)] +pub struct Input_KeyState { + _unused: [u8; 0], +} +#[repr(C)] +pub struct Input_KeyEvent { + _unused: [u8; 0], +} +#[repr(C)] +pub struct Input_MouseEvent { + _unused: [u8; 0], +} +#[repr(C)] +pub struct Input_TouchEvent { + _unused: [u8; 0], +} +#[repr(C)] +pub struct Input_AxisEvent { + _unused: [u8; 0], +} +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl Input_Result { + /// Success return code on success + pub const INPUT_SUCCESS: Input_Result = Input_Result(0); +} +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl Input_Result { + /// Permission verification failed + pub const INPUT_PERMISSION_DENIED: Input_Result = Input_Result(201); +} +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl Input_Result { + /// Non-system application + pub const INPUT_NOT_SYSTEM_APPLICATION: Input_Result = Input_Result(202); +} +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl Input_Result { + /// Parameter check failed + pub const INPUT_PARAMETER_ERROR: Input_Result = Input_Result(401); +} +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl Input_Result { + /// Service error + pub const INPUT_SERVICE_EXCEPTION: Input_Result = Input_Result(3800001); +} +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +impl Input_Result { + /// Interceptor repeatedly created for an application + pub const INPUT_REPEAT_INTERCEPTOR: Input_Result = Input_Result(4200001); +} +#[repr(transparent)] +/// Enumerates error codes. +/// +/// +/// Available since API-level: 12 +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct Input_Result(pub ::core::ffi::c_uint); +#[repr(C)] +pub struct Input_DeviceInfo { + _unused: [u8; 0], +} +/// Defines a lifecycle callback for keyEvent. If the callback is triggered, keyEvent will be destroyed. +/// +/// # Arguments +/// +/// * `keyEvent` - Key event object. +/// +/// Available since API-level: 12 +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +pub type Input_KeyEventCallback = + ::core::option::Option; +/// Defines a lifecycle callback for mouseEvent. If the callback is triggered, mouseEvent will be destroyed. +/// +/// # Arguments +/// +/// * `mouseEvent` - Mouse event object. +/// +/// Available since API-level: 12 +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +pub type Input_MouseEventCallback = + ::core::option::Option; +/// Defines a lifecycle callback for touchEvent. If the callback is triggered, touchEvent will be destroyed. +/// +/// # Arguments +/// +/// * `touchEvent` - Touch event object. +/// +/// Available since API-level: 12 +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +pub type Input_TouchEventCallback = + ::core::option::Option; +/// Defines a lifecycle callback for axisEvent. If the callback is triggered, axisEvent will be destroyed. +/// +/// # Arguments +/// +/// * `axisEvent` - Axis event object. +/// +/// Available since API-level: 12 +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +pub type Input_AxisEventCallback = + ::core::option::Option; +/// Defines the callback for device addition events. +/// # Arguments +/// +/// * `deviceId` - Device ID. +/// +/// Available since API-level: 13 +#[cfg(feature = "api-13")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))] +pub type Input_DeviceAddedCallback = ::core::option::Option; +/// Defines the callback for device removal events. +/// # Arguments +/// +/// * `deviceId` - Device ID. +/// +/// Available since API-level: 13 +#[cfg(feature = "api-13")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))] +pub type Input_DeviceRemovedCallback = ::core::option::Option; +/// Defines the structure for the interceptor of event callbacks, +/// including mouseCallback, touchCallback, and axisCallback. +/// +/// Available since API-level: 12 +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct Input_InterceptorEventCallback { + /// Defines a lifecycle callback for **mouseEvent**. + pub mouseCallback: Input_MouseEventCallback, + /// Defines a lifecycle callback for **touchEvent**. + pub touchCallback: Input_TouchEventCallback, + /// Defines a lifecycle callback for **axisEvent**. + pub axisCallback: Input_AxisEventCallback, +} +/// Defines a listener for device insertion and removal events. +/// +/// Available since API-level: 13 +#[cfg(feature = "api-13")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct Input_DeviceListener { + /// Callback for device addition events + pub deviceAddedCallback: Input_DeviceAddedCallback, + /// Callback for device removal events + pub deviceRemovedCallback: Input_DeviceRemovedCallback, +} +#[repr(C)] +pub struct Input_InterceptorOptions { + _unused: [u8; 0], +} +extern "C" { + /// Queries the key state. + /// + /// # Arguments + /// + /// * `keyState` - Key state. + /// + /// # Returns + /// + /// * OH_Input_GetKeyState function result code. + /// [`INPUT_SUCCESS`] get KeyState success. + /// + /// [`INPUT_PARAMETER_ERROR`] keyCode is invalid. + /// + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_GetKeyState(keyState: *mut Input_KeyState) -> Input_Result; + /// Creates a key status enumeration object. + /// + /// + /// # Returns + /// + /// * Returns an [`Input_KeyState`] pointer object if the operation is successful. + /// Otherwise, a null pointer is returned. The possible cause is memory allocation failure. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_CreateKeyState() -> *mut Input_KeyState; + /// Destroys a key status enumeration object. + /// + /// # Arguments + /// + /// * `keyState` - Key status enumeration object. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_DestroyKeyState(keyState: *mut *mut Input_KeyState); + /// Sets the key value of a key status enumeration object. + /// + /// # Arguments + /// + /// * `keyState` - Key status enumeration object. + /// + /// * `keyCode` - Key value of the key status enumeration object. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_SetKeyCode(keyState: *mut Input_KeyState, keyCode: i32); + /// Obtains the key value of a key status enumeration object. + /// + /// # Arguments + /// + /// * `keyState` - Key status enumeration object. + /// + /// # Returns + /// + /// * Key value of the key status enumeration object. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_GetKeyCode(keyState: *const Input_KeyState) -> i32; + /// Sets whether the key specific to a key status enumeration object is pressed. + /// + /// # Arguments + /// + /// * `keyState` - Key status enumeration object. + /// + /// * `keyAction` - Whether the key is pressed. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_SetKeyPressed(keyState: *mut Input_KeyState, keyAction: i32); + /// Checks whether the key specific to a key status enumeration object is pressed. + /// + /// # Arguments + /// + /// * `keyState` - Key status enumeration object. + /// + /// # Returns + /// + /// * Key pressing status of the key status enumeration object. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_GetKeyPressed(keyState: *const Input_KeyState) -> i32; + /// Sets the key switch of the key status enumeration object. + /// + /// # Arguments + /// + /// * `keyState` - Key status enumeration object. + /// + /// * `keySwitch` - Key switch of the key status enumeration object. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_SetKeySwitch(keyState: *mut Input_KeyState, keySwitch: i32); + /// Obtains the key switch of the key status enumeration object. + /// + /// # Arguments + /// + /// * `keyState` - Key status enumeration object. + /// + /// # Returns + /// + /// * Key switch of the key status enumeration object. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_GetKeySwitch(keyState: *const Input_KeyState) -> i32; + /// Inject system keys. + /// + /// # Arguments + /// + /// * `keyEvent` - - the key event to be injected. + /// + /// # Returns + /// + /// * OH_Input_InjectKeyEvent function result code. + /// [`INPUT_SUCCESS`] inject keyEvent success. + /// + /// [`INPUT_PERMISSION_DENIED`] Permission verification failed. + /// + /// [`INPUT_PARAMETER_ERROR`] keyCode is less 0, can not process. + /// + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_InjectKeyEvent(keyEvent: *const Input_KeyEvent) -> i32; + /// Creates a key event object. + /// + /// + /// # Returns + /// + /// * Returns an [`Input_KeyEvent`] pointer object if the operation is successful. + /// Otherwise, a null pointer is returned. The possible cause is memory allocation failure. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_CreateKeyEvent() -> *mut Input_KeyEvent; + /// Destroys a key event object. + /// + /// # Arguments + /// + /// * `keyEvent` - Key event object. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_DestroyKeyEvent(keyEvent: *mut *mut Input_KeyEvent); + /// Sets the key event type. + /// + /// # Arguments + /// + /// * `keyEvent` - Key event object. + /// + /// * `action` - Key event type. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_SetKeyEventAction(keyEvent: *mut Input_KeyEvent, action: i32); + /// Obtains the key event type. + /// + /// # Arguments + /// + /// * `keyEvent` - Key event object. + /// + /// # Returns + /// + /// * Key event type. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_GetKeyEventAction(keyEvent: *const Input_KeyEvent) -> i32; + /// Sets the key value for a key event. + /// + /// # Arguments + /// + /// * `keyEvent` - Key event object. + /// + /// * `keyCode` - keyCode Key code. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_SetKeyEventKeyCode(keyEvent: *mut Input_KeyEvent, keyCode: i32); + /// Obtains the key value of a key event. + /// + /// # Arguments + /// + /// * `keyEvent` - Key event object. + /// + /// # Returns + /// + /// * Key code. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_GetKeyEventKeyCode(keyEvent: *const Input_KeyEvent) -> i32; + /// Sets the time when a key event occurs. + /// + /// # Arguments + /// + /// * `keyEvent` - Key event object. + /// + /// * `actionTime` - Time when the key event occurs. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_SetKeyEventActionTime(keyEvent: *mut Input_KeyEvent, actionTime: i64); + /// Obtains the time when a key event occurs. + /// + /// # Arguments + /// + /// * `keyEvent` - Key event object. + /// + /// # Returns + /// + /// * Returns the time when the key event occurs. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_GetKeyEventActionTime(keyEvent: *const Input_KeyEvent) -> i64; + /// Inject mouse event. + /// + /// # Arguments + /// + /// * `mouseEvent` - - the mouse event to be injected. + /// + /// # Returns + /// + /// * OH_Input_InjectMouseEvent function result code. + /// [`INPUT_SUCCESS`] inject mouseEvent success. + /// + /// [`INPUT_PERMISSION_DENIED`] Permission verification failed. + /// + /// [`INPUT_PARAMETER_ERROR`] Parameter check failed. + /// + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_InjectMouseEvent(mouseEvent: *const Input_MouseEvent) -> i32; + /// Creates a mouse event object. + /// + /// + /// # Returns + /// + /// * Returns an [`Input_MouseEvent`] pointer object if the operation is successful. + /// Otherwise, a null pointer is returned. The possible cause is memory allocation failure. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_CreateMouseEvent() -> *mut Input_MouseEvent; + /// Destroys a mouse event object. + /// + /// # Arguments + /// + /// * `mouseEvent` - Mouse event object. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_DestroyMouseEvent(mouseEvent: *mut *mut Input_MouseEvent); + /// Sets the action for a mouse event. + /// + /// # Arguments + /// + /// * `mouseEvent` - Mouse event object. + /// + /// * `action` - Mouse action. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_SetMouseEventAction(mouseEvent: *mut Input_MouseEvent, action: i32); + /// Obtains the action of a mouse event. + /// + /// # Arguments + /// + /// * `mouseEvent` - Mouse event object. + /// + /// # Returns + /// + /// * Mouse action. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_GetMouseEventAction(mouseEvent: *const Input_MouseEvent) -> i32; + /// Sets the X coordinate for a mouse event. + /// + /// # Arguments + /// + /// * `mouseEvent` - Mouse event object. + /// + /// * `displayX` - X coordinate on the display. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_SetMouseEventDisplayX(mouseEvent: *mut Input_MouseEvent, displayX: i32); + /// Obtains the X coordinate of a mouse event. + /// + /// # Arguments + /// + /// * `mouseEvent` - Mouse event object. + /// + /// # Returns + /// + /// * X coordinate on the display. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_GetMouseEventDisplayX(mouseEvent: *const Input_MouseEvent) -> i32; + /// Sets the Y coordinate for a mouse event. + /// + /// # Arguments + /// + /// * `mouseEvent` - Mouse event object. + /// + /// * `displayY` - Y coordinate on the display. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_SetMouseEventDisplayY(mouseEvent: *mut Input_MouseEvent, displayY: i32); + /// Obtains the Y coordinate of a mouse event. + /// + /// # Arguments + /// + /// * `mouseEvent` - Mouse event object. + /// + /// # Returns + /// + /// * Y coordinate on the display. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_GetMouseEventDisplayY(mouseEvent: *const Input_MouseEvent) -> i32; + /// Sets the button for a mouse event. + /// + /// # Arguments + /// + /// * `mouseEvent` - Mouse event object. + /// + /// * `button` - Mouse button. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_SetMouseEventButton(mouseEvent: *mut Input_MouseEvent, button: i32); + /// Obtains the button of a mouse event. + /// + /// # Arguments + /// + /// * `mouseEvent` - Mouse event object. + /// + /// # Returns + /// + /// * Mouse button. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_GetMouseEventButton(mouseEvent: *const Input_MouseEvent) -> i32; + /// Sets the axis type for mouse event. + /// + /// # Arguments + /// + /// * `mouseEvent` - Mouse event object. + /// + /// * `axisType` - Axis type, for example, X axis or Y axis. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_SetMouseEventAxisType(mouseEvent: *mut Input_MouseEvent, axisType: i32); + /// Obtains the axis type of a mouse event. + /// + /// # Arguments + /// + /// * `mouseEvent` - Mouse event object. + /// + /// # Returns + /// + /// * Axis type. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_GetMouseEventAxisType(mouseEvent: *const Input_MouseEvent) -> i32; + /// Sets the axis value for a mouse axis event. + /// + /// # Arguments + /// + /// * `mouseEvent` - Mouse event object. + /// + /// * `axisType` - Axis value. A positive value means scrolling forward, + /// and a negative number means scrolling backward. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_SetMouseEventAxisValue(mouseEvent: *mut Input_MouseEvent, axisValue: f32); + /// Obtains the axis value of a mouse event. + /// + /// # Arguments + /// + /// * `mouseEvent` - Mouse event object. + /// + /// # Returns + /// + /// * Axis value. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_GetMouseEventAxisValue(mouseEvent: *const Input_MouseEvent) -> f32; + /// Sets the time when a mouse event occurs. + /// + /// # Arguments + /// + /// * `mouseEvent` - Mouse event object. + /// + /// * `actionTime` - Time when the mouse event occurs. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_SetMouseEventActionTime(mouseEvent: *mut Input_MouseEvent, actionTime: i64); + /// Obtains the time when a mouse event occurs. + /// + /// # Arguments + /// + /// * `keyEvent` - Mouse event object. + /// + /// # Returns + /// + /// * Returns the time when the mouse event occurs. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_GetMouseEventActionTime(mouseEvent: *const Input_MouseEvent) -> i64; + /// Inject touch event. + /// + /// # Arguments + /// + /// * `touchEvent` - - the touch event to be injected. + /// + /// # Returns + /// + /// * OH_Input_InjectTouchEvent function result code. + /// [`INPUT_SUCCESS`] inject touchEvent success. + /// + /// [`INPUT_PARAMETER_ERROR`] Parameter check failed. + /// + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_InjectTouchEvent(touchEvent: *const Input_TouchEvent) -> i32; + /// Creates a touch event object. + /// + /// + /// # Returns + /// + /// * Returns an [`Input_TouchEvent`] pointer object if the operation is successful. + /// Otherwise, a null pointer is returned. The possible cause is memory allocation failure. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_CreateTouchEvent() -> *mut Input_TouchEvent; + /// Destroys a touch event object. + /// + /// # Arguments + /// + /// * `touchEvent` - Touch event object. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_DestroyTouchEvent(touchEvent: *mut *mut Input_TouchEvent); + /// Sets the action for a touch event. + /// + /// # Arguments + /// + /// * `touchEvent` - Touch event object. + /// + /// * `action` - Touch action. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_SetTouchEventAction(touchEvent: *mut Input_TouchEvent, action: i32); + /// Obtains the action of a touch event. + /// + /// # Arguments + /// + /// * `touchEvent` - Touch event object. + /// + /// # Returns + /// + /// * Touch action. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_GetTouchEventAction(touchEvent: *const Input_TouchEvent) -> i32; + /// Sets the finger ID for the touch event. + /// + /// # Arguments + /// + /// * `touchEvent` - Touch event object. + /// + /// * `id` - Finger ID. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_SetTouchEventFingerId(touchEvent: *mut Input_TouchEvent, id: i32); + /// Obtains the finger ID of a touch event. + /// + /// # Arguments + /// + /// * `touchEvent` - Touch event object. + /// + /// # Returns + /// + /// * Finger ID. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_GetTouchEventFingerId(touchEvent: *const Input_TouchEvent) -> i32; + /// Sets the X coordinate for a touch event. + /// + /// # Arguments + /// + /// * `touchEvent` - Touch event object. + /// + /// * `displayX` - X coordinate. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_SetTouchEventDisplayX(touchEvent: *mut Input_TouchEvent, displayX: i32); + /// Obtains the X coordinate of a touch event. + /// + /// # Arguments + /// + /// * `touchEvent` - Touch event object. + /// + /// # Returns + /// + /// * X coordinate. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_GetTouchEventDisplayX(touchEvent: *const Input_TouchEvent) -> i32; + /// Sets the Y coordinate for a touch event. + /// + /// # Arguments + /// + /// * `touchEvent` - Touch event object. + /// + /// * `displayY` - Y coordinate. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_SetTouchEventDisplayY(touchEvent: *mut Input_TouchEvent, displayY: i32); + /// Obtains the Y coordinate of a touch event. + /// + /// # Arguments + /// + /// * `touchEvent` - Touch event object. + /// + /// # Returns + /// + /// * Y coordinate. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_GetTouchEventDisplayY(touchEvent: *const Input_TouchEvent) -> i32; + /// Sets the time when a touch event occurs. + /// + /// # Arguments + /// + /// * `keyEvent` - Touch event object. + /// + /// * `actionTime` - Time when the touch event occurs. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_SetTouchEventActionTime(touchEvent: *mut Input_TouchEvent, actionTime: i64); + /// Obtains the time when a touch event occurs. + /// + /// # Arguments + /// + /// * `keyEvent` - touch event object. + /// + /// # Returns + /// + /// * Returns the time when the touch event occurs. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_GetTouchEventActionTime(touchEvent: *const Input_TouchEvent) -> i64; + /// Cancels event injection and revokes authorization. + /// + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_CancelInjection(); + /// Creates an axis event object. + /// + /// + /// # Returns + /// + /// * If the operation is successful, a [`Input_AxisEvent`] object is returned. + /// If the operation fails, null is returned. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_CreateAxisEvent() -> *mut Input_AxisEvent; + /// Destroys an axis event object. + /// + /// # Arguments + /// + /// * `axisEvent` - Pointer to the axis event object. + /// + /// # Returns + /// + /// * OH_Input_DestroyAxisEvent function result code. + /// [`INPUT_SUCCESS`] Destroys axisEvent success. + /// + /// [`INPUT_PARAMETER_ERROR`]The axisEvent is NULL or the *axisEvent is NULL. + /// + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_DestroyAxisEvent(axisEvent: *mut *mut Input_AxisEvent) -> Input_Result; + /// Sets the axis event action. + /// + /// # Arguments + /// + /// * `axisEvent` - Axis event object. For details, see [`Input_AxisEvent`]. + /// + /// * `action` - Axis event action. The values are defined in [`InputEvent_AxisAction`]. + /// + /// # Returns + /// + /// * OH_Input_SetAxisEventAction function result code. + /// [`INPUT_SUCCESS`] Sets the axis event action success. + /// + /// [`INPUT_PARAMETER_ERROR`] The axisEvent is NULL. + /// + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_SetAxisEventAction( + axisEvent: *mut Input_AxisEvent, + action: InputEvent_AxisAction, + ) -> Input_Result; + /// Obtains the axis event action. + /// + /// # Arguments + /// + /// * `axisEvent` - Axis event object. For details, see [`Input_AxisEvent`]. + /// + /// * `action` - Axis event action. The values are defined in [`InputEvent_AxisAction`]. + /// + /// # Returns + /// + /// * OH_Input_GetAxisEventAction function result code. + /// [`INPUT_SUCCESS`] Obtains the axis event action success. + /// + /// [`INPUT_PARAMETER_ERROR`] The axisEvent is NULL or the action is NULL. + /// + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_GetAxisEventAction( + axisEvent: *const Input_AxisEvent, + action: *mut InputEvent_AxisAction, + ) -> Input_Result; + /// Sets the X coordinate of an axis event. + /// + /// # Arguments + /// + /// * `axisEvent` - Axis event object. For details, see [`Input_AxisEvent`]. + /// + /// * `displayX` - X coordinate of the axis event. + /// + /// # Returns + /// + /// * OH_Input_SetAxisEventDisplayX function result code. + /// [`INPUT_SUCCESS`] Sets the X coordinate of the axis event success. + /// + /// [`INPUT_PARAMETER_ERROR`] The axisEvent is NULL. + /// + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_SetAxisEventDisplayX( + axisEvent: *mut Input_AxisEvent, + displayX: f32, + ) -> Input_Result; + /// Obtains the X coordinate of an axis event. + /// + /// # Arguments + /// + /// * `axisEvent` - Axis event object. For details, see [`Input_AxisEvent`]. + /// + /// * `displayX` - X coordinate of the axis event. + /// + /// # Returns + /// + /// * OH_Input_GetAxisEventDisplayX function result code. + /// [`INPUT_SUCCESS`] Obtains the X coordinate of the axis event success. + /// + /// [`INPUT_PARAMETER_ERROR`] The axisEvent is NULL or the displayX is NULL. + /// + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_GetAxisEventDisplayX( + axisEvent: *const Input_AxisEvent, + displayX: *mut f32, + ) -> Input_Result; + /// Sets the Y coordinate of an axis event. + /// + /// # Arguments + /// + /// * `axisEvent` - Axis event object. For details, see [`Input_AxisEvent`]. + /// + /// * `displayY` - Y coordinate of the axis event. + /// + /// # Returns + /// + /// * OH_Input_SetAxisEventDisplayY function result code. + /// [`INPUT_SUCCESS`] Sets the Y coordinate of the axis event success. + /// + /// [`INPUT_PARAMETER_ERROR`] The axisEvent is NULL. + /// + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_SetAxisEventDisplayY( + axisEvent: *mut Input_AxisEvent, + displayY: f32, + ) -> Input_Result; + /// Obtains the Y coordinate of an axis event. + /// + /// # Arguments + /// + /// * `axisEvent` - Axis event object. For details, see [`Input_AxisEvent`]. + /// + /// * `displayY` - Y coordinate of the axis event. + /// + /// # Returns + /// + /// * OH_Input_GetAxisEventDisplayY function result code. + /// [`INPUT_SUCCESS`] Obtains the Y coordinate of the axis event success. + /// + /// [`INPUT_PARAMETER_ERROR`] The axisEvent is NULL or the displayY is NULL. + /// + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_GetAxisEventDisplayY( + axisEvent: *const Input_AxisEvent, + displayY: *mut f32, + ) -> Input_Result; + /// Sets the axis value of the axis type specified by the axis event. + /// + /// # Arguments + /// + /// * `axisEvent` - Axis event object. For details, see [`Input_AxisEvent`]. + /// + /// * `axisType` - Axis type. The values are defined in [`InputEvent_AxisType`]. + /// + /// * `axisValue` - Axis value. + /// + /// # Returns + /// + /// * OH_Input_SetAxisEventAxisValue function result code. + /// [`INPUT_SUCCESS`] Sets the axis value of the axis event success. + /// + /// [`INPUT_PARAMETER_ERROR`] The axisEvent is NULL. + /// + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_SetAxisEventAxisValue( + axisEvent: *mut Input_AxisEvent, + axisType: InputEvent_AxisType, + axisValue: f64, + ) -> Input_Result; + /// Obtains the axis value for the specified axis type of the axis event. + /// + /// # Arguments + /// + /// * `axisEvent` - Axis event object. For details, see [`Input_AxisEvent`]. + /// + /// * `axisType` - Axis type. The values are defined in [`InputEvent_AxisType`]. + /// + /// * `axisValue` - Axis value. + /// + /// # Returns + /// + /// * OH_Input_GetAxisEventAxisValue function result code. + /// [`INPUT_SUCCESS`] Obtains the axis value of the axis event success. + /// + /// [`INPUT_PARAMETER_ERROR`] The axisEvent is NULL or the axisValue is NULL, + /// or the axisType not found in the axisEvent. + /// + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_GetAxisEventAxisValue( + axisEvent: *const Input_AxisEvent, + axisType: InputEvent_AxisType, + axisValue: *mut f64, + ) -> Input_Result; + /// Sets the time when an axis event occurs. + /// + /// # Arguments + /// + /// * `axisEvent` - Axis event object. For details, see [`Input_AxisEvent`]. + /// + /// * `actionTime` - Time when an axis event occurs. + /// + /// # Returns + /// + /// * OH_Input_SetAxisEventActionTime function result code. + /// [`INPUT_SUCCESS`] Sets the time when an axis event occurs success. + /// + /// [`INPUT_PARAMETER_ERROR`] The axisEvent is NULL. + /// + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_SetAxisEventActionTime( + axisEvent: *mut Input_AxisEvent, + actionTime: i64, + ) -> Input_Result; + /// Obtains the time when an axis event occurs. + /// + /// # Arguments + /// + /// * `axisEvent` - Axis event object. For details, see [`Input_AxisEvent`]. + /// + /// * `actionTime` - Time when an axis event occurs. + /// + /// # Returns + /// + /// * OH_Input_GetAxisEventActionTime function result code. + /// [`INPUT_SUCCESS`] Obtains the time when an axis event occurs success. + /// + /// [`INPUT_PARAMETER_ERROR`] The axisEvent is NULL or the actionTime is NULL. + /// + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_GetAxisEventActionTime( + axisEvent: *const Input_AxisEvent, + actionTime: *mut i64, + ) -> Input_Result; + /// Sets the axis event type. + /// + /// # Arguments + /// + /// * `axisEvent` - Axis event object. For details, see [`Input_AxisEvent`]. + /// + /// * `axisEventType` - Axis event type. The values are defined in [`InputEvent_AxisEventType`]. + /// + /// # Returns + /// + /// * OH_Input_SetAxisEventType function result code. + /// [`INPUT_SUCCESS`] Sets the axis event type success. + /// + /// [`INPUT_PARAMETER_ERROR`] The axisEvent is NULL. + /// + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_SetAxisEventType( + axisEvent: *mut Input_AxisEvent, + axisEventType: InputEvent_AxisEventType, + ) -> Input_Result; + /// Obtains the axis event type. + /// + /// # Arguments + /// + /// * `axisEvent` - Axis event object. + /// + /// * `axisEventType` - Axis event type. The values are defined in [`InputEvent_AxisEventType`]. + /// + /// # Returns + /// + /// * OH_Input_GetAxisEventType function result code. + /// [`INPUT_SUCCESS`] Obtains the axis event type success. + /// + /// [`INPUT_PARAMETER_ERROR`] The axisEvent is NULL or the axisEventType is NULL. + /// + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_GetAxisEventType( + axisEvent: *const Input_AxisEvent, + axisEventType: *mut InputEvent_AxisEventType, + ) -> Input_Result; + /// Sets the axis event source type. + /// + /// # Arguments + /// + /// * `axisEvent` - Axis event object. + /// + /// * `sourceType` - Axis event source type. The values are defined in [`InputEvent_SourceType`]. + /// + /// # Returns + /// + /// * OH_Input_SetAxisEventSourceType function result code. + /// [`INPUT_SUCCESS`] Sets the axis event source type success. + /// + /// [`INPUT_PARAMETER_ERROR`] The axisEvent is NULL. + /// + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_SetAxisEventSourceType( + axisEvent: *mut Input_AxisEvent, + sourceType: InputEvent_SourceType, + ) -> Input_Result; + /// Obtains the axis event source type. + /// + /// # Arguments + /// + /// * `axisEvent` - Axis event object. + /// + /// * `axisEventType` - Axis event source type. The values are defined in [`InputEvent_SourceType`]. + /// + /// # Returns + /// + /// * OH_Input_GetAxisEventSourceType function result code. + /// [`INPUT_SUCCESS`] Obtains the axis event source type success. + /// + /// [`INPUT_PARAMETER_ERROR`] The axisEvent is NULL or the sourceType is NULL. + /// + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_GetAxisEventSourceType( + axisEvent: *const Input_AxisEvent, + sourceType: *mut InputEvent_SourceType, + ) -> Input_Result; + /// Adds a listener of key events. + /// + /// ohos.permission.INPUT_MONITORING + /// # Arguments + /// + /// * `callback` - - Callback used to receive key events. + /// + /// # Returns + /// + /// * OH_Input_AddKeyEventMonitor function result code. + /// [`INPUT_SUCCESS`] Adds a listener of key events success. + /// + /// [`INPUT_PERMISSION_DENIED`] Permission verification failed. + /// + /// [`INPUT_PARAMETER_ERROR`] The callback is NULL. + /// + /// [`INPUT_SERVICE_EXCEPTION`] Failed to add the monitor because the service is exception. + /// + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_AddKeyEventMonitor(callback: Input_KeyEventCallback) -> Input_Result; + /// Adds a listener for mouse events, including mouse click and movement events, + /// but not scroll wheel events. Scroll wheel events are axis events. + /// + /// ohos.permission.INPUT_MONITORING + /// # Arguments + /// + /// * `callback` - - Callback used to receive mouse events. + /// + /// # Returns + /// + /// * OH_Input_AddMouseEventMonitor function result code. + /// [`INPUT_SUCCESS`] Adds a listener of mouse events success. + /// + /// [`INPUT_PERMISSION_DENIED`] Permission verification failed. + /// + /// [`INPUT_PARAMETER_ERROR`] The callback is NULL. + /// + /// [`INPUT_SERVICE_EXCEPTION`] Failed to add the monitor because the service is exception. + /// + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_AddMouseEventMonitor(callback: Input_MouseEventCallback) -> Input_Result; + /// Add a listener for touch events. + /// + /// ohos.permission.INPUT_MONITORING + /// # Arguments + /// + /// * `callback` - - Callback used to receive touch events. + /// + /// # Returns + /// + /// * OH_Input_AddTouchEventMonitor function result code. + /// [`INPUT_SUCCESS`] Adds a listener of touch events success. + /// + /// [`INPUT_PERMISSION_DENIED`] Permission verification failed. + /// + /// [`INPUT_PARAMETER_ERROR`] The callback is NULL. + /// + /// [`INPUT_SERVICE_EXCEPTION`] Failed to add the monitor because the service is exception. + /// + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_AddTouchEventMonitor(callback: Input_TouchEventCallback) -> Input_Result; + /// Adds a listener for all types of axis events. + /// The axis event types are defined in [`InputEvent_AxisEventType`]. + /// + /// ohos.permission.INPUT_MONITORING + /// # Arguments + /// + /// * `callback` - - Callback used to receive axis events. + /// + /// # Returns + /// + /// * OH_Input_AddAxisEventMonitorForAll function result code. + /// [`INPUT_SUCCESS`] Adds a listener for all types of axis events success. + /// + /// [`INPUT_PERMISSION_DENIED`] Permission verification failed. + /// + /// [`INPUT_PARAMETER_ERROR`] The callback is NULL. + /// + /// [`INPUT_SERVICE_EXCEPTION`] Failed to add the monitor because the service is exception. + /// + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_AddAxisEventMonitorForAll(callback: Input_AxisEventCallback) -> Input_Result; + /// Adds a listener for the specified type of axis events. + /// + /// ohos.permission.INPUT_MONITORING + /// # Arguments + /// + /// * `axisEventType` - - Axis event type. The values are defined in [`InputEvent_AxisEventType`]. + /// + /// * `callback` - - Callback used to receive the specified type of axis events. + /// + /// # Returns + /// + /// * OH_Input_AddAxisEventMonitor function result code. + /// [`INPUT_SUCCESS`] Adds a listener for the specified types of axis events success. + /// + /// [`INPUT_PERMISSION_DENIED`] Permission verification failed. + /// + /// [`INPUT_PARAMETER_ERROR`] The callback is NULL. + /// + /// [`INPUT_SERVICE_EXCEPTION`] Failed to add the monitor because the service is exception. + /// + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_AddAxisEventMonitor( + axisEventType: InputEvent_AxisEventType, + callback: Input_AxisEventCallback, + ) -> Input_Result; + /// Removes a key event listener. + /// + /// ohos.permission.INPUT_MONITORING + /// # Arguments + /// + /// * `callback` - - Callback for the key event listener. + /// + /// # Returns + /// + /// * OH_Input_RemoveKeyEventMonitor function result code. + /// [`INPUT_SUCCESS`] Removes a key event listener success. + /// + /// [`INPUT_PERMISSION_DENIED`] Permission verification failed. + /// + /// [`INPUT_PARAMETER_ERROR`] The callback is NULL or has not been added. + /// + /// [`INPUT_SERVICE_EXCEPTION`] Fail to remove the monitor because the service is exception. + /// + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_RemoveKeyEventMonitor(callback: Input_KeyEventCallback) -> Input_Result; + /// Removes a mouse event listener. + /// + /// ohos.permission.INPUT_MONITORING + /// # Arguments + /// + /// * `callback` - - Callback for the mouse event listener. + /// + /// # Returns + /// + /// * OH_Input_RemoveMouseEventMonitor function result code. + /// [`INPUT_SUCCESS`] Removes a mouse event listener success. + /// + /// [`INPUT_PERMISSION_DENIED`] Permission verification failed. + /// + /// [`INPUT_PARAMETER_ERROR`] The callback is NULL or has not been added. + /// + /// [`INPUT_SERVICE_EXCEPTION`] Fail to remove the monitor because the service is exception. + /// + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_RemoveMouseEventMonitor(callback: Input_MouseEventCallback) -> Input_Result; + /// Removes a touch event listener. + /// + /// ohos.permission.INPUT_MONITORING + /// # Arguments + /// + /// * `callback` - - Callback for the touch event listener. + /// + /// # Returns + /// + /// * OH_Input_RemoveTouchEventMonitor function result code. + /// [`INPUT_SUCCESS`] Removes a touch event listener success. + /// + /// [`INPUT_PERMISSION_DENIED`] Permission verification failed. + /// + /// [`INPUT_PARAMETER_ERROR`] The callback is NULL or has not been added. + /// + /// [`INPUT_SERVICE_EXCEPTION`] Fail to remove the monitor because the service is exception. + /// + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_RemoveTouchEventMonitor(callback: Input_TouchEventCallback) -> Input_Result; + /// Removes the listener for all types of axis events. + /// + /// ohos.permission.INPUT_MONITORING + /// # Arguments + /// + /// * `callback` - - Callback for the listener used to listen for all types of axis events. + /// + /// # Returns + /// + /// * OH_Input_RemoveAxisEventMonitorForAll function result code. + /// [`INPUT_SUCCESS`] Removes the listener for all types of axis events success. + /// + /// [`INPUT_PERMISSION_DENIED`] Permission verification failed. + /// + /// [`INPUT_PARAMETER_ERROR`] The callback is NULL or has not been added. + /// + /// [`INPUT_SERVICE_EXCEPTION`] Fail to remove the monitor because the service is exception. + /// + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_RemoveAxisEventMonitorForAll(callback: Input_AxisEventCallback) + -> Input_Result; + /// Removes the listener for the specified type of axis events. + /// + /// ohos.permission.INPUT_MONITORING + /// # Arguments + /// + /// * `axisEventType` - - Axis event type. The axis event type is defined in [`InputEvent_AxisEventType`]. + /// + /// * `callback` - - Callback for the listener used to listen for the specified type of axis events. + /// + /// # Returns + /// + /// * OH_Input_RemoveAxisEventMonitor function result code. + /// [`INPUT_SUCCESS`] Removes the listener for the specified type of axis events success. + /// + /// [`INPUT_PERMISSION_DENIED`] Permission verification failed. + /// + /// [`INPUT_PARAMETER_ERROR`] The callback is NULL or has not been added. + /// + /// [`INPUT_SERVICE_EXCEPTION`] Fail to remove the monitor because the service is exception. + /// + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_RemoveAxisEventMonitor( + axisEventType: InputEvent_AxisEventType, + callback: Input_AxisEventCallback, + ) -> Input_Result; + /// Adds a key event interceptor. If multiple interceptors are added, only the first one takes effect. + /// + /// ohos.permission.INTERCEPT_INPUT_EVENT + /// # Arguments + /// + /// * `callback` - - Callback used to receive key events. + /// + /// * `option` - - Options for event interception. If **null** is passed, the default value is used. + /// + /// # Returns + /// + /// * OH_Input_AddKeyEventInterceptor function result code. + /// [`INPUT_SUCCESS`] Adds a key event interceptor success. + /// + /// [`INPUT_PERMISSION_DENIED`] Permission verification failed. + /// + /// [`INPUT_PARAMETER_ERROR`] The callback is NULL. + /// + /// [`INPUT_REPEAT_INTERCEPTOR`] Interceptor repeatedly created for an application. + /// + /// [`INPUT_SERVICE_EXCEPTION`] Failed to add the interceptor because the service is exception. + /// + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_AddKeyEventInterceptor( + callback: Input_KeyEventCallback, + option: *mut Input_InterceptorOptions, + ) -> Input_Result; + /// Adds an interceptor for input events, including mouse, touch, and axis events. + /// If multiple interceptors are added, only the first one takes effect. + /// + /// ohos.permission.INTERCEPT_INPUT_EVENT + /// # Arguments + /// + /// * `callback` - - Pointer to the structure of the callback for the input event interceptor. + /// For details, see [`Input_InterceptorEventCallback`]. + /// + /// * `option` - - Options for event interception. If **null** is passed, the default value is used. + /// + /// # Returns + /// + /// * OH_Input_AddInputEventInterceptor function result code. + /// [`INPUT_SUCCESS`] Adds an interceptor for input events success. + /// + /// [`INPUT_PERMISSION_DENIED`] Permission verification failed. + /// + /// [`INPUT_PARAMETER_ERROR`] The callback is NULL. + /// + /// [`INPUT_REPEAT_INTERCEPTOR`] Interceptor repeatedly created for an application. + /// + /// [`INPUT_SERVICE_EXCEPTION`] Failed to add the interceptor because the service is exception. + /// + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_AddInputEventInterceptor( + callback: *mut Input_InterceptorEventCallback, + option: *mut Input_InterceptorOptions, + ) -> Input_Result; + /// Removes a key event interceptor. + /// + /// ohos.permission.INTERCEPT_INPUT_EVENT + /// + /// # Returns + /// + /// * OH_Input_RemoveKeyEventInterceptor function result code. + /// [`INPUT_SUCCESS`]Removes a key event interceptor success. + /// + /// [`INPUT_PERMISSION_DENIED`] Permission verification failed. + /// + /// [`INPUT_SERVICE_EXCEPTION`] Failed to remove the interceptor because the service is exception. + /// + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_RemoveKeyEventInterceptor() -> Input_Result; + /// Removes an interceptor for input events, including mouse, touch, and axis events. + /// + /// ohos.permission.INTERCEPT_INPUT_EVENT + /// + /// # Returns + /// + /// * OH_Input_RemoveInputEventInterceptor function result code. + /// [`INPUT_SUCCESS`] Removes an interceptor for input events success. + /// + /// [`INPUT_PERMISSION_DENIED`] Permission verification failed. + /// + /// [`INPUT_SERVICE_EXCEPTION`] Failed to remove the interceptor because the service is exception. + /// + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 12 + #[cfg(feature = "api-12")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + pub fn OH_Input_RemoveInputEventInterceptor() -> Input_Result; + /// Obtains the IDs of all input devices. + /// + /// # Arguments + /// + /// * `deviceIds` - Array of input device IDs. + /// + /// * `inSize` - Size of the array of input device IDs. + /// + /// * `outSize` - Length of the list of input device IDs. The value cannot be greater than the value of inSize. + /// + /// # Returns + /// + /// * OH_Input_GetDeviceIds result code, specifically, + /// [`INPUT_SUCCESS`] if the operation is successful; + /// [`INPUT_PARAMETER_ERROR`] if deviceIds or outSize is a null pointer or inSize is less than 0. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 13 + #[cfg(feature = "api-13")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-13")))] + pub fn OH_Input_GetDeviceIds( + deviceIds: *mut i32, + inSize: i32, + outSize: *mut i32, + ) -> Input_Result; + /// Obtains the information about an input device. + /// + /// # Arguments + /// + /// * `deviceId` - Device ID. + /// + /// * `deviceInfo` - Pointer to an [`Input_DeviceInfo`] object. + /// + /// # Returns + /// + /// * OH_Input_GetDevice result code, specifically, + /// [`INPUT_SUCCESS`] if the operation is successful; + /// [`INPUT_PARAMETER_ERROR`] if the deviceInfo is a null pointer or the deviceId is invalid. + /// You can use the [`OH_Input_GetDeviceIds`] interface to query the device IDs supported by the system. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 13 + #[cfg(feature = "api-13")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-13")))] + pub fn OH_Input_GetDevice( + deviceId: i32, + deviceInfo: *mut *mut Input_DeviceInfo, + ) -> Input_Result; + /// Creates a deviceInfo object. + /// + /// + /// # Returns + /// + /// * Pointer to an [`Input_DeviceInfo`] object if the operation is successful; + /// a null pointer otherwise (possibly because of a memory allocation failure). + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 13 + #[cfg(feature = "api-13")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-13")))] + pub fn OH_Input_CreateDeviceInfo() -> *mut Input_DeviceInfo; + /// Destroys a deviceInfo object. + /// + /// # Arguments + /// + /// * `deviceInfo` - information object. For details, see [`Input_DeviceInfo`]. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 13 + #[cfg(feature = "api-13")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-13")))] + pub fn OH_Input_DestroyDeviceInfo(deviceInfo: *mut *mut Input_DeviceInfo); + /// Obtains the keyboard type of an input device. + /// + /// # Arguments + /// + /// * `deviceId` - Device ID. + /// + /// * `keyboardType` - Pointer to the keyboard type of the input device. + /// + /// # Returns + /// + /// * OH_Input_GetKeyboardType result code, specifically, + /// [`INPUT_SUCCESS`] if the operation is successful; + /// [`INPUT_PARAMETER_ERROR`] if the device ID is invalid or keyboardType is a null pointer. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 13 + #[cfg(feature = "api-13")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-13")))] + pub fn OH_Input_GetKeyboardType(deviceId: i32, keyboardType: *mut i32) -> Input_Result; + /// Obtains the ID of an input device. + /// + /// # Arguments + /// + /// * `deviceInfo` - information object. For details, see [`Input_DeviceInfo`]. + /// + /// * `id` - Pointer to the ID of the input device. + /// + /// # Returns + /// + /// * OH_Input_GetDeviceId result code, specifically, + /// [`INPUT_SUCCESS`] if the operation is successful; + /// [`INPUT_PARAMETER_ERROR`] if deviceInfo or id is a null pointer. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 13 + #[cfg(feature = "api-13")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-13")))] + pub fn OH_Input_GetDeviceId(deviceInfo: *mut Input_DeviceInfo, id: *mut i32) -> Input_Result; + /// Obtains the name of an input device. + /// + /// # Arguments + /// + /// * `deviceInfo` - information object. For details, see [`Input_DeviceInfo`]. + /// + /// * `name` - Pointer to the name of the input device. + /// + /// # Returns + /// + /// * OH_Input_GetDeviceName result code, specifically, + /// [`INPUT_SUCCESS`] if the operation is successful; + /// [`INPUT_PARAMETER_ERROR`] if deviceInfo or name is a null pointer. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 13 + #[cfg(feature = "api-13")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-13")))] + pub fn OH_Input_GetDeviceName( + deviceInfo: *mut Input_DeviceInfo, + name: *mut *mut ::core::ffi::c_char, + ) -> Input_Result; + /// Obtains the capabilities of an input device, for example, a touchscreen, touchpad, or keyboard. + /// + /// # Arguments + /// + /// * `deviceInfo` - information object. For details, see [`Input_DeviceInfo`]. + /// + /// * `capabilities` - Pointer to the capabilities of the input device. + /// + /// # Returns + /// + /// * OH_Input_GetCapabilities result code, specifically, + /// [`INPUT_SUCCESS`] if the operation is successful; + /// [`INPUT_PARAMETER_ERROR`] if deviceInfo or capabilities is a null pointer. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 13 + #[cfg(feature = "api-13")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-13")))] + pub fn OH_Input_GetCapabilities( + deviceInfo: *mut Input_DeviceInfo, + capabilities: *mut i32, + ) -> Input_Result; + /// Obtains the version information of an input device. + /// + /// # Arguments + /// + /// * `deviceInfo` - information object. For details, see [`Input_DeviceInfo`]. + /// + /// * `version` - Pointer to the version information of the input device. + /// + /// # Returns + /// + /// * OH_Input_GetDeviceVersion result code, specifically, + /// [`INPUT_SUCCESS`] if the operation is successful; + /// [`INPUT_PARAMETER_ERROR`] if deviceInfo or version is a null pointer. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 13 + #[cfg(feature = "api-13")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-13")))] + pub fn OH_Input_GetDeviceVersion( + deviceInfo: *mut Input_DeviceInfo, + version: *mut i32, + ) -> Input_Result; + /// Obtains the product information of an input device. + /// + /// # Arguments + /// + /// * `deviceInfo` - information object. For details, see [`Input_DeviceInfo`]. + /// + /// * `product` - Pointer to the product information of the input device. + /// + /// # Returns + /// + /// * OH_Input_GetDeviceProduct result code, specifically, + /// [`INPUT_SUCCESS`] if the operation is successful; + /// [`INPUT_PARAMETER_ERROR`] if deviceInfo or product is a null pointer. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 13 + #[cfg(feature = "api-13")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-13")))] + pub fn OH_Input_GetDeviceProduct( + deviceInfo: *mut Input_DeviceInfo, + product: *mut i32, + ) -> Input_Result; + /// Obtains the vendor information of an input device. + /// + /// # Arguments + /// + /// * `deviceInfo` - information object. For details, see [`Input_DeviceInfo`]. + /// + /// * `vendor` - Pointer to the vendor information of the input device. + /// + /// # Returns + /// + /// * OH_Input_GetDeviceVendor result code, specifically, + /// [`INPUT_SUCCESS`] if the operation is successful; + /// [`INPUT_PARAMETER_ERROR`] if deviceInfo or vendor is a null pointer. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 13 + #[cfg(feature = "api-13")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-13")))] + pub fn OH_Input_GetDeviceVendor( + deviceInfo: *mut Input_DeviceInfo, + vendor: *mut i32, + ) -> Input_Result; + /// Obtains the physical address of an input device. + /// + /// # Arguments + /// + /// * `deviceInfo` - information object. For details, see [`Input_DeviceInfo`]. + /// + /// * `address` - Pointer to the physical address of the input device. + /// + /// # Returns + /// + /// * OH_Input_GetDeviceAddress result code, specifically, + /// [`INPUT_SUCCESS`] if the operation is successful; + /// [`INPUT_PARAMETER_ERROR`] if deviceInfo or address is a null pointer. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 13 + #[cfg(feature = "api-13")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-13")))] + pub fn OH_Input_GetDeviceAddress( + deviceInfo: *mut Input_DeviceInfo, + address: *mut *mut ::core::ffi::c_char, + ) -> Input_Result; + /// Registers a listener for device hot swap events. + /// + /// # Arguments + /// + /// * `listener` - Pointer to an [`Input_DeviceListener`] object. + /// + /// + /// # Returns + /// + /// * OH_Input_RegisterDeviceListener status code, specifically, + /// [`INPUT_SUCCESS`] if the operation is successful; + /// + /// [`INPUT_PARAMETER_ERROR`] if listener is NULL; + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 13 + #[cfg(feature = "api-13")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-13")))] + pub fn OH_Input_RegisterDeviceListener(listener: *mut Input_DeviceListener) -> Input_Result; + /// Unregisters the listener for device hot swap events. + /// + /// # Arguments + /// + /// * `listener` - Pointer to the listener for device hot swap events. For details, see [`Input_DeviceListener`]. + /// + /// + /// # Returns + /// + /// * OH_Input_UnregisterDeviceListener status code, specifically, + /// [`INPUT_SUCCESS`] if the operation is successful; + /// + /// [`INPUT_PARAMETER_ERROR`] if listener is NULL or no listener is registered; + /// [`INPUT_SERVICE_EXCEPTION`] if the service is abnormal. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 13 + #[cfg(feature = "api-13")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-13")))] + pub fn OH_Input_UnregisterDeviceListener(listener: *mut Input_DeviceListener) -> Input_Result; + /// Unregisters the listener for all device hot swap events. + /// + /// + /// # Returns + /// + /// * OH_Input_UnregisterDeviceListener status code, specifically, + /// [`INPUT_SUCCESS`] if the operation is successful; + /// + /// [`INPUT_SERVICE_EXCEPTION`] if the service is abnormal. + /// + /// Required System Capabilities: SystemCapability.MultimodalInput.Input.Core + /// + /// Available since API-level: 13 + #[cfg(feature = "api-13")] + #[cfg_attr(docsrs, doc(cfg(feature = "api-13")))] + pub fn OH_Input_UnregisterDeviceListeners() -> Input_Result; +} diff --git a/components/multimodal-input/src/key_code.rs b/components/multimodal-input/src/key_code.rs new file mode 100644 index 0000000..63f0d5c --- /dev/null +++ b/components/multimodal-input/src/key_code.rs @@ -0,0 +1,6 @@ +//! Defines key codes of the key device. +//! +//! System capability: SystemCapability.MultimodalInput.Input.Core + +mod key_code_ffi; +pub use key_code_ffi::*; diff --git a/components/multimodal-input/src/key_code/key_code_ffi.rs b/components/multimodal-input/src/key_code/key_code_ffi.rs new file mode 100644 index 0000000..fb0e71d --- /dev/null +++ b/components/multimodal-input/src/key_code/key_code_ffi.rs @@ -0,0 +1,282 @@ +// automatically generated by rust-bindgen 0.71.1 + +#![allow(non_upper_case_globals)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] + +#[repr(i32)] +/// Enumerated values of OpenHarmony key code. +/// +/// +/// Available since API-level: 12 +#[cfg(feature = "api-12")] +#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub enum Input_KeyCode { + /// Unknown key + KEYCODE_UNKNOWN = -1, + /// Function (Fn) key + KEYCODE_FN = 0, + /// Volume Up key + KEYCODE_VOLUME_UP = 16, + /// Volume Down button + KEYCODE_VOLUME_DOWN = 17, + /// Power key + KEYCODE_POWER = 18, + /// Shutter key + KEYCODE_CAMERA = 19, + /// Speaker Mute key + KEYCODE_VOLUME_MUTE = 22, + /// Mute key + KEYCODE_MUTE = 23, + /// Brightness Up key + KEYCODE_BRIGHTNESS_UP = 40, + /// Brightness Down key + KEYCODE_BRIGHTNESS_DOWN = 41, + /// Key 0 + KEYCODE_0 = 2000, + /// Key 1 + KEYCODE_1 = 2001, + /// Key 2 + KEYCODE_2 = 2002, + /// Key 3 + KEYCODE_3 = 2003, + /// Key 4 + KEYCODE_4 = 2004, + /// Key 5 + KEYCODE_5 = 2005, + /// Key 6 + KEYCODE_6 = 2006, + /// Key 7 + KEYCODE_7 = 2007, + /// Key 8 + KEYCODE_8 = 2008, + /// Key 9 + KEYCODE_9 = 2009, + /// Key * + KEYCODE_STAR = 2010, + /// Key # + KEYCODE_POUND = 2011, + /// Up key on D-pad + KEYCODE_DPAD_UP = 2012, + /// Down key on D-pad + KEYCODE_DPAD_DOWN = 2013, + /// Left key on D-pad + KEYCODE_DPAD_LEFT = 2014, + /// Right key on D-pad + KEYCODE_DPAD_RIGHT = 2015, + /// OK key on D-pad + KEYCODE_DPAD_CENTER = 2016, + /// Key A + KEYCODE_A = 2017, + /// Key B + KEYCODE_B = 2018, + /// Key C + KEYCODE_C = 2019, + /// Key D + KEYCODE_D = 2020, + /// Key E + KEYCODE_E = 2021, + /// Key F + KEYCODE_F = 2022, + /// Key G + KEYCODE_G = 2023, + /// Key H + KEYCODE_H = 2024, + /// Key I + KEYCODE_I = 2025, + /// Key J + KEYCODE_J = 2026, + /// Key K + KEYCODE_K = 2027, + /// Key L + KEYCODE_L = 2028, + /// Key M + KEYCODE_M = 2029, + /// Key N + KEYCODE_N = 2030, + /// Key O + KEYCODE_O = 2031, + /// Key P + KEYCODE_P = 2032, + /// Key Q + KEYCODE_Q = 2033, + /// Key R + KEYCODE_R = 2034, + /// Key S + KEYCODE_S = 2035, + /// Key T + KEYCODE_T = 2036, + /// Key U + KEYCODE_U = 2037, + /// Key V + KEYCODE_V = 2038, + /// Key W + KEYCODE_W = 2039, + /// Key X + KEYCODE_X = 2040, + /// Key Y + KEYCODE_Y = 2041, + /// Key Z + KEYCODE_Z = 2042, + /// Key , + KEYCODE_COMMA = 2043, + /// Key . + KEYCODE_PERIOD = 2044, + /// Left Alt key + KEYCODE_ALT_LEFT = 2045, + /// Right Alt key + KEYCODE_ALT_RIGHT = 2046, + /// Left Shift key + KEYCODE_SHIFT_LEFT = 2047, + /// Right Shift key + KEYCODE_SHIFT_RIGHT = 2048, + /// Tab key + KEYCODE_TAB = 2049, + /// Space key + KEYCODE_SPACE = 2050, + /// Symbol key + KEYCODE_SYM = 2051, + /// Explorer key, used to start the explorer application + KEYCODE_EXPLORER = 2052, + /// Email key, used to start the email application + KEYCODE_ENVELOPE = 2053, + /// Enter key + KEYCODE_ENTER = 2054, + /// Backspace key + KEYCODE_DEL = 2055, + /// Key * + KEYCODE_GRAVE = 2056, + /// Key - + KEYCODE_MINUS = 2057, + /// Key = + KEYCODE_EQUALS = 2058, + /// Key [ + KEYCODE_LEFT_BRACKET = 2059, + /// Key ] + KEYCODE_RIGHT_BRACKET = 2060, + /// Key + KEYCODE_BACKSLASH = 2061, + /// Key ; + KEYCODE_SEMICOLON = 2062, + /// Key ' + KEYCODE_APOSTROPHE = 2063, + /// Key / + KEYCODE_SLASH = 2064, + /// Key + KEYCODE_AT = 2065, + /// Key + + KEYCODE_PLUS = 2066, + /// Menu key + KEYCODE_MENU = 2067, + /// Page Up key + KEYCODE_PAGE_UP = 2068, + /// Page Down key + KEYCODE_PAGE_DOWN = 2069, + /// ESC key + KEYCODE_ESCAPE = 2070, + /// Delete key + KEYCODE_FORWARD_DEL = 2071, + /// Left Ctrl key + KEYCODE_CTRL_LEFT = 2072, + /// Right Ctrl key + KEYCODE_CTRL_RIGHT = 2073, + /// Caps Lock key + KEYCODE_CAPS_LOCK = 2074, + /// Scroll Lock key + KEYCODE_SCROLL_LOCK = 2075, + /// Left Meta key + KEYCODE_META_LEFT = 2076, + /// Right Meta key + KEYCODE_META_RIGHT = 2077, + /// Function key + KEYCODE_FUNCTION = 2078, + /// System Request/Print Screen key + KEYCODE_SYSRQ = 2079, + /// Break/Pause key + KEYCODE_BREAK = 2080, + /// Move to Home key + KEYCODE_MOVE_HOME = 2081, + /// Move to End key + KEYCODE_MOVE_END = 2082, + /// Insert key + KEYCODE_INSERT = 2083, + /// Forward key + KEYCODE_FORWARD = 2084, + /// Play key + KEYCODE_MEDIA_PLAY = 2085, + /// Pause key + KEYCODE_MEDIA_PAUSE = 2086, + /// Close key + KEYCODE_MEDIA_CLOSE = 2087, + /// Eject key + KEYCODE_MEDIA_EJECT = 2088, + /// Record key + KEYCODE_MEDIA_RECORD = 2089, + /// F1 key + KEYCODE_F1 = 2090, + /// F2 key + KEYCODE_F2 = 2091, + /// F3 key + KEYCODE_F3 = 2092, + /// F4 key + KEYCODE_F4 = 2093, + /// F5 key + KEYCODE_F5 = 2094, + /// F6 key + KEYCODE_F6 = 2095, + /// F7 key + KEYCODE_F7 = 2096, + /// F8 key + KEYCODE_F8 = 2097, + /// F9 key + KEYCODE_F9 = 2098, + /// F10 key + KEYCODE_F10 = 2099, + /// F11 key + KEYCODE_F11 = 2100, + /// F12 key + KEYCODE_F12 = 2101, + /// Number Lock key on numeric keypad + KEYCODE_NUM_LOCK = 2102, + /// Key 0 on numeric keypad + KEYCODE_NUMPAD_0 = 2103, + /// Key 1 on numeric keypad + KEYCODE_NUMPAD_1 = 2104, + /// Key 2 on numeric keypad + KEYCODE_NUMPAD_2 = 2105, + /// Key 3 on numeric keypad + KEYCODE_NUMPAD_3 = 2106, + /// Key 4 on numeric keypad + KEYCODE_NUMPAD_4 = 2107, + /// Key 5 on numeric keypad + KEYCODE_NUMPAD_5 = 2108, + /// Key 6 on numeric keypad + KEYCODE_NUMPAD_6 = 2109, + /// Key 7 on numeric keypad + KEYCODE_NUMPAD_7 = 2110, + /// Key 8 on numeric keypad + KEYCODE_NUMPAD_8 = 2111, + /// Key 9 on numeric keypad + KEYCODE_NUMPAD_9 = 2112, + /// Key / on numeric keypad + KEYCODE_NUMPAD_DIVIDE = 2113, + /// Key * on numeric keypad + KEYCODE_NUMPAD_MULTIPLY = 2114, + /// Key - on numeric keypad + KEYCODE_NUMPAD_SUBTRACT = 2115, + /// Key + on numeric keypad + KEYCODE_NUMPAD_ADD = 2116, + /// Key . on numeric keypad + KEYCODE_NUMPAD_DOT = 2117, + /// Key , on numeric keypad + KEYCODE_NUMPAD_COMMA = 2118, + /// Enter key on numeric keypad + KEYCODE_NUMPAD_ENTER = 2119, + /// Key = on numeric keypad + KEYCODE_NUMPAD_EQUALS = 2120, + /// Key ( on numeric keypad + KEYCODE_NUMPAD_LEFT_PAREN = 2121, + /// Key ) on numeric keypad + KEYCODE_NUMPAD_RIGHT_PAREN = 2122, +} diff --git a/components/multimodal-input/src/lib.rs b/components/multimodal-input/src/lib.rs new file mode 100644 index 0000000..b717968 --- /dev/null +++ b/components/multimodal-input/src/lib.rs @@ -0,0 +1,21 @@ +//! Bindings to Input-kit API of OpenHarmony +//! +//! Available with API-level 12 and newer +//! +//! Official documentation: https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/_input_method-V5 +//! +//! ## Feature flags +#![cfg_attr( + feature = "document-features", + cfg_attr(doc, doc = ::document_features::document_features!()) +)] +#![cfg_attr(docsrs, feature(doc_cfg))] +#![cfg(feature = "api-12")] +#![cfg_attr(docsrs, doc(cfg(feature = "api-12")))] + +#[link(name = "oh_input")] +extern "C" {} + +pub mod axis_type; +pub mod input_manager; +pub mod key_code; diff --git a/scripts/generator/src/dir_conf.rs b/scripts/generator/src/dir_conf.rs new file mode 100644 index 0000000..af54efd --- /dev/null +++ b/scripts/generator/src/dir_conf.rs @@ -0,0 +1,394 @@ +//! Configuration file for OpenHarmony modules with multiple header files in a directory. +//! +//! Add new bindings to `get_module_bindings_config()` by appending a new `DirBindingsConf`. + +use bindgen::EnumVariation; +use crate::DirBindingsConf; + +/// Convenience method for stripping am optional suffix and returning an owned String +fn strip_suffix(input: &str, suffix: &str) -> String { + match input.strip_suffix(suffix) { + None => input.to_string(), + Some(stripped) => stripped.to_string() + } +} + +/// Convenience method for stripping am optional suffix and returning an owned String +fn strip_prefix(input: &str, prefix: &str) -> String { + match input.strip_prefix(prefix) { + None => input.to_string(), + Some(stripped) => stripped.to_string() + } +} + +pub(crate) fn get_module_bindings_config(api_version: u32) -> Vec { + vec![DirBindingsConf { + directory: "multimedia/image_framework/image".to_string(), + output_dir: "components/multimedia/image_framework/src/native_image".to_string(), + min_api_version: 12, + rename_output_file: Some(Box::new(|stem| strip_suffix(stem, "_native"))), + set_builder_opts: Box::new( + |file_stem, header_path, builder| { + let builder = if file_stem != "image_common" { + builder.raw_line("use crate::native_image::common::*;") + } else { + builder + }; + let builder = match file_stem { + "pixelmap" => { + builder + .raw_line("use ohos_sys_opaque_types::{napi_env, napi_value, \ + OH_NativeBuffer, OH_PixelmapNative, OH_NativeColorSpaceManager};") + + }, + "picture" => { + builder + .raw_line("use ohos_sys_opaque_types::OH_PixelmapNative;") + .raw_line("use crate::native_image::pixelmap::PIXEL_FORMAT;") + } + "image_source" => { + builder + .raw_line("pub use ohos_sys_opaque_types::OH_ImageSourceNative;") + .raw_line("use ohos_sys_opaque_types::OH_PixelmapNative;") + .raw_line("use ohos_rawfile_sys::RawFileDescriptor;") + .raw_line("#[cfg(feature = \"api-13\")]") + .raw_line("use crate::native_image::picture::{OH_PictureNative, Image_AuxiliaryPictureType};") + } + "image_receiver" => { + builder.raw_line("use crate::native_image::image::OH_ImageNative;") + } + "image_packer" => { + builder + .raw_line("use ohos_sys_opaque_types::OH_PixelmapNative;") + .raw_line("#[cfg(feature = \"api-12\")]") + .raw_line("use ohos_sys_opaque_types::OH_ImageSourceNative;") + .raw_line("#[cfg(feature = \"api-13\")]") + .raw_line("use crate::native_image::picture::OH_PictureNative;") + } + "image" => { + builder + .raw_line("use ohos_sys_opaque_types::OH_NativeBuffer;") + + } + _ => builder, + }; + builder + .allowlist_file(format!("{}", header_path.to_str().unwrap())) + .allowlist_recursively(false) + .default_enum_style(EnumVariation::NewType { + is_bitfield: false, + is_global: false, + }) + .derive_copy(false) + .derive_debug(false) + .prepend_enum_name(false) + .clang_args(&["-x", "c++"]) + } + ), + }, DirBindingsConf { + directory: "inputmethod".to_string(), + output_dir: "components/inputmethod/src".to_string(), + min_api_version: 12, + rename_output_file: Some(Box::new(|stem| { + let stem = strip_suffix(stem, "_capi"); + let stem = strip_prefix(&stem, "inputmethod_"); + stem + })), + set_builder_opts: Box::new( + |file_stem, header_path, builder| { + let builder = if file_stem != "types" { + builder.raw_line("use crate::types::*;") + } else { + builder + }; + let builder = match file_stem { + "text_editor_proxy" => { + builder + .raw_line("use crate::private_command::InputMethod_PrivateCommand;") + .raw_line("use crate::text_config::InputMethod_TextConfig;") + }, + "text_config" => { + builder + .raw_line("use crate::text_avoid_info::InputMethod_TextAvoidInfo;") + .raw_line("use crate::cursor_info::InputMethod_CursorInfo;") + } + "inputmethod_proxy" => { + builder + .raw_line("use crate::private_command::InputMethod_PrivateCommand;") + .raw_line("use crate::cursor_info::InputMethod_CursorInfo;") + } + "controller" => { + builder + .raw_line("use crate::inputmethod_proxy::InputMethod_InputMethodProxy;") + .raw_line("use crate::text_editor_proxy::InputMethod_TextEditorProxy;") + .raw_line("use crate::attach_options::InputMethod_AttachOptions;") + } + _ => builder, + }; + builder + .allowlist_file(format!("{}", header_path.to_str().unwrap())) + .allowlist_recursively(false) + .default_enum_style(EnumVariation::NewType { + is_bitfield: false, + is_global: false, + }) + .derive_copy(false) + .derive_debug(false) + .prepend_enum_name(false) + .clang_args(&["-x", "c++"]) + } + ), + }, + DirBindingsConf { + directory: "native_drawing".to_string(), + output_dir: "components/drawing/src".to_string(), + min_api_version: 12, + rename_output_file: Some(Box::new(|stem| { + let stem = strip_prefix(&stem, "drawing_"); + stem + })), + set_builder_opts: Box::new( + |file_stem, header_path, builder| { + let builder = if file_stem != "types" { + let builder = builder.raw_line("use crate::types::*;"); + if file_stem != "error_code" { + builder + .raw_line("") + .raw_line("#[allow(unused_imports)]") + .raw_line("#[cfg(feature = \"api-12\")]") + .raw_line("use crate::error_code::OH_Drawing_ErrorCode;") + } else { + builder + } + } else { + builder + }; + let builder = match file_stem { + "font_collection" => { + builder + .raw_line("use crate::text_declaration::*;") + }, + "text_typography" => { + builder + .raw_line("use crate::text_declaration::*;") + .raw_line("#[cfg(feature = \"api-12\")]") + .raw_line("use crate::font::OH_Drawing_Font_Metrics;") + // FIXME: This needs to be guarded behind API-level-12 (fixed in SDK-13) + // We blocklist for now and remove when updating to SDK-13 + .blocklist_function("OH_Drawing_TypographyGetLineFontMetrics") + } + "register_font" => { + builder + .raw_line("use crate::text_declaration::*;") + } + "image_filter" => { + builder + .raw_line("use crate::shader_effect::*;") + }, + "font_mgr" => { + builder.raw_line("use crate::text_typography::*;") + }, + "pixel_map" => { + builder.raw_line("use ohos_sys_opaque_types::{OH_PixelmapNative, NativePixelMap_};") + } + "text_blob" => { + builder + .no_copy("OH_Drawing_RunBuffer") + } + _ => builder, + }; + builder + .allowlist_file(format!("{}", header_path.to_str().unwrap())) + .allowlist_recursively(false) + .default_enum_style(EnumVariation::NewType { + is_bitfield: false, + is_global: false, + }) + .prepend_enum_name(false) + .clang_args(&["-x", "c++"]) + + } + ), + }, + DirBindingsConf { + directory: "arkui".to_string(), + output_dir: "components/arkui/src".to_string(), + min_api_version: 12, + rename_output_file: None, + set_builder_opts: Box::new( + |file_stem, header_path, builder| { + let builder = if file_stem != "native_type" { + builder.raw_line("use crate::native_type::*;") + } else { + builder + }; + let builder = builder + .allowlist_file(format!("{}", header_path.to_str().unwrap())) + .allowlist_recursively(false) + .default_enum_style(EnumVariation::NewType { + is_bitfield: false, + is_global: false, + }) + .derive_copy(false) + .derive_debug(false) + .prepend_enum_name(false) + .clang_args(&["-x", "c++"]); + match file_stem { + "drag_and_drop" => { + builder + // Todo: Requires bindings to `database/udmf` + .blocklist_function("OH_ArkUI_DragEvent_SetData") + .blocklist_function("OH_ArkUI_DragEvent_GetUdmfData") + .blocklist_function("OH_ArkUI_DragAction_SetData") + // Pixelmap is from image-kit + .raw_line("pub use ohos_sys_opaque_types::OH_PixelmapNative;") + + } + "drawable_descriptor" => { + builder + .raw_line("pub use ohos_sys_opaque_types::OH_PixelmapNative;") + + }, + "native_gesture" => { + builder + .raw_line("use crate::ui_input_event::ArkUI_UIInputEvent;") + .blocklist_function("^OH_ArkUI_GestureEvent_GetNode") + }, + "native_interface_accessibility" => { + builder + .raw_line("use ohos_sys_opaque_types::ArkUI_AccessibilityProvider;") + }, + "native_node" => { + builder + .blocklist_var("MAX_NODE_SCOPE_NUM") + .blocklist_var("MAX_COMPONENT_EVENT_ARG_NUM") + .raw_line("use crate::ui_input_event::ArkUI_UIInputEvent;") + }, + "native_node_napi" => { + builder + .raw_line("use ohos_sys_opaque_types::{napi_env, napi_value};") + .raw_line("use crate::drawable_descriptor::ArkUI_DrawableDescriptor;") + + }, + "native_type" => { + builder + .raw_line("use crate::drawable_descriptor::ArkUI_DrawableDescriptor;") + // We want copy for the union type `ArkUI_NumberValue` + .derive_copy(true) + .no_copy("ArkUI_ContextCallback") + .no_copy("ARKUI_TextPickerRangeContent") + .no_copy("ARKUI_TextPickerCascadeRangeContent") + .no_copy("ArkUI_ColorStop") + + }, + "styled_string" => { + builder + .blocklist_function("OH_ArkUI_StyledString_Create") + .blocklist_function("OH_ArkUI_StyledString_PushTextStyle") + .blocklist_function("OH_ArkUI_StyledString_CreateTypography") + .blocklist_function("OH_ArkUI_StyledString_AddPlaceholder") + } + "ui_input_event" => { + builder + .bitfield_enum("ArkUI_ModifierKeyName") + .blocklist_item("UI_TOUCH_EVENT_ACTION_.*") + .blocklist_item("UI_INPUT_EVENT_TOOL_TYPE_.*") + .blocklist_item("UI_INPUT_EVENT_SOURCE_TYPE_.*") + .blocklist_item("UI_MOUSE_EVENT_ACTION_.*") + .blocklist_item("UI_MOUSE_EVENT_BUTTON_.*") + + }, + _ => builder, + } + } + ), + }, + + DirBindingsConf { + directory: "rawfile".to_string(), + output_dir: "components/rawfile/src".to_string(), + min_api_version: 10, + rename_output_file: None, + set_builder_opts: Box::new( + |file_stem, header_path, builder| { + let builder = builder + .allowlist_file(format!("{}", header_path.to_str().unwrap())) + .allowlist_recursively(false) + .default_enum_style(EnumVariation::NewType { + is_bitfield: false, + is_global: false, + }) + .prepend_enum_name(false) + .clang_args(&["-x", "c++"]); + match file_stem { + "raw_file" => { + builder + // Types are generated separately, since they might be shared. + .blocklist_var(".*") + .blocklist_type(".*") + .raw_line("use crate::raw_file_types_ffi::*;") + .raw_line("#[cfg(doc)]") + .raw_line("use crate::raw_file_manager::{OH_ResourceManager_OpenRawFile, OH_ResourceManager_OpenRawDir};") + .raw_line("#[cfg(doc)]") + .raw_line("use crate::raw_file_manager::OH_ResourceManager_OpenRawFile64;") + }, + "raw_dir" => { + builder + .raw_line("#[cfg(doc)]") + .raw_line("use crate::raw_file_manager::{OH_ResourceManager_OpenRawFile, OH_ResourceManager_OpenRawDir};") + + } + "raw_file_manager" => { + builder + .raw_line("use ohos_sys_opaque_types::{napi_env, napi_value};") + .raw_line("use crate::raw_dir::RawDir;") + .raw_line("use crate::RawFile;") + .raw_line("#[cfg(doc)]") + .raw_line("use crate::raw_dir::OH_ResourceManager_CloseRawDir;") + .raw_line("#[cfg(doc)]") + .raw_line("use crate::raw_file::{OH_ResourceManager_CloseRawFile, OH_ResourceManager_CloseRawFile64};") + .raw_line("#[cfg(feature = \"api-11\")]") + .raw_line("use crate::RawFile64;") + + } + _ => builder, + } + } + ), + }, + DirBindingsConf { + directory: "multimodalinput".to_string(), + output_dir: "components/multimodal-input/src".to_string(), + min_api_version: 12, + rename_output_file: Some(Box::new(|name| name.trim_start_matches("oh_").to_string())), + set_builder_opts: Box::new( + |file_stem, header_path, builder| { + let builder = builder + .allowlist_file(format!("{}", header_path.to_str().unwrap())) + .allowlist_recursively(false) + .default_enum_style(EnumVariation::NewType { + is_bitfield: false, + is_global: false, + }) + .prepend_enum_name(false); + //.clang_args(&["-x", "c++"]); + match file_stem { + "input_manager" => { + builder + .raw_line("use crate::axis_type::{InputEvent_AxisAction, InputEvent_AxisEventType, InputEvent_AxisType};") + }, + "key_code" => { + builder + // Input_KeyCode is not directly exposed via FFI, instead a + // raw integer is used there. Hence, we can use a rust enum here + // which is much nicer to use. + .rustified_enum("Input_KeyCode") + + } + _ => builder, + } + } + ), + }, + ] +} diff --git a/scripts/generator/src/header_conf.rs b/scripts/generator/src/header_conf.rs new file mode 100644 index 0000000..9af7743 --- /dev/null +++ b/scripts/generator/src/header_conf.rs @@ -0,0 +1,230 @@ +use bindgen::EnumVariation; +use crate::BindingConf; + +pub(crate) fn get_bindings_config(api_version: u32) -> Vec { + vec![ + BindingConf { + include_filename: "deviceinfo.h".to_string(), + output_prefix: "components/deviceinfo/src/deviceinfo".to_string(), + set_builder_opts: Box::new(|builder| { + builder.default_enum_style(EnumVariation::NewType { + is_bitfield: false, + is_global: false, + }) + }), + }, + BindingConf { + include_filename: "syscap_ndk.h".to_string(), + output_prefix: "src/syscap/syscap".to_string(), + set_builder_opts: Box::new(|builder| { + builder.default_enum_style(EnumVariation::NewType { + is_bitfield: false, + is_global: false, + }) + }), + }, + BindingConf { + include_filename: "hilog/log.h".to_string(), + output_prefix: "components/hilog/src/hilog".to_string(), + set_builder_opts: Box::new(|builder| { + builder + .default_enum_style(EnumVariation::NewType { + is_bitfield: false, + is_global: false, + }) + .blocklist_var("LOG_DOMAIN") + }), + }, + BindingConf { + include_filename: "napi/native_api.h".to_string(), + output_prefix: "src/napi/napi".to_string(), + set_builder_opts: Box::new(|builder| { + builder + .default_enum_style(EnumVariation::NewType { + is_bitfield: false, + is_global: false, + }) + .prepend_enum_name(false) + .no_copy("napi_property_descriptor") + .no_copy("napi_extended_error_info") + .no_copy("napi_node_version") + .no_copy("napi_module") + .raw_line("pub use ohos_sys_opaque_types::{napi_env, napi_value};") + }), + }, + BindingConf { + include_filename: "hitrace/trace.h".to_string(), + output_prefix: "components/hitrace/src/hitrace".to_string(), + set_builder_opts: Box::new(|builder| { + builder + .default_enum_style(EnumVariation::NewType { + is_bitfield: false, + is_global: false, + }) + .bitfield_enum("^HiTrace_Flag$") + .rustified_non_exhaustive_enum("HiTrace_Tracepoint_Type") + .blocklist_var("LOG_DOMAIN") + .clang_arg("-include") + .clang_arg("stdbool.h") + }), + }, + BindingConf { + include_filename: "ace/xcomponent/native_interface_xcomponent.h".to_string(), + output_prefix: "components/xcomponent/src/xcomponent".to_string(), + set_builder_opts: Box::new(|builder| { + builder + .default_enum_style(EnumVariation::NewType { + is_bitfield: false, + is_global: false, + }) + .allowlist_file(r".*/xcomponent/native_.*xcomponent.*\.h") + .allowlist_recursively(false) + .no_copy("^OH_NativeXComponent$") + .no_copy("^OH_NativeXComponent_KeyEvent$") + .no_debug("^OH_NativeXComponent$") + .no_debug("^OH_NativeXComponent_KeyEvent$") + .blocklist_item("ArkUI_.*") + // Requires a patch to bindgen + .blocklist_item("OH_NATIVEXCOMPONENT_RESULT.*") + .blocklist_function("OH_NativeXComponent_.*NativeRootNode") + .blocklist_function("OH_NativeXComponent_RegisterUIInputEventCallback") + .blocklist_function("OH_NativeXComponent_RegisterOnTouchInterceptCallback") + .blocklist_function("OH_NativeXComponent_GetNativeXComponent") + .raw_line("#[cfg(feature = \"api-13\")]") + .raw_line("use ohos_sys_opaque_types::ArkUI_AccessibilityProvider;") + .clang_args(&["-x", "c++"]) + }), + }, + BindingConf { + include_filename: "ace/xcomponent/native_interface_xcomponent.h".to_string(), + output_prefix: "components/xcomponent/src/xcomponent_result".to_string(), + set_builder_opts: Box::new(|builder| { + builder + .raw_line("#![allow(unused)]") + .allowlist_var("OH_NATIVEXCOMPONENT_RESULT_.*") + .clang_args(&["-x", "c++"]) + }), + }, + BindingConf { + include_filename: "ace/xcomponent/native_interface_xcomponent.h".to_string(), + output_prefix: "components/xcomponent/src/xcomponent_arkui".to_string(), + set_builder_opts: Box::new(|builder| { + builder + .raw_line("use super::xcomponent_ffi::*;") + .raw_line("use arkui_sys::native_type::ArkUI_NodeHandle;") + .raw_line("use arkui_sys::ui_input_event::{ArkUI_UIInputEvent, ArkUI_UIInputEvent_Type, HitTestMode};") + .allowlist_function("OH_NativeXComponent_.*NativeRootNode") + .allowlist_function("OH_NativeXComponent_RegisterUIInputEventCallback") + .allowlist_function("OH_NativeXComponent_RegisterOnTouchInterceptCallback") + .blocklist_type(".*") + .clang_args(&["-x", "c++"]) + }), + }, + BindingConf { + include_filename: "native_buffer/native_buffer.h".to_string(), + output_prefix: "src/native_buffer/native_buffer".to_string(), + set_builder_opts: Box::new(|builder| { + builder + .default_enum_style(EnumVariation::NewType { + is_bitfield: false, + is_global: false, + }) + .allowlist_file(r".*/native_buffer/.*\.h") + .bitfield_enum("OH_NativeBuffer_Usage") + .blocklist_item("^(OH)?NativeWindow(Buffer)?") + .raw_line("use ohos_sys_opaque_types::{OH_NativeBuffer, OHNativeWindowBuffer};") + }), + }, + BindingConf { + include_filename: "native_image/native_image.h".to_string(), + output_prefix: "src/native_image/native_image".to_string(), + set_builder_opts: Box::new(|builder| { + builder + .default_enum_style(EnumVariation::NewType { + is_bitfield: false, + is_global: false, + }) + .allowlist_file(r".*/native_image/.*\.h") + .blocklist_item("^(OH)?NativeWindow(Buffer)?") + .raw_line("use ohos_sys_opaque_types::OHNativeWindow;") + .raw_line("#[cfg(feature = \"api-12\")]") + .raw_line("use ohos_sys_opaque_types::OHNativeWindowBuffer;") + .no_copy("^OH_OnFrameAvailableListener") + }), + }, + BindingConf { + include_filename: "native_window/external_window.h".to_string(), + output_prefix: "src/native_window/native_window".to_string(), + set_builder_opts: Box::new(|builder| { + builder + .default_enum_style(EnumVariation::NewType { + is_bitfield: false, + is_global: false, + }) + .constified_enum_module("^NativeWindowOperation$") + .allowlist_file(".*native_window/external_window.h") + .raw_line("use ohos_sys_opaque_types::{OH_NativeBuffer, OHNativeWindow, OHNativeWindowBuffer};") + .derive_copy(false) + }), + }, + BindingConf { + include_filename: "native_vsync/native_vsync.h".to_string(), + output_prefix: "components/vsync/src/vsync".to_string(), + set_builder_opts: Box::new(move |builder| { + builder + .default_enum_style(EnumVariation::NewType { + is_bitfield: false, + is_global: false, + }) + }), + }, + BindingConf { + include_filename: "arkui/ui_input_event.h".to_string(), + output_prefix: "components/arkui/src/ui_input_event/ui_input_event_anon_enums".to_string(), + set_builder_opts: Box::new(move |builder| { + builder + .default_enum_style(EnumVariation::NewType { + is_bitfield: false, + is_global: false, + }) + .allowlist_var("UI_TOUCH_EVENT_ACTION_.*") + .allowlist_var("UI_INPUT_EVENT_TOOL_TYPE_.*") + .allowlist_var("UI_INPUT_EVENT_SOURCE_TYPE_.*") + .allowlist_var("UI_MOUSE_EVENT_ACTION_.*") + .allowlist_var("UI_MOUSE_EVENT_BUTTON_*") + .allowlist_recursively(true) + .clang_args(["-include", "stdbool.h"]) + + }), + }, + BindingConf { + include_filename: "arkui/styled_string.h".to_string(), + output_prefix: "components/arkui/src/styled_string/drawing".to_string(), + set_builder_opts: Box::new(|builder| { + builder + .allowlist_function("OH_ArkUI_StyledString_Create") + .allowlist_function("OH_ArkUI_StyledString_PushTextStyle") + .allowlist_function("OH_ArkUI_StyledString_CreateTypography") + .allowlist_function("OH_ArkUI_StyledString_AddPlaceholder") + .clang_args(["-x", "c++"]) + .allowlist_recursively(false) + .raw_line("pub use super::ArkUI_StyledString;") + .raw_line("pub use ohos_drawing_sys::text_typography::OH_Drawing_PlaceholderSpan;") + .raw_line("pub use ohos_drawing_sys::text_declaration::{OH_Drawing_FontCollection, OH_Drawing_TextStyle, OH_Drawing_Typography, OH_Drawing_TypographyStyle};") + }), + }, + BindingConf { + include_filename: "rawfile/raw_file.h".to_string(), + output_prefix: "components/rawfile/src/raw_file_types".to_string(), + set_builder_opts: Box::new(|builder| { + builder + .ignore_functions() + .clang_args(["-x", "c++"]) + .blocklist_var("_LIBCPP.*") + .raw_line("#[cfg(doc)]") + .raw_line("use crate::{raw_file::{OH_ResourceManager_GetRawFileDescriptor,OH_ResourceManager_GetRawFileDescriptor64},\ + raw_file_manager::OH_ResourceManager_OpenRawFile};") + }), + }, + ] +} diff --git a/scripts/generator/src/main.rs b/scripts/generator/src/main.rs index 2603ed9..6e11df6 100644 --- a/scripts/generator/src/main.rs +++ b/scripts/generator/src/main.rs @@ -1,4 +1,6 @@ +mod dir_conf; mod opaque_types; +mod header_conf; use std::fs; use std::num::ParseIntError; @@ -7,6 +9,8 @@ use bindgen::{CodeGenAttributes, EnumVariation, Formatter}; use std::path::{Path, PathBuf}; use std::str::FromStr; use thiserror::Error; +use crate::dir_conf::get_module_bindings_config; +use crate::header_conf::get_bindings_config; /// Parse the api version /// @@ -205,649 +209,11 @@ struct DirBindingsConf { struct BindingConf { include_filename: String, - /// Will be interpolated as "${ROOT_DIR}/${output_prefix}_api${API_VERSION}" + /// Will be interpolated as "${ROOT_DIR}/${output_prefix}_ffi" output_prefix: String, set_builder_opts: Box bindgen::Builder>, } -fn get_bindings_config(api_version: u32) -> Vec { - vec![ - BindingConf { - include_filename: "deviceinfo.h".to_string(), - output_prefix: "components/deviceinfo/src/deviceinfo".to_string(), - set_builder_opts: Box::new(|builder| { - builder.default_enum_style(EnumVariation::NewType { - is_bitfield: false, - is_global: false, - }) - }), - }, - BindingConf { - include_filename: "syscap_ndk.h".to_string(), - output_prefix: "src/syscap/syscap".to_string(), - set_builder_opts: Box::new(|builder| { - builder.default_enum_style(EnumVariation::NewType { - is_bitfield: false, - is_global: false, - }) - }), - }, - BindingConf { - include_filename: "hilog/log.h".to_string(), - output_prefix: "components/hilog/src/hilog".to_string(), - set_builder_opts: Box::new(|builder| { - builder - .default_enum_style(EnumVariation::NewType { - is_bitfield: false, - is_global: false, - }) - .blocklist_var("LOG_DOMAIN") - }), - }, - BindingConf { - include_filename: "napi/native_api.h".to_string(), - output_prefix: "src/napi/napi".to_string(), - set_builder_opts: Box::new(|builder| { - builder - .default_enum_style(EnumVariation::NewType { - is_bitfield: false, - is_global: false, - }) - .prepend_enum_name(false) - .no_copy("napi_property_descriptor") - .no_copy("napi_extended_error_info") - .no_copy("napi_node_version") - .no_copy("napi_module") - .raw_line("pub use ohos_sys_opaque_types::{napi_env, napi_value};") - }), - }, - BindingConf { - include_filename: "hitrace/trace.h".to_string(), - output_prefix: "components/hitrace/src/hitrace".to_string(), - set_builder_opts: Box::new(|builder| { - builder - .default_enum_style(EnumVariation::NewType { - is_bitfield: false, - is_global: false, - }) - .bitfield_enum("^HiTrace_Flag$") - .rustified_non_exhaustive_enum("HiTrace_Tracepoint_Type") - .blocklist_var("LOG_DOMAIN") - .clang_arg("-include") - .clang_arg("stdbool.h") - }), - }, - BindingConf { - include_filename: "ace/xcomponent/native_interface_xcomponent.h".to_string(), - output_prefix: "components/xcomponent/src/xcomponent".to_string(), - set_builder_opts: Box::new(|builder| { - builder - .default_enum_style(EnumVariation::NewType { - is_bitfield: false, - is_global: false, - }) - .allowlist_file(r".*/xcomponent/native_.*xcomponent.*\.h") - .allowlist_recursively(false) - .no_copy("^OH_NativeXComponent$") - .no_copy("^OH_NativeXComponent_KeyEvent$") - .no_debug("^OH_NativeXComponent$") - .no_debug("^OH_NativeXComponent_KeyEvent$") - .blocklist_item("ArkUI_.*") - // Requires a patch to bindgen - .blocklist_item("OH_NATIVEXCOMPONENT_RESULT.*") - .blocklist_function("OH_NativeXComponent_.*NativeRootNode") - .blocklist_function("OH_NativeXComponent_RegisterUIInputEventCallback") - .blocklist_function("OH_NativeXComponent_RegisterOnTouchInterceptCallback") - .blocklist_function("OH_NativeXComponent_GetNativeXComponent") - .raw_line("#[cfg(feature = \"api-13\")]") - .raw_line("use ohos_sys_opaque_types::ArkUI_AccessibilityProvider;") - .clang_args(&["-x", "c++"]) - }), - }, - BindingConf { - include_filename: "ace/xcomponent/native_interface_xcomponent.h".to_string(), - output_prefix: "components/xcomponent/src/xcomponent_result".to_string(), - set_builder_opts: Box::new(|builder| { - builder - .raw_line("#![allow(unused)]") - .allowlist_var("OH_NATIVEXCOMPONENT_RESULT_.*") - .clang_args(&["-x", "c++"]) - }), - }, - BindingConf { - include_filename: "ace/xcomponent/native_interface_xcomponent.h".to_string(), - output_prefix: "components/xcomponent/src/xcomponent_arkui".to_string(), - set_builder_opts: Box::new(|builder| { - builder - .raw_line("use super::xcomponent_ffi::*;") - .raw_line("use arkui_sys::native_type::ArkUI_NodeHandle;") - .raw_line("use arkui_sys::ui_input_event::{ArkUI_UIInputEvent, ArkUI_UIInputEvent_Type, HitTestMode};") - .allowlist_function("OH_NativeXComponent_.*NativeRootNode") - .allowlist_function("OH_NativeXComponent_RegisterUIInputEventCallback") - .allowlist_function("OH_NativeXComponent_RegisterOnTouchInterceptCallback") - .blocklist_type(".*") - .clang_args(&["-x", "c++"]) - }), - }, - BindingConf { - include_filename: "native_buffer/native_buffer.h".to_string(), - output_prefix: "src/native_buffer/native_buffer".to_string(), - set_builder_opts: Box::new(|builder| { - builder - .default_enum_style(EnumVariation::NewType { - is_bitfield: false, - is_global: false, - }) - .allowlist_file(r".*/native_buffer/.*\.h") - .bitfield_enum("OH_NativeBuffer_Usage") - .blocklist_item("^(OH)?NativeWindow(Buffer)?") - .raw_line("use ohos_sys_opaque_types::{OH_NativeBuffer, OHNativeWindowBuffer};") - }), - }, - BindingConf { - include_filename: "native_image/native_image.h".to_string(), - output_prefix: "src/native_image/native_image".to_string(), - set_builder_opts: Box::new(|builder| { - builder - .default_enum_style(EnumVariation::NewType { - is_bitfield: false, - is_global: false, - }) - .allowlist_file(r".*/native_image/.*\.h") - .blocklist_item("^(OH)?NativeWindow(Buffer)?") - .raw_line("use ohos_sys_opaque_types::OHNativeWindow;") - .raw_line("#[cfg(feature = \"api-12\")]") - .raw_line("use ohos_sys_opaque_types::OHNativeWindowBuffer;") - .no_copy("^OH_OnFrameAvailableListener") - }), - }, - BindingConf { - include_filename: "native_window/external_window.h".to_string(), - output_prefix: "src/native_window/native_window".to_string(), - set_builder_opts: Box::new(|builder| { - builder - .default_enum_style(EnumVariation::NewType { - is_bitfield: false, - is_global: false, - }) - .constified_enum_module("^NativeWindowOperation$") - .allowlist_file(".*native_window/external_window.h") - .raw_line("use ohos_sys_opaque_types::{OH_NativeBuffer, OHNativeWindow, OHNativeWindowBuffer};") - .derive_copy(false) - }), - }, - BindingConf { - include_filename: "native_vsync/native_vsync.h".to_string(), - output_prefix: "components/vsync/src/vsync".to_string(), - set_builder_opts: Box::new(move |builder| { - builder - .default_enum_style(EnumVariation::NewType { - is_bitfield: false, - is_global: false, - }) - }), - }, - BindingConf { - include_filename: "arkui/ui_input_event.h".to_string(), - output_prefix: "components/arkui/src/ui_input_event/ui_input_event_anon_enums".to_string(), - set_builder_opts: Box::new(move |builder| { - builder - .default_enum_style(EnumVariation::NewType { - is_bitfield: false, - is_global: false, - }) - .allowlist_var("UI_TOUCH_EVENT_ACTION_.*") - .allowlist_var("UI_INPUT_EVENT_TOOL_TYPE_.*") - .allowlist_var("UI_INPUT_EVENT_SOURCE_TYPE_.*") - .allowlist_var("UI_MOUSE_EVENT_ACTION_.*") - .allowlist_var("UI_MOUSE_EVENT_BUTTON_*") - .allowlist_recursively(true) - .clang_args(["-include", "stdbool.h"]) - - }), - }, - BindingConf { - include_filename: "arkui/styled_string.h".to_string(), - output_prefix: "components/arkui/src/styled_string/drawing".to_string(), - set_builder_opts: Box::new(|builder| { - builder - .allowlist_function("OH_ArkUI_StyledString_Create") - .allowlist_function("OH_ArkUI_StyledString_PushTextStyle") - .allowlist_function("OH_ArkUI_StyledString_CreateTypography") - .allowlist_function("OH_ArkUI_StyledString_AddPlaceholder") - .clang_args(["-x", "c++"]) - .allowlist_recursively(false) - .raw_line("pub use super::ArkUI_StyledString;") - .raw_line("pub use ohos_drawing_sys::text_typography::OH_Drawing_PlaceholderSpan;") - .raw_line("pub use ohos_drawing_sys::text_declaration::{OH_Drawing_FontCollection, OH_Drawing_TextStyle, OH_Drawing_Typography, OH_Drawing_TypographyStyle};") - }), - }, - BindingConf { - include_filename: "rawfile/raw_file.h".to_string(), - output_prefix: "components/rawfile/src/raw_file_types".to_string(), - set_builder_opts: Box::new(|builder| { - builder - .ignore_functions() - .clang_args(["-x", "c++"]) - .blocklist_var("_LIBCPP.*") - .raw_line("#[cfg(doc)]") - .raw_line("use crate::{raw_file::{OH_ResourceManager_GetRawFileDescriptor,OH_ResourceManager_GetRawFileDescriptor64},\ - raw_file_manager::OH_ResourceManager_OpenRawFile};") - }), - }, - ] -} - -/// Convenience method for stripping am optional suffix and returning an owned String -fn strip_suffix(input: &str, suffix: &str) -> String { - match input.strip_suffix(suffix) { - None => input.to_string(), - Some(stripped) => stripped.to_string() - } -} - -/// Convenience method for stripping am optional suffix and returning an owned String -fn strip_prefix(input: &str, prefix: &str) -> String { - match input.strip_prefix(prefix) { - None => input.to_string(), - Some(stripped) => stripped.to_string() - } -} - -fn apply_drawing_nocopy(builder: bindgen::Builder) -> bindgen::Builder { - let blocklist = [ - "OH_Drawing_Canvas", - "OH_Drawing_Pen", - "OH_Drawing_Brush", - "OH_Drawing_Path", - "OH_Drawing_Bitmap", - "OH_Drawing_FontCollection", - "OH_Drawing_Typography", - "OH_Drawing_TextStyle", - "OH_Drawing_TypographyStyle", - "OH_Drawing_TypographyCreate", - //--- API-11 ------------------------------------- - "OH_Drawing_Point", - "OH_Drawing_Rect", - "OH_Drawing_RoundRect", - "OH_Drawing_ShaderEffect", - "OH_Drawing_Filter", - "OH_Drawing_MaskFilter", - "OH_Drawing_ColorFilter", - "OH_Drawing_Font", - "OH_Drawing_Typeface", - "OH_Drawing_TextBlob", - "OH_Drawing_TextBlobBuilder", - "OH_Drawing_TextBox", - "OH_Drawing_PositionAndAffinity", - "OH_Drawing_Range", - "OH_Drawing_Matrix", - "OH_Drawing_RunBuffer", - // ---- API-12 --------------------------------------- - "OH_Drawing_Region", - "OH_Drawing_PixelMap", - "OH_Drawing_ColorSpace", - "OH_Drawing_Point2D", - "OH_Drawing_Point3D", - "OH_Drawing_PathEffect", - "OH_Drawing_ShadowLayer", - "OH_Drawing_MemoryStream", - "OH_Drawing_Image", - "OH_Drawing_ImageFilter", - "OH_Drawing_SamplingOptions", - "OH_Drawing_GpuContext", - "OH_Drawing_Surface", - "OH_Drawing_FontMgr", - "OH_Drawing_FontStyleSet", - "OH_Drawing_BitmapFormat", - "OH_Drawing_FontParser", - "OH_Drawing_TextShadow", - // Maybe: OH_Drawing_StrutStyle - ]; - let mut builder = builder; - for obj in blocklist { - builder = builder.no_copy(obj); - builder = builder.no_debug(obj); - } - builder -} - -// todo: unify via trait -fn get_module_bindings_config(api_version: u32) -> Vec { - vec![DirBindingsConf { - directory: "multimedia/image_framework/image".to_string(), - output_dir: "components/multimedia/image_framework/src/native_image".to_string(), - min_api_version: 12, - rename_output_file: Some(Box::new(|stem| strip_suffix(stem, "_native"))), - set_builder_opts: Box::new( - |file_stem, header_path, builder| { - let builder = if file_stem != "image_common" { - builder.raw_line("use crate::native_image::common::*;") - } else { - builder - }; - let builder = match file_stem { - "pixelmap" => { - builder - .raw_line("use ohos_sys_opaque_types::{napi_env, napi_value, \ - OH_NativeBuffer, OH_PixelmapNative, OH_NativeColorSpaceManager};") - - }, - "picture" => { - builder - .raw_line("use ohos_sys_opaque_types::OH_PixelmapNative;") - .raw_line("use crate::native_image::pixelmap::PIXEL_FORMAT;") - } - "image_source" => { - builder - .raw_line("pub use ohos_sys_opaque_types::OH_ImageSourceNative;") - .raw_line("use ohos_sys_opaque_types::OH_PixelmapNative;") - .raw_line("use ohos_rawfile_sys::RawFileDescriptor;") - .raw_line("#[cfg(feature = \"api-13\")]") - .raw_line("use crate::native_image::picture::{OH_PictureNative, Image_AuxiliaryPictureType};") - } - // Todo: these bindings are hand-picked and feature guarded right now - autogenerate... - "image_receiver" => { - builder.raw_line("use crate::native_image::image::OH_ImageNative;") - } - "image_packer" => { - builder - .raw_line("use ohos_sys_opaque_types::OH_PixelmapNative;") - .raw_line("#[cfg(feature = \"api-12\")]") - .raw_line("use ohos_sys_opaque_types::OH_ImageSourceNative;") - .raw_line("#[cfg(feature = \"api-13\")]") - .raw_line("use crate::native_image::picture::OH_PictureNative;") - } - "image" => { - builder - .raw_line("use ohos_sys_opaque_types::OH_NativeBuffer;") - - } - _ => builder, - }; - builder - .allowlist_file(format!("{}", header_path.to_str().unwrap())) - .allowlist_recursively(false) - .default_enum_style(EnumVariation::NewType { - is_bitfield: false, - is_global: false, - }) - .derive_copy(false) - .derive_debug(false) - .prepend_enum_name(false) - .clang_args(&["-x", "c++"]) - } - ), - }, DirBindingsConf { - directory: "inputmethod".to_string(), - output_dir: "components/inputmethod/src".to_string(), - min_api_version: 12, - rename_output_file: Some(Box::new(|stem| { - let stem = strip_suffix(stem, "_capi"); - let stem = strip_prefix(&stem, "inputmethod_"); - stem - })), - set_builder_opts: Box::new( - |file_stem, header_path, builder| { - let builder = if file_stem != "types" { - builder.raw_line("use crate::types::*;") - } else { - builder - }; - let builder = match file_stem { - "text_editor_proxy" => { - builder - .raw_line("use crate::private_command::InputMethod_PrivateCommand;") - .raw_line("use crate::text_config::InputMethod_TextConfig;") - }, - "text_config" => { - builder - .raw_line("use crate::text_avoid_info::InputMethod_TextAvoidInfo;") - .raw_line("use crate::cursor_info::InputMethod_CursorInfo;") - } - "inputmethod_proxy" => { - builder - .raw_line("use crate::private_command::InputMethod_PrivateCommand;") - .raw_line("use crate::cursor_info::InputMethod_CursorInfo;") - } - "controller" => { - builder - .raw_line("use crate::inputmethod_proxy::InputMethod_InputMethodProxy;") - .raw_line("use crate::text_editor_proxy::InputMethod_TextEditorProxy;") - .raw_line("use crate::attach_options::InputMethod_AttachOptions;") - } - _ => builder, - }; - builder - .allowlist_file(format!("{}", header_path.to_str().unwrap())) - .allowlist_recursively(false) - .default_enum_style(EnumVariation::NewType { - is_bitfield: false, - is_global: false, - }) - .derive_copy(false) - .derive_debug(false) - .prepend_enum_name(false) - .clang_args(&["-x", "c++"]) - } - ), - }, - DirBindingsConf { - directory: "native_drawing".to_string(), - output_dir: "components/drawing/src".to_string(), - min_api_version: 12, - rename_output_file: Some(Box::new(|stem| { - let stem = strip_prefix(&stem, "drawing_"); - stem - })), - set_builder_opts: Box::new( - |file_stem, header_path, builder| { - let builder = if file_stem != "types" { - let builder = builder.raw_line("use crate::types::*;"); - if file_stem != "error_code" { - builder - .raw_line("") - .raw_line("#[allow(unused_imports)]") - .raw_line("#[cfg(feature = \"api-12\")]") - .raw_line("use crate::error_code::OH_Drawing_ErrorCode;") - } else { - builder - } - } else { - builder - }; - let builder = match file_stem { - "font_collection" => { - builder - .raw_line("use crate::text_declaration::*;") - }, - "text_typography" => { - builder - .raw_line("use crate::text_declaration::*;") - .raw_line("#[cfg(feature = \"api-12\")]") - .raw_line("use crate::font::OH_Drawing_Font_Metrics;") - // FIXME: This needs to be guarded behind API-level-12 (fixed in SDK-13) - // We blocklist for now and remove when updating to SDK-13 - .blocklist_function("OH_Drawing_TypographyGetLineFontMetrics") - } - "register_font" => { - builder - .raw_line("use crate::text_declaration::*;") - } - "image_filter" => { - builder - .raw_line("use crate::shader_effect::*;") - }, - "font_mgr" => { - builder.raw_line("use crate::text_typography::*;") - }, - "pixel_map" => { - builder.raw_line("use ohos_sys_opaque_types::{OH_PixelmapNative, NativePixelMap_};") - } - _ => builder, - }; - let builder = builder - .allowlist_file(format!("{}", header_path.to_str().unwrap())) - .allowlist_recursively(false) - .default_enum_style(EnumVariation::NewType { - is_bitfield: false, - is_global: false, - }) - .prepend_enum_name(false) - .clang_args(&["-x", "c++"]); - - apply_drawing_nocopy(builder) - } - ), - }, - DirBindingsConf { - directory: "arkui".to_string(), - output_dir: "components/arkui/src".to_string(), - min_api_version: 12, - rename_output_file: None, - set_builder_opts: Box::new( - |file_stem, header_path, builder| { - let builder = if file_stem != "native_type" { - builder.raw_line("use crate::native_type::*;") - } else { - builder - }; - let builder = builder - .allowlist_file(format!("{}", header_path.to_str().unwrap())) - .allowlist_recursively(false) - .default_enum_style(EnumVariation::NewType { - is_bitfield: false, - is_global: false, - }) - .derive_copy(false) - .derive_debug(false) - .prepend_enum_name(false) - .clang_args(&["-x", "c++"]); - match file_stem { - "drag_and_drop" => { - builder - // Todo: Requires bindings to `database/udmf` - .blocklist_function("OH_ArkUI_DragEvent_SetData") - .blocklist_function("OH_ArkUI_DragEvent_GetUdmfData") - .blocklist_function("OH_ArkUI_DragAction_SetData") - // Pixelmap is from image-kit - .raw_line("pub use ohos_sys_opaque_types::OH_PixelmapNative;") - - } - "drawable_descriptor" => { - builder - .raw_line("pub use ohos_sys_opaque_types::OH_PixelmapNative;") - - }, - "native_gesture" => { - builder - .raw_line("use crate::ui_input_event::ArkUI_UIInputEvent;") - .blocklist_function("^OH_ArkUI_GestureEvent_GetNode") - }, - "native_interface_accessibility" => { - builder - .raw_line("use ohos_sys_opaque_types::ArkUI_AccessibilityProvider;") - }, - "native_node" => { - builder - .blocklist_var("MAX_NODE_SCOPE_NUM") - .blocklist_var("MAX_COMPONENT_EVENT_ARG_NUM") - .raw_line("use crate::ui_input_event::ArkUI_UIInputEvent;") - }, - "native_node_napi" => { - builder - .raw_line("use ohos_sys_opaque_types::{napi_env, napi_value};") - .raw_line("use crate::drawable_descriptor::ArkUI_DrawableDescriptor;") - - }, - "native_type" => { - builder - .raw_line("use crate::drawable_descriptor::ArkUI_DrawableDescriptor;") - // We want copy for the union type `ArkUI_NumberValue` - .derive_copy(true) - .no_copy("ArkUI_ContextCallback") - .no_copy("ARKUI_TextPickerRangeContent") - .no_copy("ARKUI_TextPickerCascadeRangeContent") - .no_copy("ArkUI_ColorStop") - - }, - "styled_string" => { - builder - .blocklist_function("OH_ArkUI_StyledString_Create") - .blocklist_function("OH_ArkUI_StyledString_PushTextStyle") - .blocklist_function("OH_ArkUI_StyledString_CreateTypography") - .blocklist_function("OH_ArkUI_StyledString_AddPlaceholder") - } - "ui_input_event" => { - builder - .bitfield_enum("ArkUI_ModifierKeyName") - .blocklist_item("UI_TOUCH_EVENT_ACTION_.*") - .blocklist_item("UI_INPUT_EVENT_TOOL_TYPE_.*") - .blocklist_item("UI_INPUT_EVENT_SOURCE_TYPE_.*") - .blocklist_item("UI_MOUSE_EVENT_ACTION_.*") - .blocklist_item("UI_MOUSE_EVENT_BUTTON_.*") - - }, - _ => builder, - } - } - ), - }, - - DirBindingsConf { - directory: "rawfile".to_string(), - output_dir: "components/rawfile/src".to_string(), - min_api_version: 10, - rename_output_file: None, - set_builder_opts: Box::new( - |file_stem, header_path, builder| { - let builder = builder - .allowlist_file(format!("{}", header_path.to_str().unwrap())) - .allowlist_recursively(false) - .default_enum_style(EnumVariation::NewType { - is_bitfield: false, - is_global: false, - }) - .prepend_enum_name(false) - .clang_args(&["-x", "c++"]); - match file_stem { - "raw_file" => { - builder - // Types are generated separately, since they might be shared. - .blocklist_var(".*") - .blocklist_type(".*") - .raw_line("use crate::raw_file_types_ffi::*;") - .raw_line("#[cfg(doc)]") - .raw_line("use crate::raw_file_manager::{OH_ResourceManager_OpenRawFile, OH_ResourceManager_OpenRawDir};") - .raw_line("#[cfg(doc)]") - .raw_line("use crate::raw_file_manager::OH_ResourceManager_OpenRawFile64;") - }, - "raw_dir" => { - builder - .raw_line("#[cfg(doc)]") - .raw_line("use crate::raw_file_manager::{OH_ResourceManager_OpenRawFile, OH_ResourceManager_OpenRawDir};") - - } - "raw_file_manager" => { - builder - .raw_line("use ohos_sys_opaque_types::{napi_env, napi_value};") - .raw_line("use crate::raw_dir::RawDir;") - .raw_line("use crate::RawFile;") - .raw_line("#[cfg(doc)]") - .raw_line("use crate::raw_dir::OH_ResourceManager_CloseRawDir;") - .raw_line("#[cfg(doc)]") - .raw_line("use crate::raw_file::{OH_ResourceManager_CloseRawFile, OH_ResourceManager_CloseRawFile64};") - .raw_line("#[cfg(feature = \"api-11\")]") - .raw_line("use crate::RawFile64;") - - } - _ => builder, - } - } - ), - }, - ] -} /// Generate bindings for the helper crate with the opaque type definitions. fn generate_opaque_types_bindings(root_dir: &Path, builder: bindgen::Builder, sysroot_include_dir: &Path) -> anyhow::Result<()> {