-
Notifications
You must be signed in to change notification settings - Fork 2
Mouse_README
SweerItTer edited this page Feb 21, 2026
·
5 revisions
Mouse 模块提供 Linux 输入设备的鼠标事件监控功能,支持鼠标移动、点击和滚轮事件。
| 类 | 文档 | 说明 |
|---|---|---|
MouseWatcher |
MouseWatcher | 鼠标事件监控器 |
- 鼠标移动事件
- 鼠标按键事件(左键、中键、右键)
- 鼠标滚轮事件
- 事件坐标和状态
- 事件回调函数
- 实时事件通知
- 事件过滤
MouseWatcher watcher;
// 注册鼠标移动事件回调
watcher.registerHandler(
{MouseEventType::AxisX, MouseEventType::AxisY},
[](MouseEventType type, uint8_t value) {
if (type == MouseEventType::AxisX) {
printf("Mouse X movement: %d\n", static_cast<int8_t>(value));
} else if (type == MouseEventType::AxisY) {
printf("Mouse Y movement: %d\n", static_cast<int8_t>(value));
}
}
);
watcher.start();MouseWatcher watcher;
// 注册鼠标按键事件回调
watcher.registerHandler(
{MouseEventType::ButtonLeft, MouseEventType::ButtonRight},
[](MouseEventType type, uint8_t value) {
if (type == MouseEventType::ButtonLeft) {
printf("Left button: %s\n", value ? "pressed" : "released");
} else if (type == MouseEventType::ButtonRight) {
printf("Right button: %s\n", value ? "pressed" : "released");
}
}
);
watcher.start();MouseWatcher watcher;
// 注册滚轮事件回调
watcher.registerHandler(
{MouseEventType::WheelVertical},
[](MouseEventType type, uint8_t value) {
printf("Wheel scroll: %d\n", static_cast<int8_t>(value));
}
);
watcher.start();输入设备 → MouseWatcher → 回调 → 上层处理
- MouseWatcher 内部使用独立监控线程
- 回调函数在监控线程中调用
- 使用队列传递事件到其他线程
- 使用事件队列减少回调阻塞
- 过滤不需要的事件
- 批量处理事件
- 检查设备打开是否成功
- 处理设备权限错误
- 记录错误日志
- Utils 模块 - 通用工具
- 设备权限: 确保有访问输入设备的权限
- 设备路径: 确保输入设备路径正确
- 回调阻塞: 不要在回调中执行耗时操作
- 线程安全: 回调函数应该是线程安全的
- 资源清理: 使用完毕后调用 stop() 清理资源
- v1.0 - 初始版本,支持基本鼠标事件监控
主页
API 文档
DMA 模块
DRM 模块
- DRM 模块总览
- DeviceController - DRM 设备控制器
- DrmLayer - DRM 图层管理
- PlanesCompositor - DRM 平面合成器
- DrmBpp - DRM 格式定义
NET 模块
- NET 模块总览
- TcpServer - TCP 服务器
- SocketConnection - Socket 连接管理
- CommandHandler - 命令处理器
- DataPacket - 数据包
V4L2 模块
- V4L2 模块总览
- CameraController - V4L2 摄像头控制器
- Frame - V4L2 帧数据结构
- FormatTool - V4L2 格式工具
- Exception - V4L2 异常类
V4L2Param 模块
- V4L2Param 模块总览
- ParamControl - 参数控制
- ParamLogger - 参数日志
- ParamProcessor - 参数处理器
RGA 模块
- RGA 模块总览
- RgaConverter - RGA 转换器
- RgaProcessor - RGA 处理器
- FormatTool - RGA 格式工具
MPP 模块
- MPP 模块总览
- EncoderContext - 编码器上下文
- EncoderCore - 编码器核心
- JpegEncoder - JPEG 编码器
- StreamWriter - 流写入器
- MppResourceGuard - MPP 资源守护
- FileTools - 文件工具
- FormatTool - 格式工具
Sys 模块
- Sys 模块总览
- CpuMonitor - CPU 监控器
- MemoryMonitor - 内存监控器
- Base - 基础类
Mouse 模块
- Mouse 模块总览
- Watcher - 鼠标监视器
Utils 模块
- Utils 模块总览
- AsyncThreadPool - 异步线程池
- ConcurrentQueue - 并发队列
- FdWrapper - 文件描述符包装器
- FenceWatcher - 围栏监视器
- FixedSizePool - 固定大小对象池
- Logger - 日志记录器
- ObjectsPool - 对象池
- OrderedQueue - 有序队列
- ProgressBar - 进度条
- SafeQueue - 安全队列
- SharedBufferState - 共享缓冲区状态
- SimpleVariant - 简单变体类型
- ThreadPauser - 线程暂停器
- ThreadUtils - 线程工具
- Types - 类型定义
- UdevMonitor - Udev 监视器