From 5e4cd6fb6d555a544d3b0adcd697da7e613b1bb5 Mon Sep 17 00:00:00 2001 From: l30075025 Date: Fri, 4 Jul 2025 11:49:26 +0800 Subject: [PATCH 1/2] fix Signed-off-by: l30075025 --- .../js-apis-inputmonitor-sys.md | 56 +++++++++++++++++++ .../apis-input-kit/js-apis-touchevent-sys.md | 1 + 2 files changed, 57 insertions(+) diff --git a/zh-cn/application-dev/reference/apis-input-kit/js-apis-inputmonitor-sys.md b/zh-cn/application-dev/reference/apis-input-kit/js-apis-inputmonitor-sys.md index 57afebbb5f1..19203857595 100644 --- a/zh-cn/application-dev/reference/apis-input-kit/js-apis-inputmonitor-sys.md +++ b/zh-cn/application-dev/reference/apis-input-kit/js-apis-inputmonitor-sys.md @@ -1687,3 +1687,59 @@ struct Index { } } ``` + +## inputMonitor.queryTouchEvents()20+ + +queryTouchEvents(count: number): Promise<Array<TouchEvent>> + +查询最近的触屏事件,最多支持查询 100 条事件,使用Promise异步回调。 + +**需要权限:** ohos.permission.INPUT_MONITORING + + + +**系统能力:** SystemCapability.MultimodalInput.Input.InputMonitor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| count | number | 是 | 要查询的触屏事件数量。取值范围为1-100的整数。 | + +**返回值:** + +| 类型 | 说明 | +| :------------ | :---------------------------------- | +| Promise<Array<[TouchEvent](js-apis-touchevent-sys.md#touchevent)>> | Promise对象,返回查询到的触屏事件。包含以下有效信息:
- actionTime:触屏事件发生的时间,表示从1970.1.1 00:00:00 GMT逝去的微秒数。
- [SourceType](js-apis-touchevent.md#sourcetype):触摸来源的设备类型。
- [isInject](js-apis-touchevent-sys.md#touchevent):表示该触屏事件是否为注入事件。
- pressure:压力值,取值范围是[0.0, 1.0],0.0表示不支持。
- tiltX:相对YZ平面的角度,取值的范围[-90, 90],其中正值是向右倾斜。
- tiltY:相对XZ平面的角度,取值的范围[-90, 90],其中正值是向下倾斜。 | + +**错误码**: + +以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。 + + + +| 错误码ID | 错误信息 | +| -------- | ------------------------------------------------------------ | +| 201 | Permission denied. | +| 202 | Permission denied, non-system app called system api. | + +**示例:** + +```js +import { inputMonitor, TouchEvent } from '@kit.InputKit' +import { BusinessError } from '@kit.BasicServicesKit'; + +try { + inputMonitor.queryTouchEvents(10).then((events: Array) => { + events.forEach((event, index) => { + console.info(`Touch event ${index}: actionTime=${event.actionTime}, sourceType=${event.sourceType}`); + }); + }).catch((error: BusinessError) => { + console.error('queryTouchEvents promise error: ' + JSON.stringify(error)); + }); +} catch (error) { + const code = (error as BusinessError).code; + const message = (error as BusinessError).message; + console.error(`queryTouchEvents failed, error code: ${code}, message: ${message}.`); +} +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis-input-kit/js-apis-touchevent-sys.md b/zh-cn/application-dev/reference/apis-input-kit/js-apis-touchevent-sys.md index 6ce6212f6be..b9837575cdf 100644 --- a/zh-cn/application-dev/reference/apis-input-kit/js-apis-touchevent-sys.md +++ b/zh-cn/application-dev/reference/apis-input-kit/js-apis-touchevent-sys.md @@ -51,3 +51,4 @@ import { FixedMode, Touch, TouchEvent } from '@kit.InputKit'; | 名称 | 类型 | 只读 | 可选 | 说明 | | ---------- | ---------- | ---- | ---- | --------- | | fixedMode | [FixedMode](#fixedmode) | 否 | 是 | 修正坐标的模式。
**说明**:该接口仅在手机设备上生效。| +| isInject20+ | boolean | 否 | 是 | 表示该触屏事件是否为注入事件。注入事件详细介绍可参考[@ohos.multimodalInput.inputEventClient](js-apis-inputeventclient-sys.md)。
**说明**:该接口仅在手机设备上生效。| -- Gitee From 50d2d1e8b5573063d1f239b976a996da125c7e96 Mon Sep 17 00:00:00 2001 From: l30075025 Date: Fri, 4 Jul 2025 11:54:31 +0800 Subject: [PATCH 2/2] fix Signed-off-by: l30075025 --- .../reference/apis-input-kit/js-apis-inputmonitor-sys.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/zh-cn/application-dev/reference/apis-input-kit/js-apis-inputmonitor-sys.md b/zh-cn/application-dev/reference/apis-input-kit/js-apis-inputmonitor-sys.md index 19203857595..d0a6df8a692 100644 --- a/zh-cn/application-dev/reference/apis-input-kit/js-apis-inputmonitor-sys.md +++ b/zh-cn/application-dev/reference/apis-input-kit/js-apis-inputmonitor-sys.md @@ -1696,8 +1696,6 @@ queryTouchEvents(count: number): Promise<Array<TouchEvent>> **需要权限:** ohos.permission.INPUT_MONITORING - - **系统能力:** SystemCapability.MultimodalInput.Input.InputMonitor **参数:** @@ -1716,8 +1714,6 @@ queryTouchEvents(count: number): Promise<Array<TouchEvent>> 以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。 - - | 错误码ID | 错误信息 | | -------- | ------------------------------------------------------------ | | 201 | Permission denied. | -- Gitee