c语言hid,HIDAPI: HIDAPI 是一个 USB 和蓝牙的 hid 类设备在 Windows、Linux、FreeBSD 和 Mac 的 C 语言通用库,使用 HIDAPI 可以在 Wind...

HIDAPI是一个跨平台的C语言库,支持在Windows、Linux、FreeBSD和Mac上与USB和蓝牙HID设备通信。它可以作为共享库或嵌入到应用程序中。该库提供了与设备交互的基本功能,包括读取和写入输入、输出和特征报告。本文还介绍了如何在不同平台上构建和使用HIDAPI,以及示例代码展示如何连接和操作HID设备。
摘要由CSDN通过智能技术生成

HIDAPI library for Windows, Linux, FreeBSD and Mac OS X

=========================================================

About

======

HIDAPI is a multi-platform library which allows an application to interface

with USB and Bluetooth HID-Class devices on Windows, Linux, FreeBSD, and Mac

OS X. HIDAPI can be either built as a shared library (.so or .dll) or

can be embedded directly into a target application by adding a single source

file (per platform) and a single header.

HIDAPI has four back-ends:

* Windows (using hid.dll)

* Linux/hidraw (using the Kernel's hidraw driver)

* Linux/libusb (using libusb-1.0)

* FreeBSD (using libusb-1.0)

* Mac (using IOHidManager)

On Linux, either the hidraw or the libusb back-end can be used. There are

tradeoffs, and the functionality supported is slightly different.

Linux/hidraw (linux/hid.c):

This back-end uses the hidraw interface in the Linux kernel. While this

back-end will support both USB and Bluetooth, it has some limitations on

kernels prior to 2.6.39, including the inability to send or receive feature

reports. In addition, it will only communicate with devices which have

hidraw nodes associated with them. Keyboards, mice, and some other devices

which are blacklisted from having hidraw nodes will not work. Fortunately,

for nearly all the uses of hidraw, this is not a problem.

Linux/FreeBSD/libusb (libusb/hid.c):

This back-end uses libusb-1.0 to communicate directly to a USB device. This

back-end will of course not work with Bluetooth devices.

HIDAPI also comes with a Test GUI. The Test GUI is cross-platform and uses

Fox Toolkit (http://www.fox-toolkit.org). It will build on every platform

which HIDAPI supports. Since it relies on a 3rd party library, building it

is optional but recommended because it is so useful when debugging hardware.

What Does the API Look Like?

=============================

The API provides the the most commonly used HID functions including sending

and receiving of input, output, and feature reports. The sample program,

which communicates with a heavily hacked up version of the Microchip USB

Generic HID sample looks like this (with error checking removed for

simplicity):

#ifdef WIN32

#include

#endif

#include

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值