feat(input): weapon selection via number keys (1-8 -> impulse) - #23
Merged
Conversation
The number keys were never decoded, so the player was stuck on whatever weapon spawned. Wire the full path: - backend: add Key1..Key8 KeyCodes + ImpulseForKey (Key1..Key8 -> 1..8). - backend/wasm + backend/wasmbox keymaps: map DOM "Digit1".."Digit8". - runloop: a Key1..Key8 down-edge queues a one-shot PendingImpulse, fed into client.TickInput.Impulse and cleared after the tic (edge-triggered, so a held key doesn't re-switch every frame). Gated off while the menu or console has focus. The impulse rides clc_move -> the QC ImpulseCommands runs it as W_ChangeWeapon (host already writes self.impulse to the edict). Verified in-browser (Firefox/Playwright, lq_e0m1): Digit1 -> weapon=4096 (IT_AXE, 0 ammo), Digit2 -> weapon=1 (IT_SHOTGUN, 25 shells), switching both ways. 100% coverage held on backend / backend/wasm / backend/wasmbox (new ImpulseForKey test + Digit rows in both keymap tables). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The number keys were never decoded, so the player was stuck on whatever weapon spawned (the shotgun in lq_e0m1). Wire the full path:
Key1..Key8KeyCodes +ImpulseForKey(Key1..Key8 -> 1..8)."Digit1".."Digit8".Key1..Key8down-edge queues a one-shotPendingImpulse, fed intoclient.TickInput.Impulseand cleared after the tic (edge-triggered — a held key doesn't re-switch every frame). Gated off while the menu/console has focus. The impulse ridesclc_move→ the QCImpulseCommandsrunsW_ChangeWeapon(the host already writesself.impulseto the edict).Verification (Firefox/Playwright, lq_e0m1)
Digit1→weapon=4096(IT_AXE, 0 ammo)Digit2→weapon=1(IT_SHOTGUN, 25 shells)Switches both ways. 100% coverage held on
backend/backend/wasm/backend/wasmbox(newImpulseForKeytest +Digitrows in both keymap tables).🤖 Generated with Claude Code