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 * SPDX-License-Identifier: Unlicense OR CC0-1.0
*/ */
@@ -434,6 +434,7 @@ void hid_host_device_event(hid_host_device_handle_t hid_device_handle,
.callback_arg = NULL .callback_arg = NULL
}; };
if (dev_params.proto != HID_PROTOCOL_NONE) {
ESP_ERROR_CHECK(hid_host_device_open(hid_device_handle, &dev_config)); ESP_ERROR_CHECK(hid_host_device_open(hid_device_handle, &dev_config));
if (HID_SUBCLASS_BOOT_INTERFACE == dev_params.sub_class) { if (HID_SUBCLASS_BOOT_INTERFACE == dev_params.sub_class) {
ESP_ERROR_CHECK(hid_class_request_set_protocol(hid_device_handle, HID_REPORT_PROTOCOL_BOOT)); ESP_ERROR_CHECK(hid_class_request_set_protocol(hid_device_handle, HID_REPORT_PROTOCOL_BOOT));
@@ -442,6 +443,7 @@ void hid_host_device_event(hid_host_device_handle_t hid_device_handle,
} }
} }
ESP_ERROR_CHECK(hid_host_device_start(hid_device_handle)); ESP_ERROR_CHECK(hid_host_device_start(hid_device_handle));
}
break; break;
default: default:
break; break;