Skip to content

Add gamepad calibration visualization and reset functionality#15

Merged
perditavojo merged 9 commits into
mainfrom
dev
Apr 18, 2026
Merged

Add gamepad calibration visualization and reset functionality#15
perditavojo merged 9 commits into
mainfrom
dev

Conversation

@perditavojo
Copy link
Copy Markdown
Contributor

This pull request introduces several enhancements and clarifications to InputBox, focusing on controller calibration visualization, accessibility, settings, and compliance with GPG signing requirements. The most significant changes are grouped below:


1. Controller Calibration Visualization and Diagnostics

  • Added a new GamepadCalibrationVisualizerMapper utility for coordinate and deadzone calculations to support controller calibration visualization. (src/InputBox/Core/Controls/GamepadCalibrationVisualizerMapper.cs)
  • Enhanced GameInputGamepadController to maintain and update a real-time calibration snapshot, exposing it for visualization and diagnostics. (src/InputBox/Core/Input/GameInputGamepadController.cs) [1] [2] [3] [4] [5] [6] [7] [8]
  • Updated documentation and UI to introduce a "校正狀態視覺化" (calibration visualization) feature, including detailed explanations and instructions for interpreting joystick diagnostics. (README.md) [1] [2]

2. Settings and User Experience

  • Added a new "返回時最小化" (Minimize on Return) setting to automatically minimize the input box window when returning to the previous window, with documentation and UI integration. (README.md) [1] [2]
  • Improved vibration feedback patterns for toggling settings, providing distinct confirmation pulses for enabling/disabling options. (src/InputBox/Core/Feedback/VibrationPatterns.cs)

3. Accessibility and UI Robustness

  • Improved DPI change handling in PhraseEditDialog, ensuring fonts and accessibility feedback are updated correctly and robustly on DPI changes. (src/InputBox/Core/Controls/PhraseEditDialog.cs)
  • Clarified and corrected comments and documentation for better code readability, including accessibility-related method summaries. (src/InputBox/Core/Controls/PhraseEditDialog.cs, src/InputBox/Core/Extensions/ControlExtensions.cs) (Fd9478a4L8R8, [1] [2] [3]

4. GPG Signing and Compliance Policy Updates

  • Strengthened GPG signing requirements across documentation and project guidelines: agents must use the user's existing GPG configuration, must not modify any GPG-related config files, and must prompt users to resolve signing issues themselves rather than bypassing or auto-modifying configs. (docs/engineering/git-commit-safety.md, .github/copilot-instructions.md, .agents/skills/inputbox-dev/SKILL.md, GEMINI.md) [1] [2] [3] [4]

5. Minor UI and Documentation Tweaks

  • Updated button layout and parameter documentation in GamepadMessageBox. (src/InputBox/Core/Controls/GamepadMessageBox.cs)
  • Minor code cleanup and typo corrections. (src/InputBox/Core/Controls/PhraseEditDialog.cs) (Fd9478a4L8R8)

These changes collectively improve controller usability, diagnostics, accessibility, user feedback, and ensure strict compliance with security and signing standards.

- 新增 GamepadCalibrationDialog 即時診斷視窗,以 30fps 顯示雙搖桿(LS/RS)
  的原始輸入點(空心菱形)、校正後位置(藍點)、死區進入閾值(實線環)
  與死區離開閾值(虛線環),兩環間的遲滯區防止邊界抖動
- 新增 GamepadCalibrationSnapshot record 封裝單次快照資料
- 新增 GamepadCalibrationVisualizerMapper 負責死區半徑計算與畫布座標轉換
- 擴充 IGamepadController 介面新增 GetCalibrationSnapshot() 與 ResetCalibration()
- XInputGamepadController 與 GameInputGamepadController 實作 EMA 偏移學習、
  D-Pad 防污染暫停機制與 ResetCalibration() 清除執行期偏移值
- 從右鍵選單「遊戲控制器調校」子選單整合「校正狀態視覺化…」開啟入口
  及「重設目前校正狀態」功能(含震動回饋)
- 補齊 7 語系(EN、zh-Hant、zh-Hans、de、fr、ja、ko)的視覺化相關在地化字串
- 新增 GamepadCalibrationVisualizerMapperTests(9 個測試)並同步更新
  介面測試替身以符合擴充後的 IGamepadController 簽章
- 更新 README.md 補充校正狀態視覺化的四元素判讀說明
- 統一對話框 DPI 與字型更新流程。
- 為設定切換加入震動回饋與迴歸測試。
- 補充 README 與 XML 文件註解並清除建置警告。
- HandleSurfacePaint: compute float s = DeviceDpi / AppSettings.BaseDpi;
  scale all Pen widths by s (outerPen 2x2s, crossPen 1x1.5s, deadzonePen
  2x2.5s, deadzoneExitPen 1.5x2s, rawPen 2x2.5s, correctedOutlinePen 1.5x2s)
  so strokes remain visible and proportional on high-DPI displays.

- Deadzone fill alpha raised 22 to 48 (HighContrast 36 to 60); raw-dot alpha
  raised 40 to 64 (HighContrast 80 to 100) so both rings are perceptible at
  96 DPI and within accessible contrast limits on white backgrounds.

- DrawStickPlot: all fixed-pixel marker geometry scaled by dpiScale; center
  dot radius 3 to 3s, raw diamond half-size 8 to 8s, corrected dot radius
  6 to 6s.

- ShouldHandleDirectionalFocusNavigation: fix LS-triggered focus-jump bug.
  ApplyStickToButtons maps LS to D-Pad bits when correctedLeftThumb crosses
  ThumbDeadzoneEnter (~0.24 normalised). The previous guard threshold was
  normalizedDeadzone+0.02 (~0.26), which is larger than the mapping threshold,
  so the guard incorrectly passed when LS just triggered the mapping. Changed
  to normalizedDeadzone*0.75 (clamped 0.06-0.18) so any LS position that
  activates stick-to-D-Pad mapping is already outside the guard range.

- Add test ShouldHandleDirectionalFocusNavigation_WhenStickJustCrossesEnterDeadzone_ReturnsFalse
  covering the ThumbDeadzoneEnter=7849 edge case (LS at -0.24 must return false).
zh-Hant: 死區進入/離開 -> 死區進入/離開;數值分隔 {8}/{9} -> {8}/{9}
zh-Hans: 死区进入/离开 -> 死区进入/离开;數值分隔 {8}/{9} -> {8}/{9}
ja: デッドゾーン入/出 -> デッドゾーン入/出;數值分隔 {8}/{9} -> {8}/{9}

CJK 排版規範要求連接詞「/」使用全形 U+FF0F(/);
英文、德文、法文、韓文維持半形不變。
同步更新 Copilot、Gemini 與技能文件,明確要求 Agent 只能使用使用者既有的 GPG 設定。

禁止自行修改 gpg.conf、gpg-agent.conf 等設定檔,且簽章失敗時必須提醒使用者自行處理。
Copilot AI review requested due to automatic review settings April 18, 2026 14:29
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

This PR adds a live gamepad calibration visualizer to InputBox, including controller-side snapshot plumbing to support diagnostics UI, plus UX/accessibility improvements, updated vibration semantics, and tightened documentation around GPG-signing compliance.

Changes:

  • Introduces a new calibration visualizer dialog + mapper utilities, and exposes a live CurrentCalibrationSnapshot on gamepad controllers for diagnostics.
  • Adds new vibration patterns for setting toggles and expands test coverage for the new semantics and calibration mapping/formatting helpers.
  • Updates localized resources, README/docs, and engineering guidance for stricter GPG-signing compliance wording.

Reviewed changes

Copilot reviewed 35 out of 36 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/InputBox.Tests/VibrationPatternsTests.cs Adds assertions for new setting-toggle vibration semantics; updates stubs for the new controller snapshot API.
tests/InputBox.Tests/README.md Updates test inventory to include calibration visualizer mapper tests and adjusts totals.
tests/InputBox.Tests/PhraseManagerDialogGamepadTests.cs Updates stub controller to implement CurrentCalibrationSnapshot.
tests/InputBox.Tests/GamepadMessageBoxTests.cs Updates stub controller to implement CurrentCalibrationSnapshot.
tests/InputBox.Tests/GamepadEventBinderTests.cs Updates stub controller to implement CurrentCalibrationSnapshot.
tests/InputBox.Tests/GamepadCalibrationVisualizerMapperTests.cs Adds regression tests for mapper clamping/deadzone math and dialog formatting/navigation guards.
src/InputBox/Resources/Strings.zh-Hant.resx Adds menu/dialog/a11y strings for the calibration visualizer (Traditional Chinese).
src/InputBox/Resources/Strings.zh-Hans.resx Adds menu/dialog/a11y strings for the calibration visualizer (Simplified Chinese).
src/InputBox/Resources/Strings.resx Adds menu/dialog/a11y strings for the calibration visualizer (English).
src/InputBox/Resources/Strings.ko.resx Adds menu/dialog/a11y strings for the calibration visualizer (Korean).
src/InputBox/Resources/Strings.ja.resx Adds menu/dialog/a11y strings for the calibration visualizer (Japanese).
src/InputBox/Resources/Strings.fr.resx Adds menu/dialog/a11y strings for the calibration visualizer (French).
src/InputBox/Resources/Strings.de.resx Adds menu/dialog/a11y strings for the calibration visualizer (German).
src/InputBox/Resources/Strings.Designer.cs Regenerates resource accessors for newly added strings.
src/InputBox/MainForm.cs Adds/clarifies XML doc comments on lifecycle/window message handlers.
src/InputBox/MainForm.Events.cs Adds ShowGamepadCalibrationDialog() entry point to open the visualizer dialog.
src/InputBox/MainForm.ContextMenu.cs Adds menu item to open calibration visualizer; adds setting-toggle vibration feedback for several toggles.
src/InputBox/MainForm.A11y.cs Adds/clarifies partial-class summary for the a11y-focused MainForm partial.
src/InputBox/Core/Services/WindowNavigationService.cs Updates method documentation to reflect cancellation token usage.
src/InputBox/Core/Services/PhraseService.cs Fixes parameter documentation for temp-file naming/validation helper.
src/InputBox/Core/Services/ContextMenuBuilder.cs Updates XML docs to include a restart item accessible description parameter.
src/InputBox/Core/Input/XInputGamepadController.cs Adds live calibration snapshot tracking for visualization.
src/InputBox/Core/Input/IGamepadController.cs Extends controller interface with CurrentCalibrationSnapshot.
src/InputBox/Core/Input/GamepadCalibrationSnapshot.cs Adds the immutable snapshot type consumed by the visualizer and other diagnostics.
src/InputBox/Core/Input/GameInputGamepadController.cs Adds live calibration snapshot tracking and updates it during polling/disconnect/reset paths.
src/InputBox/Core/Feedback/VibrationPatterns.cs Adds SettingToggleOn/SettingToggleOff vibration profiles; documents global intensity multiplier.
src/InputBox/Core/Extensions/ControlExtensions.cs Updates parameter documentation for dwell animation helper.
src/InputBox/Core/Controls/PhraseEditDialog.cs Improves DPI-change handling to refresh shared fonts and eye-tracker feedback reliably.
src/InputBox/Core/Controls/GamepadMessageBox.cs Removes stale XML doc param line in button-building helper docs.
src/InputBox/Core/Controls/GamepadCalibrationVisualizerMapper.cs Adds helper for normalization clamping, deadzone radius conversion, and canvas mapping.
src/InputBox/Core/Controls/GamepadCalibrationDialog.cs Adds the new calibration visualizer dialog UI, painting logic, a11y announcements, and controller navigation guards.
docs/engineering/git-commit-safety.md Tightens policy wording: agents must not modify GPG config and must rely on user’s existing signing setup.
README.md Documents calibration visualizer feature and the new “Minimize on Return” setting; expands calibration explanation.
GEMINI.md Updates safety boundary text regarding GPG signing configuration constraints.
.github/copilot-instructions.md Updates Copilot-specific guidance to match the stricter GPG signing constraints.
.agents/skills/inputbox-dev/SKILL.md Updates the skill’s GPG-signing requirement wording to forbid agent-driven config changes.
Files not reviewed (1)
  • src/InputBox/Resources/Strings.Designer.cs: Language not supported

Comment thread src/InputBox/Resources/Strings.zh-Hans.resx
Comment thread src/InputBox/Resources/Strings.resx Outdated
Comment thread src/InputBox/Core/Input/GameInputGamepadController.cs Outdated
Comment thread src/InputBox/Core/Input/XInputGamepadController.cs Outdated
Comment thread src/InputBox/Core/Input/GameInputGamepadController.cs
Comment thread src/InputBox/Resources/Strings.zh-Hant.resx
perditavojo and others added 3 commits April 18, 2026 22:36
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: perditavojo <117562794+perditavojo@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: perditavojo <117562794+perditavojo@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: perditavojo <117562794+perditavojo@users.noreply.github.com>
@perditavojo
Copy link
Copy Markdown
Contributor Author

@copilot apply changes based on the comments in this thread

…tion snapshot update

Agent-Logs-Url: https://github.com/rubujo/InputBox/sessions/e2f2ea31-1f92-470b-b364-3cfbb9dd5c31

Co-authored-by: perditavojo <117562794+perditavojo@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 18, 2026

@copilot apply changes based on the comments in this thread

Applied all three unresolved changes in commit c48bc8a:

  1. zh-Hans.resx: Replaced the Japanese character "値" with the correct Simplified Chinese "值" in both Dialog_GamepadCalibrationVisualizer_Desc and Canvas_Desc ("阈値" → "阈值").
  2. zh-Hant.resx: Same fix for Traditional Chinese — "閾値" → "閾值" in both entries.
  3. GameInputGamepadController.cs: Removed the redundant UpdateCalibrationSnapshot(latestSnapshot, config, true) call after the dequeue loop. The while loop already called it for every processed state (including the last one), so the post-loop call was creating an extra GamepadCalibrationSnapshot allocation per tick with no behavioral benefit.

@perditavojo perditavojo merged commit 9b3e2cc into main Apr 18, 2026
7 of 8 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.

3 participants