Skip to content

Commit

Permalink
macOS: fix hid_send_output_report implementation
Browse files Browse the repository at this point in the history
- fix name of the function on macOS
- add compile-time check by the CI

Fixes: #683
  • Loading branch information
Youw committed Aug 2, 2024
1 parent 9fc8b01 commit d101e5c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions hidtest/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ void print_hid_report_descriptor_from_device(hid_device *device) {
int res = 0;

printf(" Report Descriptor: ");
#if HID_API_VERSION >= HID_API_MAKE_VERSION(0, 14, 0)
res = hid_get_report_descriptor(device, descriptor, sizeof(descriptor));
#else
(void)res;
#endif
if (res < 0) {
printf("error getting: %ls", hid_error(device));
}
Expand Down Expand Up @@ -131,6 +135,23 @@ int main(int argc, char* argv[])
(void)argc;
(void)argv;

/* --- HIDAPI R&D: this is just to force the compiler to ensure
each of those functions are implemented (even as a stub)
by each backend. --- */
(void)&hid_open;
(void)&hid_open_path;
(void)&hid_read_timeout;
(void)&hid_get_input_report;
#if HID_API_VERSION >= HID_API_MAKE_VERSION(0, 15, 0)
(void)&hid_send_output_report;
#endif
(void)&hid_get_feature_report;
(void)&hid_send_feature_report;
#if HID_API_VERSION >= HID_API_MAKE_VERSION(0, 14, 0)
(void)&hid_get_report_descriptor;
#endif
/* --- */

int res;
unsigned char buf[256];
#define MAX_STR 255
Expand Down
2 changes: 1 addition & 1 deletion mac/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -1341,7 +1341,7 @@ int HID_API_EXPORT hid_get_feature_report(hid_device *dev, unsigned char *data,
return get_report(dev, kIOHIDReportTypeFeature, data, length);
}

int HID_API_EXPORT hid_send_output_feature_report(hid_device *dev, const unsigned char *data, size_t length)
int HID_API_EXPORT hid_send_output_report(hid_device *dev, const unsigned char *data, size_t length)
{
return set_report(dev, kIOHIDReportTypeOutput, data, length);
}
Expand Down

0 comments on commit d101e5c

Please sign in to comment.