harmony 鸿蒙Multimodal Input ChangeLog

  • 2023-02-03
  • 浏览 (451)

Multimodal Input ChangeLog

cl.multimodalinput.1 Error Information Return Method Change of APIs

The internal APIs of the following modules used service logic return values to indicate error information, which did not comply with the error code specifications of OpenHarmony. Therefore, they are modified in API version 9 and later. - Input device management module (@ohos.multimodalInput.inputDevice.d.ts): third-party APIs

  • Input consumer module (@ohos.multimodalInput.inputConsumer.d.ts): system APIs

  • Screen hopping module (@ohos.multimodalInput.inputDeviceCooperate.d.ts): system APIs

  • Key injection module (@ohos.multimodalInput.inputEventClient.d.ts): system APIs

  • Input listening module (@ohos.multimodalInput.inputMonitor.d.ts): system APIs

  • Mouse pointer module (@ohos.multimodalInput.pointer.d.ts): system APIs and third-party APIs

Asynchronous APIs in the preceding modules have the following changes: A parameter check error is returned synchronously; a service logic error is returned via AsyncCallback or the error object of Promise. No change is made to synchronous APIs.

Change Impacts

The application developed based on earlier versions needs to adapt the method for returning API error information. Otherwise, the original service logic will be affected.

Key API/Component Changes

  • 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; >
  • 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;

Deprecated APIs: - getDeviceIds(callback: AsyncCallback<Array<number>>): void; - getDeviceIds(): Promise<Array<number>>; - getDevice(deviceId: number, callback: AsyncCallback<InputDeviceData>): void; - getDevice(deviceId: number): Promise<InputDeviceData>;

Substitute APIs: - getDeviceList(callback: AsyncCallback<Array<number>>): void; - getDeviceList(): Promise<Array<number>>; - getDeviceInfo(deviceId: number, callback: AsyncCallback<InputDeviceData>): void; - getDeviceInfo(deviceId: number): Promise<InputDeviceData>;

Changed APIs:

Before change: - supportKeys(deviceId: number, keys: Array<KeyCode>, callback: Callback<Array<boolean>>): void; - getKeyboardType(deviceId: number, callback: Callback<KeyboardType>): void;

After change: - supportKeys(deviceId: number, keys: Array<KeyCode>, callback: AsyncCallback<Array<boolean>>): void; - getKeyboardType(deviceId: number, callback: AsyncCallback<KeyboardType>): void;

Adaptation Guide

The following uses setPointerVisible as an example:

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

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Account Subsystem ChangeLog

harmony 鸿蒙ChangeLog of JS API Changes in the Multimedia Subsystem

harmony 鸿蒙Device Manager ChangeLog

harmony 鸿蒙USB Manager ChangeLog

harmony 鸿蒙DSoftBus Subsystem ChangeLog

harmony 鸿蒙File Management Subsystem ChangeLog

harmony 鸿蒙Globalization Subsystem ChangeLog

harmony 鸿蒙Input Method Framework ChangeLog

harmony 鸿蒙Power Subsystem ChangeLog

harmony 鸿蒙Upload and Download Subsystem ChangeLog

0  赞