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

Implement hid_error #690

Closed

Commits on Sep 7, 2024

  1. hid: define utf8 to wchar_t conversion function

    Most if not all libusb functions return UTF-8 encoded data
    but hidapi functions typically take and return wide character strings.
    Adapt one of the existing algorithms in the code base into a general
    conversion function.
    matheusmoreira committed Sep 7, 2024
    Configuration menu
    Copy the full SHA
    1f1d55e View commit details
    Browse the repository at this point in the history
  2. hid: define wchar_t libusb error function variant

    Returns libusb error names and strings
    converted to wide character strings.
    matheusmoreira committed Sep 7, 2024
    Configuration menu
    Copy the full SHA
    69db339 View commit details
    Browse the repository at this point in the history
  3. hid: add error data to hid_device structure

    Store libusb error code so it can be retrieved later.
    
    Includes the original error code as well as a context-specific message
    which the libusb documentation sometimes specifies for each function.
    Code which uses those functions are meant to set the contextual message
    whenever possible.
    
    The code is initialized to a success state which implies no errors yet.
    The contextual error message is initialized to NULL and is not freed
    when the device is closed. It is meant to point at string literals.
    matheusmoreira committed Sep 7, 2024
    Configuration menu
    Copy the full SHA
    277cac9 View commit details
    Browse the repository at this point in the history
  4. hid: define easy error data setter function

    Sets all error data, including an optional contextual error message
    which is supposed to be a non-freeable constant string
    such as a string literal.
    
    Contextual error messages are meant to be used in the cases
    the libusb documentation goes into detail as to what happened.
    Passing NULL will produce a message with just the libusb_error_name
    and the libusb_strerror results. Passing a string literal will produce
    a message that contains the additional context in addition to the error
    name and message.
    matheusmoreira committed Sep 7, 2024
    Configuration menu
    Copy the full SHA
    9cc5ac0 View commit details
    Browse the repository at this point in the history
  5. hid: set error data in send_feature_report

    Set error data when send_feature_report fails, including custom messages
    for the situations especially outlined in the libusb documentation for
    the libusb_control_transfer function.
    matheusmoreira committed Sep 7, 2024
    Configuration menu
    Copy the full SHA
    ec4d74a View commit details
    Browse the repository at this point in the history
  6. hid: implement hid_error

    Compute a formatted error string containing the libusb error name,
    the error message as well as any contextual information.
    Return NULL if there are no errors or if memory allocation failed.
    matheusmoreira committed Sep 7, 2024
    Configuration menu
    Copy the full SHA
    9b6bef5 View commit details
    Browse the repository at this point in the history