From d101e5c7e4646ecde66b650b3b8ce4904acfb13a Mon Sep 17 00:00:00 2001 From: Ihor Dutchak Date: Fri, 2 Aug 2024 16:48:23 +0300 Subject: [PATCH] macOS: fix hid_send_output_report implementation - fix name of the function on macOS - add compile-time check by the CI Fixes: #683 --- hidtest/test.c | 21 +++++++++++++++++++++ mac/hid.c | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/hidtest/test.c b/hidtest/test.c index 1eb65822..4ac09a16 100644 --- a/hidtest/test.c +++ b/hidtest/test.c @@ -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)); } @@ -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 diff --git a/mac/hid.c b/mac/hid.c index 1e5e17a0..e2b365c4 100644 --- a/mac/hid.c +++ b/mac/hid.c @@ -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); }