XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

LogiBoardToolBox

【WinUI】罗技鼠标板载驱动程序

公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/LogiBoardToolBox

Preserve legacy onboard library when framework creates the new product directory

2eb98f5
XFE工作室室长 <mail@xfegzs.com>
提交于

代码差异

3 个文件 +30 -7
Modified LogiBoardToolBox/LogiBoardToolBox.Core/Storage/RuntimeDataPaths.cs +10 -5
@@ -1,6 +1,6 @@
1 1 namespace LogiBoardToolBox.Core.Storage;
2 2
3 /// <summary>One-time, non-destructive migration of the former product's local settings and backups.</summary>
3 /// <summary>One-time, non-destructive migration of the former product's onboard settings and backups.</summary>
4 4 public static class RuntimeDataPaths
5 5 {
6 6 public const string ProductName = "LogiBoardToolBox";
@@ -11,18 +11,23 @@ public static class RuntimeDataPaths
11 11 var parent = Path.GetFullPath(localApplicationData);
12 12 var current = Path.Combine(parent, ProductName);
13 13 var legacy = Path.Combine(parent, LegacyProductName);
14 if (Directory.Exists(current) || !Directory.Exists(legacy)) return current;
14 var currentOnboard = Path.Combine(current, "Onboard");
15 var legacyOnboard = Path.Combine(legacy, "Onboard");
16 // The configuration framework can create the product root before this view model.
17 // Only an existing onboard library means the migration has already been handled.
18 if (Directory.Exists(currentOnboard) || !Directory.Exists(legacyOnboard)) return current;
15 19 var staging = Path.Combine(parent, ProductName + ".migrating-" + Guid.NewGuid().ToString("N"));
16 20 try
17 21 {
18 CopyDirectory(legacy, staging);
19 if (!Directory.Exists(current)) Directory.Move(staging, current);
22 CopyDirectory(legacyOnboard, staging);
23 Directory.CreateDirectory(current);
24 if (!Directory.Exists(currentOnboard)) Directory.Move(staging, currentOnboard);
20 25 return current;
21 26 }
22 27 catch (Exception error) when (error is IOException or UnauthorizedAccessException)
23 28 {
24 29 // Original data is never moved or deleted. A failed migration must not hide it.
25 return Directory.Exists(current) ? current : legacy;
30 return Directory.Exists(currentOnboard) ? current : legacy;
26 31 }
27 32 finally
28 33 {
Modified LogiBoardToolBox/LogiBoardToolBox.Test/ProductRenameTests.cs +18 -0
@@ -26,6 +26,24 @@ public class ProductRenameTests
26 26 Assert.Equal("new settings", File.ReadAllText(Path.Combine(current, "Onboard", "macros.json")));
27 27 }
28 28
29 [Test]
30 public void FrameworkCreatedProductRootDoesNotPreventOnboardDataMigration()
31 {
32 using var scratch = new ScratchDirectory();
33 var old = Path.Combine(scratch.Path, RuntimeDataPaths.LegacyProductName, "Onboard");
34 var currentRoot = Path.Combine(scratch.Path, RuntimeDataPaths.ProductName);
35 var framework = Path.Combine(currentRoot, "CrossVersion");
36 Directory.CreateDirectory(old);
37 Directory.CreateDirectory(framework);
38 File.WriteAllText(Path.Combine(old, "macros.json"), "recorded macro library");
39 File.WriteAllText(Path.Combine(framework, "settings.json"), "current framework settings");
40
41 Assert.Equal(currentRoot, RuntimeDataPaths.GetProductDirectory(scratch.Path));
42 Assert.Equal("recorded macro library", File.ReadAllText(Path.Combine(currentRoot, "Onboard", "macros.json")));
43 Assert.Equal("current framework settings", File.ReadAllText(Path.Combine(framework, "settings.json")));
44 Assert.Equal("recorded macro library", File.ReadAllText(Path.Combine(old, "macros.json")));
45 }
46
29 47 [Test]
30 48 public async Task LegacyBackupHeadersRemainLoadableAndRestorableAfterTheProductRename()
31 49 {
Modified README.md +2 -2
@@ -24,13 +24,13 @@
24 24
25 25 打开设备后自动扫描并读取。多只鼠标可在设备设置中的“设备诊断与软件配置”选择;切换前完成旧设备自动保存,再读取新设备。右上角选择“桌面: 默认”编辑软件配置,选择实际提供的“板载配置”后直接编辑相应板载槽。DPI X/Y、闲置秒数、配置名称和颜色文本在输入时仅保留草稿,按 Enter 或离开输入框后才校验并提交;Esc 撤销草稿。无效数值保留上次有效设置,不进入保存队列。已确认的有效修改在约 200ms 内合并后自动保存,无需再点写入;事务串行执行,每次自动备份、检查旧数据并逐扇区读回。正在执行的闪存事务不会被后续手势取消。失败会显示错误并保留编辑内容;仍有保存失败时不会直接关闭窗口。
26 26
27 宏库、软件配置、自定义灵敏度预设和自动备份位于 `%LOCALAPPDATA%\LogiBoardToolBox\Onboard`。项目、程序集及可执行文件统一更名为 `LogiBoardToolBox`;首次使用更名版本时会复制旧 `LogiBordToolBox` 数据目录,保留原目录且不覆盖已有新目录。旧版本生成的板载备份仍可读取和恢复。软件宏需从宏编辑器的“板载与执行”启动;LIGHTSYNC 页面用户进入时可接管软件灯效,停止或关闭会恢复控制。
27 宏库、软件配置、自定义灵敏度预设和自动备份位于 `%LOCALAPPDATA%\LogiBoardToolBox\Onboard`。项目、程序集及可执行文件统一更名为 `LogiBoardToolBox`;首次使用更名版本时会复制旧 `LogiBordToolBox\Onboard` 数据目录,保留原目录且不覆盖已有新宏库,即使配置框架已提前创建新产品目录也能迁移。旧版本生成的板载备份仍可读取和恢复。软件宏需从宏编辑器的“板载与执行”启动;LIGHTSYNC 页面用户进入时可接管软件灯效,停止或关闭会恢复控制。
28 28
29 29 完整独立按住循环序列、自由灯区及动画的 EEPROM 播放布局尚未验证;这些功能不会被静默转换成其他板载效果。屏幕、音频联动仍需要电脑。HERO 成功校准、触发循环及其他高级宏的物理执行、应用自动切换、G HUB 集成/社区仍有未完成或未确认项,不能视为 G HUB 全功能替代。
30 30
31 31 ## 构建与验证
32 32
33 更名后的 Release x64 版本构建无警告、无错误,92 项测试全部通过,包含旧数据目录迁移和旧备份格式的兼容性检查。发布可执行文件:
33 更名后的 Release x64 版本构建无警告、无错误,93 项测试全部通过,包含旧数据目录迁移、框架预创建目录和旧备份格式的兼容性检查。发布可执行文件:
34 34
35 35 ```powershell
36 36 dotnet publish LogiBoardToolBox/LogiBoardToolBox -c Release -p:Platform=x64 -o artifacts/LogiBoardToolBox