未验证 提交 66c454b8 编写于 作者: O openharmony_ci 提交者: Gitee

!11588 多模资料整改

Merge pull request !11588 from mayunteng/master
......@@ -112,6 +112,8 @@ start(sinkDeviceDescriptor: string, srcInputDeviceId: number, callback: AsyncCal
**示例**
```js
let sinkDeviceDescriptor = "descriptor";
let srcInputDeviceId = 0;
try {
inputDeviceCooperate.start(sinkDeviceDescriptor, srcInputDeviceId, (error) => {
if (error) {
......@@ -160,6 +162,8 @@ start(sinkDeviceDescriptor: string, srcInputDeviceId: number): Promise\<void>
**示例**
```js
let sinkDeviceDescriptor = "descriptor";
let srcInputDeviceId = 0;
try {
inputDeviceCooperate.start(sinkDeviceDescriptor, srcInputDeviceId).then(() => {
console.log(`Start Keyboard mouse crossing success.`);
......@@ -215,7 +219,7 @@ stop(): Promise\<void>
| 参数名 | 说明 |
| -------- | ---------------------------- |
| Promise\<void> | Promise对象,异步返回停止键鼠穿越结果。 |
| Promise\<void> | Promise对象,异步返回停止键鼠穿越结果。 |
**示例**
......@@ -249,6 +253,7 @@ getState(deviceDescriptor: string, callback: AsyncCallback<{ state: boolean }>):
**示例**
```js
let deviceDescriptor = "descriptor";
try {
inputDeviceCooperate.getState(deviceDescriptor, (error, data) => {
if (error) {
......@@ -289,6 +294,7 @@ getState(deviceDescriptor: string): Promise<{ state: boolean }>
**示例**
```js
let deviceDescriptor = "descriptor";
try {
inputDeviceCooperate.getState(deviceDescriptor).then((data) => {
console.log(`Get the status success, data: ${JSON.stringify(data)}`);
......@@ -324,7 +330,7 @@ try {
inputDeviceCooperate.on('cooperation', (data) => {
console.log(`Keyboard mouse crossing event: ${JSON.stringify(data)}`);
});
} catch (err) {
} catch (error) {
console.log(`Register failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
......@@ -350,25 +356,25 @@ off(type: 'cooperation', callback?: AsyncCallback\<void>): void
```js
// 取消注册单个回调函数
callback: function(event) {
function callback(event) {
console.log(`Keyboard mouse crossing event: ${JSON.stringify(event)}`);
return false;
},
try {
inputDeviceCooperate.on('cooperation', this.callback);
inputDeviceCooperate.off("cooperation", this.callback);
inputDeviceCooperate.on('cooperation', callback);
inputDeviceCooperate.off("cooperation", callback);
} catch (error) {
console.log(`Execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
```js
// 取消注册所有回调函数
callback: function(event) {
function callback(event) {
console.log(`Keyboard mouse crossing event: ${JSON.stringify(event)}`);
return false;
},
try {
inputDeviceCooperate.on('cooperation', this.callback);
inputDeviceCooperate.on('cooperation', callback);
inputDeviceCooperate.off("cooperation");
} catch (error) {
console.log(`Execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
......
......@@ -334,19 +334,19 @@ inputDevice.getDeviceInfo(1).then((deviceData) => {
## inputDevice.supportKeys<sup>9+</sup>
supportKeys(deviceId: number, keys: Array&lt;KeyCode&gt;, callback: Callback&lt;Array&lt;boolean&gt;&gt;): void
supportKeys(deviceId: number, keys: Array&lt;KeyCode&gt;, callback: AsyncCallback &lt;Array&lt;boolean&gt;&gt;): void
获取输入设备是否支持指定的键码值,使用Callback异步方式返回结果。
获取输入设备是否支持指定的键码值,使用AsyncCallback异步方式返回结果。
**系统能力**:SystemCapability.MultimodalInput.Input.InputDevice
**参数**
| 参数 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------ | ---- | ------------------------------------------------------ |
| deviceId | number | 是 | 输入设备id,同一个物理设备反复插拔,设备id会发生变化。 |
| keys | Array&lt;KeyCode&gt; | 是 | 需要查询的键码值,最多支持5个按键查询。 |
| callback | Callback&lt;Array&lt;boolean&gt;&gt; | 是 | 回调函数,异步返回查询结果。 |
| 参数 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------------- | ---- | ------------------------------------------------------ |
| deviceId | number | 是 | 输入设备id,同一个物理设备反复插拔,设备id会发生变化。 |
| keys | Array&lt;KeyCode&gt; | 是 | 需要查询的键码值,最多支持5个按键查询。 |
| callback | AsyncCallback&lt;Array&lt;boolean&gt;&gt; | 是 | 回调函数,异步返回查询结果。 |
**示例**
......
......@@ -41,7 +41,7 @@ try {
keyDownDuration: 0,
isIntercepted: false
}
inputEventClient.injectKeyEvent({ KeyEvent: backKeyDown });
inputEventClient.injectEvent({ KeyEvent: backKeyDown });
let backKeyUp = {
isPressed: false,
......@@ -49,7 +49,7 @@ try {
keyDownDuration: 0,
isIntercepted: false
};
inputEventClient.injectKeyEvent({ KeyEvent: backKeyUp });
inputEventClient.injectEvent({ KeyEvent: backKeyUp });
} catch (error) {
console.log(`Failed to inject KeyEvent, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
......
......@@ -194,7 +194,7 @@ try {
```js
try {
inputMonitor.on("touch", touchEvent => {
if (touchEvent.touches.size() == 3) { // 当前有三个手指按下
if (touchEvent.touches.length == 3) { // 当前有三个手指按下
return true;
} else {
return false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册