feat(hid): 实现HID通道状态管理和多通道支持

- 将原来的HID传输状态事件替换为新的HID通道状态事件,支持USB键盘、USB消费者和BLE共享通道
- 添加usb_hid_consumer_module.c模块来处理USB消费者HID报告
- 添加usb_hid_keyboard_module.c模块来处理USB键盘HID报告
- 修改CMakeLists.txt以包含新的HID模块源文件
- 更新事件系统中的transport字段为channel字段,并相应修改所有相关处理逻辑
- 在hid_flowctrl_module.c中实现多通道并发处理机制
- 删除过时的hid_transport_state_event相关代码
- 添加新的hid_channel_state_event用于报告各通道就绪状态
This commit is contained in:
2026-04-15 15:47:14 +08:00
parent 6125f04102
commit bd57b00080
16 changed files with 979 additions and 882 deletions

View File

@@ -0,0 +1,38 @@
#ifndef BLINKY_HID_CHANNEL_STATE_EVENT_H_
#define BLINKY_HID_CHANNEL_STATE_EVENT_H_
#include <app_event_manager.h>
#include <app_event_manager_profiler_tracer.h>
#include "keyboard_core.h"
#ifdef __cplusplus
extern "C" {
#endif
struct hid_channel_state_event {
struct app_event_header header;
enum hid_send_channel channel;
uint8_t report_ready_bm;
enum keyboard_protocol_mode protocol_mode;
};
APP_EVENT_TYPE_DECLARE(hid_channel_state_event);
static inline void submit_hid_channel_state_event(
enum hid_send_channel channel, uint8_t report_ready_bm,
enum keyboard_protocol_mode protocol_mode)
{
struct hid_channel_state_event *event = new_hid_channel_state_event();
event->channel = channel;
event->report_ready_bm = report_ready_bm;
event->protocol_mode = protocol_mode;
APP_EVENT_SUBMIT(event);
}
#ifdef __cplusplus
}
#endif
#endif /* BLINKY_HID_CHANNEL_STATE_EVENT_H_ */

View File

@@ -12,7 +12,7 @@ extern "C" {
struct hid_report_sent_event {
struct app_event_header header;
enum hid_transport transport;
enum hid_send_channel channel;
enum keyboard_report_type report_type;
uint16_t sequence;
bool error;
@@ -20,13 +20,13 @@ struct hid_report_sent_event {
APP_EVENT_TYPE_DECLARE(hid_report_sent_event);
static inline void submit_hid_report_sent_event(enum hid_transport transport,
static inline void submit_hid_report_sent_event(enum hid_send_channel channel,
enum keyboard_report_type report_type,
uint16_t sequence, bool error)
{
struct hid_report_sent_event *event = new_hid_report_sent_event();
event->transport = transport;
event->channel = channel;
event->report_type = report_type;
event->sequence = sequence;
event->error = error;

View File

@@ -1,42 +0,0 @@
#ifndef BLINKY_HID_TRANSPORT_STATE_EVENT_H_
#define BLINKY_HID_TRANSPORT_STATE_EVENT_H_
#include <app_event_manager.h>
#include <app_event_manager_profiler_tracer.h>
#include "keyboard_core.h"
#ifdef __cplusplus
extern "C" {
#endif
struct hid_transport_state_event {
struct app_event_header header;
enum hid_transport transport;
bool ready;
bool keys_ready;
bool consumer_ready;
enum keyboard_protocol_mode protocol_mode;
};
APP_EVENT_TYPE_DECLARE(hid_transport_state_event);
static inline void submit_hid_transport_state_event(
enum hid_transport transport, bool ready, bool keys_ready,
bool consumer_ready, enum keyboard_protocol_mode protocol_mode)
{
struct hid_transport_state_event *event = new_hid_transport_state_event();
event->transport = transport;
event->ready = ready;
event->keys_ready = keys_ready;
event->consumer_ready = consumer_ready;
event->protocol_mode = protocol_mode;
APP_EVENT_SUBMIT(event);
}
#ifdef __cplusplus
}
#endif
#endif /* BLINKY_HID_TRANSPORT_STATE_EVENT_H_ */

View File

@@ -16,7 +16,7 @@ extern "C" {
struct hid_tx_report_event {
struct app_event_header header;
enum hid_transport transport;
enum hid_send_channel channel;
enum keyboard_report_type report_type;
enum keyboard_protocol_mode protocol_mode;
uint16_t sequence;
@@ -25,7 +25,7 @@ struct hid_tx_report_event {
APP_EVENT_TYPE_DYNDATA_DECLARE(hid_tx_report_event);
static inline int submit_hid_tx_report_event(enum hid_transport transport,
static inline int submit_hid_tx_report_event(enum hid_send_channel channel,
enum keyboard_report_type report_type,
enum keyboard_protocol_mode protocol_mode,
uint16_t sequence,
@@ -38,7 +38,7 @@ static inline int submit_hid_tx_report_event(enum hid_transport transport,
}
event = new_hid_tx_report_event(size);
event->transport = transport;
event->channel = channel;
event->report_type = report_type;
event->protocol_mode = protocol_mode;
event->sequence = sequence;

View File

@@ -36,6 +36,13 @@ enum hid_transport {
HID_TRANSPORT_COUNT,
};
enum hid_send_channel {
HID_SEND_CH_USB_KEYS,
HID_SEND_CH_USB_CONSUMER,
HID_SEND_CH_BLE_SHARED,
HID_SEND_CH_COUNT,
};
enum keyboard_consumer_control {
KEYBOARD_CONSUMER_CTRL_MUTE,
KEYBOARD_CONSUMER_CTRL_VOLUME_UP,