1/* 2 * Copyright (c) 2021-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 { Callback } from './basic'; 17import { MouseEvent } from './@ohos.multimodalInput.mouseEvent'; 18 19/** 20 * Global input event listener 21 * System API, available only to system processes 22 * @since 7 23 * @syscap SystemCapability.MultimodalInput.Input.InputMonitor 24 * @permission ohos.permission.INPUT_MONITORING 25 * @systemapi hide for inner use 26 */ 27declare namespace inputMonitor { 28 /** 29 * Callback used to receive touch input events. If **true** is returned, the touch input is consumed, and the system performs the closing operation. 30 * @since 7 31 * @syscap SystemCapability.MultimodalInput.Input.InputMonitor 32 * @systemapi hide for inner use 33 */ 34 interface TouchEventReceiver { 35 (touchEvent:TouchEvent): Boolean; 36 } 37 38 /** 39 * Listens for touch input events. 40 * @since 7 41 * @syscap SystemCapability.MultimodalInput.Input.InputMonitor 42 * @systemapi hide for inner use 43 * @permission ohos.permission.INPUT_MONITORING 44 * @param type Event type. 45 * @param receiver Callback used to receive the reported data. 46 * @throws {BusinessError} 401 - Parameter error. 47 * @throws {BusinessError} 201 - Permission denied. 48 */ 49 function on(type:"touch", receiver:TouchEventReceiver):void; 50 51 /** 52 * Listens for mouse input events. 53 * @since 9 54 * @syscap SystemCapability.MultimodalInput.Input.InputMonitor 55 * @systemapi hide for inner use 56 * @permission ohos.permission.INPUT_MONITORING 57 * @param type Event type. 58 * @param receiver Callback used to receive the reported data. 59 * @throws {BusinessError} 401 - Parameter error. 60 * @throws {BusinessError} 201 - Permission denied. 61 */ 62 function on(type:"mouse", receiver:Callback<MouseEvent>):void; 63 64 /** 65 * Cancel listening for touch input events. 66 * @since 7 67 * @syscap SystemCapability.MultimodalInput.Input.InputMonitor 68 * @systemapi hide for inner use 69 * @permission ohos.permission.INPUT_MONITORING 70 * @param type Event type. 71 * @param receiver Callback used to receive the reported data. 72 * @throws {BusinessError} 401 - Parameter error. 73 * @throws {BusinessError} 201 - Permission denied. 74 */ 75 function off(type:"touch", receiver?:TouchEventReceiver):void; 76 77 /** 78 * Cancel listening for mouse input events. 79 * @since 9 80 * @syscap SystemCapability.MultimodalInput.Input.InputMonitor 81 * @systemapi hide for inner use 82 * @permission ohos.permission.INPUT_MONITORING 83 * @param type Event type. 84 * @param receiver Callback used to receive the reported data. 85 * @throws {BusinessError} 401 - Parameter error. 86 * @throws {BusinessError} 201 - Permission denied. 87 */ 88 function off(type:"mouse", receiver?:Callback<MouseEvent>):void; 89} 90export default inputMonitor;