From 4ffa57abab0370b5bd8485a51bb333b369682aea Mon Sep 17 00:00:00 2001
From: Ariver <shanghai3168@gmail.com>
Date: Mon, 18 May 2026 16:01:40 +0800
Subject: [PATCH] fix: treat right alt flags as key state
---
TODO.md | 9 +++++++++
VoiceSnapGo/app.go | 2 +-
VoiceSnapGo/build/darwin/Info.plist | 2 +-
VoiceSnapGo/internal/hotkey/hotkey_darwin.go | 3 ++-
4 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/TODO.md b/TODO.md
index f39bdcf..a411d06 100644
--- a/TODO.md
+++ b/TODO.md
@@ -17,6 +17,15 @@
## Done
+- [2026-05-18] 修复右 Alt 事件进入但被 macOS 物理状态查询误判为未按下的问题。
+ - 日志显示 R-Alt `flagsChanged` 事件正常进入,`flags=0x80140`,但 `physicalDown=false` 导致 `pollDown=false`。
+ - 修复: 按事件 keyCode 区分左右 Alt,并用该事件的 modifier flags 判定按下/释放。
+ - 验证: 重新打包安装后模拟右 Alt,日志显示 `eventDown=true`、`pollDown=true`,并成功触发录音流程。
+ - build: `20260518.1554`
+ - 输出: `VoiceSnapGo/build/local/arm64/VoiceSnap.app`
+ - 输出: `VoiceSnapGo/build/local/arm64/VoiceSnap-2.1.1-build20260518.1554-arm64-local.dmg`
+ - 兼容输出: `VoiceSnapGo/build/local/arm64/VoiceSnap-2.1.1-arm64-local.dmg` 已替换为同一份新包。
+ - 已安装到 `/Applications/VoiceSnap.app`;启动日志验证 build `20260518.1554`。
- [2026-05-18] 增加权限检查设置面板。
- 新增“权限”设置页,清晰列出麦克风、辅助功能、输入监控三个权限。
- 权限状态由后端调用 macOS 原生 API 检查;已授权显示绿灯,未授权显示红灯。
diff --git a/VoiceSnapGo/app.go b/VoiceSnapGo/app.go
index 1e9e57d..fa35b92 100755
--- a/VoiceSnapGo/app.go
+++ b/VoiceSnapGo/app.go
@@ -27,7 +27,7 @@
const (
appVersion = "2.1.1"
- appBuild = "20260518.1541"
+ appBuild = "20260518.1554"
appDisplayVersion = appVersion + " (build " + appBuild + ")"
appName = "VoiceSnap"
diff --git a/VoiceSnapGo/build/darwin/Info.plist b/VoiceSnapGo/build/darwin/Info.plist
index a25e807..d543e73 100755
--- a/VoiceSnapGo/build/darwin/Info.plist
+++ b/VoiceSnapGo/build/darwin/Info.plist
@@ -17,7 +17,7 @@
<key>CFBundleShortVersionString</key>
<string>2.1.1</string>
<key>CFBundleVersion</key>
- <string>20260518.1541</string>
+ <string>20260518.1554</string>
<key>LSMinimumSystemVersion</key>
<string>11.0</string>
<key>NSMicrophoneUsageDescription</key>
diff --git a/VoiceSnapGo/internal/hotkey/hotkey_darwin.go b/VoiceSnapGo/internal/hotkey/hotkey_darwin.go
index 710e9d6..1ddda60 100755
--- a/VoiceSnapGo/internal/hotkey/hotkey_darwin.go
+++ b/VoiceSnapGo/internal/hotkey/hotkey_darwin.go
@@ -76,7 +76,8 @@
if (mask == 0) return;
BOOL physicalDown = CGEventSourceKeyState(kCGEventSourceStateHIDSystemState, (CGKeyCode)keyCode);
- handleKeyEvent(keyCode, physicalDown ? YES : NO);
+ BOOL eventDown = (flags & mask) ? YES : NO;
+ handleKeyEvent(keyCode, (physicalDown || eventDown) ? YES : NO);
recordAltEvent(keyCode, 3, flags);
}
--
Gitblit v1.9.3