Skip to content

Commit 75809d4

Browse files
committed
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
2 parents 52e2f17 + 7fbe72c commit 75809d4

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

examples/peripherals/usb/host/hid/main/hid_host_example.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Unlicense OR CC0-1.0
55
*/
@@ -434,14 +434,16 @@ void hid_host_device_event(hid_host_device_handle_t hid_device_handle,
434434
.callback_arg = NULL
435435
};
436436

437-
ESP_ERROR_CHECK(hid_host_device_open(hid_device_handle, &dev_config));
438-
if (HID_SUBCLASS_BOOT_INTERFACE == dev_params.sub_class) {
439-
ESP_ERROR_CHECK(hid_class_request_set_protocol(hid_device_handle, HID_REPORT_PROTOCOL_BOOT));
440-
if (HID_PROTOCOL_KEYBOARD == dev_params.proto) {
441-
ESP_ERROR_CHECK(hid_class_request_set_idle(hid_device_handle, 0, 0));
437+
if (dev_params.proto != HID_PROTOCOL_NONE) {
438+
ESP_ERROR_CHECK(hid_host_device_open(hid_device_handle, &dev_config));
439+
if (HID_SUBCLASS_BOOT_INTERFACE == dev_params.sub_class) {
440+
ESP_ERROR_CHECK(hid_class_request_set_protocol(hid_device_handle, HID_REPORT_PROTOCOL_BOOT));
441+
if (HID_PROTOCOL_KEYBOARD == dev_params.proto) {
442+
ESP_ERROR_CHECK(hid_class_request_set_idle(hid_device_handle, 0, 0));
443+
}
442444
}
445+
ESP_ERROR_CHECK(hid_host_device_start(hid_device_handle));
443446
}
444-
ESP_ERROR_CHECK(hid_host_device_start(hid_device_handle));
445447
break;
446448
default:
447449
break;

0 commit comments

Comments
 (0)