• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# 多模输入changeLog
2
3## cl.multimodalinput.1 API错误信息返回方式变更
4
5下列模块内部接口使用业务逻辑返回值表示错误信息,不符合OpenHarmony接口错误码规范。在API9进行变更。
6 - 输入设备管理模块:三方接口,@ohos.multimodalInput.inputDevice.d.ts
7
8 - 组合按键订阅模块:系统接口,@ohos.multimodalInput.inputConsumer.d.ts
9
10 - 键鼠穿越功能模块:系统接口,@ohos.multimodalInput.inputDeviceCooperate.d.ts
11
12 - 按键注入模块:系统接口,@ohos.multimodalInput.inputEventClient.d.ts
13
14 - 输入监听模块:系统接口,@ohos.multimodalInput.inputMonitor.d.ts
15
16 - 鼠标指针管理模块:系统接口和三方接口,@ohos.multimodalInput.pointer.d.ts
17
18以上模块中的异步接口变更为参数检查错误同步抛出,业务逻辑错误通过AsyncCallback或Promise的error对象抛出,同步接口不作变更。
19
20**变更影响**
21
22基于此前版本开发的应用,需适配接口的错误信息返回方式,否则会影响原有业务逻辑。
23
24**关键接口/组件变更**
25
26  - supportKeys(deviceId: number, keys: Array<KeyCode>, callback: AsyncCallback<Array<boolean>>): void;
27  -  supportKeys(deviceId: number, keys: Array<KeyCode>): Promise<Array<boolean>>;
28  -  getKeyboardType(deviceId: number, callback: AsyncCallback<KeyboardType>): void; >
29  -  getKeyboardType(deviceId: number): Promise<KeyboardType>;
30  -  setPointerSpeed(speed: number, callback: AsyncCallback<void>): void;
31  -  setPointerSpeed(speed: number): Promise<void>;
32  -  getPointerSpeed(callback: AsyncCallback<number>): void;
33  -  getPointerSpeed(): Promise<number>;
34  -  setPointerStyle(windowId: number, pointerStyle: PointerStyle, callback: AsyncCallback<void>): void;
35  -  setPointerStyle(windowId: number, pointerStyle: PointerStyle): Promise<void>;
36  -  getPointerStyle(windowId: number, callback: AsyncCallback<PointerStyle>): void;
37  -  getPointerStyle(windowId: number): Promise<PointerStyle>;
38  -  setPointerVisible(visible: boolean, callback: AsyncCallback<void>): void;
39  -  setPointerVisible(visible: boolean): Promise<void>;
40  -  isPointerVisible(callback: AsyncCallback<boolean>): void;
41  -  isPointerVisible(): Promise<boolean>;
42  -  on(type:"touch", receiver:TouchEventReceiver):void;
43  -  on(type:"mouse", receiver:Callback<MouseEvent>):void;
44  -  off(type:"touch", receiver?:TouchEventReceiver):void;
45  -  off(type:"mouse", receiver?:Callback<MouseEvent>):void;
46  -  injectEvent({KeyEvent: KeyEvent}): void;
47  -  enable(enable: boolean, callback: AsyncCallback<void>): void;
48  -  enable(enable: boolean): Promise<void>;
49  -  start(sinkDeviceDescriptor: string, srcInputDeviceId: number, callback: AsyncCallback<void>): void;
50  -  start(sinkDeviceDescriptor: string, srcInputDeviceId: number): Promise<void>;
51  -  stop(callback: AsyncCallback<void>): void;
52  -  stop(): Promise<void>;
53  -  getState(deviceDescriptor: string, callback: AsyncCallback<{ state: boolean }>): void;
54  -  getState(deviceDescriptor: string): Promise<{ state: boolean }>;
55  -  on(type: 'cooperation', callback: AsyncCallback<{ deviceDescriptor: string, eventMsg: EventMsg }>): void;
56  -  off(type: 'cooperation', callback?: AsyncCallback<void>): void;
57  -  on(type: "key", keyOptions: KeyOptions, callback: Callback<KeyOptions>): void;
58  -  off(type: "key", keyOptions: KeyOptions, callback?: Callback<KeyOptions>): void;
59
60以下接口标记废除:
61   - getDeviceIds(callback: AsyncCallback<Array<number>>): void;
62   - getDeviceIds(): Promise<Array<number>>;
63   - getDevice(deviceId: number, callback: AsyncCallback<InputDeviceData>): void;
64   - getDevice(deviceId: number): Promise<InputDeviceData>;
65
66替代接口如下:
67   - getDeviceList(callback: AsyncCallback<Array<number>>): void;
68   - getDeviceList(): Promise<Array<number>>;
69   - getDeviceInfo(deviceId: number, callback: AsyncCallback<InputDeviceData>): void;
70   - getDeviceInfo(deviceId: number): Promise<InputDeviceData>;
71
72以下接口发生变更
73
74变更前:
75 - supportKeys(deviceId: number, keys: Array<KeyCode>, callback: Callback<Array<boolean>>): void;
76 - getKeyboardType(deviceId: number, callback: Callback<KeyboardType>): void;
77
78变更后:
79 - supportKeys(deviceId: number, keys: Array<KeyCode>, callback: AsyncCallback<Array<boolean>>): void;
80 - getKeyboardType(deviceId: number, callback: AsyncCallback<KeyboardType>): void;
81
82**适配指导**
83
84以setPointerVisible为例,示例代码如下:
85
86```ts
87import pointer from '@ohos.multimodalInput.pointer';
88pointer.setPointerVisible(true, (error) => {
89    console.log(`Set pointer visible success`);
90  });
91
92try {
93  pointer.setPointerVisible(true, (error) => {
94    if (error) {
95      console.log(`Set pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
96      return;
97    }
98    console.log(`Set pointer visible success`);
99  });
100} catch (error) {
101  console.log(`Set pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
102}
103```
104
105