Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
1066e497
D
Docs
项目概览
OpenHarmony
/
Docs
接近 2 年 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
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看板
未验证
提交
1066e497
编写于
10月 11, 2022
作者:
O
openharmony_ci
提交者:
Gitee
10月 11, 2022
浏览文件
操作
浏览文件
下载
差异文件
!10373 api异常处理,docs修改
Merge pull request !10373 from mayunteng/master
上级
2e33a939
c39e04d3
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
846 addition
and
107 deletion
+846
-107
en/application-dev/reference/apis/js-apis-inputconsumer.md
en/application-dev/reference/apis/js-apis-inputconsumer.md
+1
-1
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-cooperate.md
zh-cn/application-dev/reference/apis/js-apis-cooperate.md
+367
-0
zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md
...n/application-dev/reference/apis/js-apis-inputconsumer.md
+18
-10
zh-cn/application-dev/reference/apis/js-apis-inputdevice.md
zh-cn/application-dev/reference/apis/js-apis-inputdevice.md
+199
-31
zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md
...pplication-dev/reference/apis/js-apis-inputeventclient.md
+13
-2
zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md
zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md
+65
-14
zh-cn/application-dev/reference/apis/js-apis-pointer.md
zh-cn/application-dev/reference/apis/js-apis-pointer.md
+100
-49
zh-cn/application-dev/reference/errorcodes/errorcodes-multimodalinput.md
...on-dev/reference/errorcodes/errorcodes-multimodalinput.md
+82
-0
未找到文件。
en/application-dev/reference/apis/js-apis-inputconsumer.md
浏览文件 @
1066e497
...
...
@@ -68,7 +68,7 @@ This is a system API.
**Example**
```
let keyOptions = {preKeys: [], finalKey:
3
, isFinalKeyDown: true, finalKeyDownDuration: 0}
let keyOptions = {preKeys: [], finalKey:
18
, isFinalKeyDown: true, finalKeyDownDuration: 0}
let callback = function(keyOptions) {
console.info("preKeys: " + keyOptions.preKeys, "finalKey: " + keyOptions.finalKey,
"isFinalKeyDown: " + keyOptions.isFinalKeyDown, "finalKeyDownDuration: " + keyOptions.finalKeyDownDuration)
...
...
zh-cn/application-dev/reference/apis/Readme-CN.md
浏览文件 @
1066e497
...
...
@@ -215,6 +215,7 @@
-
[
@ohos.geolocation (位置服务)
](
js-apis-geolocation.md
)
-
[
@ohos.multimodalInput.inputConsumer (组合按键)
](
js-apis-inputconsumer.md
)
-
[
@ohos.multimodalInput.inputDevice (输入设备)
](
js-apis-inputdevice.md
)
-
[
@ohos.multimodalInput.inputDeviceCooperate (键鼠穿越管理)
](
js-apis-cooperate.md
)
-
[
@ohos.multimodalInput.inputEvent (输入事件)
](
js-apis-inputevent.md
)
-
[
@ohos.multimodalInput.inputEventClient (注入按键)
](
js-apis-inputeventclient.md
)
-
[
@ohos.multimodalInput.inputMonitor (输入监听)
](
js-apis-inputmonitor.md
)
...
...
zh-cn/application-dev/reference/apis/js-apis-cooperate.md
0 → 100755
浏览文件 @
1066e497
# 键鼠穿越管理
键鼠穿越功能,即两台或多台设备组网协同后可以共用一套键盘鼠标。
键鼠穿越管理模块,提供实现键盘、鼠标等外接输入设备的跨设备协同操作。在设备组网的情况下,提供多设备间共享键鼠的开关,设备穿越状态更新以及键鼠穿越光标自适应显示。
> **说明**
>
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块
```
js
import
inputDeviceCooperate
from
'
@ohos.multimodalInput.inputDeviceCooperate
'
```
## inputDeviceCooperate.enable<sup>9+</sup>
enable(enable: boolean, callback: AsyncCallback
\<
void>): void
键鼠穿越开关开启或关闭,使用callback异步回调。
**系统能力**
: SystemCapability.MultimodalInput.Input.InputDeviceCooperate
**参数**
:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ------------------------------------------------------------------- |
| enable | boolean | 是 | 键鼠穿越开关开启或关闭状态。true: 键鼠穿越开关开启; false: 键鼠穿越开关关闭。
| callback | AsyncCallback
\<
void> | 是 | 异步回调函数。当键鼠穿越开关开启或关闭成功,err为undefined,否则为错误对象。 |
**示例**
:
```
js
try
{
inputDeviceCooperate
.
enable
(
true
,
(
err
)
=>
{
if
(
err
)
{
console
.
log
(
`Turn on the key mouse crossing switch failed. error code=
${
JSON
.
stringify
(
err
.
code
)}
msg=
${
JSON
.
stringify
(
err
.
message
)}
`
);
return
;
}
console
.
log
(
`Turn on the key mouse crossing switch success.`
);
});
}
catch
(
err
)
{
console
.
log
(
`Turn on the key mouse crossing switch failed. error code=
${
JSON
.
stringify
(
err
.
code
)}
msg=
${
JSON
.
stringify
(
err
.
message
)}
`
);
}
```
## inputDeviceCooperate.enable<sup>9+</sup>
enable(enable: boolean): Promise
\<
void>
键鼠穿越开关开启或关闭,使用Promise方式作为异步方法。
**系统能力**
: SystemCapability.MultimodalInput.Input.InputDeviceCooperate
**参数**
:
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------- | ---- | ------------------------------------------------------------------- |
| enable | boolean | 是 | 键鼠穿越开关开启或关闭状态。true: 键鼠穿越开关开启; false: 键鼠穿越开关关闭。 |
**返回值**
:
| 参数 | 说明 |
| ------------------- | ------------------------------- |
| Promise
\<
void> | Promise实例,用于异步获取结果。 |
**示例**
:
```
js
try
{
inputDeviceCooperate
.
enable
(
false
).
then
((
err
)
=>
{
console
.
log
(
`Turn on the key mouse crossing switch success`
);
},
(
err
)
=>
{
console
.
log
(
`Turn on the key mouse crossing switch failed. error code=
${
JSON
.
stringify
(
err
.
code
)}
msg=
${
JSON
.
stringify
(
err
.
message
)}
`
);
});
}
catch
(
err
)
{
console
.
log
(
`Turn on the key mouse crossing switch failed. error code=
${
JSON
.
stringify
(
err
.
code
)}
msg=
${
JSON
.
stringify
(
err
.
message
)}
`
);
}
```
## inputDeviceCooperate.start<sup>9+</sup>
start(sinkDeviceDescriptor: string, srcInputDeviceId: number, callback: AsyncCallback
\<
void>): void
启动键鼠穿越,使用callback异步回调。
**系统能力**
:SystemCapability.MultimodalInput.Input.InputDeviceCooperate
**参数**
:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------- | ---- | ---------------------------- |
| sinkDeviceDescriptor | string | 是 | 键鼠穿越目标设备描述符。 |
| srcInputDeviceId | number | 是 | 键鼠穿越待穿越外设标识符。 |
| callback | AsyncCallback
\<
void> | 是 | 异步回调函数。当键鼠穿越启动成功,err为undefined,否则为错误对象。|
**示例**
:
```
js
try
{
inputDeviceCooperate
.
start
(
sinkDeviceDescriptor
,
srcInputDeviceId
,
(
err
)
=>
{
if
(
err
)
{
console
.
log
(
`Start key mouse crossing failed. error code=
${
JSON
.
stringify
(
err
.
code
)}
msg=
${
JSON
.
stringify
(
err
.
message
)}
`
);
return
;
}
console
.
log
(
`Start key mouse crossing success.`
);
});
}
catch
(
err
)
{
console
.
log
(
`Start key mouse crossing failed. error code=
${
JSON
.
stringify
(
err
.
code
)}
msg=
${
JSON
.
stringify
(
err
.
message
)}
`
);
}
```
## inputDeviceCooperate.start<sup>9+</sup>
start(sinkDeviceDescriptor: string, srcInputDeviceId: number): Promise
\<
void>
启动键鼠穿越,使用Promise方式作为异步方法。
**系统能力**
: SystemCapability.MultimodalInput.Input.InputDeviceCooperate
**参数**
:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------- | ---- | ---------------------------- |
| sinkDeviceDescriptor | string | 是 | 键鼠穿越目标设备描述符。 |
| srcInputDeviceId | number | 是 | 键鼠穿越待穿越外设标识符。 |
**返回值**
:
| 参数名 | 说明 |
| ---------------------- | ------------------------------- |
| Promise
\<
void> | Promise实例,用于异步获取结果。 |
**示例**
:
```
js
try
{
inputDeviceCooperate
.
start
(
sinkDeviceDescriptor
,
srcInputDeviceId
).
then
((
err
)
=>
{
console
.
log
(
`Start key mouse crossing success.`
);
},
(
err
)
=>
{
console
.
log
(
`Start key mouse crossing failed. error code=
${
JSON
.
stringify
(
err
.
code
)}
msg=
${
JSON
.
stringify
(
err
.
message
)}
`
);
});
}
catch
(
err
)
{
console
.
log
(
`Start key mouse crossing failed. error code=
${
JSON
.
stringify
(
err
.
code
)}
msg=
${
JSON
.
stringify
(
err
.
message
)}
`
);
}
```
## inputDeviceCooperate.stop<sup>9+</sup>
stop(callback: AsyncCallback
\<
void>): void
停止键鼠穿越,使用callback异步回调。
**系统能力**
:SystemCapability.MultimodalInput.Input.InputDeviceCooperate
**参数**
:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------- | ---- | ---------------------------- |
| callback | AsyncCallback
\<
void> | 是 | 异步回调函数,返回查询结果。 |
**示例**
:
```
js
try
{
inputDeviceCooperate
.
stop
((
err
)
=>
{
if
(
err
)
{
console
.
log
(
`Stop key mouse crossing failed. error code=
${
JSON
.
stringify
(
err
.
code
)}
msg=
${
JSON
.
stringify
(
err
.
message
)}
`
);
return
;
}
console
.
log
(
`Stop key mouse crossing success.`
);
});
}
catch
(
err
)
{
console
.
log
(
`Stop key mouse crossing failed. error code=
${
JSON
.
stringify
(
err
.
code
)}
msg=
${
JSON
.
stringify
(
err
.
message
)}
`
);
}
```
## inputDeviceCooperate.stop<sup>9+</sup>
stop(): Promise
\<
void>
停止键鼠穿越,使用Promise异步回调。
**系统能力**
:SystemCapability.MultimodalInput.Input.InputDeviceCooperate
**参数**
:
| 参数名 | 说明 |
| -------- | ---------------------------- |
| Promise
\<
void> | Promise实例,用于异步获取结果。 |
**示例**
:
```
js
try
{
inputDeviceCooperate
.
stop
().
then
((
err
)
=>
{
console
.
log
(
`Stop key mouse crossing success.`
);
},
(
err
)
=>
{
console
.
log
(
`Stop key mouse crossing failed. error code=
${
JSON
.
stringify
(
err
.
code
)}
msg=
${
JSON
.
stringify
(
err
.
message
)}
`
);
});
}
catch
(
err
)
{
console
.
log
(
`Stop key mouse crossing failed. error code=
${
JSON
.
stringify
(
err
.
code
)}
msg=
${
JSON
.
stringify
(
err
.
message
)}
`
);
}
```
## inputDeviceCooperate.getState<sup>9+</sup>
getState(deviceDescriptor: string, callback: AsyncCallback
<
{
state:
boolean
}
>
): void
获取键鼠穿越开关的状态,使用callback异步回调。
**系统能力**
:SystemCapability.MultimodalInput.Input.InputDeviceCooperate
**参数**
:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------- | ---- | ---------------------------- |
| deviceDescriptor | string | 是 | 键鼠穿越目标设备描述符。 |
| callback | AsyncCallback
<
{
state:
boolean
}
>
| 是 | 异步回调函数,接收键鼠穿越开关状态。 |
**示例**
:
```
js
try
{
inputDeviceCooperate
.
getState
(
deviceDescriptor
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`Get the status failed. error code=
${
JSON
.
stringify
(
err
.
code
)}
msg=
${
JSON
.
stringify
(
err
.
message
)}
`
);
return
;
}
console
.
log
(
`Get the status success. data=
${
JSON
.
stringify
(
data
)}
`
);
});
}
catch
(
err
)
{
console
.
log
(
`Get the status failed. error code=
${
JSON
.
stringify
(
err
.
code
)}
msg=
${
JSON
.
stringify
(
err
.
message
)}
`
);
}
```
## inputDeviceCooperate.getState<sup>9+</sup>
getState(deviceDescriptor: string): Promise
<
{
state:
boolean
}
>
获取键鼠穿越开关的状态,使用Promise异步回调。
**系统能力**
:SystemCapability.MultimodalInput.Input.InputDeviceCooperate
**参数**
:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------- | ---- | ---------------------------- |
| deviceDescriptor | string | 是 | 键鼠穿越目标设备描述符。 |
**返回值**
:
| 参数 | 说明 |
| ------------------- | ------------------------------- |
| Promise
<
{
state:
boolean
}
>
| Promise实例,用于异步获取结果。 |
**示例**
:
```
js
try
{
inputDeviceCooperate
.
getState
(
deviceDescriptor
).
then
((
data
)
=>
{
console
.
log
(
`Get the status success. data=
${
JSON
.
stringify
(
data
)}
`
);
},
(
err
)
=>
{
console
.
log
(
`Get the status failed. error code=
${
JSON
.
stringify
(
err
.
code
)}
msg=
${
JSON
.
stringify
(
err
.
message
)}
`
);
});
}
catch
(
err
)
{
console
.
log
(
`Get the status failed. error code=
${
JSON
.
stringify
(
err
.
code
)}
msg=
${
JSON
.
stringify
(
err
.
message
)}
`
);
}
```
## on('cooperation')<sup>9+</sup>
on(type: 'cooperation', callback: AsyncCallback
<
{
deviceDescriptor:
string
,
eventMsg:
EventMsg
}
>
): void
注册监听键鼠穿越状态。
**系统能力**
:SystemCapability.MultimodalInput.Input.InputDeviceCooperate
**参数**
:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------- | ---- | ---------------------------- |
| type | string | 是 | 注册类型,'cooperation'。 |
| callback | AsyncCallback
<
{
deviceDescriptor:
string
,
eventMsg:
[
EventMsg
](
#eventmsg
)
}
>
| 是 | 异步回调函数,接收键鼠穿越事件消息。 |
**示例**
:
```
js
try
{
inputDeviceCooperate
.
on
(
'
cooperation
'
,
(
data
)
=>
{
if
(
data
)
{
console
.
log
(
`error:
${
JSON
.
stringify
(
data
)}
`
);
}
else
{
console
.
log
(
`cooperation:
${
JSON
.
stringify
(
data
)}
`
);
}
});
}
catch
(
err
)
{
console
.
log
(
`Registered failed. error code=
${
JSON
.
stringify
(
err
.
code
)}
msg=
${
JSON
.
stringify
(
err
.
message
)}
`
);
}
```
## off('cooperation')<sup>9+</sup>
off(type: 'cooperation', callback?: AsyncCallback
\<
void>): void
关闭监听键鼠穿越状态。
**系统能力**
:SystemCapability.MultimodalInput.Input.InputDeviceCooperate
**参数**
:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------- | ---- | ---------------------------- |
| type | string | 是 | 注册类型,'cooperation'。 |
| callback | AsyncCallback
<void>
| 否 | 异步回调函数,用于返回结果。 |
**示例**
:
```
js
try
{
inputDeviceCooperate
.
off
(
'
cooperation
'
,
(
err
)
=>
{
if
(
err
)
{
console
.
log
(
`error:
${
JSON
.
stringify
(
err
)}
`
);
}
else
{
console
.
log
(
`Unregistered succeed`
);
}
});
}
catch
(
err
)
{
console
.
log
(
`Unregistered failed. error code=
${
JSON
.
stringify
(
err
.
code
)}
msg=
${
JSON
.
stringify
(
err
.
message
)}
`
);
}
```
## EventMsg<sup>9+</sup>
键鼠穿越事件。
**系统能力**
:SystemCapability.MultimodalInput.Input.InputDeviceCooperate
| 参数名 | 值 | 说明 |
| -------- | --------- | ----------------- |
| MSG_COOPERATE_INFO_START | 200 | 键鼠穿越消息,表示键鼠穿越开始。 |
| MSG_COOPERATE_INFO_SUCCESS | 201 | 键鼠穿越消息,表示键鼠穿越成功。 |
| MSG_COOPERATE_INFO_FAIL | 202 | 键鼠穿越消息,表示键鼠穿越失败。 |
| MSG_COOPERATE_STATE_ON | 500 | 键鼠穿越状态,表示键鼠穿越状态开启。 |
| MSG_COOPERATE_STATE_OFF | 501 | 键鼠穿越状态,表示键鼠穿越状态关闭。 |
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md
浏览文件 @
1066e497
...
...
@@ -36,12 +36,16 @@ on(type: "key", keyOptions: KeyOptions, callback: Callback<KeyOptions>): v
**示例:**
```
js
let
keyOptions
=
{
preKeys
:
[],
finalKey
:
3
,
isFinalKeyDown
:
true
,
finalKeyDownDuration
:
0
}
let
callback
=
function
(
keyOptions
)
{
console
.
info
(
"
preKeys:
"
+
keyOptions
.
preKeys
,
"
finalKey:
"
+
keyOptions
.
finalKey
,
"
isFinalKeyDown:
"
+
keyOptions
.
isFinalKeyDown
,
"
finalKeyDownDuration:
"
+
keyOptions
.
finalKeyDownDuration
)
let
keyOptions
=
{
preKeys
:
[],
finalKey
:
18
,
isFinalKeyDown
:
true
,
finalKeyDownDuration
:
0
}
let
callback
=
function
(
keyOptions
)
{
console
.
info
(
"
preKeys:
"
+
keyOptions
.
preKeys
,
"
finalKey:
"
+
keyOptions
.
finalKey
,
"
isFinalKeyDown:
"
+
keyOptions
.
isFinalKeyDown
,
"
finalKeyDownDuration:
"
+
keyOptions
.
finalKeyDownDuration
)
}
try
{
inputConsumer
.
on
(
inputConsumer
.
SubscribeType
.
KEY
,
keyOptions
,
callback
);
}
catch
(
error
)
{
console
.
info
(
`inputConsumer.on, error.code=
${
JSON
.
stringify
(
error
.
code
)}
, error.msg=
${
JSON
.
stringify
(
error
.
message
)}
`
);
}
inputConsumer
.
on
(
'
key
'
,
keyOptions
,
callback
);
```
...
...
@@ -64,12 +68,16 @@ off(type: "key", keyOptions: KeyOptions, callback?: Callback<KeyOptions>):
**示例:**
```
js
let
keyOptions
=
{
preKeys
:
[],
finalKey
:
3
,
isFinalKeyDown
:
true
,
finalKeyDownDuration
:
0
}
let
callback
=
function
(
keyOptions
)
{
console
.
info
(
"
preKeys:
"
+
keyOptions
.
preKeys
,
"
finalKey:
"
+
keyOptions
.
finalKey
,
"
isFinalKeyDown:
"
+
keyOptions
.
isFinalKeyDown
,
"
finalKeyDownDuration:
"
+
keyOptions
.
finalKeyDownDuration
)
let
keyOptions
=
{
preKeys
:
[],
finalKey
:
18
,
isFinalKeyDown
:
true
,
finalKeyDownDuration
:
0
}
let
callback
=
function
(
keyOptions
)
{
console
.
info
(
"
preKeys:
"
+
keyOptions
.
preKeys
,
"
finalKey:
"
+
keyOptions
.
finalKey
,
"
isFinalKeyDown:
"
+
keyOptions
.
isFinalKeyDown
,
"
finalKeyDownDuration:
"
+
keyOptions
.
finalKeyDownDuration
)
}
try
{
inputConsumer
.
off
(
inputConsumer
.
SubscribeType
.
KEY
,
keyOptions
,
callback
);
}
catch
(
error
)
{
console
.
info
(
`inputConsumer.off, error.code=
${
JSON
.
stringify
(
error
.
code
)}
, error.msg=
${
JSON
.
stringify
(
error
.
message
)}
`
);
}
inputConsumer
.
off
(
'
key
'
,
keyOptions
,
callback
);
```
...
...
zh-cn/application-dev/reference/apis/js-apis-inputdevice.md
浏览文件 @
1066e497
...
...
@@ -16,6 +16,130 @@
import
inputDevice
from
'
@ohos.multimodalInput.inputDevice
'
;
```
## inputDevice.getDeviceList<sup>9+</sup>
getDeviceList(callback: AsyncCallback
<
Array
<
number
>>
): void
获取所有输入设备的id列表,使用callback方式作为异步方法。
**系统能力**
:SystemCapability.MultimodalInput.Input.InputDevice
**参数**
:
| 参数 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ---------- |
| callback | AsyncCallback
<
Array
<
number
>>
| 是 | 回调函数。 |
**示例**
:
```
js
try
{
inputDevice
.
getDeviceList
((
error
,
ids
)
=>
{
if
(
error
)
{
console
.
log
(
`Failed to get device list.
error code=
${
JSON
.
stringify
(
err
.
code
)}
msg=
${
JSON
.
stringify
(
err
.
message
)}
`
);
return
;
}
this
.
data
=
ids
;
console
.
log
(
"
The device ID list is:
"
+
ids
);
});
}
catch
(
error
)
{
console
.
info
(
"
getDeviceList
"
+
error
.
code
+
"
"
+
error
.
message
);
}
```
## inputDevice.getDeviceList<sup>9+</sup>
getDeviceList(): Promise
<
Array
<
number
>>
获取所有输入设备的id列表,使用Promise方式作为异步方法。
**系统能力**
:SystemCapability.MultimodalInput.Input.InputDevice
**返回值**
:
| 参数 | 说明 |
| ---------------------------------- | ------------------------------- |
| Promise
<
Array
<
number
>>
| Promise实例,用于异步获取结果。 |
**示例**
:
```
js
try
{
inputDevice
.
getDeviceList
().
then
((
ids
)
=>
{
console
.
log
(
"
The device ID list is:
"
+
ids
);
});
}
catch
(
error
)
{
console
.
info
(
"
getDeviceList
"
+
error
.
code
+
"
"
+
error
.
message
);
}
```
## inputDevice.getDeviceInfo<sup>9+</sup>
getDeviceInfo(deviceId: number, callback: AsyncCallback
<
InputDeviceData
>
): void
获取输入设备的描述信息,使用callback方式作为异步方法。
**系统能力**
:SystemCapability.MultimodalInput.Input.InputDevice
**参数**
:
| 参数 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------------------------- | ---- | --------------------------------------- |
| deviceId | number | 是 | 需要获取信息的设备id。 |
| callback | AsyncCallback
<
[InputDeviceData](#inputdevicedata)
>
| 是 | 回调函数,异步返回InputDeviceData对象。 |
**示例**
:
```
js
// 示例获取设备id为1的设备name信息。
try
{
inputDevice
.
getDeviceInfo
(
1
,
(
error
,
inputDevice
)
=>
{
if
(
error
)
{
console
.
log
(
`Failed to get device information.
error code=
${
JSON
.
stringify
(
err
.
code
)}
msg=
${
JSON
.
stringify
(
err
.
message
)}
`
);
return
;
}
console
.
log
(
"
The device name is:
"
+
inputDevice
.
name
);
});
}
catch
(
error
)
{
console
.
info
(
"
getDeviceInfo
"
+
error
.
code
+
"
"
+
error
.
message
);
}
```
## inputDevice.getDeviceInfo<sup>9+</sup>
getDeviceInfo(deviceId: number): Promise
<
InputDeviceData
>
获取输入设备的描述信息,使用Promise方式作为异步方法。
**系统能力**
:SystemCapability.MultimodalInput.Input.InputDevice
**参数**
:
| 参数 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ---------------------- |
| deviceId | number | 是 | 需要获取信息的设备id。 |
**返回值**
:
| 参数 | 说明 |
| -------------------------------------------------- | ------------------------------- |
| Promise
<
[InputDeviceData](#inputdevicedata)
>
| Promise实例,用于异步获取结果。 |
**示例**
:
```
js
// 示例获取设备id为1的设备name信息。
try
{
inputDevice
.
getDeviceInfo
(
id
).
then
((
inputDevice
)
=>
{
console
.
log
(
"
The device name is:
"
+
inputDevice
.
name
);
});
}
catch
(
error
)
{
console
.
info
(
"
getDeviceInfo
"
+
error
.
code
+
"
"
+
error
.
message
);
}
```
## inputDevice.on<sup>9+</sup>
on(type: “change”, listener: Callback
<
DeviceListener
>
): void
...
...
@@ -35,20 +159,24 @@ on(type: “change”, listener: Callback<DeviceListener>): void
```
js
let
isPhysicalKeyboardExist
=
true
;
inputDevice
.
on
(
"
change
"
,
(
data
)
=>
{
try
{
inputDevice
.
on
(
"
change
"
,
(
data
)
=>
{
console
.
log
(
"
type:
"
+
data
.
type
+
"
, deviceId:
"
+
data
.
deviceId
);
inputDevice
.
getKeyboardType
(
data
.
deviceId
,
(
err
,
ret
)
=>
{
console
.
log
(
"
The keyboard type of the device is:
"
+
ret
);
if
(
ret
==
inputDevice
.
KeyboardType
.
ALPHABETIC_KEYBOARD
&&
data
.
type
==
'
add
'
)
{
// 监听物理键盘已连接。
isPhysicalKeyboardExist
=
true
;
}
else
if
(
ret
==
inputDevice
.
KeyboardType
.
ALPHABETIC_KEYBOARD
&&
data
.
type
==
'
remove
'
)
{
// 监听物理键盘已断开。
isPhysicalKeyboardExist
=
false
;
}
console
.
log
(
"
The keyboard type of the device is:
"
+
ret
);
if
(
ret
==
inputDevice
.
KeyboardType
.
ALPHABETIC_KEYBOARD
&&
data
.
type
==
'
add
'
)
{
// 监听物理键盘已连接。
isPhysicalKeyboardExist
=
true
;
}
else
if
(
ret
==
inputDevice
.
KeyboardType
.
ALPHABETIC_KEYBOARD
&&
data
.
type
==
'
remove
'
)
{
// 监听物理键盘已断开。
isPhysicalKeyboardExist
=
false
;
}
});
});
// 根据isPhysicalKeyboardExist的值决定软键盘是否弹出。
});
// 根据isPhysicalKeyboardExist的值决定软键盘是否弹出。
}
catch
(
error
)
{
console
.
info
(
"
oninputdevcie
"
+
error
.
code
+
"
"
+
error
.
message
);
}
```
## inputDevice.off<sup>9+</sup>
...
...
@@ -69,27 +197,40 @@ off(type: “change”, listener?: Callback<DeviceListener>): void
**示例**
:
```
js
function
listener
(
data
)
{
console
.
log
(
"
type:
"
+
data
.
type
+
"
, deviceId:
"
+
data
.
deviceId
);
callback
:
function
(
data
)
{
console
.
log
(
"
type:
"
+
data
.
type
+
"
, deviceId:
"
+
data
.
deviceId
);
}
// 监听输入设备的热插拔事件
inputDevice
.
on
(
"
change
"
,
listener
);
try
{
inputDevice
.
on
(
"
change
"
,
this
.
callback
);
}
catch
(
error
)
{
console
.
info
(
"
oninputdevcie
"
+
error
.
code
+
"
"
+
error
.
message
)
}
// 单独取消listener的监听。
inputDevice
.
off
(
"
change
"
,
listener
);
try
{
inputDevice
.
off
(
"
change
"
,
this
.
callback
);
}
catch
(
error
)
{
console
.
info
(
"
offinputdevcie
"
+
error
.
code
+
"
"
+
error
.
message
)
}
// 取消所有监听。
inputDevice
.
off
(
"
change
"
);
try
{
inputDevice
.
off
(
"
change
"
);
}
catch
(
error
)
{
console
.
info
(
"
offinputdevcie
"
+
error
.
code
+
"
"
+
error
.
message
);
}
// 取消监听后,软键盘默认都弹出。
```
## inputDevice.getDeviceIds
## inputDevice.getDeviceIds
<sup>(deprecated)</sup>
getDeviceIds(callback: AsyncCallback
<
Array
<
number
>>
): void
获取所有输入设备的id列表,使用callback方式作为异步方法。
从API version 9 开始不再维护,建议使用
[
inputDevice.getDeviceList
](
#inputdevicegetdevicelist9
)
代替。
**系统能力**
:SystemCapability.MultimodalInput.Input.InputDevice
**参数**
:
...
...
@@ -106,12 +247,14 @@ inputDevice.getDeviceIds((ids)=>{
});
```
## inputDevice.getDeviceIds
## inputDevice.getDeviceIds
<sup>(deprecated)</sup>
getDeviceIds(): Promise
<
Array
<
number
>>
获取所有输入设备的id列表,使用Promise方式作为异步方法。
从API version 9 开始不再维护,建议使用
[
inputDevice.getDeviceList
](
#inputdevicegetdevicelist9
)
代替。
**系统能力**
:SystemCapability.MultimodalInput.Input.InputDevice
**返回值**
:
...
...
@@ -128,12 +271,14 @@ inputDevice.getDeviceIds().then((ids)=>{
});
```
## inputDevice.getDevice
## inputDevice.getDevice
<sup>(deprecated)</sup>
getDevice(deviceId: number, callback: AsyncCallback
<
InputDeviceData
>
): void
获取输入设备的描述信息,使用callback方式作为异步方法。
从API version 9 开始不再维护,建议使用
[
inputDevice.getDeviceInfo
](
#inputdevicegetdeviceinfo9
)
代替。
**系统能力**
:SystemCapability.MultimodalInput.Input.InputDevice
**参数**
:
...
...
@@ -152,12 +297,14 @@ inputDevice.getDevice(1, (inputDevice)=>{
});
```
## inputDevice.getDevice
## inputDevice.getDevice
<sup>(deprecated)</sup>
getDevice(deviceId: number): Promise
<
InputDeviceData
>
获取输入设备的描述信息,使用Promise方式作为异步方法。
从API version 9 开始不再维护,建议使用
[
inputDevice.getDeviceInfo
](
#inputdevicegetdeviceinfo9
)
代替。
**系统能力**
:SystemCapability.MultimodalInput.Input.InputDevice
**参数**
:
...
...
@@ -201,9 +348,13 @@ supportKeys(deviceId: number, keys: Array<KeyCode>, callback: Callback<
```
js
// 示例查询id为1的设备对于17、22和2055按键的支持情况。
inputDevice
.
supportKeys
(
1
,
[
17
,
22
,
2055
],
(
ret
)
=>
{
try
{
inputDevice
.
supportKeys
(
1
,
[
17
,
22
,
2055
],
(
error
,
ret
)
=>
{
console
.
log
(
"
The query result is as follows:
"
+
ret
);
});
});
}
catch
(
error
)
{
console
.
info
(
"
supportKeys
"
+
error
.
code
+
"
"
+
error
.
message
);
}
```
## inputDevice.supportKeys<sup>9+</sup>
...
...
@@ -231,9 +382,13 @@ supportKeys(deviceId: number, keys: Array<KeyCode>): Promise<Array<b
```
js
// 示例查询id为1的设备对于17、22和2055按键的支持情况。
inputDevice
.
supportKeys
(
1
,
[
17
,
22
,
2055
]).
then
((
ret
)
=>
{
try
{
inputDevice
.
supportKeys
(
1
,
[
17
,
22
,
2055
]).
then
((
ret
)
=>
{
console
.
log
(
"
The query result is as follows:
"
+
ret
);
})
});
}
catch
(
error
)
{
console
.
info
(
"
supportKeys
"
+
error
.
code
+
"
"
+
error
.
message
);
}
```
## inputDevice.getKeyboardType<sup>9+</sup>
...
...
@@ -255,9 +410,18 @@ getKeyboardType(deviceId: number, callback: AsyncCallback<KeyboardType>):
```
js
// 示例查询设备id为1的设备键盘类型。
inputDevice
.
getKeyboardType
(
1
,
(
ret
)
=>
{
console
.
log
(
"
The keyboard type of the device is:
"
+
ret
);
});
try
{
inputDevice
.
getKeyboardType
(
1
,
(
error
,
number
)
=>
{
if
(
error
)
{
console
.
log
(
`Failed to get keyboardtype.
error code=
${
JSON
.
stringify
(
err
.
code
)}
msg=
${
JSON
.
stringify
(
err
.
message
)}
`
);
return
;
}
console
.
log
(
"
The keyboard type of the device is:
"
+
number
);
});
}
catch
(
error
)
{
console
.
info
(
"
getKeyboardType
"
+
error
.
code
+
"
"
+
error
.
message
);
}
```
## inputDevice.getKeyboardType<sup>9+</sup>
...
...
@@ -278,9 +442,13 @@ getKeyboardType(deviceId: number): Promise<KeyboardType>
```
js
// 示例查询设备id为1的设备键盘类型。
inputDevice
.
getKeyboardType
(
1
).
then
((
ret
)
=>
{
console
.
log
(
"
The keyboard type of the device is:
"
+
ret
);
})
try
{
inputDevice
.
getKeyboardType
(
1
).
then
((
number
)
=>
{
console
.
log
(
"
The keyboard type of the device is:
"
+
number
);
});
}
catch
(
error
)
{
console
.
info
(
"
getKeyboardType
"
+
error
.
code
+
"
"
+
error
.
message
);
}
```
## DeviceListener<sup>9+</sup>
...
...
zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md
浏览文件 @
1066e497
...
...
@@ -34,13 +34,24 @@ injectEvent({KeyEvent: KeyEvent}): void
**示例:**
```
js
let
keyEvent
=
{
try
{
var
keyEvent
=
{
isPressed
:
true
,
keyCode
:
2
,
keyDownDuration
:
0
,
isIntercepted
:
false
}
inputEventClient
.
injectKeyEvent
({
KeyEvent
:
keyEvent
});
var
keyEvent1
=
{
isPressed
:
false
,
keyCode
:
2
,
keyDownDuration
:
0
,
isIntercepted
:
false
};
inputEventClient
.
injectKeyEvent
({
KeyEvent
:
keyEvent1
});
}
catch
(
error
)
{
console
.
info
(
"
injectKeyEvent
"
+
error
.
code
+
"
"
+
error
.
message
);
}
let
res
=
inputEventClient
.
injectEvent
({
KeyEvent
:
keyEvent
});
```
...
...
zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md
浏览文件 @
1066e497
...
...
@@ -35,10 +35,14 @@ on(type: "touch", receiver: TouchEventReceiver): void
**示例:**
```
js
inputMonitor
.
off
(
"
touch
"
,
(
event
)
=>
{
// 消费触屏事件
return
false
;
});
try
{
inputMonitor
.
on
(
"
touch
"
,
(
data
)
=>
{
console
.
info
(
`monitorOnTouchEvent success
${
JSON
.
stringify
(
data
)}
`
);
return
false
;
});
}
catch
(
error
)
{
console
.
info
(
"
onMonitor
"
+
error
.
code
+
"
"
+
error
.
message
)
}
```
...
...
@@ -60,9 +64,14 @@ on(type: "mouse", receiver: Callback<MouseEvent>): void
**示例:**
```
js
inputMonitor
.
off
(
"
mouse
"
,
(
event
)
=>
{
// 消费鼠标事件
});
try
{
inputMonitor
.
on
(
"
mouse
"
,
(
data
)
=>
{
console
.
info
(
`monitorOnMouseEvent success
${
JSON
.
stringify
(
data
)}
`
);
return
false
;
});
}
catch
(
error
)
{
console
.
info
(
"
onMonitor
"
+
error
.
code
+
"
"
+
error
.
message
)
}
```
...
...
@@ -86,7 +95,26 @@ off(type: "touch", receiver?: TouchEventReceiver): void
**示例:**
```
js
inputMonitor
.
off
(
"
touch
"
);
// 取消所有监听。
try
{
inputMonitor
.
off
(
"
touch
"
);
}
catch
(
error
)
{
console
.
info
(
"
offMonitor
"
+
error
.
code
+
"
"
+
error
.
message
)
}
// 单独取消receiver的监听。
callback
:
function
(
data
)
{
console
.
info
(
`call success
${
JSON
.
stringify
(
data
)}
`
);
},
try
{
inputMonitor
.
on
(
"
touch
"
,
this
.
callback
);
}
catch
(
error
)
{
console
.
info
(
"
onTouchMonitor
"
+
error
.
code
+
"
"
+
error
.
message
)
}
,
try
{
inputMonitor
.
off
(
"
touch
"
,
this
.
callback
);
}
catch
(
error
)
{
console
.
info
(
"
offTouchMonitor
"
+
error
.
code
+
"
"
+
error
.
message
)
}
```
off(type: "mouse", receiver?: Callback
<
MouseEvent
>
): void
...
...
@@ -107,7 +135,26 @@ off(type: "mouse", receiver?: Callback<MouseEvent>): void
**示例:**
```
js
inputMonitor
.
off
(
"
mouse
"
);
// 取消所有监听。
try
{
inputMonitor
.
off
(
"
mouse
"
);
}
catch
(
error
)
{
console
.
info
(
"
offMonitor
"
+
error
.
code
+
"
"
+
error
.
message
)
}
// 单独取消receiver的监听。
callback
:
function
(
data
)
{
console
.
info
(
`call success
${
JSON
.
stringify
(
data
)}
`
);
},
try
{
inputMonitor
.
on
(
"
mouse
"
,
this
.
callback
);
}
catch
(
error
)
{
console
.
info
(
"
onMouseMonitor
"
+
error
.
code
+
"
"
+
error
.
message
)
}
,
try
{
inputMonitor
.
off
(
"
mouse
"
,
this
.
callback
);
}
catch
(
error
)
{
console
.
info
(
"
offMouseMonitor
"
+
error
.
code
+
"
"
+
error
.
message
)
}
```
...
...
@@ -133,9 +180,13 @@ inputMonitor.off("mouse");
**示例:**
```
js
inputMonitor
.
on
(
"
touch
"
,
(
event
)
=>
{
// 消费触摸输入事件
return
false
;
});
inputMonitor
.
off
(
"
touch
"
);
try
{
inputMonitor
.
on
(
"
touch
"
,
(
event
)
=>
{
// 若返回true,表示本次操作后续所有事件不再分发到窗口,事件都由监听者消费。
return
false
;
});
inputMonitor
.
off
(
"
touch
"
);
}
catch
(
error
)
{
console
.
info
(
"
offMonitor
"
+
error
.
code
+
"
"
+
error
.
message
)
}
```
zh-cn/application-dev/reference/apis/js-apis-pointer.md
浏览文件 @
1066e497
...
...
@@ -30,13 +30,13 @@ setPointerVisible(visible: boolean, callback: AsyncCallback<void>): void
**示例**
:
```
js
pointer
.
setPointerVisible
(
true
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`
set pointer visible failed. err=
${
JSON
.
stringify
(
err
)}
`
);
return
;
}
console
.
log
(
`
set pointer visible success.
`
);
);
try
{
pointer
.
setPointerVisible
(
true
,
(
err
,
data
)
=>
{
console
.
log
(
`
Set pointer visible success
`
);
})
;
}
catch
(
err
)
{
console
.
log
(
`
Set pointer visible failed. err=
${
JSON
.
stringify
(
err
)}
, msg=
${
JSON
.
stringify
(
message
)}
`
);
}
```
## pointer.setPointerVisible<sup>9+</sup>
...
...
@@ -62,11 +62,13 @@ setPointerVisible(visible: boolean): Promise<void>
**示例**
:
```
js
pointer
.
setPointerVisible
(
false
).
then
(
data
=>
{
console
.
log
(
`set mouse pointer visible success`
);
},
data
=>
{
console
.
log
(
`set mouse pointer visible failed err=
${
JSON
.
stringify
(
data
)}
`
);
});
try
{
pointer
.
setPointerVisible
(
false
).
then
(
data
=>
{
console
.
log
(
`Set mouse pointer visible success`
);
});
}
catch
{
console
.
log
(
`Set mouse pointer visible failed err=
${
JSON
.
stringify
(
data
)}
, msg=
${
JSON
.
stringify
(
message
)}
`
);
}
```
## pointer.isPointerVisible<sup>9+</sup>
...
...
@@ -86,9 +88,13 @@ isPointerVisible(callback: AsyncCallback<boolean>): void
**示例**
:
```
js
pointer
.
isPointerVisible
((
visible
)
=>
{
console
.
log
(
"
The mouse pointer visible attributes is
"
+
visible
);
});
try
{
pointer
.
isPointerVisible
(
visible
,
(
err
,
data
)
=>
{
console
.
log
(
`The mouse pointer visible attributes is `
+
visible
);
});
}
catch
(
err
)
{
console
.
log
(
`The mouse pointer visible attributes is failed. err=
${
JSON
.
stringify
(
err
)}
, msg=
${
JSON
.
stringify
(
message
)}
`
);
}
```
## pointer.isPointerVisible<sup>9+</sup>
...
...
@@ -108,9 +114,13 @@ isPointerVisible(): Promise<boolean>
**示例**
:
```
js
pointer
.
isPointerVisible
().
then
(
data
=>
{
console
.
log
(
`isPointerThen success data=
${
JSON
.
stringify
(
data
)}
`
);
});
try
{
pointer
.
isPointerVisible
().
then
((
data
)
=>
{
console
.
log
(
`The mouse pointer visible attributes is success. data=
${
JSON
.
stringify
(
data
)}
`
);
});
}
catch
(
err
)
{
ponsole
.
info
(
`The mouse pointer visible attributes is failed. err=
${
JSON
.
stringify
(
err
)}
, msg=
${
JSON
.
stringify
(
message
)}
`
);
}
```
## pointer.setPointerSpeed<sup>9+</sup>
...
...
@@ -131,13 +141,13 @@ setPointerSpeed(speed: number, callback: AsyncCallback<void>): void
**示例**
:
```
js
pointer
.
setPointerSpeed
(
5
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`
set pointer speed failed. err=
${
JSON
.
stringify
(
err
)}
`
);
return
;
}
console
.
log
(
`
set pointer speed success.
`
);
);
try
{
pointer
.
setPointerSpeed
(
5
,
(
err
,
data
)
=>
{
console
.
log
(
`
Set pointer speed success
`
);
})
;
}
catch
(
err
)
{
console
.
log
(
`
Set pointer speed failed. err=
${
JSON
.
stringify
(
err
)}
, msg=
${
JSON
.
stringify
(
message
)}
`
);
}
```
## pointer.setPointerSpeed<sup>9+</sup>
...
...
@@ -163,11 +173,13 @@ setPointerSpeed(speed: number): Promise<void>
**示例**
:
```
js
pointer
.
setPointerSpeed
(
5
).
then
(
data
=>
{
console
.
log
(
`set pointer speed success`
);
},
err
=>
{
console
.
log
(
`set pointer speed failed err=
${
JSON
.
stringify
(
err
)}
`
);
});
try
{
pointer
.
setPointerSpeed
(
5
).
then
(
data
=>
{
console
.
log
(
`Set pointer speed success`
);
});
}
catch
(
err
)
{
console
.
log
(
`Set pointer speed failed err=
${
JSON
.
stringify
(
err
)}
, msg=
${
JSON
.
stringify
(
message
)}
`
);
}
```
## pointer.getPointerSpeed<sup>9+</sup>
...
...
@@ -187,9 +199,13 @@ getPointerSpeed(callback: AsyncCallback<number>): void
**示例**
:
```
js
pointer
.
getPointerSpeed
((
speed
)
=>
{
console
.
log
(
"
The pointer speed is
"
+
speed
);
});
try
{
pointer
.
getPointerSpeed
(
speed
,
(
err
,
data
)
=>
{
console
.
log
(
`The pointer speed is `
+
speed
);
});
}
catch
(
err
)
{
console
.
log
(
`Failed to get the pointer speed. err=
${
JSON
.
stringify
(
err
)}
, msg=
${
JSON
.
stringify
(
message
)}
`
);
}
```
## pointer.getPointerSpeed<sup>9+</sup>
...
...
@@ -209,9 +225,13 @@ getPointerSpeed(): Promise<number>
**示例**
:
```
js
pointer
.
getPointerSpeed
().
then
(
data
=>
{
console
.
log
(
`getPointerSpeed success data=
${
JSON
.
stringify
(
data
)}
`
);
});
try
{
pointer
.
getPointerSpeed
().
then
(
data
=>
{
console
.
log
(
`Get pointer speed success. data=
${
JSON
.
stringify
(
data
)}
`
);
});
}
catch
(
err
)
{
console
.
log
(
`Get pointer speed failed err=
${
JSON
.
stringify
(
err
)}
, msg=
${
JSON
.
stringify
(
message
)}
`
);
}
```
## pointer.getPointerStyle<sup>9+</sup>
...
...
@@ -239,9 +259,17 @@ window.getTopWindow((err, data) => {
windowClass
=
data
;
windowClass
.
getProperties
((
err
,
data
)
=>
{
var
windowId
=
data
.
id
;
pointer
.
getPointerStyle
(
windowId
,
(
err
,
ret
)
=>
{
console
.
log
(
"
The mouse pointer style is:
"
+
ret
);
});
if
(
windowId
<
0
)
{
console
.
log
(
`Invalid windowId`
);
return
;
}
try
{
pointer
.
getPointerStyle
(
windowId
,
(
err
,
ret
)
=>
{
console
.
log
(
`The mouse pointer style is: `
+
ret
);
});
}
catch
(
err
)
{
console
.
log
(
`Failed to get the pointer style. err=
${
JSON
.
stringify
(
err
)}
, msg=
${
JSON
.
stringify
(
message
)}
`
);
}
});
});
```
...
...
@@ -260,7 +288,6 @@ getPointerStyle(windowId: number): Promise<PointerStyle>
| ---------------------------------------- | ------------------- |
| Promise
<
[PointerStyle](#pointerstyle9)
>
| Promise实例,用于异步获取结果。 |
**示例**
:
```
js
...
...
@@ -271,9 +298,17 @@ window.getTopWindow((err, data) => {
windowClass
=
data
;
windowClass
.
getProperties
((
err
,
data
)
=>
{
var
windowId
=
data
.
id
;
pointer
.
getPointerStyle
(
windowId
).
then
((
ret
)
=>
{
console
.
log
(
"
The mouse pointer style is:
"
+
ret
);
});
if
(
windowId
<
0
)
{
console
.
log
(
`Invalid windowId`
);
return
;
}
try
{
pointer
.
getPointerStyle
(
windowId
).
then
((
ret
)
=>
{
console
.
log
(
`The mouse pointer style is: `
+
ret
);
});
}
catch
(
err
)
{
console
.
log
(
`Get pointer style failed err=
${
JSON
.
stringify
(
err
)}
, msg=
${
JSON
.
stringify
(
message
)}
`
);
}
});
});
```
...
...
@@ -304,9 +339,17 @@ window.getTopWindow((err, data) => {
windowClass
=
data
;
windowClass
.
getProperties
((
err
,
data
)
=>
{
var
windowId
=
data
.
id
;
pointer
.
setPointerStyle
(
windowId
,
pointer
.
PointerStyle
.
CROSS
,
(
err
)
=>
{
console
.
log
(
`Set mouse pointer style success.`
);
});
if
(
windowId
<
0
)
{
console
.
log
(
`Invalid windowId`
);
return
;
}
try
{
pointer
.
setPointerStyle
(
windowId
,
pointer
.
PointerStyle
.
CROSS
,
(
err
)
=>
{
console
.
log
(
`Successfully set mouse pointer style`
);
});
}
catch
(
err
)
{
console
.
log
(
`Failed to set the pointer style. err=
${
JSON
.
stringify
(
err
)}
, msg=
${
JSON
.
stringify
(
message
)}
`
);
}
});
});
```
...
...
@@ -336,9 +379,17 @@ window.getTopWindow((err, data) => {
windowClass
=
data
;
windowClass
.
getProperties
((
err
,
data
)
=>
{
var
windowId
=
data
.
id
;
pointer
.
setPointerStyle
(
windowId
,
pointer
.
PointerStyle
.
CROSS
).
then
(()
=>
{
console
.
log
(
`Set mouse pointer style success`
);
});
if
(
windowId
<
0
)
{
console
.
log
(
`Invalid windowId`
);
return
;
}
try
{
pointer
.
setPointerStyle
(
windowId
,
pointer
.
PointerStyle
.
CROSS
).
then
(()
=>
{
console
.
log
(
`Successfully set mouse pointer style`
);
});
}
catch
(
err
)
{
console
.
log
(
`Failed to set the pointer style. err=
${
JSON
.
stringify
(
err
)}
, msg=
${
JSON
.
stringify
(
message
)}
`
);
}
});
});
```
...
...
zh-cn/application-dev/reference/errorcodes/errorcodes-multimodalinput.md
0 → 100644
浏览文件 @
1066e497
# 多模输入子系统错误码
## 201 权限校验失败
### 错误信息
Permission denied.
### 错误描述
当调用监听模块on和off接口时,若没有申请权限,会报此错误码。
### 可能原因
监听、去监听鼠标和触屏事件时未配置相应的权限。
### 处理步骤
查看权限是否已适配,具体配置方式请参考
[
权限申请声明
](
../../security/accesstoken-guidelines.md
)
。
## 401 参数检查错误
### 错误信息
The parameter invalid.
### 错误描述
当调用监听模块或者键鼠穿越等其他模块接口时,若传入参数的类型或者范围不匹配,会报此错误码。
### 可能原因
1.
入参类型错误不匹配,如监听接口传入type为非string类型等。
2.
入参范围不匹配,如插上设备信息时传入非法的deviceId。
### 处理步骤
检查入参类型和范围是否匹配。
## 4400001 目标设备描述符错误
### 错误信息
Incorrect descriptor for the target device.
### 错误描述
当调用键鼠穿越start接口时,若设备无效,会报此错误码。
### 可能原因
1.
穿越目标设备不存在(设备未组网)。
2.
目标设备描述符为空。
### 处理步骤
1.
确认键鼠穿越目标设备是否已正确与本地设备完整组网。
2.
正确使用穿越目标设备的设备描述符。
## 4400002 操作输入设备失败
### 错误信息
Failed to operate the input device.
### 错误描述
当调用键鼠穿越start接口时,若穿越状态异常,会报此错误码。
### 可能原因
1.
发起键鼠穿越时,本机键鼠穿越为穿出状态。
2.
关闭键鼠穿越时,本机键鼠穿越为自由态。
3.
发起关闭键鼠穿越时,本机键鼠穿越状态正在切换中。
### 处理步骤
1.
发起键鼠穿越时,本机键鼠穿越状态需要为非穿出状态。
2.
关闭键鼠穿越时,本机键鼠穿越状态需要为非自由态。
3.
发起关闭键鼠穿越时,本机键鼠穿越状态不能处于切换中。
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录