• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2025 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 * @addtogroup HdiHidDdk
18 * @{
19 *
20 * @brief Provides HID DDK APIs, including open device, get an input report, send an output report, etc.
21 *
22 * @since 5.1
23 * @version 1.1
24 */
25
26 /**
27 * @file IHidDdk.idl
28 *
29 * @brief Declares the HID DDK interfaces for the host to access an input device.
30 *
31 * @since 5.1
32 * @version 1.1
33 */
34
35package ohos.hdi.input.ddk.v1_1;
36
37import ohos.hdi.input.ddk.v1_1.HidDdkTypes;
38import ohos.hdi.input.ddk.v1_0.HidDdkTypes;
39import ohos.hdi.input.ddk.v1_0.IHidDdk;
40
41/**
42 * @brief Declares the HID DDK interfaces for the host to access an input device.
43 *
44 * @since 5.1
45 * @version 1.1
46 */
47interface IHidDdk extends ohos.hdi.input.ddk.v1_0.IHidDdk {
48    /**
49    * @brief Initializes the HID DDK.
50    *
51    * @return <b>0</b> if the operation is successful; a negative value otherwise.
52    * @since 5.1
53    * @version 1.0
54    */
55    Init();
56
57    /**
58    * @brief Releases the HID DDK.
59    *
60    * @return <b>0</b> if the operation is successful; a negative value otherwise.
61    * @since 5.1
62    * @version 1.0
63    */
64    Release();
65
66    /**
67    * @brief Open HID device by deviceId in blocking mode.
68    *
69    * @param deviceId ID of the device to be operated.
70    * @param interfaceIndex Interface index, which corresponds to interface which supports USB protocol HID.
71    * @param dev Device operation handle.
72    *
73    * @return <b>0</b> if the operation is successful; a negative value otherwise.
74    * @since 5.1
75    * @version 1.0
76    */
77    Open([in] unsigned long deviceId, [in] unsigned char interfaceIndex, [out] struct HidDeviceHandle dev);
78
79    /**
80    * @brief Close HID device by dev.
81    *
82    * @param dev Device operation handle.
83    *
84    * @return <b>0</b> if the operation is successful; a negative value otherwise.
85    * @since 5.1
86    * @version 1.0
87    */
88    Close([in] struct HidDeviceHandle dev);
89
90    /**
91    * @brief Write an Output report to a HID device.
92    *
93    * @param dev Device operation handle.
94    * @param data The data to be sent.
95    * @param bytesWritten The acture bytes of the data be sent.
96    *
97    * @return <b>0</b> if the operation is successful; a negative value otherwise.
98    * @since 5.1
99    * @version 1.0
100    */
101    Write([in] struct HidDeviceHandle dev, [in] unsigned char[] data, [out] unsigned int bytesWritten);
102
103    /**
104    * @brief Read an input report from the device with timeout.
105    *
106    * @param dev Device operation handle.
107    * @param data A buffer to put the read data into.
108    * @param buffSize A buffer size to put the read data into.
109    * @param timeout Timeout in milliseconds or -1 for blocking wait.
110    * @param bytesRead The number of bytes to read.
111    *
112    * @return <b>0</b> if the operation is successful; a negative value otherwise.
113    * @since 5.1
114    * @version 1.0
115    */
116    ReadTimeout([in] struct HidDeviceHandle dev, [out] unsigned char[] data, [in] unsigned int buffSize, [in] int timeout, [out] unsigned int bytesRead);
117
118    /**
119    * @brief Set the device handle to be non-blocking.
120    *
121    * @param dev Device operation handle.
122    * @param nonBlock Enable or not the nonblocking reads
123    *             - 1 to enable nonblocking
124    *             - 0 to disable nonblocking.
125    *
126    * @return <b>0</b> if the operation is successful; a negative value otherwise.
127    * @since 5.1
128    * @version 1.0
129    */
130    SetNonBlocking([in] struct HidDeviceHandle dev, [in] int nonBlock);
131
132    /**
133    * @brief Get a raw info from the device.
134    *
135    * @param dev Device operation handle.
136    * @param rawDevInfo Vendor id, product id and bus type get from the device.
137    *
138    * @return <b>0</b> if the operation is successful; a negative value otherwise.
139    * @since 5.1
140    * @version 1.0
141    */
142    GetRawInfo([in] struct HidDeviceHandle dev, [out] struct HidRawDevInfo rawDevInfo);
143
144    /**
145    * @brief Get a raw name from the device.
146    *
147    * @param dev Device operation handle.
148    * @param data A buffer to put the read data into.
149    * @param buffSize A buffer size to put the read data into.
150    *
151    * @return <b>0</b> if the operation is successful; a negative value otherwise.
152    * @since 5.1
153    * @version 1.0
154    */
155    GetRawName([in] struct HidDeviceHandle dev, [out] unsigned char[] data, [in] unsigned int buffSize);
156
157    /**
158    * @brief Get a physical address from the device.
159    *
160    * @param dev Device operation handle.
161    * @param data A buffer to put the read data into.
162    * @param buffSize A buffer size to put the read data into.
163    *
164    * @return <b>0</b> if the operation is successful; a negative value otherwise.
165    * @since 5.1
166    * @version 1.0
167    */
168    GetPhysicalAddress([in] struct HidDeviceHandle dev, [out] unsigned char[] data, [in] unsigned int buffSize);
169
170    /**
171    * @brief Get a raw unique id from the device.
172    *
173    * @param dev Device operation handle.
174    * @param data A buffer to put the read data into.
175    * @param buffSize A buffer size to put the read data into.
176    *
177    * @return <b>0</b> if the operation is successful; a negative value otherwise.
178    * @since 5.1
179    * @version 1.0
180    */
181    GetRawUniqueId([in] struct HidDeviceHandle dev, [out] unsigned char[] data, [in] unsigned int buffSize);
182
183    /**
184    * @brief Send a report to the device.
185    *
186    * @param dev Device operation handle.
187    * @param reportType Report type will be sent.
188    * @param data The data to be sent.
189    *
190    * @return <b>0</b> if the operation is successful; a negative value otherwise.
191    * @since 5.1
192    * @version 1.0
193    */
194    SendReport([in] struct HidDeviceHandle dev, [in] HidReportType reportType, [in] unsigned char[] data);
195
196    /**
197    * @brief Get a report from the device.
198    *
199    * @param dev Device operation handle.
200    * @param reportType Report type get from device.
201    * @param reportNumber The specified report number.
202    * @param data A buffer to put the read data into.
203    * @param buffSize A buffer size to put the read data into.
204    *
205    * @return <b>0</b> if the operation is successful; a negative value otherwise.
206    * @since 5.1
207    * @version 1.0
208    */
209    GetReport([in] struct HidDeviceHandle dev, [in] HidReportType reportType, [in] unsigned char reportNumber, [out] unsigned char[] data, [in] unsigned int buffSize);
210
211    /**
212    * @brief Get a report descriptor from the device.
213    *
214    * @param dev Device operation handle.
215    * @param buf The buffer to copy descriptor into.
216    * @param buffSize A buffer size to put the read data into.
217    * @param bytesRead The number of bytes to read.
218    *
219    * @return <b>0</b> if the operation is successful; a negative value otherwise.
220    * @since 5.1
221    * @version 1.0
222    */
223    GetReportDescriptor([in] struct HidDeviceHandle dev, [out] unsigned char[] buf, [in] unsigned int buffSize, [out] unsigned int bytesRead);
224}
225
226/** @} */