- 新增keyboard_module.c实现完整的键盘HID功能,包括按键映射、 协议处理和报告生成 - 添加hid_protocol_event和hid_report_event事件系统支持 - 实现键盘和consumer类型的HID报告处理 - 支持Boot协议和Report协议两种模式 - 添加hid_keymap_def.h定义键盘映射表 refactor(ble_hid): 重构HIDS模块为BLE HID模块 - 将hids_module.c重命名为ble_hid_module.c - 集成新的hid_protocol_event和hid_report_event事件处理 - 改进协议切换逻辑,添加协议事件发布功能 - 优化BLE HID报告发送机制 refactor(CMakeLists): 更新构建配置 - 添加新的事件模块源文件到构建列表 - 添加keyboard_module.c替换原有的button_map_module.c - 添加ble_hid_module.c替换原有的hids_module.c - 配置HID密钥映射定义路径编译选项 refactor(events): 简化USB HID事件结构 - 移除USB HID事件中的冗余状态字段 - 更新事件日志和分析器字段定义 docs(hid): 添加HID报告描述符文档 - 定义REPORT_ID_KEYBOARD和REPORT_ID_CONSUMER枚举值 - 整理HID报告相关的常量定义
47 lines
1.5 KiB
C
47 lines
1.5 KiB
C
#include "usb_hid_event.h"
|
|
|
|
static const char *const usb_hid_evt_type_name[] = {
|
|
[USB_HID_EVT_STATE_REPORT] = "STATE_REPORT",
|
|
};
|
|
|
|
static const char *const usb_hid_usbd_state_name[] = {
|
|
[USB_HID_USBD_DISCONNECTED] = "DISCONNECTED",
|
|
[USB_HID_USBD_CONNECTED] = "CONNECTED",
|
|
[USB_HID_USBD_SUSPENDED] = "SUSPENDED",
|
|
};
|
|
|
|
static void log_usb_hid_event(const struct app_event_header *aeh)
|
|
{
|
|
const struct usb_hid_event *event = cast_usb_hid_event(aeh);
|
|
|
|
__ASSERT_NO_MSG(event->evt_type < ARRAY_SIZE(usb_hid_evt_type_name));
|
|
__ASSERT_NO_MSG(event->usbd_state < ARRAY_SIZE(usb_hid_usbd_state_name));
|
|
|
|
APP_EVENT_MANAGER_LOG(aeh, "type=%s en=%u usbd=%s",
|
|
usb_hid_evt_type_name[event->evt_type],
|
|
event->enable,
|
|
usb_hid_usbd_state_name[event->usbd_state]);
|
|
}
|
|
|
|
static void profile_usb_hid_event(struct log_event_buf *buf,
|
|
const struct app_event_header *aeh)
|
|
{
|
|
const struct usb_hid_event *event = cast_usb_hid_event(aeh);
|
|
|
|
nrf_profiler_log_encode_uint8(buf, (uint8_t)event->evt_type);
|
|
nrf_profiler_log_encode_uint8(buf, (uint8_t)event->enable);
|
|
nrf_profiler_log_encode_uint8(buf, (uint8_t)event->usbd_state);
|
|
}
|
|
|
|
APP_EVENT_INFO_DEFINE(usb_hid_event,
|
|
ENCODE(NRF_PROFILER_ARG_U8,
|
|
NRF_PROFILER_ARG_U8,
|
|
NRF_PROFILER_ARG_U8),
|
|
ENCODE("evt_type", "enable", "usbd"),
|
|
profile_usb_hid_event);
|
|
|
|
APP_EVENT_TYPE_DEFINE(usb_hid_event,
|
|
log_usb_hid_event,
|
|
&usb_hid_event_info,
|
|
APP_EVENT_FLAGS_CREATE(APP_EVENT_TYPE_FLAGS_INIT_LOG_ENABLE));
|