apmorton / pyhidapi

hidapi bindings in ctypes
MIT License
111 stars 42 forks source link

Missing `hid_get_input_report()` #45

Closed mbaussenwein closed 2 years ago

mbaussenwein commented 3 years ago

The package seems to be missing one of the hidapi functions. The library offers two 'get_report'-functions hid_get_feature_report() and hid_get_input_report()(see below). The former works nicely, while the latter is not implemented. Is this on purpose becausehid_get_input_report() is not working fully on all platforms yet?

/** @brief Get a feature report from a HID device.
            Set the first byte of @p data[] to the Report ID of the
            report to be read.  Make sure to allow space for this
            extra byte in @p data[]. Upon return, the first byte will
            still contain the Report ID, and the report data will
            start in data[1].
            This function sets the return value of hid_error().
            @ingroup API
            @param dev A device handle returned from hid_open().
            @param data A buffer to put the read data into, including
                the Report ID. Set the first byte of @p data[] to the
                Report ID of the report to be read, or set it to zero
                if your device does not use numbered reports.
            @param length The number of bytes to read, including an
                extra byte for the report ID. The buffer can be longer
                than the actual report.
            @returns
                This function returns the number of bytes read plus
                one for the report ID (which is still in the first
                byte), or -1 on error.
        */
        int HID_API_EXPORT HID_API_CALL hid_get_feature_report(hid_device *dev, unsigned char *data, size_t length);

        /** @brief Get a input report from a HID device.
            Set the first byte of @p data[] to the Report ID of the
            report to be read. Make sure to allow space for this
            extra byte in @p data[]. Upon return, the first byte will
            still contain the Report ID, and the report data will
            start in data[1].
            @ingroup API
            @param device A device handle returned from hid_open().
            @param data A buffer to put the read data into, including
                the Report ID. Set the first byte of @p data[] to the
                Report ID of the report to be read, or set it to zero
                if your device does not use numbered reports.
            @param length The number of bytes to read, including an
                extra byte for the report ID. The buffer can be longer
                than the actual report.
            @returns
                This function returns the number of bytes read plus
                one for the report ID (which is still in the first
                byte), or -1 on error.
        */
        int HID_API_EXPORT HID_API_CALL hid_get_input_report(hid_device *dev, unsigned char *data, size_t length);

from: https://github.com/libusb/hidapi/blob/master/hidapi/hidapi.h

apmorton commented 3 years ago

hid_get_input_report is only 15 months old: https://github.com/libusb/hidapi/commit/083223e77952e1ef57e6b77796536a3359c1b2a3

If someone submits a PR adding support for any new APIs in hidapi I will gladly merge it and update pypi.