1/* 2 * Copyright (C) 2021 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 { MouseEvent } from './@ohos.multimodalInput.mouseEvent'; 22import { TouchEvent } from './@ohos.multimodalInput.touchEvent'; 23/** 24 * Global Key Event Injection 25 * 26 * @namespace inputEventClient 27 * @syscap SystemCapability.MultimodalInput.Input.InputSimulator 28 * @systemapi hide for inner use 29 * @since 8 30 */ 31declare namespace inputEventClient { 32 /** 33 * Defines event of key that user want to inject. 34 * 35 * @interface KeyEvent 36 * @syscap SystemCapability.MultimodalInput.Input.InputSimulator 37 * @systemapi hide for inner use 38 * @since 8 39 */ 40 interface KeyEvent { 41 /** 42 * The status of key. 43 * 44 * @syscap SystemCapability.MultimodalInput.Input.InputSimulator 45 * @systemapi hide for inner use 46 * @since 8 47 */ 48 isPressed: boolean; 49 50 /** 51 * The keyCode value of key. 52 * 53 * @syscap SystemCapability.MultimodalInput.Input.InputSimulator 54 * @systemapi hide for inner use 55 * @since 8 56 */ 57 keyCode: number; 58 59 /** 60 * Key hold duration. 61 * 62 * @syscap SystemCapability.MultimodalInput.Input.InputSimulator 63 * @systemapi hide for inner use 64 * @since 8 65 */ 66 keyDownDuration: number; 67 68 /** 69 * Whether the key is blocked. 70 * 71 * @syscap SystemCapability.MultimodalInput.Input.InputSimulator 72 * @systemapi hide for inner use 73 * @since 8 74 */ 75 isIntercepted: boolean; 76 } 77 78 /** 79 * Defines event of mouse that user want to inject. 80 * 81 * @interface MouseEventData 82 * @syscap SystemCapability.MultimodalInput.Input.InputSimulator 83 * @systemapi hide for inner use 84 * @since 11 85 */ 86 interface MouseEventData { 87 /** 88 * Inject mouse event. 89 * 90 * @type { MouseEvent } 91 * @syscap SystemCapability.MultimodalInput.Input.InputSimulator 92 * @systemapi hide for inner use 93 * @since 11 94 */ 95 mouseEvent: MouseEvent; 96 } 97 98 /** 99 * Defines event of touch that user want to inject. 100 * 101 * @interface TouchEventData 102 * @syscap SystemCapability.MultimodalInput.Input.InputSimulator 103 * @systemapi hide for inner use 104 * @since 11 105 */ 106 interface TouchEventData { 107 /** 108 * Inject touch event. 109 * 110 * @type { TouchEvent } 111 * @syscap SystemCapability.MultimodalInput.Input.InputSimulator 112 * @systemapi hide for inner use 113 * @since 11 114 */ 115 touchEvent: TouchEvent; 116 } 117 118 /** 119 * Defines event of key that user want to inject. 120 * 121 * @interface KeyEventData 122 * @syscap SystemCapability.MultimodalInput.Input.InputSimulator 123 * @systemapi hide for inner use 124 * @since 11 125 */ 126 interface KeyEventData { 127 /** 128 * Inject key event. 129 * 130 * @type { KeyEvent } 131 * @syscap SystemCapability.MultimodalInput.Input.InputSimulator 132 * @systemapi hide for inner use 133 * @since 11 134 */ 135 keyEvent: KeyEvent; 136 } 137 138 /** 139 * Inject system keys. 140 * 141 * @param { KeyEventData } keyEvent - the key event to be injected. 142 * @throws { BusinessError } 202 - SystemAPI permission error. 143 * @throws { BusinessError } 401 - Parameter error. 144 * @syscap SystemCapability.MultimodalInput.Input.InputSimulator 145 * @systemapi hide for inner use 146 * @since 11 147 */ 148 function injectKeyEvent(keyEvent: KeyEventData): void; 149 150 /** 151 * Inject system keys. 152 * 153 * @param { { KeyEvent } } KeyEvent - the key event to be injected. 154 * @throws { BusinessError } 401 - Parameter error. 155 * @syscap SystemCapability.MultimodalInput.Input.InputSimulator 156 * @systemapi hide for inner use 157 * @since 8 158 */ 159 function injectEvent({ KeyEvent: KeyEvent }): void; 160 161 /** 162 * Inject mouse event. 163 * 164 * @param { MouseEventData } mouseEvent - the mouse event to be injected. 165 * @throws { BusinessError } 202 - SystemAPI permission error. 166 * @throws { BusinessError } 401 - Parameter error. 167 * @syscap SystemCapability.MultimodalInput.Input.InputSimulator 168 * @systemapi hide for inner use 169 * @since 11 170 */ 171 function injectMouseEvent(mouseEvent: MouseEventData): void; 172 173 /** 174 * Inject touch event. 175 * 176 * @param { TouchEventData } touchEvent - the touch event to be injected. 177 * @throws { BusinessError } 202 - SystemAPI permission error. 178 * @throws { BusinessError } 401 - Parameter error. 179 * @syscap SystemCapability.MultimodalInput.Input.InputSimulator 180 * @systemapi hide for inner use 181 * @since 11 182 */ 183 function injectTouchEvent(touchEvent: TouchEventData): void; 184} 185 186export default inputEventClient; 187