quack/main/SDK/quack.diff

64 lines
2.7 KiB
Diff

diff --git a/components/esp_hid/include/esp_hidh.h b/components/esp_hid/include/esp_hidh.h
index b1a8264307..d3d1002103 100644
--- a/components/esp_hid/include/esp_hidh.h
+++ b/components/esp_hid/include/esp_hidh.h
@@ -100,6 +100,7 @@ typedef union {
typedef struct {
esp_event_handler_t callback;
+ uint16_t event_stack_size;
} esp_hidh_config_t;
/**
diff --git a/components/esp_hid/src/ble_hidh.c b/components/esp_hid/src/ble_hidh.c
index 5fe54f2fa7..a56eb04c44 100644
--- a/components/esp_hid/src/ble_hidh.c
+++ b/components/esp_hid/src/ble_hidh.c
@@ -617,7 +617,7 @@ esp_err_t esp_ble_hidh_init(const esp_hidh_config_t *config)
.queue_size = 5,
.task_name = "esp_ble_hidh_events",
.task_priority = uxTaskPriorityGet(NULL),
- .task_stack_size = 2048,
+ .task_stack_size = config->event_stack_size > 0 ? config->event_stack_size : 2048,
.task_core_id = tskNO_AFFINITY
};
ret = esp_event_loop_create(&event_task_args, &event_loop_handle);
diff --git a/components/esp_hid/src/bt_hidh.c b/components/esp_hid/src/bt_hidh.c
index 1a17e6aa35..16fae9e65a 100644
--- a/components/esp_hid/src/bt_hidh.c
+++ b/components/esp_hid/src/bt_hidh.c
@@ -320,7 +320,7 @@ esp_err_t esp_bt_hidh_init(const esp_hidh_config_t *config)
.queue_size = 5,
.task_name = "esp_bt_hidh_events",
.task_priority = uxTaskPriorityGet(NULL),
- .task_stack_size = 2048,
+ .task_stack_size = config->event_stack_size > 0 ? config->event_stack_size : 2048,
.task_core_id = tskNO_AFFINITY
};
esp_err_t ret = esp_event_loop_create(&event_task_args, &event_loop_handle);
@@ -386,6 +386,24 @@ void bta_hh_co_data(uint8_t handle, uint8_t *p_rpt, uint16_t len, tBTA_HH_PROTO_
ESP_LOGE(TAG, "Device Not Found: handle %u", handle);
return;
}
+
+ /*
+ * quack patch: mode is always ESP_HID_PROTOCOL_MODE_BOOT even if the device is in BOOT mode
+ * BTA_HH_PROTO_RPT_MODE from Bluedroid is 0
+ * BOOT report id is also questionable, assume than an REPORT mode with a lengh of 3 or 4 is a BOOT packet
+ */
+
+ if (len >= 2 + 1 && p_rpt[0] == 2 && mode == 0) {
+ esp_hidh_event_data_t p = {0};
+ p.input.dev = dev;
+ p.feature.report_id = 2;
+ p.feature.usage = ESP_HID_USAGE_MOUSE;
+ p.feature.data = p_rpt + 1;
+ p.input.length = len - 1;
+ esp_event_post_to(event_loop_handle, ESP_HIDH_EVENTS, ESP_HIDH_INPUT_EVENT, &p, sizeof(esp_hidh_event_data_t), portMAX_DELAY);
+ return ;
+ }
+
report = esp_hidh_dev_get_input_report_by_id_and_proto(dev, p_rpt[0], mode ? ESP_HID_PROTOCOL_MODE_BOOT : ESP_HID_PROTOCOL_MODE_REPORT);
if (report == NULL) {
ESP_LOGE(TAG, "Report Not Found: %d mode: %s", p_rpt[0], mode ? "BOOT" : "REPORT");