changelogs-multimodalinput.md 5.7 KB
Newer Older
M
mayunteng_1 已提交
1 2 3 4
# 多模输入changeLog

## cl.multimodalinput.1 API错误信息返回方式变更

5 6
如下原有接口使用业务逻辑返回值表示错误信息,不符合OpenHarmony接口错误码规范。从API9开始作以下变更,
设备管理:三方接口,@ohos.multimodalInput.inputDevice.d.ts
M
mayunteng_1 已提交
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48

按键订阅:系统接口,@ohos.multimodalInput.inputConsumer.d.ts

键鼠穿越:系统接口,@ohos.multimodalInput.inputDeviceCooperate.d.ts

按键注入:系统接口,@ohos.multimodalInput.inputEventClient.d.ts

事件监听:系统接口,@ohos.multimodalInput.inputMonitor.d.ts

指针事件:系统接口和三方接口,@ohos.multimodalInput.pointer.d.t

异步接口:通过AsyncCallback或Promise的error对象返回错误信息。

同步接口:不涉及。

**变更影响**

基于此前版本开发的应用,需适配接口的错误信息返回方式,否则会影响原有业务逻辑。

**关键接口/组件变更**

以下接口标记废除:

   -  **function** getDeviceIds(callback: AsyncCallback<Array<**number**>>): **void**; 

   -  **function** getDeviceIds(): Promise<Array<**number**>>; 

   -  **function** getDevice(deviceId: **number**, callback: AsyncCallback<InputDeviceData>): **void**; 

 **function** getDevice(deviceId: **number**): Promise<InputDeviceData>; 

替代接口如下:

   -  **function** getDeviceList(callback: AsyncCallback<Array<**number**>>): **void**; 

   -  **function** getDeviceList(): Promise<Array<**number**>>; 

   -  **function** getDeviceInfo(deviceId: **number**, callback: AsyncCallback<InputDeviceData>): **void**; 

  -  **function** getDeviceInfo(deviceId: **number**): Promise<InputDeviceData>; 

以下接口增加错误码处理:
49 50 51 52
  -   **function** supportKeys(deviceId: **number**, keys: Array<KeyCode>, callback: AsyncCallback<Array<boolean>>): **void**; 
  -   **function** supportKeys(deviceId: **number**, keys: Array<KeyCode>): Promise<Array<boolean>>; 
  -   **function** getKeyboardType(deviceId: **number**, callback: AsyncCallback<KeyboardType>): **void**; &gt;
  -   **function** getKeyboardType(deviceId: **number**): Promise<KeyboardType>; 
M
mayunteng_1 已提交
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
  -   **function** setPointerSpeed(speed: **number**, callback: AsyncCallback<**void**>): **void**; 
  -   **function** setPointerSpeed(speed: **number**): Promise<**void**>; 
  -   **function** getPointerSpeed(callback: AsyncCallback<**number**>): **void**; 
  -   **function** getPointerSpeed(): Promise<**number**>; 
  -   **function** setPointerStyle(windowId: **number**, pointerStyle: PointerStyle, callback: AsyncCallback<**void**>): **void**; 
  -   **function** setPointerStyle(windowId: **number**, pointerStyle: PointerStyle): Promise<**void**>; 
  -   **function** getPointerStyle(windowId: **number**, callback: AsyncCallback<PointerStyle>): **void**; 
  -   **function** getPointerStyle(windowId: **number**): Promise<PointerStyle>; 
  -   **function** setPointerVisible(visible: boolean, callback: AsyncCallback<**void**>): **void**; 
  -   **function** setPointerVisible(visible: boolean): Promise<**void**>; 
  -   **function** isPointerVisible(callback: AsyncCallback<boolean>): **void**; 
  -   **function** isPointerVisible(): Promise<boolean>; 
  -   **function** on(**type**:"touch", receiver:TouchEventReceiver):**void**; 
  -   **function** on(**type**:"mouse", receiver:Callback<MouseEvent>):**void**; 
  -   **function** off(**type**:"touch", receiver?:TouchEventReceiver):**void**; 
  -   **function** off(**type**:"mouse", receiver?:Callback<MouseEvent>):**void**; 
  -   **function** injectEvent({KeyEvent: KeyEvent}): **void**; 
  -   **function** enable(enable: boolean, callback: AsyncCallback<**void**>): **void**; 
  -   **function** enable(enable: boolean): Promise<**void**>; 
  -   **function** start(sinkDeviceDescriptor: **string**, srcInputDeviceId: **number**, callback: AsyncCallback<**void**>): **void**; 
  -   **function** start(sinkDeviceDescriptor: **string**, srcInputDeviceId: **number**): Promise<**void**>; 
  -   **function** stop(callback: AsyncCallback<**void**>): **void**; 
  -   **function** stop(): Promise<**void**>; 
  -   **function** getState(deviceDescriptor: **string**, callback: AsyncCallback<{ state: boolean }>): **void**; 
  -   **function** getState(deviceDescriptor: **string**): Promise<{ state: boolean }>; 
  -   **function** on(**type**: 'cooperation', callback: AsyncCallback<{ deviceDescriptor: **string**, eventMsg: EventMsg }>): **void**; 
  -   **function** off(**type**: 'cooperation', callback?: AsyncCallback<**void**>): **void**; 
  -   **function** on(**type**: "key", keyOptions: KeyOptions, callback: Callback<KeyOptions>): **void**; 
  -   **function** off(**type**: "key", keyOptions: KeyOptions, callback?: Callback<KeyOptions>): **void**; 

**以下接口发生变更**

变更前:

- **function** supportKeys(deviceId: **number**, keys: Array<KeyCode>, callback: Callback<Array<boolean>>): **void**; 

- **function** getKeyboardType(deviceId: **number**, callback: Callback<KeyboardType>): **void**; 

变更后:

-  **function** supportKeys(deviceId: **number**, keys: Array<KeyCode>, callback: AsyncCallback<Array<boolean>>): **void**; 

- **function** getKeyboardType(deviceId: **number**, callback: AsyncCallback<KeyboardType>): **void**; 

**适配指导**

以setPointerVisible为例,示例代码如下:

```ts
import pointer from '@ohos.multimodalInput.pointer';
pointer.setPointerVisible(true, (error) => {
    console.log(`Set pointer visible success`);
  });

try {
  pointer.setPointerVisible(true, (error) => {
    if (error) {
      console.log(`Set pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
      return;
    }
    console.log(`Set pointer visible success`);
  });
} catch (error) {
  console.log(`Set pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```