input(macos): wire GameController extendedGamepad into GameInput #11

Manually merged
github merged 1 commit from gh-pr/11/head into gh-pr/11/base 2026-11-26 14:42:27 +00:00
Owner

@⁠claytonblythe on GitHub · 2026-11-26 08:55 UTC · original
claytonblythe:feat/macos-game-controller → main · +315 −5 · 2 files · 1 commits · merged 2026-11-26 09:21 UTC

What this changes

Closes #10. Wires Apple's GameController.framework (GCController / GCExtendedGamepad) into GameInput on macOS so Xbox, DualSense, and MFi controllers drive the game's gamepad alongside the keyboard and VICTORY_KEYS.

  • crates/victory-hle/src/modules/gameinput.rs:
    • Adds ControllerSnapshot, pad_from_snapshot, set_live_pad, and release_live_pad under #[cfg(not(windows))] (maps A/B/X/Y, D-pad, shoulders, L3/R3 stick clicks, Menu/View, analog triggers 0..=1, and analog sticks -1..=1, sanitizing non-finite values and clamping ranges).
    • Merges live controller state into the stand-in pad via stand_in_pad + merge_pad (buttons ORed, triggers max, sticks summed and clamped), so physical controllers work seamlessly alongside live keyboard keys and VICTORY_KEYS.
  • apps/victory/src/window.rs:
    • Links GameController.framework and polls the first connected GCController with an extendedGamepad each iteration of event_loop while isKeyWindow is true.
    • Handles null optional buttons (buttonOptions, leftThumbstickButton, rightThumbstickButton) safely.
    • Calls release_live_pad() on disconnect, window focus loss, and window exit so no button or axis sticks.

How it was tested

  • cargo test --target x86_64-apple-darwin -p victory window (2/2 passed, including poll_controller_queries_game_controller_framework_cleanly against live GameController.framework)
  • cargo test --target x86_64-apple-darwin -p victory-hle gameinput (11/11 passed, including controller_snapshot_maps_all_buttons_and_analog_axes and live_controller_merges_with_keyboard_and_clears_on_release)
  • cargo xtask policy (356 files ok)
  • cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings (0 warnings)
  • Manual test with a physical controller against the game (not yet run with a paired controller; verified live GameController.framework linking/querying on Apple M4 macOS 26.3 and end-to-end snapshot -> Hub COM reading path in unit tests)

Checklist

  • No game files, game code, disassembly listings or SDK files are included
  • Guesses about undocumented console behaviour are marked in the code and in docs/native-host.md (N/A)
  • New diagnostics are behind a VICTORY_* variable and documented (N/A)
**@⁠claytonblythe** on GitHub · 2026-11-26 08:55 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/11) `claytonblythe:feat/macos-game-controller` → `main` · +315 −5 · 2 files · 1 commits · merged 2026-11-26 09:21 UTC ## What this changes Closes #10. Wires Apple's `GameController.framework` (`GCController` / `GCExtendedGamepad`) into `GameInput` on macOS so Xbox, DualSense, and MFi controllers drive the game's gamepad alongside the keyboard and `VICTORY_KEYS`. - **`crates/victory-hle/src/modules/gameinput.rs`**: - Adds `ControllerSnapshot`, `pad_from_snapshot`, `set_live_pad`, and `release_live_pad` under `#[cfg(not(windows))]` (maps A/B/X/Y, D-pad, shoulders, L3/R3 stick clicks, Menu/View, analog triggers `0..=1`, and analog sticks `-1..=1`, sanitizing non-finite values and clamping ranges). - Merges live controller state into the stand-in pad via `stand_in_pad` + `merge_pad` (buttons ORed, triggers max, sticks summed and clamped), so physical controllers work seamlessly alongside live keyboard keys and `VICTORY_KEYS`. - **`apps/victory/src/window.rs`**: - Links `GameController.framework` and polls the first connected `GCController` with an `extendedGamepad` each iteration of `event_loop` while `isKeyWindow` is true. - Handles null optional buttons (`buttonOptions`, `leftThumbstickButton`, `rightThumbstickButton`) safely. - Calls `release_live_pad()` on disconnect, window focus loss, and window exit so no button or axis sticks. ## How it was tested - [x] `cargo test --target x86_64-apple-darwin -p victory window` (2/2 passed, including `poll_controller_queries_game_controller_framework_cleanly` against live `GameController.framework`) - [x] `cargo test --target x86_64-apple-darwin -p victory-hle gameinput` (11/11 passed, including `controller_snapshot_maps_all_buttons_and_analog_axes` and `live_controller_merges_with_keyboard_and_clears_on_release`) - [x] `cargo xtask policy` (356 files ok) - [x] `cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings` (0 warnings) - [ ] Manual test with a physical controller against the game (not yet run with a paired controller; verified live `GameController.framework` linking/querying on Apple M4 macOS 26.3 and end-to-end snapshot -> `Hub` COM reading path in unit tests) ## Checklist - [x] No game files, game code, disassembly listings or SDK files are included - [x] Guesses about undocumented console behaviour are marked in the code and in docs/native-host.md (N/A) - [x] New diagnostics are behind a `VICTORY_*` variable and documented (N/A)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 14:42:25 +00:00
github manually merged commit 44339bfda2 into gh-pr/11/base 2026-11-26 14:42:27 +00:00
Author
Owner

@⁠LakshanSivakumar on GitHub · 2026-11-26 09:21 UTC · original · approved these changes

Reviewed and tested merged with main on macOS (tests, Windows clippy, policy). Thanks!

**@⁠LakshanSivakumar** on GitHub · 2026-11-26 09:21 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/11#pullrequestreview-6071444819) · **approved these changes** Reviewed and tested merged with main on macOS (tests, Windows clippy, policy). Thanks!
This discussion has been locked. Commenting is limited to contributors.
No description provided.