HID ioctl 命令详解 .

本文详细介绍了ioctl()控制接口的功能及使用方法,包括获取设备版本、应用用途、设备信息等控制命令,同时还涵盖了如何获取报告信息、字段信息及设置报告用途等内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 ioctl(): This is the control interface. There are a number of controls:
HIDIOCGVERSIONint (read)Gets the version code out of the hiddev driver.
HIDIOCAPPLICATION(none)This ioctl call returns the HID application usage associated with the hid device. The third argument to ioctl() specifies which application index to get. This is useful when the device has more than one application collection. If the index is invalid (greater or equal to the number of application collections this device has) the ioctl returns -1. You can find out beforehand how many application collections the device has from the num_applications field from the hiddev_devinfo structure.
HIDIOCGDEVINFOstruct hiddev_devinfo (read)Gets a hiddev_devinfo structure which describes the device.
HIDIOCGSTRINGstruct struct hiddev_string_descriptor (read/write)Gets a string descriptor from the device. The caller must fill in the "index" field to indicate which descriptor should be returned.
HIDIOCINITREPORT Instructs the kernel to retrieve all input and feature report values from the device. At this point, all the usage structures will contain current values for the device, and will maintain it as the device changes.
HIDIOCGNAMEstring (variable length)Gets the device name
HIDIOCGREPORTstruct hiddev_report_info (write)Instructs the kernel to get a feature or input report from the device, in order to selectively update the usage structures (in contrast to INITREPORT).
HIDIOCSREPORTstruct hiddev_report_info (write)Instructs the kernel to send a report to the device. This report can be filled in by the user throughHIDIOCSUSAGE calls (below) to fill in individual usage values in the report before sending the report in full to the device.
HIDIOCGREPORTINFOstruct hiddev_report_info (read/write)Fills in a hiddev_report_info structure for the user. The report is looked up by type (input, output or feature) and id, so these fields must be filled in by the user. The ID can be absolute -- the actual report id as reported by the device -- or relative -- HID_REPORT_ID_FIRST for the first report, and (HID_REPORT_ID_NEXT | report_id) for the next report after report_id. Without a-priori information about report ids, the right way to use this ioctl is to use the relative IDs above to enumerate the valid IDs. The ioctl returns non-zero when there is no more next ID. The real report ID is filled into the returned hiddev_report_info structure.
HIDIOCGFIELDINFOstruct hiddev_field_info (read/write)Returns the field information associated with a report in a hiddev_field_info structure. The user must fill in report_id and report_type in this structure, as above. The field_index should also be filled in, which should be a number from 0 and maxfield-1, as returned from a previous HIDIOCGREPORTINFO call.
HIDIOCGUCODEstruct hiddev_usage_ref (read/write)Returns the usage_code in a hiddev_usage_ref structure, given that given its report type, report id, field index, and index within the field have already been filled into the structure.
HIDIOCGUSAGEstruct hiddev_usage_ref (read/write)Returns the value of a usage in a hiddev_usage_ref structure. The usage to be retrieved can be specified as above, or the user can choose to fill in the report_type field and specify the report_id asHID_REPORT_ID_UNKNOWN. In this case, the hiddev_usage_ref will be filled in with the report and field infomation associated with this usage if it is found.
HIDIOCSUSAGEstruct hiddev_usage_ref (write)Sets the value of a usage in an output report.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值