1/* 2* Copyright (c) 2022-2023 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 16/** 17 * @file 18 * @kit InputKit 19 */ 20 21import { AsyncCallback } from "./@ohos.base"; 22 23/** 24 * Events for input devices 25 * 26 * @namespace inputDeviceCooperate 27 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 28 * @since 9 29 */ 30 31 32declare namespace inputDeviceCooperate { 33 /** 34 * Enumerates mouse traversal events. 35 * @enum { number } 36 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 37 * @systemapi hide for inner use. 38 * @since 9 39 */ 40 enum EventMsg { 41 /** 42 * Mouse traversal message: mouse traversal is enabled. 43 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 44 * @systemapi hide for inner use 45 * @since 9 46 */ 47 MSG_COOPERATE_INFO_START = 200, 48 49 /** 50 * Mouse traversal message: mouse traversal is successful. 51 * 52 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 53 * @systemapi hide for inner use 54 * @since 9 55 */ 56 MSG_COOPERATE_INFO_SUCCESS = 201, 57 58 /** 59 * Mouse traversal message: mouse traversal fails. 60 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 61 * @systemapi hide for inner use 62 * @since 9 63 */ 64 MSG_COOPERATE_INFO_FAIL = 202, 65 66 /** 67 * Mouse traversal status: mouse traversal is enabled. 68 * 69 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 70 * @systemapi hide for inner use 71 * @since 9 72 */ 73 MSG_COOPERATE_STATE_ON = 500, 74 75 /** 76 * Mouse traversal status: mouse traversal is disabled. 77 * 78 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 79 * @systemapi hide for inner use 80 * @since 9 81 */ 82 MSG_COOPERATE_STATE_OFF = 501, 83 } 84 85 /** 86 * Enable or disable the mouse traversal. 87 * 88 * @param { boolean } enable Whether to enable mouse traversal. 89 * @param { AsyncCallback<void> } callback Asynchronous callback function. 90 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 91 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 92 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 93 * @systemapi hide for inner use 94 * @since 9 95 */ 96 /** 97 * Enable or disable the mouse traversal. 98 * 99 * @param { boolean } enable Whether to enable mouse traversal. 100 * @param { AsyncCallback<void> } callback Asynchronous callback function. 101 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 102 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 103 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 104 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 105 * @systemapi hide for inner use 106 * @since 12 107 */ 108 function enable(enable: boolean, callback: AsyncCallback<void>): void; 109 110 /** 111 * Enable or disable the mouse traversal. 112 * 113 * @param enable Whether to enable mouse traversal. 114 * @returns { Promise<void> } Promise returned by this function 115 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 116 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 117 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 118 * @systemapi hide for inner use 119 * @since 9 120 */ 121 /** 122 * Enable or disable the mouse traversal. 123 * 124 * @param enable Whether to enable mouse traversal. 125 * @returns { Promise<void> } Promise returned by this function 126 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 127 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 128 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 129 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 130 * @systemapi hide for inner use 131 * @since 12 132 */ 133 function enable(enable: boolean): Promise<void>; 134 135 /** 136 * Starts mouse traversal. 137 * 138 * @param { string } sinkDeviceDescriptor Descriptor of the target network for mouse traversal. 139 * @param { number } srcInputDeviceId Identifier of the peripheral device for mouse traversal. 140 * @param { AsyncCallback<void> } callback Asynchronous callback function. 141 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 142 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 143 * @throws { BusinessError } 4400001 - Incorrect descriptor for the target device. 144 * @throws { BusinessError } 4400002 - Screen hop failed. 145 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 146 * @systemapi hide for inner use 147 * @since 9 148 */ 149 /** 150 * Starts mouse traversal. 151 * 152 * @param { string } sinkDeviceDescriptor Descriptor of the target network for mouse traversal. 153 * @param { number } srcInputDeviceId Identifier of the peripheral device for mouse traversal. 154 * @param { AsyncCallback<void> } callback Asynchronous callback function. 155 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 156 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 157 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 158 * @throws { BusinessError } 4400001 - Incorrect descriptor for the target device. 159 * @throws { BusinessError } 4400002 - Screen hop failed. 160 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 161 * @systemapi hide for inner use 162 * @since 12 163 */ 164 function start(sinkDeviceDescriptor: string, srcInputDeviceId: number, callback: AsyncCallback<void>): void; 165 166 /** 167 * Starts mouse traversal. 168 * 169 * @param { string } sinkDeviceDescriptor Descriptor of the target network for mouse traversal. 170 * @param { number } srcInputDeviceId Identifier of the peripheral device for mouse traversal. 171 * @returns { Promise<void> } Promise returned by this function 172 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 173 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 174 * @throws { BusinessError } 4400001 - Incorrect descriptor for the target device. 175 * @throws { BusinessError } 4400002 - Screen hop failed. 176 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 177 * @systemapi hide for inner use 178 * @since 9 179 */ 180 /** 181 * Starts mouse traversal. 182 * 183 * @param { string } sinkDeviceDescriptor Descriptor of the target network for mouse traversal. 184 * @param { number } srcInputDeviceId Identifier of the peripheral device for mouse traversal. 185 * @returns { Promise<void> } Promise returned by this function 186 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 187 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 188 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 189 * @throws { BusinessError } 4400001 - Incorrect descriptor for the target device. 190 * @throws { BusinessError } 4400002 - Screen hop failed. 191 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 192 * @systemapi hide for inner use 193 * @since 12 194 */ 195 function start(sinkDeviceDescriptor: string, srcInputDeviceId: number): Promise<void>; 196 197 /** 198 * Stops mouse traversal. 199 * 200 * @param { AsyncCallback<void> } callback Asynchronous callback function. 201 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 202 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 203 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 204 * @systemapi hide for inner use 205 * @since 9 206 */ 207 /** 208 * Stops mouse traversal. 209 * 210 * @param { AsyncCallback<void> } callback Asynchronous callback function. 211 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 212 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 213 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 214 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 215 * @systemapi hide for inner use 216 * @since 12 217 */ 218 function stop(callback: AsyncCallback<void>): void; 219 220 /** 221 * Stops mouse traversal. 222 * 223 * @returns { Promise<void> } Promise returned by this function 224 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 225 * @systemapi hide for inner use 226 * @since 9 227 */ 228 /** 229 * Stops mouse traversal. 230 * 231 * @returns { Promise<void> } Promise returned by this function 232 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 233 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 234 * @systemapi hide for inner use 235 * @since 12 236 */ 237 function stop(): Promise<void>; 238 239 /** 240 * Obtains the status of the mouse traversal switch. 241 * 242 * @param {string} deviceDescriptor Descriptor of the target network for mouse traversal. 243 * @param {AsyncCallback<{ state: boolean }>} callback Asynchronous callback used to receive the status of the mouse traversal switch. 244 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 245 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 246 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 247 * @systemapi hide for inner use 248 * @since 9 249 */ 250 /** 251 * Obtains the status of the mouse traversal switch. 252 * 253 * @param {string} deviceDescriptor Descriptor of the target network for mouse traversal. 254 * @param {AsyncCallback<{ state: boolean }>} callback Asynchronous callback used to receive the status of the mouse traversal switch. 255 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 256 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 257 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 258 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 259 * @systemapi hide for inner use 260 * @since 12 261 */ 262 function getState(deviceDescriptor: string, callback: AsyncCallback<{ state: boolean }>): void; 263 264 /** 265 * Obtains the status of the mouse traversal switch. 266 * 267 * @param deviceDescriptor Descriptor of the target network for mouse traversal. 268 * @returns { Promise<{ state: boolean }> } A promise used by returning state 269 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 270 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 271 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 272 * @systemapi hide for inner use 273 * @since 9 274 */ 275 /** 276 * Obtains the status of the mouse traversal switch. 277 * 278 * @param deviceDescriptor Descriptor of the target network for mouse traversal. 279 * @returns { Promise<{ state: boolean }> } A promise used by returning state 280 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 281 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 282 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 283 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 284 * @systemapi hide for inner use 285 * @since 12 286 */ 287 function getState(deviceDescriptor: string): Promise<{ state: boolean }>; 288 289 /** 290 * Enables listening for mouse traversal events. 291 * 292 * @param { 'cooperation' } type Registration type. 293 * @param { AsyncCallback<{ deviceDescriptor: string, eventMsg: EventMsg }> } callback Asynchronous callback used to receive mouse traversal events. 294 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 295 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 296 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 297 * @systemapi hide for inner use 298 * @since 9 299 */ 300 /** 301 * Enables listening for mouse traversal events. 302 * 303 * @param { 'cooperation' } type Registration type. 304 * @param { AsyncCallback<{ deviceDescriptor: string, eventMsg: EventMsg }> } callback Asynchronous callback used to receive mouse traversal events. 305 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 306 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 307 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 308 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 309 * @systemapi hide for inner use 310 * @since 12 311 */ 312 function on(type: 'cooperation', callback: AsyncCallback<{ deviceDescriptor: string, eventMsg: EventMsg }>): void; 313 314 /** 315 * Disables listening for mouse traversal events. 316 * 317 * @param { 'cooperation' } type Registration type. 318 * @param { AsyncCallback<void> } callback Asynchronous callback used to return the result. 319 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 320 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 321 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 322 * @systemapi hide for inner use 323 * @since 9 324 */ 325 /** 326 * Disables listening for mouse traversal events. 327 * 328 * @param { 'cooperation' } type Registration type. 329 * @param { AsyncCallback<void> } callback Asynchronous callback used to return the result. 330 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 331 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 332 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 333 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 334 * @systemapi hide for inner use 335 * @since 12 336 */ 337 function off(type: 'cooperation', callback?: AsyncCallback<void>): void; 338 339} 340 341export default inputDeviceCooperate;