Linux HID APIS similar to Windows HID APIs [closed]

一笑奈何 提交于 2020-01-25 13:07:28

问题


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

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 :

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

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

Thanks,


回答1:


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.

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).

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.

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



来源:https://stackoverflow.com/questions/22528522/linux-hid-apis-similar-to-windows-hid-apis

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!