1/* 2 * Copyright (c) 2021-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 { Callback } from './@ohos.base'; 22import { MouseEvent } from './@ohos.multimodalInput.mouseEvent'; 23import type display from './@ohos.display'; 24import type { TouchEvent } from './@ohos.multimodalInput.touchEvent'; 25import type { Rotate, Pinch, ThreeFingersSwipe, FourFingersSwipe, SwipeInward } from './@ohos.multimodalInput.gestureEvent'; 26import type { ThreeFingersTap } from './@ohos.multimodalInput.gestureEvent'; 27import type { FingerprintEvent } from './@ohos.multimodalInput.shortKey'; 28 29/** 30 * Global input event listener 31 * System API, available only to system processes 32 * 33 * @namespace inputMonitor 34 * @syscap SystemCapability.MultimodalInput.Input.InputMonitor 35 * @systemapi hide for inner use 36 * @since 7 37 */ 38declare namespace inputMonitor { 39 /** 40 * Callback used to receive touch input events. If **true** is returned, the touch input is consumed, 41 * and the system performs the closing operation. 42 * 43 * @interface TouchEventReceiver 44 * @syscap SystemCapability.MultimodalInput.Input.InputMonitor 45 * @systemapi hide for inner use 46 * @since 7 47 */ 48 interface TouchEventReceiver { 49 /** 50 * Callback used to receive touch input events. 51 * 52 * @param { TouchEvent } touchEvent - the reported touch event. 53 * @returns { Boolean } Returns true indicates the touch input is consumed, the value false indicates opposite. 54 * @syscap SystemCapability.MultimodalInput.Input.InputMonitor 55 * @systemapi hide for inner use 56 * @since 7 57 */ 58 (touchEvent: TouchEvent): Boolean; 59 } 60 61 /** 62 * Listens for touch input events. 63 * 64 * @permission ohos.permission.INPUT_MONITORING 65 * @param { 'touch' } type - Event type, which is **touch**. 66 * @param { TouchEventReceiver } receiver - Callback used to receive the reported data. 67 * @throws { BusinessError } 201 - Permission denied. 68 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 69 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 70 * @syscap SystemCapability.MultimodalInput.Input.InputMonitor 71 * @systemapi hide for inner use 72 * @since 7 73 */ 74 /** 75 * Listens for touch input events. 76 * 77 * @permission ohos.permission.INPUT_MONITORING 78 * @param { 'touch' } type - Event type, which is **touch**. 79 * @param { TouchEventReceiver } receiver - Callback used to receive the reported data. 80 * @throws { BusinessError } 201 - Permission denied. 81 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 82 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 83 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 84 * @syscap SystemCapability.MultimodalInput.Input.InputMonitor 85 * @systemapi hide for inner use 86 * @since 12 87 */ 88 function on(type: 'touch', receiver: TouchEventReceiver): void; 89 90 /** 91 * Listens for mouse input events. 92 * 93 * @permission ohos.permission.INPUT_MONITORING 94 * @param { 'mouse' } type - Event type, which is **mouse**. 95 * @param { Callback<MouseEvent> } receiver - Callback used to receive the reported data. 96 * @throws { BusinessError } 201 - Permission denied. 97 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 98 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 99 * @syscap SystemCapability.MultimodalInput.Input.InputMonitor 100 * @systemapi hide for inner use 101 * @since 9 102 */ 103 /** 104 * Listens for mouse input events. 105 * 106 * @permission ohos.permission.INPUT_MONITORING 107 * @param { 'mouse' } type - Event type, which is **mouse**. 108 * @param { Callback<MouseEvent> } receiver - Callback used to receive the reported data. 109 * @throws { BusinessError } 201 - Permission denied. 110 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 111 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 112 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 113 * @syscap SystemCapability.MultimodalInput.Input.InputMonitor 114 * @systemapi hide for inner use 115 * @since 12 116 */ 117 function on(type: 'mouse', receiver: Callback<MouseEvent>): void; 118 119 /** 120 * Listens for mouse input events when the mouse arrow is within the specified rectangular area. 121 * 122 * @permission ohos.permission.INPUT_MONITORING 123 * @param { 'mouse' } type - Event type, which is **mouse**. 124 * @param { display.Rect[] } rect - A specified rectangular area that can trigger a callback, with a maximum of two. 125 * @param { Callback<MouseEvent> } receiver - Callback used to receive the reported data. 126 * @throws { BusinessError } 201 - Permission denied. 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.InputMonitor 130 * @systemapi hide for inner use 131 * @since 11 132 */ 133 /** 134 * Listens for mouse input events when the mouse arrow is within the specified rectangular area. 135 * 136 * @permission ohos.permission.INPUT_MONITORING 137 * @param { 'mouse' } type - Event type, which is **mouse**. 138 * @param { display.Rect[] } rect - A specified rectangular area that can trigger a callback, with a maximum of two. 139 * @param { Callback<MouseEvent> } receiver - Callback used to receive the reported data. 140 * @throws { BusinessError } 201 - Permission denied. 141 * @throws { BusinessError } 202 - SystemAPI permit error. 142 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 143 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 144 * @syscap SystemCapability.MultimodalInput.Input.InputMonitor 145 * @systemapi hide for inner use 146 * @since 12 147 */ 148 function on(type: 'mouse', rect: display.Rect[], receiver: Callback<MouseEvent>): void; 149 150 /** 151 * Cancel listening for touch input events. 152 * 153 * @permission ohos.permission.INPUT_MONITORING 154 * @param { 'touch' } type - Event type, which is **touch**. 155 * @param { TouchEventReceiver } receiver - Callback used to receive the reported data. 156 * @throws { BusinessError } 201 - Permission denied. 157 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 158 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 159 * @syscap SystemCapability.MultimodalInput.Input.InputMonitor 160 * @systemapi hide for inner use 161 * @since 7 162 */ 163 /** 164 * Cancel listening for touch input events. 165 * 166 * @permission ohos.permission.INPUT_MONITORING 167 * @param { 'touch' } type - Event type, which is **touch**. 168 * @param { TouchEventReceiver } receiver - Callback used to receive the reported data. 169 * @throws { BusinessError } 201 - Permission denied. 170 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 171 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 172 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 173 * @syscap SystemCapability.MultimodalInput.Input.InputMonitor 174 * @systemapi hide for inner use 175 * @since 12 176 */ 177 function off(type: 'touch', receiver?: TouchEventReceiver): void; 178 179 /** 180 * Cancel listening for mouse input events. 181 * 182 * @permission ohos.permission.INPUT_MONITORING 183 * @param { 'mouse' } type - Event type, which is **mouse**. 184 * @param { Callback<MouseEvent> } receiver - Callback used to receive the reported data. 185 * @throws { BusinessError } 201 - Permission denied. 186 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 187 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 188 * @syscap SystemCapability.MultimodalInput.Input.InputMonitor 189 * @systemapi hide for inner use 190 * @since 9 191 */ 192 /** 193 * Cancel listening for mouse input events. 194 * 195 * @permission ohos.permission.INPUT_MONITORING 196 * @param { 'mouse' } type - Event type, which is **mouse**. 197 * @param { Callback<MouseEvent> } receiver - Callback used to receive the reported data. 198 * @throws { BusinessError } 201 - Permission denied. 199 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 200 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 201 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 202 * @syscap SystemCapability.MultimodalInput.Input.InputMonitor 203 * @systemapi hide for inner use 204 * @since 12 205 */ 206 function off(type: 'mouse', receiver?: Callback<MouseEvent>): void; 207 208 /** 209 * Listens for touchPad pinch events. 210 * 211 * @permission ohos.permission.INPUT_MONITORING 212 * @param { 'pinch' } type - Event type, which is **pinch**. 213 * @param { Callback<Pinch> } receiver - Callback used to receive the reported data. 214 * @throws { BusinessError } 201 - Permission denied. 215 * @throws { BusinessError } 202 - SystemAPI permit error. 216 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 217 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 218 * @syscap SystemCapability.MultimodalInput.Input.InputMonitor 219 * @systemapi hide for inner use 220 * @since 10 221 */ 222 function on(type: 'pinch', receiver: Callback<Pinch>): void; 223 224 /** 225 * Cancel listening for touchPad pinch events. 226 * 227 * @permission ohos.permission.INPUT_MONITORING 228 * @param { 'pinch' } type - Event type, which is **pinch**. 229 * @param { Callback<Pinch> } receiver - Callback used to receive the reported data. 230 * @throws { BusinessError } 201 - Permission denied. 231 * @throws { BusinessError } 202 - SystemAPI permit error. 232 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 233 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 234 * @syscap SystemCapability.MultimodalInput.Input.InputMonitor 235 * @systemapi hide for inner use 236 * @since 10 237 */ 238 function off(type: 'pinch', receiver?: Callback<Pinch>): void; 239 240 /** 241 * Listens for touchPad fingers pinch events. 242 * 243 * @permission ohos.permission.INPUT_MONITORING 244 * @param { 'pinch' } type - Event type, which is **pinch**. 245 * @param { number } fingers - the number of fingers. 246 * @param { Callback<Pinch> } receiver - Callback used to receive the reported data. 247 * @throws { BusinessError } 201 - Permission denied. 248 * @throws { BusinessError } 202 - SystemAPI permit error. 249 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 250 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 251 * @syscap SystemCapability.MultimodalInput.Input.InputMonitor 252 * @systemapi hide for inner use 253 * @since 11 254 */ 255 function on(type: 'pinch', fingers: number, receiver: Callback<Pinch>): void; 256 257 /** 258 * Cancel listening for touchPad fingers pinch events. 259 * 260 * @permission ohos.permission.INPUT_MONITORING 261 * @param { 'pinch' } type - Event type, which is **pinch**. 262 * @param { number } fingers - the number of fingers. 263 * @param { Callback<Pinch> } receiver - Callback used to receive the reported data. 264 * @throws { BusinessError } 201 - Permission denied. 265 * @throws { BusinessError } 202 - SystemAPI permit error. 266 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 267 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 268 * @syscap SystemCapability.MultimodalInput.Input.InputMonitor 269 * @systemapi hide for inner use 270 * @since 11 271 */ 272 function off(type: 'pinch', fingers: number, receiver?: Callback<Pinch>): void; 273 274 /** 275 * Listens for touchPad fingers rotate events. 276 * 277 * @permission ohos.permission.INPUT_MONITORING 278 * @param { 'rotate' } type - Event type, which is **rotate**. 279 * @param { number } fingers - the number of fingers. 280 * @param { Callback<Rotate> } receiver - Callback used to receive the reported data. 281 * @throws { BusinessError } 201 - Permission denied. 282 * @throws { BusinessError } 202 - SystemAPI permit error. 283 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 284 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 285 * @syscap SystemCapability.MultimodalInput.Input.InputMonitor 286 * @systemapi hide for inner use 287 * @since 11 288 */ 289 function on(type: 'rotate', fingers: number, receiver: Callback<Rotate>): void; 290 291 /** 292 * Cancel listening for touchPad fingers rotate events. 293 * 294 * @permission ohos.permission.INPUT_MONITORING 295 * @param { 'rotate' } type - Event type, which is **rotate**. 296 * @param { number } fingers - the number of fingers. 297 * @param { Callback<Rotate> } receiver - Callback used to receive the reported data. 298 * @throws { BusinessError } 201 - Permission denied. 299 * @throws { BusinessError } 202 - SystemAPI permit error. 300 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 301 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 302 * @syscap SystemCapability.MultimodalInput.Input.InputMonitor 303 * @systemapi hide for inner use 304 * @since 11 305 */ 306 function off(type: 'rotate', fingers: number, receiver?: Callback<Rotate>): void; 307 308 /** 309 * Listens for touchPad three fingers swipe events. 310 * 311 * @permission ohos.permission.INPUT_MONITORING 312 * @param { 'threeFingersSwipe' } type - Event type, which is **threeFingersSwipe**. 313 * @param { Callback<ThreeFingersSwipe> } receiver - Callback used to receive the reported data. 314 * @throws { BusinessError } 201 - Permission denied. 315 * @throws { BusinessError } 202 - SystemAPI permit error. 316 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 317 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 318 * @syscap SystemCapability.MultimodalInput.Input.InputMonitor 319 * @systemapi hide for inner use 320 * @since 10 321 */ 322 function on(type: 'threeFingersSwipe', receiver: Callback<ThreeFingersSwipe>): void; 323 324 /** 325 * Cancel listening touchPad three fingers swipe events. 326 * 327 * @permission ohos.permission.INPUT_MONITORING 328 * @param { 'threeFingersSwipe' } type - Event type, which is **threeFingersSwipe**. 329 * @param { Callback<ThreeFingersSwipe> } receiver - Callback used to receive the reported data. 330 * @throws { BusinessError } 201 - Permission denied. 331 * @throws { BusinessError } 202 - SystemAPI permit error. 332 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 333 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 334 * @syscap SystemCapability.MultimodalInput.Input.InputMonitor 335 * @systemapi hide for inner use 336 * @since 10 337 */ 338 function off(type: 'threeFingersSwipe', receiver?: Callback<ThreeFingersSwipe>): void; 339 340 /** 341 * Listens for touchPad four fingers swipe events. 342 * 343 * @permission ohos.permission.INPUT_MONITORING 344 * @param { 'fourFingersSwipe' } type - Event type, which is **fourFingersSwipe**.. 345 * @param { Callback<FourFingersSwipe> } receiver - Callback used to receive the reported data. 346 * @throws { BusinessError } 201 - Permission denied. 347 * @throws { BusinessError } 202 - SystemAPI permit error. 348 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 349 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 350 * @syscap SystemCapability.MultimodalInput.Input.InputMonitor 351 * @systemapi hide for inner use 352 * @since 10 353 */ 354 function on(type: 'fourFingersSwipe', receiver: Callback<FourFingersSwipe>): void; 355 356 /** 357 * Cancel listening touchPad four finger swipe events. 358 * 359 * @permission ohos.permission.INPUT_MONITORING 360 * @param { 'fourFingersSwipe' } type - Event type, which is **fourFingersSwipe**. 361 * @param { Callback<FourFingersSwipe> } receiver - Callback used to receive the reported data. 362 * @throws { BusinessError } 201 - Permission denied. 363 * @throws { BusinessError } 202 - SystemAPI permit error. 364 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 365 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 366 * @syscap SystemCapability.MultimodalInput.Input.InputMonitor 367 * @systemapi hide for inner use 368 * @since 10 369 */ 370 function off(type: 'fourFingersSwipe', receiver?: Callback<FourFingersSwipe>): void; 371 372 /** 373 * Listens for touchPad three fingers tap events. 374 * 375 * @permission ohos.permission.INPUT_MONITORING 376 * @param { 'threeFingersTap' } type - Event type, which is **threeFingersTap**. 377 * @param { Callback<ThreeFingersTap> } receiver - Callback used to receive the reported data. 378 * @throws { BusinessError } 201 - Permission denied. 379 * @throws { BusinessError } 202 - SystemAPI permit error. 380 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 381 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 382 * @syscap SystemCapability.MultimodalInput.Input.InputMonitor 383 * @systemapi hide for inner use 384 * @since 11 385 */ 386 function on(type: 'threeFingersTap', receiver: Callback<ThreeFingersTap>): void; 387 388 /** 389 * Cancel listening touchPad three fingers tap events. 390 * 391 * @permission ohos.permission.INPUT_MONITORING 392 * @param { 'threeFingersTap' } type - Event type, which is **threeFingersTap**. 393 * @param { Callback<ThreeFingersTap> } receiver - Callback used to receive the reported data. 394 * @throws { BusinessError } 201 - Permission denied. 395 * @throws { BusinessError } 202 - SystemAPI permit error. 396 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 397 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 398 * @syscap SystemCapability.MultimodalInput.Input.InputMonitor 399 * @systemapi hide for inner use 400 * @since 11 401 */ 402 function off(type: 'threeFingersTap', receiver?: Callback<ThreeFingersTap>): void; 403 404 /** 405 * Enables listening for fingerprint key events. 406 * 407 * @permission ohos.permission.INPUT_MONITORING 408 * @param { 'fingerprint' } type - Event type, which is **fingerprint**. 409 * @param { Callback<FingerprintEvent> } receiver - Callback used to receive the reported data. 410 * @throws { BusinessError } 201 - Permission denied. 411 * @throws { BusinessError } 202 - SystemAPI permit error. 412 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 413 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 414 * @syscap SystemCapability.MultimodalInput.Input.InputMonitor 415 * @systemapi hide for inner use 416 * @since 12 417 */ 418 function on(type: 'fingerprint', receiver: Callback<FingerprintEvent>): void; 419 420 /** 421 * Cancels listening for fingerprint key events. 422 * 423 * @permission ohos.permission.INPUT_MONITORING 424 * @param { 'fingerprint' } type - Event type, which is **fingerprint**. 425 * @param { Callback<FingerprintEvent> } receiver - Callback used to receive the reported data. 426 * @throws { BusinessError } 201 - Permission denied. 427 * @throws { BusinessError } 202 - SystemAPI permit error. 428 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 429 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 430 * @syscap SystemCapability.MultimodalInput.Input.InputMonitor 431 * @systemapi hide for inner use 432 * @since 12 433 */ 434 function off(type: 'fingerprint', receiver?: Callback<FingerprintEvent>): void; 435 436 /** 437 * Enables listening touchPad swipe inward events. 438 * 439 * @permission ohos.permission.INPUT_MONITORING 440 * @param { 'swipeInward' } type - Event type, which is **swipeInward**. 441 * @param { Callback<SwipeInward> } receiver - Callback used to receive the reported data. 442 * @throws { BusinessError } 201 - Permission denied. 443 * @throws { BusinessError } 202 - SystemAPI permit error. 444 * @throws { BusinessError } 401 - Parameter error. 445 * @syscap SystemCapability.MultimodalInput.Input.InputMonitor 446 * @systemapi hide for inner use 447 * @since 12 448 */ 449 function on(type: 'swipeInward', receiver: Callback<SwipeInward>): void; 450 451 /** 452 * Cancel listening touchPad swipe inward events. 453 * 454 * @permission ohos.permission.INPUT_MONITORING 455 * @param { 'swipeInward' } type - Event type, which is **swipeInward**. 456 * @param { Callback<SwipeInward> } receiver - Callback used to receive the reported data. 457 * @throws { BusinessError } 201 - Permission denied. 458 * @throws { BusinessError } 202 - SystemAPI permit error. 459 * @throws { BusinessError } 401 - Parameter error. 460 * @syscap SystemCapability.MultimodalInput.Input.InputMonitor 461 * @systemapi hide for inner use 462 * @since 12 463 */ 464 function off(type: 'swipeInward', receiver?: Callback<SwipeInward>): void; 465} 466export default inputMonitor; 467