Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Coping0606
Docs
提交
f0336962
D
Docs
项目概览
Coping0606
/
Docs
与 Fork 源项目一致
Fork自
OpenHarmony / Docs
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
f0336962
编写于
3月 22, 2022
作者:
O
openharmony_ci
提交者:
Gitee
3月 22, 2022
浏览文件
操作
浏览文件
下载
差异文件
!2250 添加inputeventclient的api
Merge pull request !2250 from mayunteng/master
上级
ef7a7e53
c7a1f207
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
157 addition
and
13 deletion
+157
-13
zh-cn/application-dev/reference/apis/Readme-CN.md
zh-cn/application-dev/reference/apis/Readme-CN.md
+1
-0
zh-cn/application-dev/reference/apis/js-apis-inputdevice.md
zh-cn/application-dev/reference/apis/js-apis-inputdevice.md
+99
-13
zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md
...pplication-dev/reference/apis/js-apis-inputeventclient.md
+57
-0
未找到文件。
zh-cn/application-dev/reference/apis/Readme-CN.md
浏览文件 @
f0336962
...
@@ -80,6 +80,7 @@
...
@@ -80,6 +80,7 @@
-
[
输入设备
](
js-apis-inputdevice.md
)
-
[
输入设备
](
js-apis-inputdevice.md
)
-
[
组合按键
](
js-apis-inputconsumer.md
)
-
[
组合按键
](
js-apis-inputconsumer.md
)
-
[
输入监听
](
js-apis-inputmonitor.md
)
-
[
输入监听
](
js-apis-inputmonitor.md
)
-
[
事件注入
](
js-apis-inputeventclient.md
)
-
基本功能
-
基本功能
-
[
应用上下文
](
js-apis-system-app.md
)
-
[
应用上下文
](
js-apis-system-app.md
)
-
[
日志打印
](
js-apis-basic-features-logs.md
)
-
[
日志打印
](
js-apis-basic-features-logs.md
)
...
...
zh-cn/application-dev/reference/apis/js-apis-inputdevice.md
浏览文件 @
f0336962
...
@@ -30,6 +30,7 @@ getDeviceIds(callback: AsyncCallback<Array<number>>): void
...
@@ -30,6 +30,7 @@ getDeviceIds(callback: AsyncCallback<Array<number>>): void
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback
<
Array
<
number
>>
| 是 | 回调函数。 |
| callback | AsyncCallback
<
Array
<
number
>>
| 是 | 回调函数。 |
**示例:**
**示例:**
```
```
...
@@ -46,6 +47,37 @@ testGetDeviceIds: function () {
...
@@ -46,6 +47,37 @@ testGetDeviceIds: function () {
}
}
```
```
## inputDevice.getDeviceIds
function getDeviceIds(): Promise
<Array
<
number
>
>
获取所有输入设备的id列表,使用Promise方式作为异步方法。
**系统能力:**
SystemCapability.MultimodalInput.Input.InputDevice
**返回值:**
| 参数 | 说明 |
| -------- | -------- |
| Promise
<Array
<
number
>
> | Promise实例,用于异步获取结果 |
**示例:**
```
testGetDeviceIds: function () {
console.info("InputDeviceJsTest---start---testGetDeviceIds");
let promise = inputDevice.getDeviceIds();
promise.then((data)=> {
console.info('GetDeviceIds successed, Data: ' + JSON.stringify(data))
}).catch((err)=>{
console.error('Failed GetDeviceIds. Cause: ' + JSON.stringify(err));
});
}
```
## inputDevice.getDevice
## inputDevice.getDevice
...
@@ -82,27 +114,81 @@ testGetDevice: function () {
...
@@ -82,27 +114,81 @@ testGetDevice: function () {
}
}
```
```
## inputDevice.getDevice
function getDevice(deviceId: number): Promise
<InputDeviceData>
获取输入设备的描述信息,使用Promise方式作为异步方法。
**系统能力:**
SystemCapability.MultimodalInput.Input.InputDevice
**返回值:**
| 参数 | 说明 |
| -------- | -------- |
| Promise
<InputDeviceData>
| Promise实例,用于异步获取结果 |
**示例:**
```
InputDeviceData {
deviceId : 0,
name : "NA",
sources : Array,
axisRanges : Array,
},
testGetDevice: function () {
// 示例获取设备id为1的设备信息。
console.info("InputDeviceJsTest---start---testGetDevice");
let promise = inputDevice.getDevice(1);
promise.then((data)=> {
console.info('GetDeviceId successed, Data: ' + JSON.stringify(data))
}).catch((err)=>{
console.error('Failed GetDeviceId. Cause: ' + JSON.stringify(err));
});
}
```
## InputDeviceData
## InputDeviceData
输入设备的描述信息。
输入设备的描述信息。
**系统能力:**
以下各项对应系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
**系统能力:**
以下各项对应
的
系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
| 名称 | 参数类型 | 说明 |
| 名称 | 参数类型 | 说明 |
| -------- | -------- | -------- |
| -------- | -------- | -------- |
| id | number | 输入设备的唯一标识,同一个物理设备反复插拔,其设备id会发生变化。 |
| id | number | 输入设备的唯一标识,同一个物理设备反复插拔,其设备id会发生变化。 |
| name | string | 输入设备的名字。 |
| name | string | 输入设备的名字。 |
| sources | Array
<
[SourceType](#sourcetype)
>
| 输入设备支持的源类型。比如有的键盘上附带触摸板,则此设备有keyboard和touchpad两种输入源。 |
| sources | Array
<
[SourceType](#sourcetype)
>
| 输入设备支持的源类型。比如有的键盘上附带触摸板,则此设备有keyboard和touchpad两种输入源。 |
## AxisType
轴类型,本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。
## AxisRange
输入设备的轴信息
**系统能力:**
以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
| 名称 | 参数类型 | 说明 |
| ------ | ------------------------- | ---------------- |
| source |
[
SourceType
](
#sourcetype
)
| 轴的输入源类型。 |
| axis |
[
AxisType
](
axistype
)
| 轴的类型 |
| max | number | 轴上报的最大值 |
| min | number | 轴上报的最小值 |
## SourceType
## SourceType
定义这个轴的输入源类型。比如鼠标设备可上报x轴事件,则x轴的源就是鼠标。
定义这个轴的输入源类型。比如鼠标设备可上报x轴事件,则x轴的源就是鼠标。
**系统能力:**
以下各项对应系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
**系统能力:**
以下各项对应
的
系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
| 名称 | 参数类型 | 说明 |
| 名称 | 参数类型 | 说明 |
| -------- | -------- | -------- |
| -------- | -------- | -------- |
| keyboard | string | 表示输入设备是键盘。 |
| keyboard | string | 表示输入设备是键盘。 |
| touchscreen | string | 表示输入设备是触摸屏。 |
| touchscreen | string | 表示输入设备是触摸屏。 |
...
...
zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md
0 → 100644
浏览文件 @
f0336962
# 注入按键
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
>
> - 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
>
> - 本模块接口均为系统接口,三方应用不支持调用。
## 导入模块
```
import inputEventClient from '@ohos.multimodalInput.inputEventClient';
```
## inputEventClient.injectEvent
injectEvent({KeyEvent: KeyEvent}): void
注入按键,KeyEvent为注入按键的描述信息。
**系统能力:**
SystemCapability.MultimodalInput.Input.InputSimulator
**参数:**
| 参数 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| KeyEvent |
[
KeyEvent
](
#keyevent
)
| 是 | 注入按键的描述信息 |
**示例:**
```
let keyEvent = {
isPressed: true,
keyCode: 2,
keyDownDuration: 0,
isIntercepted: false
}
res = inputEventClient.injectEvent({KeyEvent: keyEvent});
```
## KeyEvent
注入按键的描述信息
**系统能力:**
以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputSimulator
| 参数 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| isPressed | boolean | 是 | 按键是否按下 |
| keyCode | Number | 是 | 按键键值 |
| keyDownDuration | boolean | 是 | 按键按下持续时间 |
| isIntercepted | Number | 是 | 按键是否可以被拦截 |
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录