1/* 2* Copyright (c) 2022 Huawei Device Co., Ltd. 3* Licensed under the Apache License, Version 2.0 (the "License"); 4* you may not use this file except in compliance with the License. 5* You may obtain a copy of the License at 6* 7* http://www.apache.org/licenses/LICENSE-2.0 8* 9* Unless required by applicable law or agreed to in writing, software 10* distributed under the License is distributed on an "AS IS" BASIS, 11* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12* See the License for the specific language governing permissions and 13* limitations under the License. 14*/ 15 16import { AsyncCallback } from "./basic"; 17 18declare namespace inputDeviceCooperate { 19 /** 20 * Enumerates mouse traversal events. 21 * 22 * @since 9 23 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 24 * @systemapi hide for inner use. 25 */ 26 enum EventMsg { 27 /** 28 * Mouse traversal message: mouse traversal is enabled. 29 * 30 * @since 9 31 */ 32 MSG_COOPERATE_INFO_START = 200, 33 34 /** 35 * Mouse traversal message: mouse traversal is successful. 36 * 37 * @since 9 38 */ 39 MSG_COOPERATE_INFO_SUCCESS = 201, 40 41 /** 42 * Mouse traversal message: mouse traversal fails. 43 * 44 * @since 9 45 */ 46 MSG_COOPERATE_INFO_FAIL = 202, 47 48 /** 49 * Mouse traversal status: mouse traversal is enabled. 50 * 51 * @since 9 52 */ 53 MSG_COOPERATE_STATE_ON = 500, 54 55 /** 56 * Mouse traversal status: mouse traversal is disabled. 57 * 58 * @since 9 59 */ 60 MSG_COOPERATE_STATE_OFF = 501, 61 } 62 63 /** 64 * Enable or disable the mouse traversal. 65 * 66 * @since 9 67 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 68 * @systemapi hide for inner use 69 * @param enable Whether to enable mouse traversal. 70 * @param callback Asynchronous callback function. 71 * @throws {BusinessError} 401 - Parameter error. 72 */ 73 function enable(enable: boolean, callback: AsyncCallback<void>): void; 74 75 /** 76 * Enable or disable the mouse traversal. 77 * 78 * @since 9 79 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 80 * @systemapi hide for inner use 81 * @param enable Whether to enable mouse traversal. 82 * @throws {BusinessError} 401 - Parameter error. 83 */ 84 function enable(enable: boolean): Promise<void>; 85 86 /** 87 * Starts mouse traversal. 88 * 89 * @since 9 90 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 91 * @systemapi hide for inner use 92 * @param sinkDeviceDescriptor Descriptor of the target network for mouse traversal. 93 * @param srcInputDeviceId Identifier of the peripheral device for mouse traversal. 94 * @param callback Asynchronous callback function. 95 * @throws {BusinessError} 401 - Parameter error. 96 * @throws {BusinessError} 4400001 - Incorrect descriptor for the target device. 97 * @throws {BusinessError} 4400002 - Screen hop failed. 98 */ 99 function start(sinkDeviceDescriptor: string, srcInputDeviceId: number, callback: AsyncCallback<void>): void; 100 101 /** 102 * Starts mouse traversal. 103 * 104 * @since 9 105 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 106 * @systemapi hide for inner use 107 * @param sinkDeviceDescriptor Descriptor of the target network for mouse traversal. 108 * @param srcInputDeviceId Identifier of the peripheral device for mouse traversal. 109 * @throws {BusinessError} 401 - Parameter error. 110 * @throws {BusinessError} 4400001 - Incorrect descriptor for the target device. 111 * @throws {BusinessError} 4400002 - Screen hop failed. 112 */ 113 function start(sinkDeviceDescriptor: string, srcInputDeviceId: number): Promise<void>; 114 115 /** 116 * Stops mouse traversal. 117 * 118 * @since 9 119 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 120 * @systemapi hide for inner use 121 * @param callback Asynchronous callback function. 122 * @throws {BusinessError} 401 - Parameter error. 123 */ 124 function stop(callback: AsyncCallback<void>): void; 125 126 /** 127 * Stops mouse traversal. 128 * 129 * @since 9 130 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 131 * @systemapi hide for inner use 132 */ 133 function stop(): Promise<void>; 134 135 /** 136 * Obtains the status of the mouse traversal switch. 137 * 138 * @since 9 139 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 140 * @systemapi hide for inner use 141 * @param deviceDescriptor Descriptor of the target network for mouse traversal. 142 * @param callback Asynchronous callback used to receive the status of the mouse traversal switch. 143 * @throws {BusinessError} 401 - Parameter error. 144 */ 145 function getState(deviceDescriptor: string, callback: AsyncCallback<{ state: boolean }>): void; 146 147 /** 148 * Obtains the status of the mouse traversal switch. 149 * 150 * @since 9 151 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 152 * @systemapi hide for inner use 153 * @param deviceDescriptor Descriptor of the target network for mouse traversal. 154 * @throws {BusinessError} 401 - Parameter error. 155 */ 156 function getState(deviceDescriptor: string): Promise<{ state: boolean }>; 157 158 /** 159 * Enables listening for mouse traversal events. 160 * 161 * @since 9 162 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 163 * @systemapi hide for inner use 164 * @param type Registration type. 165 * @param callback Asynchronous callback used to receive mouse traversal events. 166 * @throws {BusinessError} 401 - Parameter error. 167 */ 168 function on(type: 'cooperation', callback: AsyncCallback<{ deviceDescriptor: string, eventMsg: EventMsg }>): void; 169 170 /** 171 * Disables listening for mouse traversal events. 172 * 173 * @since 9 174 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 175 * @systemapi hide for inner use 176 * @param type Registration type. 177 * @param callback Asynchronous callback used to return the result. 178 * @throws {BusinessError} 401 - Parameter error. 179 */ 180 function off(type: 'cooperation', callback?: AsyncCallback<void>): void; 181 182} 183 184export default inputDeviceCooperate;