changelogs-multimodalinput.md 5.2 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
 - 组合按键订阅模块:系统接口,@ohos.multimodalInput.inputConsumer.d.ts
M
mayunteng_1 已提交
9

10
 - 键鼠穿越功能模块:系统接口,@ohos.multimodalInput.inputDeviceCooperate.d.ts
M
mayunteng_1 已提交
11

12
 - 按键注入模块:系统接口,@ohos.multimodalInput.inputEventClient.d.ts
M
mayunteng_1 已提交
13

14
 - 输入监听模块:系统接口,@ohos.multimodalInput.inputMonitor.d.ts
M
mayunteng_1 已提交
15

16
 - 鼠标指针管理模块:系统接口和三方接口,@ohos.multimodalInput.pointer.d.ts
M
mayunteng_1 已提交
17

18
以上模块中的异步接口变更为参数检查错误同步抛出,业务逻辑错误通过AsyncCallback或Promise的error对象抛出,同步接口不作变更。
M
mayunteng_1 已提交
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 49 50 51 52 53 54 55 56 57 58
  -  supportKeys(deviceId: **number**, keys: Array<KeyCode>, callback: AsyncCallback<Array<boolean>>): **void**; 
  -  supportKeys(deviceId: **number**, keys: Array<KeyCode>): Promise<Array<boolean>>; 
  -  getKeyboardType(deviceId: **number**, callback: AsyncCallback<KeyboardType>): **void**; &gt;
  -  getKeyboardType(deviceId: **number**): Promise<KeyboardType>; 
  -  setPointerSpeed(speed: **number**, callback: AsyncCallback<**void**>): **void**; 
  -  setPointerSpeed(speed: **number**): Promise<**void**>; 
  -  getPointerSpeed(callback: AsyncCallback<**number**>): **void**; 
  -  getPointerSpeed(): Promise<**number**>; 
  -  setPointerStyle(windowId: **number**, pointerStyle: PointerStyle, callback: AsyncCallback<**void**>): **void**; 
  -  setPointerStyle(windowId: **number**, pointerStyle: PointerStyle): Promise<**void**>; 
  -  getPointerStyle(windowId: **number**, callback: AsyncCallback<PointerStyle>): **void**; 
  -  getPointerStyle(windowId: **number**): Promise<PointerStyle>; 
  -  setPointerVisible(visible: boolean, callback: AsyncCallback<**void**>): **void**; 
  -  setPointerVisible(visible: boolean): Promise<**void**>; 
  -  isPointerVisible(callback: AsyncCallback<boolean>): **void**; 
  -  isPointerVisible(): Promise<boolean>; 
  -  on(**type**:"touch", receiver:TouchEventReceiver):**void**; 
  -  on(**type**:"mouse", receiver:Callback<MouseEvent>):**void**; 
  -  off(**type**:"touch", receiver?:TouchEventReceiver):**void**; 
  -  off(**type**:"mouse", receiver?:Callback<MouseEvent>):**void**; 
  -  injectEvent({KeyEvent: KeyEvent}): **void**; 
  -  enable(enable: boolean, callback: AsyncCallback<**void**>): **void**; 
  -  enable(enable: boolean): Promise<**void**>; 
  -  start(sinkDeviceDescriptor: **string**, srcInputDeviceId: **number**, callback: AsyncCallback<**void**>): **void**; 
  -  start(sinkDeviceDescriptor: **string**, srcInputDeviceId: **number**): Promise<**void**>; 
  -  stop(callback: AsyncCallback<**void**>): **void**; 
  -  stop(): Promise<**void**>; 
  -  getState(deviceDescriptor: **string**, callback: AsyncCallback<{ state: boolean }>): **void**; 
  -  getState(deviceDescriptor: **string**): Promise<{ state: boolean }>; 
  -  on(**type**: 'cooperation', callback: AsyncCallback<{ deviceDescriptor: **string**, eventMsg: EventMsg }>): **void**; 
  -  off(**type**: 'cooperation', callback?: AsyncCallback<**void**>): **void**; 
  -  on(**type**: "key", keyOptions: KeyOptions, callback: Callback<KeyOptions>): **void**; 
  -  off(**type**: "key", keyOptions: KeyOptions, callback?: Callback<KeyOptions>): **void**; 
M
mayunteng_1 已提交
59

60 61 62 63 64
以下接口标记废除:
   - getDeviceIds(callback: AsyncCallback<Array<**number**>>): **void**; 
   - getDeviceIds(): Promise<Array<**number**>>; 
   - getDevice(deviceId: **number**, callback: AsyncCallback<InputDeviceData>): **void**; 
   - getDevice(deviceId: **number**): Promise<InputDeviceData>; 
M
mayunteng_1 已提交
65 66

替代接口如下:
67 68 69 70
   - getDeviceList(callback: AsyncCallback<Array<**number**>>): **void**; 
   - getDeviceList(): Promise<Array<**number**>>; 
   - getDeviceInfo(deviceId: **number**, callback: AsyncCallback<InputDeviceData>): **void**; 
  - getDeviceInfo(deviceId: **number**): Promise<InputDeviceData>; 
M
mayunteng_1 已提交
71

72
以下接口发生变更
73

M
mayunteng_1 已提交
74
变更前:
75 76
 - supportKeys(deviceId: **number**, keys: Array<KeyCode>, callback: Callback<Array<boolean>>): **void**; 
 - getKeyboardType(deviceId: **number**, callback: Callback<KeyboardType>): **void**; 
M
mayunteng_1 已提交
77 78

变更后:
79 80
- supportKeys(deviceId: **number**, keys: Array<KeyCode>, callback: AsyncCallback<Array<boolean>>): **void**; 
 - getKeyboardType(deviceId: **number**, callback: AsyncCallback<KeyboardType>): **void**; 
M
mayunteng_1 已提交
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104

**适配指导**

以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`])}`);
}
```