libusb / hidapi

A Simple cross-platform library for communicating with HID devices
https://libusb.info/hidapi/
Other
1.68k stars 398 forks source link

Implement `hid_error` #690

Closed matheusmoreira closed 1 month ago

matheusmoreira commented 2 months ago

The hid_error function is not implemented yet, and contributions are welcome. So add error data to the device structure and return it from hid_error. Also set error data in the functions I need.

Closes: #684

matheusmoreira commented 2 months ago

It implements a general stored error mechanism for hid_error. There's even an internal API that makes it easy to use.

All that remains is setting the error data in the appropriate functions. I added the one I needed. More can be added in future contributions.

matheusmoreira commented 2 months ago

Fixed the issues pointed out in code review. Got rid of a lot of wide character stuff, much easier to just do everything needed with the utf8 data and convert just before returning the actual result. Improved the generated error message, now it contains the standard libusb error strings in addition to the context, if any.

Youw commented 1 month ago

Ideally there would be an hid_libusb_error function

Why not - we have all means for it.

Youw commented 1 month ago

I added the one I needed. More can be added in future contributions.

In that case I'd accept it into the future branch for now. Having small improvements/changes/fixes for a future branch might speedup the development/readiness for master branch.

Youw commented 1 month ago

I've updated the implementation myself: #698 I don't have a good environment right now to do extensive testing, @matheusmoreira would be great if you could check it.

matheusmoreira commented 1 month ago

Ideally there would be an hid_libusb_error function

Why not - we have all means for it.

Huh, I was trying to avoid adding new functions this whole time. If we can just add that function then most of this PR becomes unnecessary since its just juggling error strings.

Looks like it's become a new pull request so I'll close this one.