Skip to content

Fix keyboard scancode mapping for GFN input translation#301

Merged
zortos293 merged 4 commits intodevfrom
capy/fix-keyboard-scancode-mapping
Apr 14, 2026
Merged

Fix keyboard scancode mapping for GFN input translation#301
zortos293 merged 4 commits intodevfrom
capy/fix-keyboard-scancode-mapping

Conversation

@zortos293
Copy link
Copy Markdown
Collaborator

@zortos293 zortos293 commented Apr 14, 2026

This PR fixes broken keyboard behavior across layouts by replacing the incorrect USB HID usage ID mappings with Windows Set-1 scancodes required by the GFN input protocol.

src/renderer/src/gfn/inputProtocol.ts:

  • Replaced codeMap with correct Windows Set-1/extended scancodes for letters (A–Z), digits, punctuation, navigation, and function keys.
  • Added mappings for international physical keys (IntlBackslash, IntlRo, IntlYen) to support non-US layouts.
  • Consolidated synthetic text injection (mapTextCharToKeySpec) and keyboard event mapping (mapKeyboardEvent) to use the shared codeMap, ensuring consistent scancodes for pasted text and physical presses.
  • Fixed numpad (e.g., NumLock, Numpad0) and modifier (e.g., ShiftLeft/Right) scancodes to match Windows scan code set 1.

src/renderer/src/gfn/webrtcClient.ts:

  • Updated AFK pulse (sendAntiAfkPulse), paste shortcuts (sendPasteShortcut), and shift handling in sendText to reference the shared codeMap instead of hardcoded values.

Tests & Tooling:

  • Added src/renderer/src/gfn/inputProtocol.test.ts with coverage for representative keys (KeyN, KeyT, KeyZ, Escape, IntlBackslash, numpad) and verifying code-over-key precedence.
  • Added tsx dependency to devDependencies and created npm run test script.

Open in Capy OPE-61 · 5.4

@zortos293 zortos293 added the capy Generated by capy.ai label Apr 14, 2026 — with Capy AI
zortos293 and others added 3 commits April 14, 2026 08:18
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@zortos293 zortos293 merged commit 1047d43 into dev Apr 14, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

capy Generated by capy.ai

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant