Merge branch 'refactor/usb_host_hid_example_open_proto_only' into 'master'

refactor(usb_host_example): Added opening only for HID device with proto

See merge request espressif/esp-idf!40228
This commit is contained in:
Roman Leonov
2025-07-21 16:01:23 +08:00

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
@@ -434,14 +434,16 @@ void hid_host_device_event(hid_host_device_handle_t hid_device_handle,
.callback_arg = NULL
};
ESP_ERROR_CHECK(hid_host_device_open(hid_device_handle, &dev_config));
if (HID_SUBCLASS_BOOT_INTERFACE == dev_params.sub_class) {
ESP_ERROR_CHECK(hid_class_request_set_protocol(hid_device_handle, HID_REPORT_PROTOCOL_BOOT));
if (HID_PROTOCOL_KEYBOARD == dev_params.proto) {
ESP_ERROR_CHECK(hid_class_request_set_idle(hid_device_handle, 0, 0));
if (dev_params.proto != HID_PROTOCOL_NONE) {
ESP_ERROR_CHECK(hid_host_device_open(hid_device_handle, &dev_config));
if (HID_SUBCLASS_BOOT_INTERFACE == dev_params.sub_class) {
ESP_ERROR_CHECK(hid_class_request_set_protocol(hid_device_handle, HID_REPORT_PROTOCOL_BOOT));
if (HID_PROTOCOL_KEYBOARD == dev_params.proto) {
ESP_ERROR_CHECK(hid_class_request_set_idle(hid_device_handle, 0, 0));
}
}
ESP_ERROR_CHECK(hid_host_device_start(hid_device_handle));
}
ESP_ERROR_CHECK(hid_host_device_start(hid_device_handle));
break;
default:
break;