Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor refactoring and add Input-kit bindings #72

Merged
merged 4 commits into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions components/drawing/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions components/drawing/src/text_blob/text_blob_ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions components/drawing/src/types/types_ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
33 changes: 33 additions & 0 deletions components/multimodal-input/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions components/multimodal-input/Changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changelog

## v0.1.0

- Initial release
11 changes: 11 additions & 0 deletions components/multimodal-input/README.md
Original file line number Diff line number Diff line change
@@ -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.
5 changes: 5 additions & 0 deletions components/multimodal-input/src/axis_type.rs
Original file line number Diff line number Diff line change
@@ -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::*;
159 changes: 159 additions & 0 deletions components/multimodal-input/src/axis_type/axis_type_ffi.rs
Original file line number Diff line number Diff line change
@@ -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);
6 changes: 6 additions & 0 deletions components/multimodal-input/src/input_manager.rs
Original file line number Diff line number Diff line change
@@ -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::*;
Loading
Loading