Linux的HID APIS类似于Windows API的HID [英] Linux HID APIS similar to Windows HID APIs

查看:420
本文介绍了Linux的HID APIS类似于Windows API的HID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要寻找相应的Linux HID的API类似什么是微软提起这页:

I am looking for corresponding Linux HID APIs similar to what is mentioned on Microsoft this page :

http://msdn.microsoft.com/en-us/library/windows/hardware/jj126202(v=vs.85).aspx

基本功能是对应DataMovement:

Basically functions corresponding to DataMovement :

Data Movement
The following list identifies HID API that an application can use to move data back and forth  between the app and a selected device.

HidD_GetInputReport
HidD_SetFeature
HidD_SetOutputReport
ReadFile
WriteFile 

我目前有两个方向为:

I have two directions currently to :

- >安装酒框架,并尝试使用Windows应用程序(HID利用API)的

-> Install the wine framework and try use the Windows Application(utilizing HID Apis)

- >二来使用相应的Linux HID蜜蜂(为我暗区)

-> Second to Use the Corresponding Linux HID Apis(dark area for me)

谢谢,

推荐答案

一个跨平台的HID API库的 HIDAPI (引擎盖下,它使用的Windows的ReadFile / WriteFile的东西,libusb的Linux版)。我从来没有使用它,所以我不能保证它。

A cross-platform HID API library is HIDAPI (under the hood, it uses the ReadFile/WriteFile stuff for Windows and libusb for Linux). I have never used it so I cannot vouch for it.

如果你需要的是SetReport和GetReport,那么它可能是更容易操作上的 hidraw 的在Linux设备。我用这个技术来 ltunify 。您可以发现哪些的/ dev / hidrawX 设备通过查询sysfs中属于设备(<一href=\"https://git.lekensteyn.nl/ltunify/tree/ltunify.c?id=1938dc08d1b0111f4eb236e4b920a321e78cb5da#n1142\"相对=nofollow>例如)。

If all you need is SetReport and GetReport, then it may be easier to operate on hidraw devices in Linux. I use this technique for ltunify. You can discover which /dev/hidrawX device belongs to a device by querying sysfs (example).

一旦你有一个设备(例如,的/ dev / hidraw0 ),那么你就可以打开它进行读取和写入,并使用POSIX 阅读()的write()功能。你可能会碰到权限问题,而是通过改变设备的权限是可解的,无论是手动( setfacl的-mu:$ USER:RW的/ dev / hidraw0 )或udev规则,如 42罗技统一的权限。规则的。

Once you have a device (say, /dev/hidraw0), then you can open it for reading and writing and use the POSIX read() and write() functions. You may hit a permissions issue, but that is solvable by changing the permissions of the device, either manually (setfacl -m u:$USER:rw /dev/hidraw0) or with a udev rule such as 42-logitech-unify-permissions.rules.

由于需要同时支持Windows和Linux平台,我认为你是用前面提到的HIDAPI库更好。

Since you need to support both Windows and Linux platforms, I think that you are better off with using the HIDAPI library mentioned before.

这篇关于Linux的HID APIS类似于Windows API的HID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆