1# hid_ddk_api.h 2<!--Kit: Driver Development Kit--> 3<!--Subsystem: Driver--> 4<!--Owner: @lixinsheng2--> 5<!--Designer: @w00373942--> 6<!--Tester: @dong-dongzhen--> 7<!--Adviser: @w_Machine_cc--> 8 9## Overview 10 11Declares the HID DDK functions for accessing an input device from the host. 12 13**File to include**: <hid/hid_ddk_api.h> 14 15**Library**: libhid.z.so 16 17**System capability**: SystemCapability.Driver.HID.Extension 18 19**Since**: 11 20 21**Related module**: [HidDdk](capi-hidddk.md) 22 23## Summary 24 25### Functions 26 27| Name| Description| 28| -- | -- | 29| [int32_t OH_Hid_CreateDevice(Hid_Device *hidDevice, Hid_EventProperties *hidEventProperties)](#oh_hid_createdevice) | Creates a device.| 30| [int32_t OH_Hid_EmitEvent(int32_t deviceId, const Hid_EmitItem items[], uint16_t length)](#oh_hid_emitevent) | Sends an event list to a device.| 31| [int32_t OH_Hid_DestroyDevice(int32_t deviceId)](#oh_hid_destroydevice) | Destroys a device.| 32| [int32_t OH_Hid_Init(void)](#oh_hid_init) | Initializes an HID DDK.| 33| [int32_t OH_Hid_Release(void)](#oh_hid_release) | Releases an HID DDK.| 34| [int32_t OH_Hid_Open(uint64_t deviceId, uint8_t interfaceIndex, Hid_DeviceHandle **dev)](#oh_hid_open) | Opens the device specified by **deviceId** and **interfaceIndex**.| 35| [int32_t OH_Hid_Close(Hid_DeviceHandle **dev)](#oh_hid_close) | Closes an HID device.| 36| [int32_t OH_Hid_Write(Hid_DeviceHandle *dev, uint8_t *data, uint32_t length, uint32_t *bytesWritten)](#oh_hid_write) | Writes reports to an HID device.| 37| [int32_t OH_Hid_ReadTimeout(Hid_DeviceHandle *dev, uint8_t *data, uint32_t bufSize, int timeout, uint32_t *bytesRead)](#oh_hid_readtimeout) | Reads reports from the HID device within the specified timeout interval.| 38| [int32_t OH_Hid_Read(Hid_DeviceHandle *dev, uint8_t *data, uint32_t bufSize, uint32_t *bytesRead)](#oh_hid_read) | Reads reports from the HID device. The blocking mode (that is, blocking remains active until data can be read) is used by default. You can call [OH_Hid_SetNonBlocking](capi-hid-ddk-api-h.md#oh_hid_setnonblocking) to change the mode.| 39| [int32_t OH_Hid_SetNonBlocking(Hid_DeviceHandle *dev, int nonBlock)](#oh_hid_setnonblocking) | Sets the device read mode to non-blocking mode.| 40| [int32_t OH_Hid_GetRawInfo(Hid_DeviceHandle *dev, Hid_RawDevInfo *rawDevInfo)](#oh_hid_getrawinfo) | Obtains the original device information.| 41| [int32_t OH_Hid_GetRawName(Hid_DeviceHandle *dev, char *data, uint32_t bufSize)](#oh_hid_getrawname) | Obtains the original device name.| 42| [int32_t OH_Hid_GetPhysicalAddress(Hid_DeviceHandle *dev, char *data, uint32_t bufSize)](#oh_hid_getphysicaladdress) | Obtains the physical address of the HID device.| 43| [int32_t OH_Hid_GetRawUniqueId(Hid_DeviceHandle *dev, uint8_t *data, uint32_t bufSize)](#oh_hid_getrawuniqueid) | Obtains the original unique identifier of a device.| 44| [int32_t OH_Hid_SendReport(Hid_DeviceHandle *dev, Hid_ReportType reportType, const uint8_t *data, uint32_t length)](#oh_hid_sendreport) | Sends reports to the HID device.| 45| [int32_t OH_Hid_GetReport(Hid_DeviceHandle *dev, Hid_ReportType reportType, uint8_t *data, uint32_t bufSize)](#oh_hid_getreport) | Obtains reports from the HID device.| 46| [int32_t OH_Hid_GetReportDescriptor(Hid_DeviceHandle *dev, uint8_t *buf, uint32_t bufSize, uint32_t *bytesRead)](#oh_hid_getreportdescriptor) | Obtains the report descriptor of the HID device.| 47 48## Function Description 49 50### OH_Hid_CreateDevice() 51 52``` 53int32_t OH_Hid_CreateDevice(Hid_Device *hidDevice, Hid_EventProperties *hidEventProperties) 54``` 55 56**Description** 57 58Creates a device. 59 60**Required permissions**: ohos.permission.ACCESS_DDK_HID 61 62**Since**: 11 63 64 65**Parameters** 66 67| Name | Description| 68|-------------------------------------------------------------------------------| -- | 69| [Hid_Device](capi-hidddk-hid-device.md) *hidDevice | Pointer to the basic information about the device to create, including the device name, vendor ID, and product ID.| 70| [Hid_EventProperties](capi-hidddk-hid-eventproperties.md) *hidEventProperties | Pointer to the event properties related to the device to create, including the event type, key event properties, absolute coordinate event properties, and relative coordinate event properties.| 71 72**Returns** 73 74| Type| Description| 75| -- | -- | 76| int32_t | deviceID (a non-negative number) if the API call is successful.<br> [HID_DDK_NO_PERM](capi-hid-ddk-types-h.md#hid_ddkerrcode): The permission verification fails.<br> [HID_DDK_INVALID_OPERATION](capi-hid-ddk-types-h.md#hid_ddkerrcode): The hid_ddk service connection fails.<br> [HID_DDK_INVALID_PARAMETER](capi-hid-ddk-types-h.md#hid_ddkerrcode): The parameter check fails. Possible causes: 1. The input **hidDevice** is a null pointer.<br> 2. The input **hidEventProperties** is a null pointer. 3. The length of **properties** exceeds 7 characters. 4. The length of **hidEventTypes** exceeds 5 characters.<br> 5. The length of **hidKeys** exceeds 100 characters. 6. The length of **hidAbs** exceeds 26 characters. 7. The length of **hidRelBits** exceeds 13 characters.<br> 8. The length of **hidMiscellaneous** exceeds 6 characters.<br> [HID_DDK_FAILURE](capi-hid-ddk-types-h.md#hid_ddkerrcode): The number of devices reaches the maximum value 200.| 77 78### OH_Hid_EmitEvent() 79 80``` 81int32_t OH_Hid_EmitEvent(int32_t deviceId, const Hid_EmitItem items[], uint16_t length) 82``` 83 84**Description** 85 86Sends an event list to a device. 87 88**Required permissions**: ohos.permission.ACCESS_DDK_HID 89 90**Since**: 11 91 92 93**Parameters** 94 95| Name| Description| 96| -- | -- | 97| int32_t deviceId | Device ID.| 98| items | List of the events to send. The event information includes the event type (**Hid_EventType**), code (**Hid_SynEvent**, **Hid_KeyCode**, **HidBtnCode**, **Hid_AbsAxes**, **Hid_RelAxes**, or **Hid_MscEvent**), and value (depending on the actual device input).| 99| uint16_t length | Length of the event list (number of events to be sent at a time).| 100 101**Returns** 102 103| Type| Description| 104| -- | -- | 105| int32_t | [HID_DDK_SUCCESS](capi-hid-ddk-types-h.md#hid_ddkerrcode): The API call is successful.<br> [HID_DDK_NO_PERM](capi-hid-ddk-types-h.md#hid_ddkerrcode): The permission verification fails.<br> [HID_DDK_INVALID_OPERATION](capi-hid-ddk-types-h.md#hid_ddkerrcode): The hid_ddk service connection fails or the caller is not the device creator.<br> [HID_DDK_INVALID_PARAMETER](capi-hid-ddk-types-h.md#hid_ddkerrcode): The parameter check fails. Possible causes: 1. The device ID is less than 0.<br> 2. The length of the input parameter length exceeds 7 characters. 3. The input parameter items is a null pointer.<br> [HID_DDK_NULL_PTR](capi-hid-ddk-types-h.md#hid_ddkerrcode): The input device is a null pointer.<br> [HID_DDK_FAILURE](capi-hid-ddk-types-h.md#hid_ddkerrcode): The corresponding device does not exist.| 106 107### OH_Hid_DestroyDevice() 108 109``` 110int32_t OH_Hid_DestroyDevice(int32_t deviceId) 111``` 112 113**Description** 114 115Destroys a device. 116 117**Required permissions**: ohos.permission.ACCESS_DDK_HID 118 119**Since**: 11 120 121 122**Parameters** 123 124| Name| Description| 125| -- | -- | 126| int32_t deviceId | Device ID.| 127 128**Returns** 129 130| Type| Description| 131| -- | -- | 132| int32_t | [HID_DDK_SUCCESS](capi-hid-ddk-types-h.md#hid_ddkerrcode): The API call is successful.<br> [HID_DDK_NO_PERM](capi-hid-ddk-types-h.md#hid_ddkerrcode): The permission verification fails.<br> [HID_DDK_INVALID_OPERATION](capi-hid-ddk-types-h.md#hid_ddkerrcode): The hid_ddk service connection fails or the caller is not the device creator.<br> [HID_DDK_FAILURE](capi-hid-ddk-types-h.md#hid_ddkerrcode): The corresponding device does not exist.| 133 134### OH_Hid_Init() 135 136``` 137int32_t OH_Hid_Init(void) 138``` 139 140**Description** 141 142Initializes an HID DDK. 143 144**Required permissions**: ohos.permission.ACCESS_DDK_HID 145 146**Since**: 18 147 148**Returns** 149 150| Type| Description| 151| -- | -- | 152| int32_t | [HID_DDK_SUCCESS](capi-hid-ddk-types-h.md#hid_ddkerrcode): The operation is successful.<br> [HID_DDK_NO_PERM](capi-hid-ddk-types-h.md#hid_ddkerrcode): The permission verification fails.<br> [HID_DDK_INIT_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): The DDK initialization fails.<br> [HID_DDK_SERVICE_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): Communication with the DDK server fails.| 153 154### OH_Hid_Release() 155 156``` 157int32_t OH_Hid_Release(void) 158``` 159 160**Description** 161 162Releases an HID DDK. 163 164**Required permissions**: ohos.permission.ACCESS_DDK_HID 165 166**Since**: 18 167 168**Returns** 169 170| Type| Description| 171| -- | -- | 172| int32_t | [HID_DDK_SUCCESS](capi-hid-ddk-types-h.md#hid_ddkerrcode): The operation is successful.<br> [HID_DDK_NO_PERM](capi-hid-ddk-types-h.md#hid_ddkerrcode): The permission verification fails.<br> [HID_DDK_INIT_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): The DDK initialization fails.<br> [HID_DDK_SERVICE_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): Communication with the DDK server fails.| 173 174### OH_Hid_Open() 175 176``` 177int32_t OH_Hid_Open(uint64_t deviceId, uint8_t interfaceIndex, Hid_DeviceHandle **dev) 178``` 179 180**Description** 181 182Opens the device specified by **deviceId** and **interfaceIndex**. 183 184**Required permissions**: ohos.permission.ACCESS_DDK_HID 185 186**Since**: 18 187 188 189**Parameters** 190 191| Name | Description| 192|----------------------------| -- | 193| uint64_t deviceId | Device ID.| 194| uint8_t interfaceIndex | Interface index for the API of the HID device.| 195| [Hid_DeviceHandle](capi-hidddk-hid-devicehandle.md) **dev | Device operation handle.| 196 197**Returns** 198 199| Type| Description| 200| -- | -- | 201| int32_t | [HID_DDK_SUCCESS](capi-hid-ddk-types-h.md#hid_ddkerrcode): The operation is successful.<br> [HID_DDK_NO_PERM](capi-hid-ddk-types-h.md#hid_ddkerrcode): The permission verification fails.<br> [HID_DDK_INIT_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): The DDK initialization fails.<br> [HID_DDK_SERVICE_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): Communication with the DDK server fails.<br> [HID_DDK_MEMORY_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): Memory allocation for the device fails.<br> [HID_DDK_IO_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): The I/O operation fails.<br> [HID_DDK_INVALID_PARAMETER](capi-hid-ddk-types-h.md#hid_ddkerrcode): The input **dev** is empty.<br> [HID_DDK_DEVICE_NOT_FOUND](capi-hid-ddk-types-h.md#hid_ddkerrcode): No device is found based on **deviceId** and **interfaceIndex**.| 202 203### OH_Hid_Close() 204 205``` 206int32_t OH_Hid_Close(Hid_DeviceHandle **dev) 207``` 208 209**Description** 210 211Closes an HID device. 212 213**Required permissions**: ohos.permission.ACCESS_DDK_HID 214 215**Since**: 18 216 217 218**Parameters** 219 220| Name| Description| 221| -- | -- | 222| [Hid_DeviceHandle](capi-hidddk-hid-devicehandle.md) **dev | Device operation handle.| 223 224**Returns** 225 226| Type| Description| 227| -- | -- | 228| int32_t | [HID_DDK_SUCCESS](capi-hid-ddk-types-h.md#hid_ddkerrcode): The operation is successful.<br> [HID_DDK_NO_PERM](capi-hid-ddk-types-h.md#hid_ddkerrcode): The permission verification fails.<br> [HID_DDK_INIT_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): The DDK initialization fails.<br> [HID_DDK_SERVICE_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): Communication with the DDK server fails.<br> [HID_DDK_IO_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): The I/O operation fails.<br> [HID_DDK_INVALID_PARAMETER](capi-hid-ddk-types-h.md#hid_ddkerrcode): The dev parameter is empty.| 229 230### OH_Hid_Write() 231 232``` 233int32_t OH_Hid_Write(Hid_DeviceHandle *dev, uint8_t *data, uint32_t length, uint32_t *bytesWritten) 234``` 235 236**Description** 237 238Writes reports to an HID device. 239 240**Required permissions**: ohos.permission.ACCESS_DDK_HID 241 242**Since**: 18 243 244 245**Parameters** 246 247| Name| Description| 248| -- | -- | 249| [Hid_DeviceHandle](capi-hidddk-hid-devicehandle.md) *dev | Device operation handle.| 250| uint8_t *data | Data to be written.| 251| uint32_t length | Length of the data to be written, in bytes. The value cannot exceed [HID_MAX_REPORT_BUFFER_SIZE](capi-hid-ddk-types-h.md#hid_max_report_buffer_size).| 252| uint32_t *bytesWritten | Number of written bytes.| 253 254**Returns** 255 256| Type| Description| 257| -- | -- | 258| int32_t | [HID_DDK_SUCCESS](capi-hid-ddk-types-h.md#hid_ddkerrcode): The operation is successful.<br> [HID_DDK_NO_PERM](capi-hid-ddk-types-h.md#hid_ddkerrcode): The permission verification fails.<br> [HID_DDK_INVALID_PARAMETER](capi-hid-ddk-types-h.md#hid_ddkerrcode): The parameter check fails. Possible causes: 1. **dev** is empty.<br> 2. **data** is empty. 3. The value of **length** is **0**; 4. The value of **length** exceeds [HID_MAX_REPORT_BUFFER_SIZE](capi-hid-ddk-types-h.md#hid_max_report_buffer_size).<br> 5. **bytesWritten** is empty.<br> [HID_DDK_INIT_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): The DDK initialization fails.<br> [HID_DDK_SERVICE_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): Communication with the DDK server fails.<br> [HID_DDK_IO_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): The I/O operation fails.| 259 260### OH_Hid_ReadTimeout() 261 262``` 263int32_t OH_Hid_ReadTimeout(Hid_DeviceHandle *dev, uint8_t *data, uint32_t bufSize, int timeout, uint32_t *bytesRead) 264``` 265 266**Description** 267 268Reads reports from the HID device within the specified timeout interval. 269 270**Required permissions**: ohos.permission.ACCESS_DDK_HID 271 272**Since**: 18 273 274 275**Parameters** 276 277| Name| Description| 278| -- | -- | 279| [Hid_DeviceHandle](capi-hidddk-hid-devicehandle.md) *dev | Device operation handle.| 280| uint8_t *data | Buffer for storing the read data.| 281| uint32_t bufSize | Size of the buffer for storing read data. The value cannot exceed [HID_MAX_REPORT_BUFFER_SIZE](capi-hid-ddk-types-h.md#hid_max_report_buffer_size).| 282| int timeout | Timeout interval, in ms. The value **-1** indicates block waiting.| 283| uint32_t *bytesRead | Number of bytes to read.| 284 285**Returns** 286 287| Type| Description| 288| -- | -- | 289| int32_t | [HID_DDK_SUCCESS](capi-hid-ddk-types-h.md#hid_ddkerrcode): The operation is successful.<br> [HID_DDK_NO_PERM](capi-hid-ddk-types-h.md#hid_ddkerrcode): The permission verification fails.<br> [HID_DDK_INVALID_PARAMETER](capi-hid-ddk-types-h.md#hid_ddkerrcode): The parameter check fails. Possible causes: 1. **dev** is empty.<br> 2. **data** is empty. 3. The value of **bufSize** is **0**. 4. The value of **bufSize** exceeds [HID_MAX_REPORT_BUFFER_SIZE](capi-hid-ddk-types-h.md#hid_max_report_buffer_size).<br> 5. **bytesRead** is empty.<br> [HID_DDK_INIT_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): The DDK initialization fails.<br> [HID_DDK_SERVICE_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): Communication with the DDK server fails.<br> [HID_DDK_MEMORY_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): The memory data copy fails.<br> [HID_DDK_IO_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): The I/O operation fails.<br> [HID_DDK_TIMEOUT](capi-hid-ddk-types-h.md#hid_ddkerrcode): The read operation times out.| 290 291### OH_Hid_Read() 292 293``` 294int32_t OH_Hid_Read(Hid_DeviceHandle *dev, uint8_t *data, uint32_t bufSize, uint32_t *bytesRead) 295``` 296 297**Description** 298 299Reads reports from the HID device. The blocking mode (that is, blocking remains active until data can be read) is used by default. You can call [OH_Hid_SetNonBlocking](capi-hid-ddk-api-h.md#oh_hid_setnonblocking) to change the mode. 300 301**Required permissions**: ohos.permission.ACCESS_DDK_HID 302 303**Since**: 18 304 305 306**Parameters** 307 308| Name| Description| 309| -- | -- | 310| [Hid_DeviceHandle](capi-hidddk-hid-devicehandle.md) *dev | Device operation handle.| 311| uint8_t *data | Buffer for storing the read data.| 312| uint32_t bufSize | Size of the buffer for storing read data. The value cannot exceed [HID_MAX_REPORT_BUFFER_SIZE](capi-hid-ddk-types-h.md#hid_max_report_buffer_size).| 313| uint32_t *bytesRead | Number of bytes to read.| 314 315**Returns** 316 317| Type| Description| 318| -- | -- | 319| int32_t | [HID_DDK_SUCCESS](capi-hid-ddk-types-h.md#hid_ddkerrcode): The operation is successful.<br> [HID_DDK_NO_PERM](capi-hid-ddk-types-h.md#hid_ddkerrcode): The permission verification fails.<br> [HID_DDK_INVALID_PARAMETER](capi-hid-ddk-types-h.md#hid_ddkerrcode): The parameter check fails. Possible causes: 1. **dev** is empty.<br> 2. **data** is empty. 3. The value of **bufSize** is **0**. 4. The value of **bufSize** exceeds [HID_MAX_REPORT_BUFFER_SIZE](capi-hid-ddk-types-h.md#hid_max_report_buffer_size).<br> 5. **bytesRead** is empty.<br> [HID_DDK_INIT_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): The DDK initialization fails.<br> [HID_DDK_SERVICE_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): Communication with the DDK server fails.<br> [HID_DDK_MEMORY_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): The memory data copy fails.<br> [HID_DDK_IO_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): The I/O operation fails.<br> [HID_DDK_TIMEOUT](capi-hid-ddk-types-h.md#hid_ddkerrcode): The read operation times out.| 320 321### OH_Hid_SetNonBlocking() 322 323``` 324int32_t OH_Hid_SetNonBlocking(Hid_DeviceHandle *dev, int nonBlock) 325``` 326 327**Description** 328 329Sets the device read mode to non-blocking mode. 330 331**Required permissions**: ohos.permission.ACCESS_DDK_HID 332 333**Since**: 18 334 335 336**Parameters** 337 338| Name| Description| 339| -- | -- | 340| [Hid_DeviceHandle](capi-hidddk-hid-devicehandle.md) *dev | Device operation handle.| 341| int nonBlock | Whether to enable the non-blocking mode for reading data. - **1**: The non-blocking mode is enabled. When [OH_Hid_Read](capi-hid-ddk-api-h.md#oh_hid_read) is called, if the device has readable data, [HID_DDK_SUCCESS](capi-hid-ddk-types-h.md#hid_ddkerrcode) is returned;<br> if the device has no readable data, [HID_DDK_TIMEOUT](capi-hid-ddk-types-h.md#hid_ddkerrcode) is returned. - **0**: The non-blocking mode is disabled.| 342 343**Returns** 344 345| Type| Description| 346| -- | -- | 347| int32_t | [HID_DDK_SUCCESS](capi-hid-ddk-types-h.md#hid_ddkerrcode): The operation is successful.<br> [HID_DDK_NO_PERM](capi-hid-ddk-types-h.md#hid_ddkerrcode): The permission verification fails.<br> [HID_DDK_INIT_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): The DDK initialization fails.<br> [HID_DDK_INVALID_PARAMETER](capi-hid-ddk-types-h.md#hid_ddkerrcode): The parameter check fails. Possible causes: 1. **dev** is empty.<br> 2. The value of **nonBlock** is not **1** or **0**.<br> [HID_DDK_SERVICE_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): Communication with the DDK server fails.| 348 349### OH_Hid_GetRawInfo() 350 351``` 352int32_t OH_Hid_GetRawInfo(Hid_DeviceHandle *dev, Hid_RawDevInfo *rawDevInfo) 353``` 354 355**Description** 356 357Obtains the original device information. 358 359**Required permissions**: ohos.permission.ACCESS_DDK_HID 360 361**Since**: 18 362 363 364**Parameters** 365 366| Name | Description| 367|-------------------------------------------------------------| -- | 368| [Hid_DeviceHandle](capi-hidddk-hid-devicehandle.md) *dev | Device operation handle.| 369| [Hid_RawDevInfo](capi-hidddk-hid-rawdevinfo.md) *rawDevInfo | Original device information, including the vendor ID, product ID, and bus type.| 370 371**Returns** 372 373| Type| Description| 374| -- | -- | 375| int32_t | [HID_DDK_SUCCESS](capi-hid-ddk-types-h.md#hid_ddkerrcode): The operation is successful.<br> [HID_DDK_NO_PERM](capi-hid-ddk-types-h.md#hid_ddkerrcode): The permission verification fails.<br> [HID_DDK_INVALID_PARAMETER](capi-hid-ddk-types-h.md#hid_ddkerrcode): The parameter check fails. Possible causes: 1. **dev** is empty.<br> 2. **rawDevInfo** is empty.<br> [HID_DDK_INIT_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): The DDK initialization fails.<br> [HID_DDK_SERVICE_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): Communication with the DDK server fails.<br> [HID_DDK_IO_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): The I/O operation fails.<br> [HID_DDK_INVALID_OPERATION](capi-hid-ddk-types-h.md#hid_ddkerrcode): This operation is not supported.| 376 377### OH_Hid_GetRawName() 378 379``` 380int32_t OH_Hid_GetRawName(Hid_DeviceHandle *dev, char *data, uint32_t bufSize) 381``` 382 383**Description** 384 385Obtains the original device name. 386 387**Required permissions**: ohos.permission.ACCESS_DDK_HID 388 389**Since**: 18 390 391 392**Parameters** 393 394| Name| Description| 395| -- | -- | 396| [Hid_DeviceHandle](capi-hidddk-hid-devicehandle.md) *dev | Device operation handle.| 397| char *data | Buffer for storing the read data.| 398| uint32_t bufSize | Size of the buffer for storing read data. The value cannot exceed [HID_MAX_REPORT_BUFFER_SIZE](capi-hid-ddk-types-h.md#hid_max_report_buffer_size).| 399 400**Returns** 401 402| Type| Description| 403| -- | -- | 404| int32_t | [HID_DDK_SUCCESS](capi-hid-ddk-types-h.md#hid_ddkerrcode): The operation is successful.<br> [HID_DDK_NO_PERM](capi-hid-ddk-types-h.md#hid_ddkerrcode): The permission verification fails.<br> [HID_DDK_INVALID_PARAMETER](capi-hid-ddk-types-h.md#hid_ddkerrcode): The parameter check fails. Possible causes: 1. **dev** is empty.<br> 2. **data** is empty. 3. The value of **bufSize** is **0**. 4. The value of **bufSize** exceeds [HID_MAX_REPORT_BUFFER_SIZE](capi-hid-ddk-types-h.md#hid_max_report_buffer_size).<br> [HID_DDK_INIT_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): The DDK initialization fails.<br> [HID_DDK_SERVICE_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): Communication with the DDK server fails.<br> [HID_DDK_MEMORY_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): The memory data copy fails.<br> [HID_DDK_IO_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): The I/O operation fails.<br> [HID_DDK_INVALID_OPERATION](capi-hid-ddk-types-h.md#hid_ddkerrcode): This operation is not supported.| 405 406### OH_Hid_GetPhysicalAddress() 407 408``` 409int32_t OH_Hid_GetPhysicalAddress(Hid_DeviceHandle *dev, char *data, uint32_t bufSize) 410``` 411 412**Description** 413 414Obtains the physical address of the HID device. 415 416**Required permissions**: ohos.permission.ACCESS_DDK_HID 417 418**Since**: 18 419 420 421**Parameters** 422 423| Name| Description| 424| -- | -- | 425| [Hid_DeviceHandle](capi-hidddk-hid-devicehandle.md) *dev | Device operation handle.| 426| char *data | Buffer for storing the read data.| 427| uint32_t bufSize | Size of the buffer for storing read data. The value cannot exceed [HID_MAX_REPORT_BUFFER_SIZE](capi-hid-ddk-types-h.md#hid_max_report_buffer_size).| 428 429**Returns** 430 431| Type| Description| 432| -- | -- | 433| int32_t | [HID_DDK_SUCCESS](capi-hid-ddk-types-h.md#hid_ddkerrcode): The operation is successful.<br> [HID_DDK_NO_PERM](capi-hid-ddk-types-h.md#hid_ddkerrcode): The permission verification fails.<br> [HID_DDK_INVALID_PARAMETER](capi-hid-ddk-types-h.md#hid_ddkerrcode): The parameter check fails. Possible causes: 1. **dev** is empty.<br> 2. **data** is empty. 3. The value of **bufSize** is **0**. 4. The value of **bufSize** exceeds [HID_MAX_REPORT_BUFFER_SIZE](capi-hid-ddk-types-h.md#hid_max_report_buffer_size).<br> [HID_DDK_INIT_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): The DDK initialization fails.<br> [HID_DDK_SERVICE_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): Communication with the DDK server fails.<br> [HID_DDK_MEMORY_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): The memory data copy fails.<br> [HID_DDK_IO_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): The I/O operation fails.<br> [HID_DDK_INVALID_OPERATION](capi-hid-ddk-types-h.md#hid_ddkerrcode): This operation is not supported.| 434 435### OH_Hid_GetRawUniqueId() 436 437``` 438int32_t OH_Hid_GetRawUniqueId(Hid_DeviceHandle *dev, uint8_t *data, uint32_t bufSize) 439``` 440 441**Description** 442 443Obtains the original unique identifier of a device. 444 445**Required permissions**: ohos.permission.ACCESS_DDK_HID 446 447**Since**: 18 448 449 450**Parameters** 451 452| Name| Description| 453| -- | -- | 454| [Hid_DeviceHandle](capi-hidddk-hid-devicehandle.md) *dev | Device operation handle.| 455| uint8_t *data | Buffer for storing the read data.| 456| uint32_t bufSize | Size of the buffer for storing read data. The value cannot exceed [HID_MAX_REPORT_BUFFER_SIZE](capi-hid-ddk-types-h.md#hid_max_report_buffer_size).| 457 458**Returns** 459 460| Type| Description| 461| -- | -- | 462| int32_t | [HID_DDK_SUCCESS](capi-hid-ddk-types-h.md#hid_ddkerrcode): The operation is successful.<br> [HID_DDK_NO_PERM](capi-hid-ddk-types-h.md#hid_ddkerrcode): The permission verification fails.<br> [HID_DDK_INVALID_PARAMETER](capi-hid-ddk-types-h.md#hid_ddkerrcode): The parameter check fails. Possible causes: 1. **dev** is empty.<br> 2. **data** is empty. 3. The value of **bufSize** is **0**. 4. The value of **bufSize** exceeds [HID_MAX_REPORT_BUFFER_SIZE](capi-hid-ddk-types-h.md#hid_max_report_buffer_size).<br> [HID_DDK_INIT_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): The DDK initialization fails.<br> [HID_DDK_SERVICE_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): Communication with the DDK server fails.<br> [HID_DDK_MEMORY_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): The memory data copy fails.<br> [HID_DDK_IO_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): The I/O operation fails.<br> [HID_DDK_INVALID_OPERATION](capi-hid-ddk-types-h.md#hid_ddkerrcode): This operation is not supported.| 463 464### OH_Hid_SendReport() 465 466``` 467int32_t OH_Hid_SendReport(Hid_DeviceHandle *dev, Hid_ReportType reportType, const uint8_t *data, uint32_t length) 468``` 469 470**Description** 471 472Sends reports to the HID device. 473 474**Required permissions**: ohos.permission.ACCESS_DDK_HID 475 476**Since**: 18 477 478 479**Parameters** 480 481| Name| Description | 482| -- |---------------------------------------------------------------------------------------------------| 483| [Hid_DeviceHandle](capi-hidddk-hid-devicehandle.md) *dev | Device operation handle. | 484| [Hid_ReportType](capi-hid-ddk-types-h.md#hid_reporttype) reportType | Report type. | 485| const uint8_t *data | Data to be sent. | 486| uint32_t length | Length of the data to be sent, in bytes. The value cannot exceed [HID_MAX_REPORT_BUFFER_SIZE](capi-hid-ddk-types-h.md#hid_max_report_buffer_size).| 487 488**Returns** 489 490| Type| Description| 491| -- | -- | 492| int32_t | [HID_DDK_SUCCESS](capi-hid-ddk-types-h.md#hid_ddkerrcode): The operation is successful.<br> [HID_DDK_NO_PERM](capi-hid-ddk-types-h.md#hid_ddkerrcode): The permission verification fails.<br> [HID_DDK_INVALID_PARAMETER](capi-hid-ddk-types-h.md#hid_ddkerrcode): The parameter check fails. Possible causes: 1. **dev** is empty.<br> 2. **data** is empty. 3. The value of **length** is **0**; 4. The value of **length** exceeds [HID_MAX_REPORT_BUFFER_SIZE](capi-hid-ddk-types-h.md#hid_max_report_buffer_size).<br> [HID_DDK_INIT_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): The DDK initialization fails.<br> [HID_DDK_SERVICE_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): Communication with the DDK server fails.<br> [HID_DDK_IO_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): The I/O operation fails.<br> [HID_DDK_INVALID_OPERATION](capi-hid-ddk-types-h.md#hid_ddkerrcode): This operation is not supported.| 493 494### OH_Hid_GetReport() 495 496``` 497int32_t OH_Hid_GetReport(Hid_DeviceHandle *dev, Hid_ReportType reportType, uint8_t *data, uint32_t bufSize) 498``` 499 500**Description** 501 502Obtains reports from the HID device. 503 504**Required permissions**: ohos.permission.ACCESS_DDK_HID 505 506**Since**: 18 507 508 509**Parameters** 510 511| Name| Description| 512| -- | -- | 513| [Hid_DeviceHandle](capi-hidddk-hid-devicehandle.md) *dev | Device operation handle.| 514| [Hid_ReportType](capi-hid-ddk-types-h.md#hid_reporttype) reportType | Report type.| 515| uint8_t *data | Buffer for storing the read data.| 516| uint32_t bufSize | Size of the buffer for storing read data. The value cannot exceed [HID_MAX_REPORT_BUFFER_SIZE](capi-hid-ddk-types-h.md#hid_max_report_buffer_size).| 517 518**Returns** 519 520| Type| Description| 521| -- | -- | 522| int32_t | [HID_DDK_SUCCESS](capi-hid-ddk-types-h.md#hid_ddkerrcode): The operation is successful.<br> [HID_DDK_NO_PERM](capi-hid-ddk-types-h.md#hid_ddkerrcode): The permission verification fails.<br> [HID_DDK_INVALID_PARAMETER](capi-hid-ddk-types-h.md#hid_ddkerrcode): The parameter check fails. Possible causes: 1. **dev** is empty.<br> 2. **data** is empty. 3. The value of **bufSize** is **0**. 4. The value of **bufSize** exceeds [HID_MAX_REPORT_BUFFER_SIZE](capi-hid-ddk-types-h.md#hid_max_report_buffer_size).<br> [HID_DDK_INIT_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): The DDK initialization fails.<br> [HID_DDK_SERVICE_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): Communication with the DDK server fails.<br> [HID_DDK_MEMORY_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): The memory data copy fails.<br> [HID_DDK_IO_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): The I/O operation fails.<br> [HID_DDK_INVALID_OPERATION](capi-hid-ddk-types-h.md#hid_ddkerrcode): This operation is not supported.| 523 524### OH_Hid_GetReportDescriptor() 525 526``` 527int32_t OH_Hid_GetReportDescriptor(Hid_DeviceHandle *dev, uint8_t *buf, uint32_t bufSize, uint32_t *bytesRead) 528``` 529 530**Description** 531 532Obtains the report descriptor of the HID device. 533 534**Required permissions**: ohos.permission.ACCESS_DDK_HID 535 536**Since**: 18 537 538 539**Parameters** 540 541| Name| Description| 542| -- | -- | 543| [Hid_DeviceHandle](capi-hidddk-hid-devicehandle.md) *dev | Device operation handle.| 544| uint8_t *buf | Buffer for storing descriptors.| 545| uint32_t bufSize | Buffer size, in bytes. The value cannot exceed [HID_MAX_REPORT_BUFFER_SIZE](capi-hid-ddk-types-h.md#hid_max_report_buffer_size).| 546| uint32_t *bytesRead | Number of bytes to read.| 547 548**Returns** 549 550| Type| Description| 551| -- | -- | 552| int32_t | [HID_DDK_SUCCESS](capi-hid-ddk-types-h.md#hid_ddkerrcode): The operation is successful.<br> [HID_DDK_NO_PERM](capi-hid-ddk-types-h.md#hid_ddkerrcode): The permission verification fails.<br> [HID_DDK_INVALID_PARAMETER](capi-hid-ddk-types-h.md#hid_ddkerrcode): The parameter check fails. Possible causes: 1. **dev** is empty.<br> 2. **buf** is empty. 3. The value of **bufSize** is **0**. 4. The value of **bufSize** exceeds [HID_MAX_REPORT_BUFFER_SIZE](capi-hid-ddk-types-h.md#hid_max_report_buffer_size).<br> 5. **bytesRead** is empty.<br> [HID_DDK_INIT_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): The DDK initialization fails.<br> [HID_DDK_SERVICE_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): Communication with the DDK server fails.<br> [HID_DDK_MEMORY_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): The memory data copy fails.<br> [HID_DDK_IO_ERROR](capi-hid-ddk-types-h.md#hid_ddkerrcode): The I/O operation fails.<br> [HID_DDK_INVALID_OPERATION](capi-hid-ddk-types-h.md#hid_ddkerrcode): This operation is not supported.| 553