Skip to content

Refactor Gamescope protection and enhance surface recovery#29

Merged
perditavojo merged 5 commits into
mainfrom
dev
Apr 25, 2026
Merged

Refactor Gamescope protection and enhance surface recovery#29
perditavojo merged 5 commits into
mainfrom
dev

Conversation

@perditavojo
Copy link
Copy Markdown
Contributor

This pull request introduces several improvements and clarifications to both the documentation and codebase, focusing on enhanced compatibility and user experience in Steam Deck's Gamescope (game mode) and Wine/Proton environments. The most significant changes are the addition of a universal controller-based "surface recovery" feature for Gamescope, expanded and clarified documentation for Steam Deck/GameInput/XInput behavior, and improved handling of the on-screen keyboard in non-native Windows environments.

Gamescope (Steam Deck game mode) compatibility and recovery:

  • Added a controller chord (LB+RB+Y/△/X) as a universal "surface recovery" action in dialogs (GamepadCalibrationDialog, GamepadMessageBox, HelpDialog, NumericInputDialog, PhraseEditDialog, PhraseManagerDialog), allowing users to recover from black screens or focus loss in Gamescope. This is implemented via the GamescopeSurfaceRecovery.TryRecoverFromGamepadChord method, with appropriate event handler wiring/unwiring and context-specific logic. ([[1]](https://github.com/rubujo/InputBox/pull/29/files#diff-ec0b2eab913526b05b01e1bc13e1d49256932b592834cc854d40e56874d7ea97R514), [[2]](https://github.com/rubujo/InputBox/pull/29/files#diff-ec0b2eab913526b05b01e1bc13e1d49256932b592834cc854d40e56874d7ea97R544), [[3]](https://github.com/rubujo/InputBox/pull/29/files#diff-ec0b2eab913526b05b01e1bc13e1d49256932b592834cc854d40e56874d7ea97R659-R670), [[4]](https://github.com/rubujo/InputBox/pull/29/files#diff-ded05d10f195020a0116241ecede9d965d4989514ec91764db0241a7e04f9feaR88), [[5]](https://github.com/rubujo/InputBox/pull/29/files#diff-ded05d10f195020a0116241ecede9d965d4989514ec91764db0241a7e04f9feaR114), [[6]](https://github.com/rubujo/InputBox/pull/29/files#diff-ded05d10f195020a0116241ecede9d965d4989514ec91764db0241a7e04f9feaR999-R1010), [[7]](https://github.com/rubujo/InputBox/pull/29/files#diff-96aa356a51a255d0d2c1ea1c94ea1f070aaddbbb2883e04423d6bda5113b60dcR897), [[8]](https://github.com/rubujo/InputBox/pull/29/files#diff-96aa356a51a255d0d2c1ea1c94ea1f070aaddbbb2883e04423d6bda5113b60dcR923), [[9]](https://github.com/rubujo/InputBox/pull/29/files#diff-96aa356a51a255d0d2c1ea1c94ea1f070aaddbbb2883e04423d6bda5113b60dcR1043-R1054), [[10]](https://github.com/rubujo/InputBox/pull/29/files#diff-0bb8bf3c2427f191da721d7255a9fb0b67df241ea5633977e8ce574879528f9dR1054-R1062), [[11]](https://github.com/rubujo/InputBox/pull/29/files#diff-f7d7e17bf37dcc41786388bfaf2db0af0fd2bef102c4540ca40562f97f4c30c4R1627-R1636), [[12]](https://github.com/rubujo/InputBox/pull/29/files#diff-f7d7e17bf37dcc41786388bfaf2db0af0fd2bef102c4540ca40562f97f4c30c4R1661-R1668), [[13]](https://github.com/rubujo/InputBox/pull/29/files#diff-97f37bafd8fa98f9e4632654f13e2272b5e0c66d1e8c1bf3c965f070c77868d2R1264-R1272))
  • Removed the previous interception logic in GamepadMessageBox that blocked dialog display in Gamescope, now allowing dialogs to show with the new recovery mechanism. ([src/InputBox/Core/Controls/GamepadMessageBox.csL1122-L1146](https://github.com/rubujo/InputBox/pull/29/files#diff-ded05d10f195020a0116241ecede9d965d4989514ec91764db0241a7e04f9feaL1122-L1146))

Documentation updates (README):

  • Expanded and clarified the Gamescope/Steam Deck section, explaining full-screen behavior, feature limitations (e.g., transparency, audio cues, A11y broadcast), and new recovery actions for black screens or focus loss. Also added troubleshooting steps and locale configuration examples for Steam Deck/SteamOS. ([[1]](https://github.com/rubujo/InputBox/pull/29/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L65-R78), [[2]](https://github.com/rubujo/InputBox/pull/29/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L419-R474))
  • Clarified the behavior of controller face button mapping in "Auto" mode: when using XInput, device type cannot be detected, so Xbox mapping is always used. This is now consistently documented in all relevant sections, including settings and UI descriptions. ([[1]](https://github.com/rubujo/InputBox/pull/29/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L134-R129), [[2]](https://github.com/rubujo/InputBox/pull/29/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L256-R251), [[3]](https://github.com/rubujo/InputBox/pull/29/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L310-R305))

Steam Deck/Wine/Proton on-screen keyboard handling:

  • Improved TouchKeyboardService to prioritize the Steam virtual keyboard via URI scheme when running under Wine/Proton or Gamescope, falling back to Windows-native methods only if not in those environments. ([src/InputBox/Core/Services/TouchKeyboardService.csL75-R94](https://github.com/rubujo/InputBox/pull/29/files#diff-a4cbf09e449988eb40201e014a23807ff9684bffb351cbfbd702dbc63460cf51L75-R94))

Codebase cleanup:

  • Removed the restrictHighRiskShortcuts parameter and related logic from CmdKeyDispatcher.TryHandleGlobal, simplifying shortcut handling. ([[1]](https://github.com/rubujo/InputBox/pull/29/files#diff-311eacec8ba8e00bc15e4982f2185f3181b88d8404da65f4ce2e0b11e9516158L102), [[2]](https://github.com/rubujo/InputBox/pull/29/files#diff-311eacec8ba8e00bc15e4982f2185f3181b88d8404da65f4ce2e0b11e9516158L113-L127))

Gamescope/Steam Deck compatibility and recovery:

  • Added controller-based surface recovery (LB+RB+Y/△/X) for all major dialogs, with event handler integration and context-specific logic. ([[1]](https://github.com/rubujo/InputBox/pull/29/files#diff-ec0b2eab913526b05b01e1bc13e1d49256932b592834cc854d40e56874d7ea97R514), [[2]](https://github.com/rubujo/InputBox/pull/29/files#diff-ec0b2eab913526b05b01e1bc13e1d49256932b592834cc854d40e56874d7ea97R544), [[3]](https://github.com/rubujo/InputBox/pull/29/files#diff-ec0b2eab913526b05b01e1bc13e1d49256932b592834cc854d40e56874d7ea97R659-R670), [[4]](https://github.com/rubujo/InputBox/pull/29/files#diff-ded05d10f195020a0116241ecede9d965d4989514ec91764db0241a7e04f9feaR88), [[5]](https://github.com/rubujo/InputBox/pull/29/files#diff-ded05d10f195020a0116241ecede9d965d4989514ec91764db0241a7e04f9feaR114), [[6]](https://github.com/rubujo/InputBox/pull/29/files#diff-ded05d10f195020a0116241ecede9d965d4989514ec91764db0241a7e04f9feaR999-R1010), [[7]](https://github.com/rubujo/InputBox/pull/29/files#diff-96aa356a51a255d0d2c1ea1c94ea1f070aaddbbb2883e04423d6bda5113b60dcR897), [[8]](https://github.com/rubujo/InputBox/pull/29/files#diff-96aa356a51a255d0d2c1ea1c94ea1f070aaddbbb2883e04423d6bda5113b60dcR923), [[9]](https://github.com/rubujo/InputBox/pull/29/files#diff-96aa356a51a255d0d2c1ea1c94ea1f070aaddbbb2883e04423d6bda5113b60dcR1043-R1054), [[10]](https://github.com/rubujo/InputBox/pull/29/files#diff-0bb8bf3c2427f191da721d7255a9fb0b67df241ea5633977e8ce574879528f9dR1054-R1062), [[11]](https://github.com/rubujo/InputBox/pull/29/files#diff-f7d7e17bf37dcc41786388bfaf2db0af0fd2bef102c4540ca40562f97f4c30c4R1627-R1636), [[12]](https://github.com/rubujo/InputBox/pull/29/files#diff-f7d7e17bf37dcc41786388bfaf2db0af0fd2bef102c4540ca40562f97f4c30c4R1661-R1668), [[13]](https://github.com/rubujo/InputBox/pull/29/files#diff-97f37bafd8fa98f9e4632654f13e2272b5e0c66d1e8c1bf3c965f070c77868d2R1264-R1272))
  • Removed dialog interception logic in Gamescope, enabling dialogs to show with new recovery support. ([src/InputBox/Core/Controls/GamepadMessageBox.csL1122-L1146](https://github.com/rubujo/InputBox/pull/29/files#diff-ded05d10f195020a0116241ecede9d965d4989514ec91764db0241a7e04f9feaL1122-L1146))

Documentation improvements:

  • Expanded README with detailed Gamescope/Steam Deck usage, limitations, troubleshooting, and locale configuration. ([[1]](https://github.com/rubujo/InputBox/pull/29/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L65-R78), [[2]](https://github.com/rubujo/InputBox/pull/29/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L419-R474))
  • Clarified controller mapping behavior for XInput and GameInput in both settings and feature descriptions. ([[1]](https://github.com/rubujo/InputBox/pull/29/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L134-R129), [[2]](https://github.com/rubujo/InputBox/pull/29/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L256-R251), [[3]](https://github.com/rubujo/InputBox/pull/29/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L310-R305))

Wine/Proton/Steam Deck keyboard handling:

  • On-screen keyboard now prioritizes Steam virtual keyboard in Wine/Proton or Gamescope environments. ([src/InputBox/Core/Services/TouchKeyboardService.csL75-R94](https://github.com/rubujo/InputBox/pull/29/files#diff-a4cbf09e449988eb40201e014a23807ff9684bffb351cbfbd702dbc63460cf51L75-R94))

Codebase cleanup:

  • Removed obsolete restrictHighRiskShortcuts logic from command key dispatcher. ([[1]](https://github.com/rubujo/InputBox/pull/29/files#diff-311eacec8ba8e00bc15e4982f2185f3181b88d8404da65f4ce2e0b11e9516158L102), [[2]](https://github.com/rubujo/InputBox/pull/29/files#diff-311eacec8ba8e00bc15e4982f2185f3181b88d8404da65f4ce2e0b11e9516158L113-L127))

perditavojo and others added 3 commits April 24, 2026 08:01
收斂 Gamescope 下的返回前景視窗與右鍵選單防護,將重複判斷集中到共用入口。

同步調整 Wine/Proton 觸控鍵盤分流與 CmdKeyDispatcher 測試,確保核心輸入、OSK 與剪貼簿流程仍維持非自動化、非模擬、非注入邊界。
移除 Gamescope 與 Wine/Proton 下非必要的功能攔截,保留滿版與 OSK 相關行為。

新增 Gamescope surface recovery 流程,讓 MainForm 與控制器支援的 Dialog 可透過救援組合鍵重建 HWND。

補齊恢復選單多語系文字,並修正英文視窗操作選單助記鍵顯示。
更新 Gamescope 模式描述,移除過時的功能限制清單,改以環境限制
角度說明透明度、音效、A11y 廣播的實際行為,並補充畫面恢復的
操作說明與使用警語。

新增疑難排解第 5 至 11 項,涵蓋 Gamescope 焦點失效的兩種情境
與對應解法(含新增的控制器救援組合鍵)、休眠後 OSK 失效、透明
度與音效無效、A11y 廣播無作用、Proton 版本問題,以及 SteamOS 3
語系設定說明(含支援語系對照表與 locale -a 確認步驟)。

將注意事項中的操作性內容移至疑難排解;補充控制器主按鍵配置在
XInput 下自動模式一律套用 Xbox 配置的說明(三處)。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 25, 2026 13:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors Gamescope (Steam Deck game mode) protections by replacing prior “intercept/disable” behavior with a universal surface-recovery mechanism, updates related UX/docs, and simplifies global shortcut handling.

Changes:

  • Added a shared Gamescope surface recovery helper and wired controller-chord recovery (LB+RB+North/Y) into multiple dialogs and the main window, plus a Gamescope-only context menu recovery item.
  • Simplified global shortcut dispatch by removing the “restrictHighRiskShortcuts” path and updating callers/tests accordingly.
  • Updated documentation and localization resources (README and new menu strings), and adjusted touch keyboard strategy to prefer Steam OSK under Wine/Gamescope.

Reviewed changes

Copilot reviewed 27 out of 28 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
README.md Expanded/clarified Steam Deck Gamescope behavior, limitations, and recovery/troubleshooting steps.
src/InputBox/Core/Utilities/GamescopeSurfaceRecovery.cs New shared helper to rebuild WinForms top-level surfaces in Gamescope via controller chord.
src/InputBox/MainForm.ContextMenu.cs Adds Gamescope recovery context-menu item; implements main surface recovery flow and refactors context-menu show logic.
src/InputBox/MainForm.Gamepad.cs Adds controller chord handling to recover the main surface in Gamescope; removes shortcut restriction branches.
src/InputBox/Core/Controls/HelpDialog.cs Wires Y/North button to Gamescope surface recovery.
src/InputBox/Core/Controls/GamepadMessageBox.cs Removes Gamescope interception and adds Y/North recovery handling.
src/InputBox/Core/Controls/GamepadCalibrationDialog.cs Adds Y/North recovery handling.
src/InputBox/Core/Controls/NumericInputDialog.cs Adds recovery-chord check in gamepad action handler.
src/InputBox/Core/Controls/PhraseEditDialog.cs Adds recovery-chord check and closes active textbox context menu before recovery.
src/InputBox/Core/Controls/PhraseManagerDialog.cs Adds recovery-chord check in gamepad action handler.
src/InputBox/Core/Services/TouchKeyboardService.cs Prioritizes Steam virtual keyboard URI under Wine/Gamescope before Windows-native approaches.
src/InputBox/Core/Services/CmdKeyDispatcher.cs Removes restrictHighRiskShortcuts parameter and related logic.
src/InputBox/MainForm.cs Updates global command-key dispatch call to match simplified dispatcher API.
src/InputBox/MainForm.Events.cs Removes Gamescope-specific interception for Help and copy/return behavior; delegates OSK selection to TouchKeyboardService.
src/InputBox/Program.cs Removes Wine locale bootstrapper invocation at startup.
src/InputBox/Core/Utilities/WineLocaleBootstrapper.cs Deletes Wine locale bootstrapper implementation.
tests/InputBox.Tests/WineLocaleBootstrapperTests.cs Deletes unit tests tied to removed Wine locale bootstrapper.
tests/InputBox.Tests/CmdKeyDispatcherTests.cs Adds/updates tests for the simplified global shortcut dispatcher behavior.
tests/InputBox.Tests/README.md Updates test inventory to reflect removed/added tests.
src/InputBox/Core/Utilities/SystemHelper.cs Removes high-risk shortcut restriction helper methods.
src/InputBox/Resources/Strings.resx Adds Gamescope recovery menu strings; adjusts one menu label.
src/InputBox/Resources/Strings.Designer.cs Regenerated to include new resource keys/updated string comment.
src/InputBox/Resources/Strings.zh-Hant.resx Adds localized Gamescope recovery menu strings.
src/InputBox/Resources/Strings.zh-Hans.resx Adds localized Gamescope recovery menu strings.
src/InputBox/Resources/Strings.ja.resx Adds localized Gamescope recovery menu strings.
src/InputBox/Resources/Strings.ko.resx Adds localized Gamescope recovery menu strings.
src/InputBox/Resources/Strings.fr.resx Adds localized Gamescope recovery menu strings.
src/InputBox/Resources/Strings.de.resx Adds localized Gamescope recovery menu strings.
Files not reviewed (1)
  • src/InputBox/Resources/Strings.Designer.cs: Language not supported

Comment thread tests/InputBox.Tests/README.md
perditavojo and others added 2 commits April 25, 2026 21:50
磁碟 I/O(LoggerService.LogException)原先在 onException 回呼之前執行,
在 CI 環境下可能超過 300 ms,導致測試在計時器到期後 captured 仍為 null。

將回呼呼叫移至 I/O 之前,並將測試改為以 TaskCompletionSource 等待
回呼觸發,取代固定的 Task.Delay(300),消除計時依賴。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
README 表格漏掉 SystemHelperTests(11 個測試),導致列加總只有 353,
與實際 dotnet test 回報的 total: 364(353 通過 + 11 略過的 UI smoke)不符。

補上該列並將合計從 353 改回 364。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@perditavojo perditavojo merged commit d32372c into main Apr 25, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants