From 12b6f0ecfb5a01c0757b1a778f75ffed1c1cd992 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 20 Dec 2024 07:37:48 -0800 Subject: [PATCH] reports btstack version. compiles with older btstack versions --- external/btstack | 2 +- src/components/bluepad32/include/uni_version.h | 16 ++++++++++++++-- .../bluepad32/parser/uni_hid_parser.c | 17 +++++++++++++++++ src/components/bluepad32/uni_init.c | 1 + 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/external/btstack b/external/btstack index 4da9eab9..16e6ddac 160000 --- a/external/btstack +++ b/external/btstack @@ -1 +1 @@ -Subproject commit 4da9eab982db614e33cc14c37d0c28d337f6cbd1 +Subproject commit 16e6ddaccbf694e2e71028d99df1c15ce2b012c1 diff --git a/src/components/bluepad32/include/uni_version.h b/src/components/bluepad32/include/uni_version.h index 32fed4a8..ac8a3e8e 100644 --- a/src/components/bluepad32/include/uni_version.h +++ b/src/components/bluepad32/include/uni_version.h @@ -6,13 +6,25 @@ #define UNI_VERSION_H // String version -#define UNI_VERSION "4.1.0" +#define UNI_VERSION "4.2.0" // Number version, in case a 3rd party needs to check it #define UNI_VERSION_MAJOR 4 -#define UNI_VERSION_MINOR 1 +#define UNI_VERSION_MINOR 2 #define UNI_VERSION_PATCH 0 extern const char* uni_version; +// btstack_version.h was included in v1.6.2 +#if defined __has_include +#if __has_include() +#include +#else +#define BTSTACK_VERSION_MAJOR 1 +#define BTSTACK_VERSION_MINOR 6 +#define BTSTACK_VERSION_PATCH 1 +#define BTSTACK_VERSION_STRING "1.6.1" +#endif +#endif + #endif // UNI_VERSION_H diff --git a/src/components/bluepad32/parser/uni_hid_parser.c b/src/components/bluepad32/parser/uni_hid_parser.c index d8e8bfff..f57f3036 100644 --- a/src/components/bluepad32/parser/uni_hid_parser.c +++ b/src/components/bluepad32/parser/uni_hid_parser.c @@ -7,10 +7,18 @@ #include "hid_usage.h" #include "uni_hid_device.h" #include "uni_log.h" +#include "uni_version.h" // HID Usage Tables: // https://www.usb.org/sites/default/files/documents/hut1_12v2.pdf +// Minimum version is 1.6.1 +#if BTSTACK_VERSION_MAJOR > 1 || BTSTACK_VERSION_MINOR > 6 || BTSTACK_VERSION_PATCH > 1 +#define USE_NEW_PARSER_API 1 +#else +#define USE_NEW_PARSER_API 0 +#endif + void uni_hid_parse_input_report(struct uni_hid_device_s* d, const uint8_t* report, uint16_t report_len) { btstack_hid_parser_t parser; @@ -40,12 +48,21 @@ void uni_hid_parse_input_report(struct uni_hid_device_s* d, const uint8_t* repor // Save globals, since they are destroyed by btstack_hid_parser_get_field() // see: https://github.com/bluekitchen/btstack/issues/187 +#if USE_NEW_PARSER_API globals.logical_minimum = parser.usage_iterator.global_logical_minimum; globals.logical_maximum = parser.usage_iterator.global_logical_maximum; globals.report_count = parser.usage_iterator.global_report_count; globals.report_id = parser.usage_iterator.global_report_id; globals.report_size = parser.usage_iterator.global_report_size; globals.usage_page = parser.usage_iterator.global_usage_page; +#else + globals.logical_minimum = parser.global_logical_minimum; + globals.logical_maximum = parser.global_logical_maximum; + globals.report_count = parser.global_report_count; + globals.report_id = parser.global_report_id; + globals.report_size = parser.global_report_size; + globals.usage_page = parser.global_usage_page; +#endif btstack_hid_parser_get_field(&parser, &usage_page, &usage, &value); diff --git a/src/components/bluepad32/uni_init.c b/src/components/bluepad32/uni_init.c index dec21039..2e549b30 100644 --- a/src/components/bluepad32/uni_init.c +++ b/src/components/bluepad32/uni_init.c @@ -26,6 +26,7 @@ int uni_init(int argc, const char** argv) { // Honoring BTstack license loge("BTstack: Copyright (C) 2017 BlueKitchen GmbH.\n"); + loge("Version: v" BTSTACK_VERSION_STRING "\n"); uni_property_init(); uni_platform_init(argc, argv);