Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added hid_send_output_report() function #677

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

mbcinergy
Copy link

Where hid_get_input_report() was already available for some time, hid_send_output_report() was still missing.

We have used our own fork with this function added for a couple of years now, but believe it's better to add this to the main repository as well.

The changes are tested for Windows and on Linux (hidraw and libusb).

The functions for mac and netbsd are also added but not tested, since we currently have no hardware available for that. It would be great if somebody can test this function for those platforms as well, but the functions are very straightforward so I don't expect any issues with them.

@Youw
Copy link
Member

Youw commented Apr 15, 2024

So far I haven't encountered cases when you have to use hid_send_output_report specifically, instead of using hid_write.

Most implementations of hid_write would try to use interrupt pipe to send the data if possible first, and would fallback to "hid_send_output_report" if there is no interrupt (output) pipe for a specific device.

On some platforms, the implementation of hid_write is identical to suggested hid_send_output_report, and on others - should work identically (but "better").
Have you tried it?

@Youw Youw added the enhancement New feature or request label Apr 15, 2024
@mbcinergy
Copy link
Author

So far I haven't encountered cases when you have to use hid_send_output_report specifically, instead of using hid_write.

Most implementations of hid_write would try to use interrupt pipe to send the data if possible first, and would fallback to "hid_send_output_report" if there is no interrupt (output) pipe for a specific device.

On some platforms, the implementation of hid_write is identical to suggested hid_send_output_report, and on others - should work identically (but "better"). Have you tried it?

I've tried hid_write, but it does not work in this case. The issue is that we have a couple of devices which do have an interrupt output pipe but use the control pipe for some vendor specific reports. That's why the hid_write does not work out of the box for those devices. So we need a function which is able to specify the pipe we need to write to.

hidapi/hidapi.h Show resolved Hide resolved
libusb/hid.c Show resolved Hide resolved
windows/hid.c Outdated Show resolved Hide resolved
- added `hid_send_output_report` reference in function description for `hid_write`
- added see `hid_write` reference in function description for `hid_send_output_report`
- modified `hid_send_output_report` for windows to be more in line with `hid_send_feature_report`
- `hid_write` for libusb now calls `hid_send_output_report` if there is no interrupt out endpoint to prevent code duplication
@JoergAtGithub
Copy link
Contributor

Wouldn't it be better to read the Endpoint Descriptor to determine if the particular interface of the USB device has a Interupt Out?

@Youw
Copy link
Member

Youw commented Apr 16, 2024

Not sure what do you mean.
Right now libusb backend looks for a first interrupt endpoint of a particular interface. But it reads from a USB config descriptor.

I didn't check the linux/hidraw implementation, but Windows and macOS implementation is not exactly known.

@JoergAtGithub
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants