feat(keyboard): 添加键盘核心模块和HID报告事件支持
- 添加keyboard_core_module.c实现键盘核心功能,包括按键映射、 报告构建和状态管理 - 添加keyboard_hid_report_event相关文件,实现键盘HID报告事件 的定义和处理 - 在CMakeLists.txt中注册新的源文件 - 定义键盘协议模式(BOOT/REPORT)和报告类型枚举 - 实现按键事件处理、模式切换响应和电源管理功能 - 支持多媒体控制键和标准键盘按键的不同处理逻辑
This commit is contained in:
28
inc/events/keyboard_hid_report_event.h
Normal file
28
inc/events/keyboard_hid_report_event.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#ifndef BLINKY_KEYBOARD_HID_REPORT_EVENT_H_
|
||||
#define BLINKY_KEYBOARD_HID_REPORT_EVENT_H_
|
||||
|
||||
#include <app_event_manager.h>
|
||||
#include <app_event_manager_profiler_tracer.h>
|
||||
|
||||
#include "keyboard_core.h"
|
||||
#include "mode_switch_event.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct keyboard_hid_report_event {
|
||||
struct app_event_header header;
|
||||
enum mode_switch_mode mode;
|
||||
enum keyboard_report_type report_type;
|
||||
enum keyboard_protocol_mode protocol_mode;
|
||||
struct event_dyndata dyndata;
|
||||
};
|
||||
|
||||
APP_EVENT_TYPE_DYNDATA_DECLARE(keyboard_hid_report_event);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BLINKY_KEYBOARD_HID_REPORT_EVENT_H_ */
|
||||
40
inc/keyboard_core.h
Normal file
40
inc/keyboard_core.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#ifndef BLINKY_KEYBOARD_CORE_H_
|
||||
#define BLINKY_KEYBOARD_CORE_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define KEYBOARD_BOOT_REPORT_SIZE 8U
|
||||
#define KEYBOARD_NKRO_USAGE_MAX 0xDFU
|
||||
#define KEYBOARD_NKRO_BITMAP_BYTES ((KEYBOARD_NKRO_USAGE_MAX + 8U) / 8U)
|
||||
#define KEYBOARD_NKRO_REPORT_SIZE (1U + KEYBOARD_NKRO_BITMAP_BYTES)
|
||||
#define KEYBOARD_CONSUMER_REPORT_SIZE 2U
|
||||
|
||||
enum keyboard_protocol_mode {
|
||||
KEYBOARD_PROTOCOL_MODE_BOOT,
|
||||
KEYBOARD_PROTOCOL_MODE_REPORT,
|
||||
};
|
||||
|
||||
enum keyboard_report_type {
|
||||
KEYBOARD_REPORT_TYPE_KEYS,
|
||||
KEYBOARD_REPORT_TYPE_CONSUMER,
|
||||
};
|
||||
|
||||
enum keyboard_consumer_control {
|
||||
KEYBOARD_CONSUMER_CTRL_MUTE,
|
||||
KEYBOARD_CONSUMER_CTRL_VOLUME_UP,
|
||||
KEYBOARD_CONSUMER_CTRL_VOLUME_DOWN,
|
||||
KEYBOARD_CONSUMER_CTRL_PLAY_PAUSE,
|
||||
KEYBOARD_CONSUMER_CTRL_NEXT_TRACK,
|
||||
KEYBOARD_CONSUMER_CTRL_PREV_TRACK,
|
||||
KEYBOARD_CONSUMER_CTRL_COUNT,
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BLINKY_KEYBOARD_CORE_H_ */
|
||||
Reference in New Issue
Block a user