• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
16import { Callback } from './@ohos.base';
17import { MouseEvent } from './@ohos.multimodalInput.mouseEvent';
18import type { Pinch, ThreeFingersSwipe, FourFingersSwipe } from './@ohos.multimodalInput.gestureEvent';
19
20/**
21 * Global input event listener
22 * System API, available only to system processes
23 *
24 * @namespace inputMonitor
25 * @permission ohos.permission.INPUT_MONITORING
26 * @syscap SystemCapability.MultimodalInput.Input.InputMonitor
27 * @systemapi hide for inner use
28 * @since 7
29 */
30declare namespace inputMonitor {
31  /**
32   * Callback used to receive touch input events. If **true** is returned, the touch input is consumed,
33   * and the system performs the closing operation.
34   *
35   * @interface TouchEventReceiver
36   * @permission ohos.permission.INPUT_MONITORING
37   * @syscap SystemCapability.MultimodalInput.Input.InputMonitor
38   * @systemapi hide for inner use
39   * @since 7
40   */
41  interface TouchEventReceiver {
42    (touchEvent: TouchEvent): Boolean;
43  }
44
45  /**
46   * Listens for touch input events.
47   *
48   * @permission ohos.permission.INPUT_MONITORING
49   * @param { 'touch' } type - Event type, which is **touch**.
50   * @param { TouchEventReceiver } receiver - Callback used to receive the reported data.
51   * @throws { BusinessError } 401 - Parameter error.
52   * @throws { BusinessError } 201 - Permission denied.
53   * @syscap SystemCapability.MultimodalInput.Input.InputMonitor
54   * @systemapi hide for inner use
55   * @since 7
56   */
57  function on(type: 'touch', receiver: TouchEventReceiver): void;
58
59  /**
60   * Listens for mouse input events.
61   *
62   * @permission ohos.permission.INPUT_MONITORING
63   * @param { 'mouse' } type - Event type, which is **mouse**.
64   * @param { Callback<MouseEvent> } receiver - Callback used to receive the reported data.
65   * @throws { BusinessError } 401 - Parameter error.
66   * @throws { BusinessError } 201 - Permission denied.
67   * @syscap SystemCapability.MultimodalInput.Input.InputMonitor
68   * @systemapi hide for inner use
69   * @since 9
70   */
71  function on(type: 'mouse', receiver: Callback<MouseEvent>): void;
72
73  /**
74   * Cancel listening for touch input events.
75   *
76   * @permission ohos.permission.INPUT_MONITORING
77   * @param { 'touch' } type - Event type, which is **touch**.
78   * @param { TouchEventReceiver } receiver - Callback used to receive the reported data.
79   * @throws { BusinessError } 401 - Parameter error.
80   * @throws { BusinessError } 201 - Permission denied.
81   * @syscap SystemCapability.MultimodalInput.Input.InputMonitor
82   * @systemapi hide for inner use
83   * @since 7
84   */
85  function off(type: 'touch', receiver?: TouchEventReceiver): void;
86
87  /**
88   * Cancel listening for mouse input events.
89   *
90   * @permission ohos.permission.INPUT_MONITORING
91   * @param { 'mouse' } type - Event type, which is **mouse**.
92   * @param { Callback<MouseEvent> } receiver - Callback used to receive the reported data.
93   * @throws { BusinessError } 401 - Parameter error.
94   * @throws { BusinessError } 201 - Permission denied.
95   * @syscap SystemCapability.MultimodalInput.Input.InputMonitor
96   * @systemapi hide for inner use
97   * @since 9
98   */
99  function off(type: 'mouse', receiver?: Callback<MouseEvent>): void;
100
101  /**
102   * Listens for touchPad pinch events.
103   *
104   * @permission ohos.permission.INPUT_MONITORING
105   * @param { 'pinch' } type - Event type, which is **pinch**.
106   * @param { Callback<Pinch> } receiver - Callback used to receive the reported data.
107   * @throws { BusinessError } 201 - Permission denied.
108   * @throws { BusinessError } 202 - SystemAPI permit error.
109   * @throws { BusinessError } 401 - Parameter error.
110   * @syscap SystemCapability.MultimodalInput.Input.InputMonitor
111   * @systemapi hide for inner use
112   * @since 10
113   */
114  function on(type: 'pinch', receiver: Callback<Pinch>): void;
115
116  /**
117   * Cancel listening for touchPad pinch events.
118   *
119   * @permission ohos.permission.INPUT_MONITORING
120   * @param { 'pinch' } type - Event type, which is **pinch**.
121   * @param { Callback<Pinch> } receiver - Callback used to receive the reported data.
122   * @throws { BusinessError } 201 - Permission denied.
123   * @throws { BusinessError } 202 - SystemAPI permit error.
124   * @throws { BusinessError } 401 - Parameter error.
125   * @syscap SystemCapability.MultimodalInput.Input.InputMonitor
126   * @systemapi hide for inner use
127   * @since 10
128   */
129  function off(type: 'pinch', receiver?: Callback<Pinch>): void;
130
131  /**
132   * Listens for touchPad three fingers swipe events.
133   *
134   * @permission ohos.permission.INPUT_MONITORING
135   * @param { 'threeFingersSwipe' } type - Event type, which is **threeFingersSwipe**.
136   * @param { Callback<ThreeFingersSwipe> } receiver - Callback used to receive the reported data.
137   * @throws { BusinessError } 201 - Permission denied.
138   * @throws { BusinessError } 202 - SystemAPI permit error.
139   * @throws { BusinessError } 401 - Parameter error.
140   * @syscap SystemCapability.MultimodalInput.Input.InputMonitor
141   * @systemapi hide for inner use
142   * @since 10
143   */
144  function on(type: 'threeFingersSwipe', receiver: Callback<ThreeFingersSwipe>): void;
145
146  /**
147   * Cancel listening touchPad three fingers swipe events.
148   *
149   * @permission ohos.permission.INPUT_MONITORING
150   * @param { 'threeFingersSwipe' } type - Event type, which is **threeFingersSwipe**.
151   * @param { Callback<ThreeFingersSwipe> } receiver - Callback used to receive the reported data.
152   * @throws { BusinessError } 201 - Permission denied.
153   * @throws { BusinessError } 202 - SystemAPI permit error.
154   * @throws { BusinessError } 401 - Parameter error.
155   * @syscap SystemCapability.MultimodalInput.Input.InputMonitor
156   * @systemapi hide for inner use
157   * @since 10
158   */
159  function off(type: 'threeFingersSwipe', receiver?: Callback<ThreeFingersSwipe>): void;
160
161  /**
162   * Listens for touchPad four fingers swipe events.
163   *
164   * @permission ohos.permission.INPUT_MONITORING
165   * @param { 'fourFingersSwipe' } type - Event type, which is **fourFingersSwipe**..
166   * @param { Callback<FourFingersSwipe> } receiver - Callback used to receive the reported data.
167   * @throws { BusinessError } 201 - Permission denied.
168   * @throws { BusinessError } 202 - SystemAPI permit error.
169   * @throws { BusinessError } 401 - Parameter error.
170   * @syscap SystemCapability.MultimodalInput.Input.InputMonitor
171   * @systemapi hide for inner use
172   * @since 10
173   */
174  function on(type: 'fourFingersSwipe', receiver: Callback<FourFingersSwipe>): void;
175
176  /**
177   * Cancel listening touchPad four finger swipe events.
178   *
179   * @permission ohos.permission.INPUT_MONITORING
180   * @param { 'fourFingersSwipe' } type - Event type, which is **fourFingersSwipe**.
181   * @param { Callback<FourFingersSwipe> } receiver - Callback used to receive the reported data.
182   * @throws { BusinessError } 201 - Permission denied.
183   * @throws { BusinessError } 202 - SystemAPI permit error.
184   * @throws { BusinessError } 401 - Parameter error.
185   * @syscap SystemCapability.MultimodalInput.Input.InputMonitor
186   * @systemapi hide for inner use
187   * @since 10
188   */
189  function off(type: 'fourFingersSwipe', receiver?: Callback<FourFingersSwipe>): void;
190}
191export default inputMonitor;