Skip to content

Bring PS5 GTA6 to 120FPS with DLSS 5. An advanced Windows video player and capture enhancement tool featuring real-time preview for videos, images, and capture card sources. Combine AI-powered Super Resolution, DLSS5 image enhancement, and Frame Generation to deliver a next-generation visual experience.

C++

feat(shortcuts): F7 screenshot and F8 start/stop recording, also in game mode

Veyra Goal Agentbb36660dc65d
diff --git a/docs/CAPTURE_FPS_AUDIO_REPORT_2026-10-27.md b/docs/CAPTURE_FPS_AUDIO_REPORT_2026-10-27.md
index aff3b607..df8858cb 100644
--- a/docs/CAPTURE_FPS_AUDIO_REPORT_2026-10-27.md
+++ b/docs/CAPTURE_FPS_AUDIO_REPORT_2026-10-27.md
@@ -130,3 +130,14 @@ PS5 设为“位流(杜比/DTS)”时,会把含中置的 5.1 以 IEC 61937
- GitHub NVIDIA/DLSS 的 releases API(310.5.0 加入超分 L/M;310.6.0 加入补帧 5x/6x;310.9.1 加入 RR Preset F;310.9.16 只修 bug)。
- 本机 DLSS SDK 310.7 头文件。
- 项目历史文档 `docs/history/plans/DLSS45_SR_PLAN_2026-10-11.md`。
+
+## 4. 截图 F7、录制 F8
+
+- 默认快捷键:截图由 Ctrl+S 改为 F7,新增“开始 / 停止录制”F8。二者都可以在设置→快捷键里改。已保存的自定义键保持不变;如果老配置里另一个功能已经占了 F7/F8,那个功能保留原键,新功能先不绑定,显示“未设置”。
+- 游戏模式下键盘焦点在游戏上,所以改由游戏模式的键盘钩子接管:被捕获的游戏或 Veyra 在前台时生效,并吞掉这个键;其他程序在前台时不拦截。PC 游戏自己要用 F7/F8 时,在设置里改键即可。
+- 冲突:Veyra 现有快捷键和保留键、NVIDIA 叠加层(Alt+F1/F9/F10)、Steam(F12)、AMD(Ctrl+Shift+…)、OBS 默认都不用 F7/F8。不少笔记本的 F7/F8 默认是媒体键,需要配合 Fn。
+- 验证:
+ - `veyra_game_passthrough_tests` 0 失败:新增 F7/F8 的触发、松开配对、其他程序放行检查;真实钩子下原有的面板/退出键在新的四槽打包下照常工作。
+ - 界面合同、翻译、QtQuick(117 通过、1 跳过)通过。
+ - `scripts/acceptance/shortcut-defaults.py`:私有配置下全新默认为 F7/F8;全屏已占 F8 时,全屏保留 F8、录制为空;设置页两行都在,没有 QML 错误。
+ - 没有往真实程序里注入按键做端到端截图/录制。
diff --git a/docs/WORKLOG.md b/docs/WORKLOG.md
index 421b57cf..58662f9f 100644
--- a/docs/WORKLOG.md
+++ b/docs/WORKLOG.md
@@ -10,6 +10,8 @@
- 采集音频75444b3:G50仅双声道USB音频,PS5多声道LPCM时中置(对白)在卡内丢失,OBS同样;强制PCM不改PS5输出。通用16-bit立体声DirectShow引脚加PcmCarrierRouter,复用AverMediaAudioCarrier解码载波内AC3/E-AC-3/DTS(PS5位流),真PCM原路径不变。单测真实AC3 5.1中置有信号、无载波字节作PCM播放;carrier 39363、vendor 65+7、passthrough 26+8+8、IEC、采集音频(静音)通过。未上实卡/PS5。
- 调研:建议去色带、独立RCAS、对白增强优先,CRT光束模拟再评估;NR沿用10-26结论;DLSS RR(310.9.1 Preset F)需游戏G-buffer,不适用于视频/采集。
+- 快捷键:截图默认Ctrl+S→F7,新增录制F8,可在设置改;游戏模式钩子扩为面板/退出/截图/录制四槽,仅在游戏或Veyra在前台时接管。老配置已占F7/F8时保留原功能、新项未设置。game_passthrough/UI合同/翻译/QtQuick及私有配置启动检查通过。
+
构建build-recording-handoff --task claude-capture-fps-audio-20261027(首轮--reconfigure 79.4秒,其后增量)。未验证:用户165Hz实机与游戏模式、G50位流透传、无该属性的旧Windows。
## 2026-10-27 项目整理1–4
diff --git a/i18n/catalog.json b/i18n/catalog.json
index ef72e9e4..6cc6c8f4 100644
--- a/i18n/catalog.json
+++ b/i18n/catalog.json
@@ -7890,6 +7890,13 @@
"en": "Start",
"ja": "開始"
},
+ {
+ "zh": "开始 / 停止录制",
+ "src": "qml/SettingsPage.qml",
+ "zh-TW": "開始 / 停止錄製",
+ "en": "Start / stop recording",
+ "ja": "録画の開始 / 停止"
+ },
{
"zh": "开始串流",
"src": "qml/PcSourceDialog.qml",
@@ -10957,6 +10964,13 @@
"en": "No cap",
"ja": "上限なし"
},
+ {
+ "zh": "未设置",
+ "src": "qml/SettingsPage.qml",
+ "zh-TW": "未設定",
+ "en": "Not set",
+ "ja": "未設定"
+ },
{
"zh": "未设置录制保存位置",
"src": "src/engine/LiveRecorder.cpp",
@@ -12182,6 +12196,13 @@
"en": "Game mode",
"ja": "ゲームモード"
},
+ {
+ "zh": "游戏模式下在游戏里也能用",
+ "src": "qml/SettingsPage.qml",
+ "zh-TW": "遊戲模式下在遊戲裡也能用",
+ "en": "Also works inside the game in game mode",
+ "ja": "ゲームモード中はゲーム内でも使えます"
+ },
{
"zh": "游戏模式不裁剪;贴合原窗口时画面与鼠标位置一一对应",
"src": "qml/ScreenSourceDialog.qml",
diff --git a/include/veyra/ui/GameHotkeys.h b/include/veyra/ui/GameHotkeys.h
index 7cfa5b9b..1e04c40b 100644
--- a/include/veyra/ui/GameHotkeys.h
+++ b/include/veyra/ui/GameHotkeys.h
@@ -36,7 +36,10 @@ class GameKeyState {
public:
struct Result { bool consume = false; int action = -1; };
void seed(unsigned vk, bool down) { if (vk < keys_.size()) keys_[vk] = down; }
- Result input(unsigned vk, bool down, GameKey panel, GameKey exit, bool panelOwned) {
+ // Actions: 0 panel, 1 exit, 2 screenshot, 3 record. Everything but exit only
+ // while the picture owns the keys (panelOwned), so Veyra in front never sees
+ // a key twice and other programs keep theirs. An unbound key has vk 0.
+ Result input(unsigned vk, bool down, GameKey panel, GameKey exit, bool panelOwned, GameKey shot = {}, GameKey record = {}) {
if (vk >= keys_.size()) return {};
const bool repeat = keys_[vk];
const bool claimed = claimed_[vk];
@@ -44,7 +47,8 @@ public:
const bool modifier = vk == VK_CONTROL || vk == VK_LCONTROL || vk == VK_RCONTROL ||
vk == VK_MENU || vk == VK_LMENU || vk == VK_RMENU || vk == VK_SHIFT || vk == VK_LSHIFT || vk == VK_RSHIFT ||
vk == VK_LWIN || vk == VK_RWIN;
- if (modifier || vk == panel.vk || vk == exit.vk || claimed || repeat) keys_[vk] = down;
+ const bool bound = vk == panel.vk || vk == exit.vk || (shot.vk && vk == shot.vk) || (record.vk && vk == record.vk);
+ if (modifier || bound || claimed || repeat) keys_[vk] = down;
if (!down) { claimed_[vk] = false; return {claimed, -1}; }
if (claimed) return {true, -1};
if (repeat || modifier) return {};
@@ -53,7 +57,8 @@ public:
((keys_[VK_SHIFT] || keys_[VK_LSHIFT] || keys_[VK_RSHIFT]) ? 4 : 0) |
((keys_[VK_LWIN] || keys_[VK_RWIN]) ? 8 : 0);
const GameKey pressed{vk, mods};
- const int action = pressed == exit ? 1 : panelOwned && pressed == panel ? 0 : -1;
+ const int action = pressed == exit ? 1 : !panelOwned ? -1 : pressed == panel ? 0 :
+ shot.vk && pressed == shot ? 2 : record.vk && pressed == record ? 3 : -1;
if (action < 0) return {};
claimed_[vk] = true;
return {true, action};
@@ -66,8 +71,10 @@ class GameHotkeyListener {
public:
static constexpr UINT message = WM_APP + 0x347;
~GameHotkeyListener() { stop(); }
- void bindings(GameKey panel, GameKey exit) {
- config_.store(uint64_t(panel.vk) | (uint64_t(panel.mods) << 8) | (uint64_t(exit.vk) << 16) | (uint64_t(exit.mods) << 24));
+ // Four 16-bit slots (vk, mods << 8): panel, exit, screenshot, record.
+ void bindings(GameKey panel, GameKey exit, GameKey shot = {}, GameKey record = {}) {
+ const auto slot = [](GameKey k) { return uint64_t(k.vk & 255) | (uint64_t(k.mods & 15) << 8); };
+ config_.store(slot(panel) | (slot(exit) << 16) | (slot(shot) << 32) | (slot(record) << 48));
++epoch_;
}
void panelOwned(bool on) { panelOwned_.store(on); }
@@ -125,9 +132,8 @@ private:
const bool up = wp == WM_KEYUP || wp == WM_SYSKEYUP;
if (key && (down || up)) {
auto& self = *self_; const auto epoch = self.epoch_.load(); const auto config = self.config_.load();
- const GameKey panel{unsigned(config & 255), unsigned((config >> 8) & 15)};
- const GameKey exit{unsigned((config >> 16) & 255), unsigned((config >> 24) & 15)};
- const auto result = self.state_.input(key->vkCode, down, panel, exit, self.panelOwned_.load());
+ const auto slot = [config](unsigned at) { return GameKey{unsigned((config >> at) & 255), unsigned((config >> (at + 8)) & 15)}; };
+ const auto result = self.state_.input(key->vkCode, down, slot(0), slot(16), self.panelOwned_.load(), slot(32), slot(48));
if (result.action >= 0 && epoch == self.epoch_.load() &&
!PostMessageW(self.target_, message, WPARAM(result.action), LPARAM(epoch))) {
const DWORD error = GetLastError();
diff --git a/include/veyra/ui/GamePassthrough.h b/include/veyra/ui/GamePassthrough.h
index 9864ca04..9a9cea5a 100644
--- a/include/veyra/ui/GamePassthrough.h
+++ b/include/veyra/ui/GamePassthrough.h
@@ -47,7 +47,7 @@ public:
// Off: a normal window. Panel: on top and interactive (Home panel open).
// Through: exact click-through. Scaled: blocks mouse, target retains keyboard/gamepad.
using Mode = GameInputMode;
- enum class Event { PanelHotkey, ExitHotkey, ExitUnavailable, HangReleased };
+ enum class Event { PanelHotkey, ExitHotkey, ExitUnavailable, HangReleased, ScreenshotHotkey, RecordHotkey };
std::function<void(Event)> onEvent;
GamePassthrough() { s_instance = this; }
@@ -76,7 +76,7 @@ public:
}
Mode mode() const { return mode_; }
- void setHotkeys(GameKey panel, GameKey exit) { keys_.bindings(panel, exit); }
+ void setHotkeys(GameKey panel, GameKey exit, GameKey shot = {}, GameKey record = {}) { keys_.bindings(panel, exit, shot, record); }
// WGC captures the visible window frame, not an enlarged movie viewport.
// Coordinates are physical pixels in the fullscreen host's client space.
RECT pictureBounds() const {
@@ -216,10 +216,11 @@ private:
}
auto* self = reinterpret_cast<GamePassthrough*>(GetWindowLongPtrW(window, GWLP_USERDATA));
if (self && message == GameHotkeyListener::message) {
- if (self->keys_.current(lp) && self->mode_ != Mode::Off && wp <= 1 &&
+ if (self->keys_.current(lp) && self->mode_ != Mode::Off && wp <= 3 &&
(wp == 1 || self->panelOwned_)) {
veyra::log::info("game-mode", std::format("hotkey received action={} epoch={}", wp, lp));
- if (self->onEvent) self->onEvent(wp == 0 ? Event::PanelHotkey : Event::ExitHotkey);
+ static constexpr Event events[] = {Event::PanelHotkey, Event::ExitHotkey, Event::ScreenshotHotkey, Event::RecordHotkey};
+ if (self->onEvent) self->onEvent(events[wp]);
}
return 0;
}
diff --git a/include/veyra/ui/QmlPlayerBridge.h b/include/veyra/ui/QmlPlayerBridge.h
index 9d027c7c..fa437b9e 100644
--- a/include/veyra/ui/QmlPlayerBridge.h
+++ b/include/veyra/ui/QmlPlayerBridge.h
@@ -1424,6 +1424,8 @@ private:
void emitParameterChanged(void (QmlPlayerBridge::*group)(), bool wasValid);
void updateGameMode();
void updateGameGeometry();
+ // Game mode's keyboard hook gets the current panel, exit, screenshot and record keys.
+ void applyGameHotkeys();
// 抖音直播伴侣 running (gfx/PresentationHooks.h): Realtime GPU priority is capped at
// High while it runs and restored when it exits; 监控软件兼容 "off" leaves it alone.
void updateLiveCompanionCompat();
diff --git a/qml/Veyra/Main.qml b/qml/Veyra/Main.qml
index 51b76225..f73a348e 100644
--- a/qml/Veyra/Main.qml
+++ b/qml/Veyra/Main.qml
@@ -717,6 +717,7 @@ Window {
Shortcut { sequence: veyra.shortcuts.playPause; onActivated: veyra.togglePlayPause() }
Shortcut { sequence: veyra.shortcuts.fullscreen; onActivated: root.toggleFullscreen() }
Shortcut { sequence: veyra.shortcuts.screenshot; onActivated: veyra.takeScreenshot() }
+ Shortcut { sequence: veyra.shortcuts.record; onActivated: veyra.toggleRecording() }
Shortcut {
sequence: veyra.shortcuts.toggleMode
enabled: dialogs.dialog === ""
diff --git a/qml/Veyra/SettingsPage.qml b/qml/Veyra/SettingsPage.qml
index 14822fd5..ccc2339b 100644
--- a/qml/Veyra/SettingsPage.qml
+++ b/qml/Veyra/SettingsPage.qml
@@ -970,7 +970,8 @@ VPage {
{ id: "fullscreen", a: qsTr("全屏"), note: qsTr("F11 / Alt+Enter 也可以") },
{ id: "lock", a: qsTr("锁定全屏控制条") },
{ id: "hold", a: qsTr("按住查看原画") },
- { id: "screenshot", a: qsTr("截图") },
+ { id: "screenshot", a: qsTr("截图"), note: qsTr("游戏模式下在游戏里也能用") },
+ { id: "record", a: qsTr("开始 / 停止录制"), note: qsTr("游戏模式下在游戏里也能用") },
{ id: "toggleMode", a: qsTr("切换极简 / 专业") },
{ id: "gamePanel", a: qsTr("游戏模式:调整画面"), note: qsTr("仅在游戏模式中接管按键;支持 Ctrl、Alt、Shift 组合") },
{ id: "gameExit", a: qsTr("游戏模式:退出鼠标穿透"), note: qsTr("退出全屏,恢复普通窗口操作") }
@@ -992,7 +993,7 @@ VPage {
Text {
id: keyText
anchors.centerIn: parent
- text: parent.capturing ? qsTr("按下新按键…") : veyra.shortcuts[keyRow.modelData.id]
+ text: parent.capturing ? qsTr("按下新按键…") : (veyra.shortcuts[keyRow.modelData.id] || qsTr("未设置"))
color: Theme.t1
font.family: Theme.fontMono
font.pixelSize: Theme.fsSmall
diff --git a/scripts/acceptance/shortcut-defaults.py b/scripts/acceptance/shortcut-defaults.py
new file mode 100644
index 00000000..c74c67aa
--- /dev/null
+++ b/scripts/acceptance/shortcut-defaults.py
@@ -0,0 +1,57 @@
+"""Screenshot F7 / record F8 defaults on a private profile (claude-capture-fps-audio-20261027).
+
+Two runs of this tree's build in the staged copy that screen-capture-rate.py made: a
+fresh profile (F7 / F8), and a profile whose fullscreen key was already F8 (fullscreen
+keeps it, record stays unbound until set). Opens on the settings page; no key input
+is sent to any window.
+usage: py -3.11 -X utf8 -B -I scripts/acceptance/shortcut-defaults.py
+"""
+from pathlib import Path
+import json, os, shutil, subprocess
+
+B = Path('E:/项目/Veyra'); T = 'claude-capture-fps-audio-20261027'; R = Path(__file__).resolve().parents[2]
+D = B/'build/claude-screen-recording-20261022'; A = B/'tests'/T/'app'; L = B/'logs'/T/'shortcuts'; TMP = B/'tmp'/T/'shortcuts'
+assert (A/'veyra_qml_ui.exe').exists(), 'run screen-capture-rate.py --exe build first (it stages the app)'
+for p in [L, TMP]: p.mkdir(parents=True, exist_ok=True)
+
+
+def replace(p, data):
+ p.parent.mkdir(parents=True, exist_ok=True)
+ if p.exists(): p.unlink()
+ p.write_bytes(data)
+
+
+replace(A/'veyra_qml_ui.exe', (D/'veyra_qml_ui.exe').read_bytes())
+for folder in ['qml', 'i18n']:
+ for p in (R/folder).rglob('*'):
+ if p.is_file(): replace(A/folder/p.relative_to(R/folder), p.read_bytes())
+cases = {'fresh': ({}, {'screenshot': 'F7', 'record': 'F8', 'fullscreen': 'F'}),
+ 'f8-taken': ({'fullscreen': 'F8'}, {'screenshot': 'F7', 'record': '', 'fullscreen': 'F8'})}
+results = {}
+main_src = R/'qml/Veyra/Main.qml'; main = main_src.read_text('utf8'); pos = main.rfind('}')
+for name, (custom, expect) in cases.items():
+ P = B/'tests'/T/('profile-shortcuts-' + name)
+ if P.exists(): shutil.rmtree(P)
+ P.mkdir(parents=True)
+ prefs = dict(language='zh-CN', autoResume=False, prewarmEnhancement=False)
+ if custom: prefs['shortcuts'] = custom
+ (P/'qml-preferences.v1.json').write_text(json.dumps(prefs), 'utf8')
+ loader = ('\nLoader { anchors.fill: parent; source: ' + json.dumps((R/'scripts/acceptance/shortcut-defaults.qml').as_uri()) +
+ '; onLoaded: item.expect=' + json.dumps(expect) + ' }\n')
+ replace(A/'qml/Veyra/Main.qml', (main[:pos] + loader + main[pos:]).encode('utf8'))
+ env = {k: v for k, v in os.environ.items() if not k.upper().startswith(('VEYRA_', 'QT_', 'QSG_', 'QML_'))}
+ log_file = L/f'{name}.log'; console = L/f'{name}-console.log'
+ env.update(TEMP=str(TMP), TMP=str(TMP), APPDATA=str(P/'AppData'), LOCALAPPDATA=str(P/'LocalAppData'),
+ QML_DISABLE_DISK_CACHE='1', QT_FORCE_STDERR_LOGGING='1', VEYRA_LOG_FILE=str(log_file))
+ try:
+ with console.open('wb') as f:
+ run = subprocess.run([str(A/'veyra_qml_ui.exe'), '--page', 'set', '--size', '1100x700', '--data-dir', str(P), '--exit-after', '30000'],
+ cwd=A, env=env, stdout=f, stderr=subprocess.STDOUT, timeout=60)
+ finally:
+ replace(A/'qml/Veyra/Main.qml', main_src.read_bytes())
+ text = console.read_text('utf8', errors='replace')
+ results[name] = dict(exit=run.returncode, passed='SC_PASS' in text and 'SC_FAIL' not in text,
+ line=next((l for l in text.splitlines() if 'SC_' in l), ''),
+ qmlErrors=[l for l in text.splitlines() if any(s in l for s in ['ReferenceError:', 'TypeError:', 'Binding loop detected', 'ambiguous'])][:5])
+(B/'reports'/T/'shortcuts.json').write_text(json.dumps(results, ensure_ascii=False, indent=1), 'utf8')
+print(json.dumps(results, ensure_ascii=False, indent=1))
diff --git a/scripts/acceptance/shortcut-defaults.qml b/scripts/acceptance/shortcut-defaults.qml
new file mode 100644
index 00000000..e73d7867
--- /dev/null
+++ b/scripts/acceptance/shortcut-defaults.qml
@@ -0,0 +1,24 @@
+// Loaded only into a private staging copy, never the user's running package.
+// claude-capture-fps-audio-20261027: the screenshot / record shortcuts on the
+// settings page, with the defaults or with a key an older profile already took.
+import QtQuick
+Item {
+ id: test
+ property var expect: ({})
+ Timer {
+ interval: 1500; running: Object.keys(test.expect).length > 0
+ onTriggered: {
+ const keys = veyra.shortcuts
+ let ok = true
+ for (const id in test.expect) ok = ok && keys[id] === test.expect[id]
+ // The settings page shows every row, an unbound one as 未设置.
+ const rows = []
+ const walk = item => { if (item.objectName && item.objectName.startsWith("key-")) rows.push(item.objectName); for (const c of item.children) walk(c) }
+ walk(test.parent.parent) // the Loader's parent: the window's content item
+ ok = ok && rows.indexOf("key-screenshot") >= 0 && rows.indexOf("key-record") >= 0
+ veyra.logUi("shortcut-test", "keys=" + JSON.stringify(keys) + " rows=" + rows.join(","))
+ console.log(ok ? "SC_PASS" : "SC_FAIL " + JSON.stringify(keys) + " " + rows.join(","))
+ Qt.quit()
+ }
+ }
+}
diff --git a/src/ui/QmlPlayerBridge.cpp b/src/ui/QmlPlayerBridge.cpp
index 0a3af697..6571eace 100644
--- a/src/ui/QmlPlayerBridge.cpp
+++ b/src/ui/QmlPlayerBridge.cpp
@@ -73,9 +73,7 @@ QmlPlayerBridge::QmlPlayerBridge(engine::EngineController& engine, std::filesyst
// The compute GPU decides which effects exist, so it is settled before
// anything below samples the capabilities or restores the saved chain.
impl_->loadPrefs();
- const auto gameKeys=shortcuts();
- impl_->game.setHotkeys(ui::gameKey(QKeySequence(gameKeys.value("gamePanel").toString(),QKeySequence::PortableText)),
- ui::gameKey(QKeySequence(gameKeys.value("gameExit").toString(),QKeySequence::PortableText)));
+ applyGameHotkeys();
impl_->enumerateGpuAdapters();
impl_->resolveGpuMonitor();
impl_->applyComputeGpu();
@@ -131,6 +129,9 @@ QmlPlayerBridge::QmlPlayerBridge(engine::EngineController& engine, std::filesyst
emit gameModeChanged();
impl_->game.apply(ui::GamePassthrough::Mode::Off);
emit gameModeStopped(tr("界面卡住超过 3 秒,已退出游戏模式")); break;
+ // The game has the keyboard in game mode; the hook hands these over.
+ case E::ScreenshotHotkey: takeScreenshot(); break;
+ case E::RecordHotkey: toggleRecording(); break;
}
};
auto* gameBeat = new QTimer(this);
diff --git a/src/ui/bridge/Preferences.cpp b/src/ui/bridge/Preferences.cpp
index d6b58814..fe8c21b7 100644
--- a/src/ui/bridge/Preferences.cpp
+++ b/src/ui/bridge/Preferences.cpp
@@ -450,8 +450,9 @@ void QmlPlayerBridge::refreshAudioDevices() {
// --- shortcuts (P4-f) --------------------------------------------------------
namespace {
const QVariantMap& shortcutDefaults() {
+ // Screenshot was Ctrl+S before 2026-10-27; saved custom keys are kept.
static const QVariantMap d{{"playPause", "Space"}, {"fullscreen", "F"}, {"lock", "Ctrl+L"},
- {"hold", "V"}, {"screenshot", "Ctrl+S"}, {"toggleMode", "Tab"},
+ {"hold", "V"}, {"screenshot", "F7"}, {"record", "F8"}, {"toggleMode", "Tab"},
{"gamePanel", "Home"}, {"gameExit", "Ctrl+Alt+Home"}};
return d;
}
@@ -459,13 +460,24 @@ const QVariantMap& shortcutDefaults() {
QVariantMap QmlPlayerBridge::shortcuts() const {
QVariantMap out = shortcutDefaults();
const auto custom = impl_->prefs.value("shortcuts").toMap();
+ QStringList taken;
for (auto it = custom.begin(); it != custom.end(); ++it)
if (out.contains(it.key())) {
if ((it.key()=="gamePanel"||it.key()=="gameExit") && !ui::gameKey(QKeySequence(it.value().toString(),QKeySequence::PortableText)).vk) continue;
out[it.key()] = it.value();
+ taken << it.value().toString();
}
+ // A default added later (F7/F8) may be a key the user already gave another
+ // action: that action keeps it and the new one stays unbound until set.
+ for (auto it = out.begin(); it != out.end(); ++it)
+ if (!custom.contains(it.key()) && taken.contains(it.value().toString())) it.value() = QString();
return out;
}
+void QmlPlayerBridge::applyGameHotkeys() {
+ const auto keys = shortcuts();
+ const auto key = [&keys](const char* action) { return ui::gameKey(QKeySequence(keys.value(action).toString(), QKeySequence::PortableText)); };
+ impl_->game.setHotkeys(key("gamePanel"), key("gameExit"), key("screenshot"), key("record"));
+}
bool QmlPlayerBridge::setShortcut(const QString& action, const QString& sequence) {
if (!shortcutDefaults().contains(action)) return false;
const QKeySequence seq(sequence, QKeySequence::PortableText);
@@ -493,9 +505,7 @@ bool QmlPlayerBridge::setShortcut(const QString& action, const QString& sequence
impl_->prefs["shortcuts"] = custom;
if (!impl_->savePrefs()) { impl_->prefs = previous; emit notice(tr("快捷键保存失败"), true); return false; }
veyra::log::info("ui-prefs", std::format("shortcut {}={}", action.toStdString(), text.toStdString()));
- const auto keys=shortcuts();
- impl_->game.setHotkeys(ui::gameKey(QKeySequence(keys.value("gamePanel").toString(),QKeySequence::PortableText)),
- ui::gameKey(QKeySequence(keys.value("gameExit").toString(),QKeySequence::PortableText)));
+ applyGameHotkeys();
emit preferencesChanged();
return true;
}
@@ -503,7 +513,7 @@ void QmlPlayerBridge::resetShortcuts() {
const auto previous = impl_->prefs;
impl_->prefs.remove("shortcuts");
if (!impl_->savePrefs()) { impl_->prefs = previous; return; }
- impl_->game.setHotkeys(ui::gameKey(QKeySequence("Home")),ui::gameKey(QKeySequence("Ctrl+Alt+Home")));
+ applyGameHotkeys();
emit preferencesChanged();
}
bool QmlPlayerBridge::obsGameCaptureActive() const { return qApp && qApp->property("veyraObsGameCapture").toBool(); }
diff --git a/tests/integration/GamePassthroughTests.cpp b/tests/integration/GamePassthroughTests.cpp
index 7ba8c1cb..8e889ff0 100644
--- a/tests/integration/GamePassthroughTests.cpp
+++ b/tests/integration/GamePassthroughTests.cpp
@@ -99,6 +99,12 @@ int main(int argc,char** argv){
GameKeyState changed;changed.input(VK_F9,true,{VK_F9,0},{VK_F10,3},false);
changed.input(VK_F9,false,{VK_F8,0},{VK_F10,3},false);
check(changed.input(VK_F9,true,{VK_F9,0},{VK_F10,3},true).action==0,"released old binding does not stay latched after rebinding");
+ GameKeyState capture;const GameKey shot{VK_F7,0},record{VK_F8,0};
+ auto press=[&](unsigned vk,bool down,bool owned=true){return capture.input(vk,down,panel,exit,owned,shot,record);};
+ check(press(VK_F7,true).action==2&&press(VK_F7,true).action<0&&press(VK_F7,false).consume,"F7 screenshot fires once per press, release paired");
+ check(press(VK_F8,true).action==3&&press(VK_F8,false).consume,"F8 toggles recording");
+ check(!press(VK_F7,true,false).consume&&!press(VK_F7,false,false).consume,"other programs keep F7 and F8");
+ check(capture.input(VK_F7,true,panel,exit,true).action<0,"unbound screenshot key passes through");
const HWND previous=GetForegroundWindow();
WNDCLASSW wc{};wc.lpfnWndProc=proc;wc.hInstance=GetModuleHandleW(nullptr);wc.lpszClassName=L"VeyraGameHotkeyTest";RegisterClassW(&wc);