feat: Phase2 Task1 — DeviceCommand添加SetCursorVisible + DeviceCapability::Cursor

This commit is contained in:
showen
2026-03-13 07:14:44 +08:00
parent 28566386d2
commit f0605196fe
4 changed files with 48 additions and 0 deletions

View File

@@ -2331,3 +2331,29 @@ Task 4 已完成DevicePlugin 阶段一基础框架全部就绪。等待 PM
plugin-sdk 现在已与主库的 Device 消息系统完全同步,第三方插件可以使用这些类型与 DevicePlugin 进行通信。
---
**张明远** (2026-03-13 14:30)
DevicePlugin 阶段二 Task 1 已完成。
**完成内容**
1. 在 `src/core/message.rs` 中扩展 `DeviceCommand`,添加 `SetCursorVisible(bool)` 变体
2. 在 `DeviceCapability` 中添加 `Cursor` 变体
3. 同步更新 `plugin-sdk/src/lib.rs`,保持 SDK 与主程序 ABI 一致
4. 添加中文文档注释,说明 Linux 平台通过 unclutter 实现
**验收结果**
- ✅ `cargo check --workspace --all-targets` 零 warning
- ✅ `cargo test --workspace` 全部通过73/73 测试)
- ✅ `SetCursorVisible` 正确派生 serde traits
- ✅ `DeviceCapability::Cursor` 已添加
**修改文件**
- `src/core/message.rs` (line 138-160, line 162-193)
- `plugin-sdk/src/lib.rs` (line 189-212, line 212-245)
Task 1 完成,可以开始 Task 2LinuxArm64Backend 实现光标控制)。
@赵雨薇 现在可以开始 Task 2 了。

View File

@@ -207,6 +207,8 @@ pub enum DeviceCapability {
Framebuffer,
/// GPIO
GPIO,
/// 光标控制能力
Cursor,
}
/// 设备命令(业务插件 → DevicePlugin
@@ -222,6 +224,10 @@ pub enum DeviceCommand {
WriteFramebuffer { data: Vec<u8>, format: PixelFormat },
/// 设置防息屏
SetSleepInhibit(bool),
/// 设置光标可见性
/// - true: 显示光标
/// - false: 隐藏光标(通过 unclutter 或平台特定方式)
SetCursorVisible(bool),
/// 获取电池电量
GetBatteryLevel,
/// 设置音量0-100

View File

@@ -59,3 +59,13 @@
- 所有类型正确派生 Debug, Clone, Serialize, Deserialize跨 FFI 要求)
- 修复了 tests.rs 中的 match 穷尽性检查(新增三个 message 变体)
- cargo check 零 warningcargo test 全部通过66 个测试)
## 个人经验 (2026-03-13 - DevicePlugin 阶段二 Task 1)
- 完成 DeviceCommand 扩展,添加光标控制命令
- 在 DeviceCommand 中添加 SetCursorVisible(bool) 变体
- 在 DeviceCapability 中添加 Cursor 变体
- 同步更新 plugin-sdk/src/lib.rs 保持 ABI 一致性
- 文档注释说明 Linux 平台通过 unclutter 实现光标隐藏
- cargo check --workspace --all-targets 零 warning
- cargo test --workspace 全部通过73 个测试)
- 为 Task 2LinuxArm64Backend 实现)铺平道路

View File

@@ -155,6 +155,8 @@ pub enum DeviceCapability {
Framebuffer,
/// GPIO
GPIO,
/// 光标控制能力
Cursor,
}
/// 设备命令(业务插件 → DevicePlugin
@@ -170,6 +172,10 @@ pub enum DeviceCommand {
WriteFramebuffer { data: Vec<u8>, format: PixelFormat },
/// 设置防息屏
SetSleepInhibit(bool),
/// 设置光标可见性
/// - true: 显示光标
/// - false: 隐藏光标(通过 unclutter 或平台特定方式)
SetCursorVisible(bool),
/// 获取电池电量
GetBatteryLevel,
/// 设置音量0-100