Skip to content

Commit 72b9095

Browse files
committed
Joypad working again
1 parent db40286 commit 72b9095

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

main/badge_hid_host.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <stdio.h>
1313
#include "bsp/input.h"
1414
#include "esp_log.h"
15+
#include "usb/hid.h"
1516
#include "usb/hid_host.h"
1617
#include "usb/hid_usage_keyboard.h"
1718
#include "usb/hid_usage_mouse.h"
@@ -302,7 +303,9 @@ static void print_gamepad_report(const gamepad_report_t* rpt, int length) {
302303
}
303304
}
304305

305-
ESP_LOGI(TAG, "%s\n%s\n%s\n", button_line, line1, line2);
306+
ESP_LOGI(TAG, "%s", button_line);
307+
ESP_LOGI(TAG, "%s", line1);
308+
ESP_LOGI(TAG, "%s", line2);
306309
}
307310

308311
/**
@@ -605,19 +608,17 @@ static void hid_host_device_event(hid_host_device_handle_t hid_device_handle, co
605608
ESP_LOGI(TAG, "HID Device, protocol '%s' CONNECTED", hid_proto_name_str[dev_params.proto]);
606609

607610
const hid_host_device_config_t dev_config = {.callback = hid_host_interface_callback, .callback_arg = NULL};
611+
ESP_ERROR_CHECK(hid_host_device_open(hid_device_handle, &dev_config));
608612

609-
if (dev_params.proto != HID_PROTOCOL_NONE) {
610-
ESP_ERROR_CHECK(hid_host_device_open(hid_device_handle, &dev_config));
611-
if (HID_SUBCLASS_BOOT_INTERFACE == dev_params.sub_class) {
612-
ESP_ERROR_CHECK(hid_class_request_set_protocol(hid_device_handle, HID_REPORT_PROTOCOL_BOOT));
613-
if (HID_PROTOCOL_KEYBOARD == dev_params.proto) {
614-
ESP_ERROR_CHECK(hid_class_request_set_idle(hid_device_handle, 0, 0));
615-
}
616-
if (HID_PROTOCOL_MOUSE == dev_params.proto) { // Luxury mouse support
617-
// hid_class_request_set_protocol(hid_device_handle, HID_REPORT_PROTOCOL_REPORT);
618-
619-
// print_report_descriptor(hid_device_handle);
620-
}
613+
if (HID_SUBCLASS_BOOT_INTERFACE == dev_params.sub_class) {
614+
ESP_ERROR_CHECK(hid_class_request_set_protocol(hid_device_handle, HID_REPORT_PROTOCOL_BOOT));
615+
if (HID_PROTOCOL_KEYBOARD == dev_params.proto) {
616+
ESP_ERROR_CHECK(hid_class_request_set_idle(hid_device_handle, 0, 0));
617+
}
618+
if (HID_PROTOCOL_MOUSE == dev_params.proto) { // Luxury mouse support
619+
// hid_class_request_set_protocol(hid_device_handle, HID_REPORT_PROTOCOL_REPORT);
620+
621+
// print_report_descriptor(hid_device_handle);
621622
}
622623
}
623624
ESP_ERROR_CHECK(hid_host_device_start(hid_device_handle));

0 commit comments

Comments
 (0)