• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
115   * <br>2. Incorrect parameter types; 3. Parameter verification failed.
116   * @syscap SystemCapability.MultimodalInput.Input.Cooperator
117   * @systemapi hide for inner use
118   * @since 9
119   */
120  /**
121   * Enable or disable the mouse traversal.
122   *
123   * @param enable Whether to enable mouse traversal.
124   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
125   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
126   * <br>2. Incorrect parameter types; 3. Parameter verification failed.
127   * @syscap SystemCapability.MultimodalInput.Input.Cooperator
128   * @systemapi hide for inner use
129   * @since 12
130   */
131  function enable(enable: boolean): Promise<void>;
132
133  /**
134   * Starts mouse traversal.
135   *
136   * @param { string } sinkDeviceDescriptor Descriptor of the target network for mouse traversal.
137   * @param { number } srcInputDeviceId Identifier of the peripheral device for mouse traversal.
138   * @param { AsyncCallback<void> } callback Asynchronous callback function.
139   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
140   * <br>2. Incorrect parameter types; 3. Parameter verification failed.
141   * @throws { BusinessError } 4400001 - Incorrect descriptor for the target device.
142   * @throws { BusinessError } 4400002 - Screen hop failed.
143   * @syscap SystemCapability.MultimodalInput.Input.Cooperator
144   * @systemapi hide for inner use
145   * @since 9
146   */
147  /**
148   * Starts mouse traversal.
149   *
150   * @param { string } sinkDeviceDescriptor Descriptor of the target network for mouse traversal.
151   * @param { number } srcInputDeviceId Identifier of the peripheral device for mouse traversal.
152   * @param { AsyncCallback<void> } callback Asynchronous callback function.
153   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
154   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
155   * <br>2. Incorrect parameter types; 3. Parameter verification failed.
156   * @throws { BusinessError } 4400001 - Incorrect descriptor for the target device.
157   * @throws { BusinessError } 4400002 - Screen hop failed.
158   * @syscap SystemCapability.MultimodalInput.Input.Cooperator
159   * @systemapi hide for inner use
160   * @since 12
161   */
162  function start(sinkDeviceDescriptor: string, srcInputDeviceId: number, callback: AsyncCallback<void>): void;
163
164  /**
165   * Starts mouse traversal.
166   *
167   * @param { string } sinkDeviceDescriptor Descriptor of the target network for mouse traversal.
168   * @param { number } srcInputDeviceId Identifier of the peripheral device for mouse traversal.
169   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
170   * <br>2. Incorrect parameter types; 3. Parameter verification failed.
171   * @throws { BusinessError } 4400001 - Incorrect descriptor for the target device.
172   * @throws { BusinessError } 4400002 - Screen hop failed.
173   * @syscap SystemCapability.MultimodalInput.Input.Cooperator
174   * @systemapi hide for inner use
175   * @since 9
176  */
177  /**
178   * Starts mouse traversal.
179   *
180   * @param { string } sinkDeviceDescriptor Descriptor of the target network for mouse traversal.
181   * @param { number } srcInputDeviceId Identifier of the peripheral device for mouse traversal.
182   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
183   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
184   * <br>2. Incorrect parameter types; 3. Parameter verification failed.
185   * @throws { BusinessError } 4400001 - Incorrect descriptor for the target device.
186   * @throws { BusinessError } 4400002 - Screen hop failed.
187   * @syscap SystemCapability.MultimodalInput.Input.Cooperator
188   * @systemapi hide for inner use
189   * @since 12
190  */
191  function start(sinkDeviceDescriptor: string, srcInputDeviceId: number): Promise<void>;
192
193  /**
194   * Stops mouse traversal.
195   *
196   * @param { AsyncCallback<void> } callback Asynchronous callback function.
197   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
198   * <br>2. Incorrect parameter types; 3. Parameter verification failed.
199   * @syscap SystemCapability.MultimodalInput.Input.Cooperator
200   * @systemapi hide for inner use
201   * @since 9
202   */
203  /**
204   * Stops mouse traversal.
205   *
206   * @param { AsyncCallback<void> } callback Asynchronous callback function.
207   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
208   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
209   * <br>2. Incorrect parameter types; 3. Parameter verification failed.
210   * @syscap SystemCapability.MultimodalInput.Input.Cooperator
211   * @systemapi hide for inner use
212   * @since 12
213   */
214  function stop(callback: AsyncCallback<void>): void;
215
216  /**
217   * Stops mouse traversal.
218   *
219   * @syscap SystemCapability.MultimodalInput.Input.Cooperator
220   * @systemapi hide for inner use
221   * @since 9
222   */
223  /**
224   * Stops mouse traversal.
225   *
226   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
227   * @syscap SystemCapability.MultimodalInput.Input.Cooperator
228   * @systemapi hide for inner use
229   * @since 12
230   */
231  function stop(): Promise<void>;
232
233  /**
234   * Obtains the status of the mouse traversal switch.
235   *
236   * @param {string} deviceDescriptor Descriptor of the target network for mouse traversal.
237   * @param {AsyncCallback<{ state: boolean }>} callback Asynchronous callback used to receive the status of the mouse traversal switch.
238   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
239   * <br>2. Incorrect parameter types; 3. Parameter verification failed.
240   * @syscap SystemCapability.MultimodalInput.Input.Cooperator
241   * @systemapi hide for inner use
242   * @since 9
243   */
244  /**
245   * Obtains the status of the mouse traversal switch.
246   *
247   * @param {string} deviceDescriptor Descriptor of the target network for mouse traversal.
248   * @param {AsyncCallback<{ state: boolean }>} callback Asynchronous callback used to receive the status of the mouse traversal switch.
249   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
250   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
251   * <br>2. Incorrect parameter types; 3. Parameter verification failed.
252   * @syscap SystemCapability.MultimodalInput.Input.Cooperator
253   * @systemapi hide for inner use
254   * @since 12
255   */
256  function getState(deviceDescriptor: string, callback: AsyncCallback<{ state: boolean }>): void;
257
258  /**
259   * Obtains the status of the mouse traversal switch.
260   *
261   * @param deviceDescriptor Descriptor of the target network for mouse traversal.
262   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
263   * <br>2. Incorrect parameter types; 3. Parameter verification failed.
264   * @syscap SystemCapability.MultimodalInput.Input.Cooperator
265   * @systemapi hide for inner use
266   * @since 9
267   */
268  /**
269   * Obtains the status of the mouse traversal switch.
270   *
271   * @param deviceDescriptor Descriptor of the target network for mouse traversal.
272   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
273   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
274   * <br>2. Incorrect parameter types; 3. Parameter verification failed.
275   * @syscap SystemCapability.MultimodalInput.Input.Cooperator
276   * @systemapi hide for inner use
277   * @since 12
278   */
279  function getState(deviceDescriptor: string): Promise<{ state: boolean }>;
280
281  /**
282   * Enables listening for mouse traversal events.
283   *
284   * @param { 'cooperation' } type Registration type.
285   * @param { AsyncCallback<{ deviceDescriptor: string, eventMsg: EventMsg }> } callback Asynchronous callback used to receive mouse traversal events.
286   * @returns Callback for the input device event.
287   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
288   * <br>2. Incorrect parameter types; 3. Parameter verification failed.
289   * @syscap SystemCapability.MultimodalInput.Input.Cooperator
290   * @systemapi hide for inner use
291   * @since 9
292   */
293  /**
294   * Enables listening for mouse traversal events.
295   *
296   * @param { 'cooperation' } type Registration type.
297   * @param { AsyncCallback<{ deviceDescriptor: string, eventMsg: EventMsg }> } callback Asynchronous callback used to receive mouse traversal events.
298   * @returns Callback for the input device event.
299   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
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.Cooperator
303   * @systemapi hide for inner use
304   * @since 12
305   */
306  function on(type: 'cooperation', callback: AsyncCallback<{ deviceDescriptor: string, eventMsg: EventMsg }>): void;
307
308  /**
309   * Disables listening for mouse traversal events.
310   *
311   * @param { 'cooperation' } type Registration type.
312   * @param { AsyncCallback<void> } callback Asynchronous callback used to return the result.
313   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
314   * <br>2. Incorrect parameter types; 3. Parameter verification failed.
315   * @syscap SystemCapability.MultimodalInput.Input.Cooperator
316   * @systemapi hide for inner use
317   * @since 9
318   */
319  /**
320   * Disables listening for mouse traversal events.
321   *
322   * @param { 'cooperation' } type Registration type.
323   * @param { AsyncCallback<void> } callback Asynchronous callback used to return the result.
324   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
325   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
326   * <br>2. Incorrect parameter types; 3. Parameter verification failed.
327   * @syscap SystemCapability.MultimodalInput.Input.Cooperator
328   * @systemapi hide for inner use
329   * @since 12
330   */
331  function off(type: 'cooperation', callback?: AsyncCallback<void>): void;
332
333}
334
335export default inputDeviceCooperate;