input(macos): add PS/2 scan codes, full keyboard/modifier mapping, and NSEvent tests #9
No reviewers
Labels
No labels
accessibility
bug
claimed
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
tester report
urgent
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LakshanSivakumar--Native-Victory-macOS!9
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/9/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@claytonblythe on GitHub · 2026-11-26 08:44 UTC · original
claytonblythe:feat/macos-live-keyboard→main· +310 −16 · 2 files · 2 commits · merged 2026-11-26 09:03 UTCWhat this changes
Rebased onto
main(c96c82a, afternative/keyboardlanded). Extends live macOS keyboard input (#1) with:crates/victory-hle/src/modules/gameinput.rs): PopulatesKeyState::scan_code(including0xE0extended prefixes matchingMapVirtualKeyW(..., MAPVK_VK_TO_VSC_EX)) instead of leavingscan_code: 0.apps/victory/src/window.rs): Maps remaining alphanumeric keys, digits0–9, F1–F12, Home/End/PageUp/PageDown/Forward Delete, punctuation, andNSEventTypeFlagsChangedL/R Shift/Control/Option modifiers.real_nsevents_update_live_keys_and_ignore_non_key_events: exerciseskey_eventwith real synthetic AppKitNSEventobjects (KeyDown,KeyUp,Cmd+Q,FlagsChanged, andNSApplicationDefinednon-key events soc96c82acannot regress).live_keys_report_ps2_scan_codes_through_hub_readings: exercisesset_live_key->Hub::poll()->IGameInput::GetCurrentReadingfor bothKEYBOARD_KIND(verifyingscan_code) andGAMEPAD_KIND(FALLBACK).How it was tested
cargo test --target x86_64-apple-darwin -p victory window(2/2 passed, including realNSEventtest)cargo test --target x86_64-apple-darwin -p victory-hle gameinput(10/10 passed, including COMHubscan-code test)cargo xtask policy(356 files ok)cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings(0 warnings)NSEventobjects and theGameInputCOMHub)Checklist
VICTORY_*variable and documented (N/A)@LakshanSivakumar on GitHub · 2026-11-26 08:47 UTC · original
Thanks for this, it's careful work: reading the event type before
keyCode, the modifier handling and the realNSEventtests are all good.I'm not merging it as is, though. While it was open, live keyboard input landed on
main(c96c82a) in the same two files, so this PR now conflicts, and much of it duplicates what's there. It also hasn't been run against the game yet, and CI hasn't run on it.The parts of yours that
maindoesn't have are worth keeping: the GameInput keyboard device (scan codes viavk_to_scan_code) andFlagsChangedfor Shift/Control/Option. If you'd like, rebase ontomainand keep only those, on top of the existing key mapping (Enter/Space = A, Esc/Backspace = B, Tab = Menu, see the README), and I'll review it again.What would help most next is real controllers: I've opened #10 for wiring the Game Controller framework into
GameInput. You already know this part of the code better than anyone else outside the project, so it would be great if you took it on. Comment on #10 if you're picking it up.@claytonblythe on GitHub · 2026-11-26 08:50 UTC · original
Thanks for the review! I had just rebased onto
main(c96c82a) right as your comment came in —4383783is now conflict-free and keeps only the additions on top ofmain(vk_to_scan_codePS/2 Set-1 scan codes, full keyboard +FlagsChangedShift/Control/Option handling, and the realNSEvent+ COMHubtests). Will also test it against the real game once my setup finishes, and I'm claiming #10 next.@LakshanSivakumar on GitHub · 2026-11-26 08:57 UTC · original · approved these changes
Reviewed: the scan codes, full key mapping and FlagsChanged handling sit cleanly on top of main. Tests and Windows clippy pass locally on the merged result. Thanks!