• 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 * @since 9
27 * @syscap SystemCapability.MultimodalInput.Input.Cooperator
28 */
29
30
31declare namespace inputDeviceCooperate {
32  /**
33   * Enumerates mouse traversal events.
34   *
35   * @since 9
36   * @syscap SystemCapability.MultimodalInput.Input.Cooperator
37   * @systemapi hide for inner use.
38   */
39  enum EventMsg {
40    /**
41     * Mouse traversal message: mouse traversal is enabled.
42     *
43     * @since 9
44    */
45    MSG_COOPERATE_INFO_START = 200,
46
47    /**
48     * Mouse traversal message: mouse traversal is successful.
49     *
50     * @since 9
51    */
52    MSG_COOPERATE_INFO_SUCCESS = 201,
53
54    /**
55     * Mouse traversal message: mouse traversal fails.
56     *
57     * @since 9
58    */
59    MSG_COOPERATE_INFO_FAIL = 202,
60
61    /**
62     * Mouse traversal status: mouse traversal is enabled.
63     *
64     * @since 9
65    */
66    MSG_COOPERATE_STATE_ON = 500,
67
68    /**
69     * Mouse traversal status: mouse traversal is disabled.
70     *
71     * @since 9
72    */
73    MSG_COOPERATE_STATE_OFF = 501,
74  }
75
76  /**
77   * Enable or disable the mouse traversal.
78   *
79   * @since 9
80   * @syscap SystemCapability.MultimodalInput.Input.Cooperator
81   * @systemapi hide for inner use
82   * @param enable Whether to enable mouse traversal.
83   * @param callback Asynchronous callback function.
84   * @throws {BusinessError} 401 - Parameter error.
85   */
86  function enable(enable: boolean, callback: AsyncCallback<void>): void;
87
88  /**
89   * Enable or disable the mouse traversal.
90   *
91   * @since 9
92   * @syscap SystemCapability.MultimodalInput.Input.Cooperator
93   * @systemapi hide for inner use
94   * @param enable Whether to enable mouse traversal.
95   * @throws {BusinessError} 401 - Parameter error.
96   */
97  function enable(enable: boolean): Promise<void>;
98
99  /**
100   * Starts mouse traversal.
101   *
102   * @since 9
103   * @syscap SystemCapability.MultimodalInput.Input.Cooperator
104   * @systemapi hide for inner use
105   * @param sinkDeviceDescriptor Descriptor of the target network for mouse traversal.
106   * @param srcInputDeviceId Identifier of the peripheral device for mouse traversal.
107   * @param callback Asynchronous callback function.
108   * @throws {BusinessError} 401 - Parameter error.
109   * @throws {BusinessError} 4400001 - Incorrect descriptor for the target device.
110   * @throws {BusinessError} 4400002 - Screen hop failed.
111   */
112  function start(sinkDeviceDescriptor: string, srcInputDeviceId: number, callback: AsyncCallback<void>): void;
113
114  /**
115   * Starts mouse traversal.
116   *
117   * @since 9
118   * @syscap SystemCapability.MultimodalInput.Input.Cooperator
119   * @systemapi hide for inner use
120   * @param sinkDeviceDescriptor Descriptor of the target network for mouse traversal.
121   * @param srcInputDeviceId Identifier of the peripheral device for mouse traversal.
122   * @throws {BusinessError} 401 - Parameter error.
123   * @throws {BusinessError} 4400001 - Incorrect descriptor for the target device.
124   * @throws {BusinessError} 4400002 - Screen hop failed.
125   */
126  function start(sinkDeviceDescriptor: string, srcInputDeviceId: number): Promise<void>;
127
128  /**
129   * Stops mouse traversal.
130   *
131   * @since 9
132   * @syscap SystemCapability.MultimodalInput.Input.Cooperator
133   * @systemapi hide for inner use
134   * @param callback Asynchronous callback function.
135   * @throws {BusinessError} 401 - Parameter error.
136   */
137  function stop(callback: AsyncCallback<void>): void;
138
139  /**
140   * Stops mouse traversal.
141   *
142   * @since 9
143   * @syscap SystemCapability.MultimodalInput.Input.Cooperator
144   * @systemapi hide for inner use
145   */
146  function stop(): Promise<void>;
147
148  /**
149   * Obtains the status of the mouse traversal switch.
150   *
151   * @since 9
152   * @syscap SystemCapability.MultimodalInput.Input.Cooperator
153   * @systemapi hide for inner use
154   * @param deviceDescriptor Descriptor of the target network for mouse traversal.
155   * @param callback Asynchronous callback used to receive the status of the mouse traversal switch.
156   * @throws {BusinessError} 401 - Parameter error.
157   */
158  function getState(deviceDescriptor: string, callback: AsyncCallback<{ state: boolean }>): void;
159
160  /**
161   * Obtains the status of the mouse traversal switch.
162   *
163   * @since 9
164   * @syscap SystemCapability.MultimodalInput.Input.Cooperator
165   * @systemapi hide for inner use
166   * @param deviceDescriptor Descriptor of the target network for mouse traversal.
167   * @throws {BusinessError} 401 - Parameter error.
168   */
169  function getState(deviceDescriptor: string): Promise<{ state: boolean }>;
170
171  /**
172   * Enables listening for mouse traversal events.
173   *
174   * @since 9
175   * @syscap SystemCapability.MultimodalInput.Input.Cooperator
176   * @systemapi hide for inner use
177   * @param type Registration type.
178   * @param callback Asynchronous callback used to receive mouse traversal events.
179   * @returns Callback for the input device event.
180   * @throws {BusinessError} 401 - Parameter error.
181   */
182  function on(type: 'cooperation', callback: AsyncCallback<{ deviceDescriptor: string, eventMsg: EventMsg }>): void;
183
184  /**
185   * Disables listening for mouse traversal events.
186   *
187   * @since 9
188   * @syscap SystemCapability.MultimodalInput.Input.Cooperator
189   * @systemapi hide for inner use
190   * @param type Registration type.
191   * @param callback Asynchronous callback used to return the result.
192   * @throws {BusinessError} 401 - Parameter error.
193   */
194  function off(type: 'cooperation', callback?: AsyncCallback<void>): void;
195
196}
197
198export default inputDeviceCooperate;