feat(events): 添加功能位图状态事件并移除旧的按键功能事件

- 添加新的 function_bitmap_state_event 事件类型用于跟踪功能键位图状态
- 移除已废弃的 key_function_event 事件及其相关文件
- 更新 CMakeLists.txt 中的源文件列表以包含新事件文件
- 修改协议定义文件 device_comm.options 和 device_comm.proto
  以使用位图方式传输功能键状态而不是单独的按键事件
- 更新键盘核心模块中的位图处理逻辑,添加 usage_to_bitmap_pos
 辅助函数来正确定位修饰键和普通按键的位置
- 修改报告构建逻辑以正确处理新的位图布局
- 更新协议模块以处理新的功能位图状态事件和 LED 状态事件
- 实现协议模块中的 ACK、错误响应和 LED 状态编码功能
This commit is contained in:
2026-04-15 10:52:01 +08:00
parent bc42a4dd63
commit 79af0eb025
9 changed files with 341 additions and 127 deletions

View File

@@ -0,0 +1,41 @@
#ifndef BLINKY_FUNCTION_BITMAP_STATE_EVENT_H_
#define BLINKY_FUNCTION_BITMAP_STATE_EVENT_H_
#include <errno.h>
#include <string.h>
#include <app_event_manager.h>
#include <app_event_manager_profiler_tracer.h>
#include "keyboard_core.h"
#ifdef __cplusplus
extern "C" {
#endif
struct function_bitmap_state_event {
struct app_event_header header;
uint8_t bitmap[KEYBOARD_PROTOCOL_BITMAP_BYTES];
};
APP_EVENT_TYPE_DECLARE(function_bitmap_state_event);
static inline int submit_function_bitmap_state_event(const uint8_t *bitmap)
{
struct function_bitmap_state_event *event;
if (bitmap == NULL) {
return -EINVAL;
}
event = new_function_bitmap_state_event();
memcpy(event->bitmap, bitmap, sizeof(event->bitmap));
APP_EVENT_SUBMIT(event);
return 0;
}
#ifdef __cplusplus
}
#endif
#endif /* BLINKY_FUNCTION_BITMAP_STATE_EVENT_H_ */

View File

@@ -1,37 +0,0 @@
#ifndef BLINKY_KEY_FUNCTION_EVENT_H_
#define BLINKY_KEY_FUNCTION_EVENT_H_
#include <app_event_manager.h>
#include <app_event_manager_profiler_tracer.h>
#ifdef __cplusplus
extern "C" {
#endif
enum key_function_action {
KEY_FUNCTION_ACTION_RELEASE = 0U,
KEY_FUNCTION_ACTION_PRESS = 1U,
};
struct key_function_event {
struct app_event_header header;
uint16_t usage;
uint8_t action;
};
APP_EVENT_TYPE_DECLARE(key_function_event);
static inline void submit_key_function_event(uint16_t usage, uint8_t action)
{
struct key_function_event *event = new_key_function_event();
event->usage = usage;
event->action = action;
APP_EVENT_SUBMIT(event);
}
#ifdef __cplusplus
}
#endif
#endif /* BLINKY_KEY_FUNCTION_EVENT_H_ */