Real game controllers on macOS (Game Controller framework → GameInput) #10

Closed
opened 2026-11-26 14:42:23 +00:00 by github-bot · 3 comments
Owner

@⁠LakshanSivakumar on GitHub · 2026-11-26 08:47 UTC · original

Follow-up to #1. The keyboard now drives the game's stand-in pad in the window (merged in c96c82a). Physical controllers are the next piece.

Goal: an Xbox, DualSense or other MFi controller connected to the Mac drives the game's gamepad through GameInput, alongside the keyboard and the scripted VICTORY_KEYS.

Where things are

  • crates/victory-hle/src/modules/gameinput.rs: the stand-in pad, its button bits and the merge of live keys with scripted keys. Controller state should feed the same pad (buttons ORed; sticks and triggers as analog values, not just full deflection).
  • apps/victory/src/window.rs: the AppKit event loop. Game Controller framework objects (GCController, GCExtendedGamepad) can be polled from here each frame, or observed through valueChangedHandler.

Scope

  • Connect and disconnect at any time (GCControllerDidConnectNotification / DidDisconnect); use the first connected extended gamepad.
  • Map buttons to the Xbox layout: A/B/X/Y, shoulders, triggers (analog), sticks (analog, with clicks), D-pad, Menu/View.
  • Release everything on disconnect and when the window loses focus.
  • Unit-test the mapping from a controller snapshot to the pad state. The real device path needs a manual test with a controller; please say which controller you tested in the PR.

Out of scope for now: rumble, adaptive triggers, more than one player.

**@⁠LakshanSivakumar** on GitHub · 2026-11-26 08:47 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/10) Follow-up to #1. The keyboard now drives the game's stand-in pad in the window (merged in c96c82a). Physical controllers are the next piece. **Goal:** an Xbox, DualSense or other MFi controller connected to the Mac drives the game's gamepad through `GameInput`, alongside the keyboard and the scripted `VICTORY_KEYS`. **Where things are** - `crates/victory-hle/src/modules/gameinput.rs`: the stand-in pad, its button bits and the merge of live keys with scripted keys. Controller state should feed the same pad (buttons ORed; sticks and triggers as analog values, not just full deflection). - `apps/victory/src/window.rs`: the AppKit event loop. Game Controller framework objects (`GCController`, `GCExtendedGamepad`) can be polled from here each frame, or observed through `valueChangedHandler`. **Scope** - Connect and disconnect at any time (`GCControllerDidConnectNotification` / `DidDisconnect`); use the first connected extended gamepad. - Map buttons to the Xbox layout: A/B/X/Y, shoulders, triggers (analog), sticks (analog, with clicks), D-pad, Menu/View. - Release everything on disconnect and when the window loses focus. - Unit-test the mapping from a controller snapshot to the pad state. The real device path needs a manual test with a controller; please say which controller you tested in the PR. Out of scope for now: rumble, adaptive triggers, more than one player.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 14:42:23 +00:00
Author
Owner

@⁠LakshanSivakumar on GitHub · 2026-11-26 08:47 UTC · original

@⁠claytonblythe this one's yours if you want it (see the note on #9).

**@⁠LakshanSivakumar** on GitHub · 2026-11-26 08:47 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/10#issuecomment-7187023242) @⁠claytonblythe this one's yours if you want it (see the note on #9).
Author
Owner

@⁠claytonblythe on GitHub · 2026-11-26 08:50 UTC · original

Picking this up! I'll wire GameController.framework (GCController / GCExtendedGamepad) into apps/victory/src/window.rs and merge analog pad state into GameInput in crates/victory-hle/src/modules/gameinput.rs, with unit tests for snapshot mapping, connect/disconnect, and focus-loss clearing.

**@⁠claytonblythe** on GitHub · 2026-11-26 08:50 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/10#issuecomment-7187088275) Picking this up! I'll wire `GameController.framework` (`GCController` / `GCExtendedGamepad`) into `apps/victory/src/window.rs` and merge analog pad state into `GameInput` in `crates/victory-hle/src/modules/gameinput.rs`, with unit tests for snapshot mapping, connect/disconnect, and focus-loss clearing.
Author
Owner

@⁠claytonblythe on GitHub · 2026-11-26 08:54 UTC · original

Opened #11 implementing GCController / GCExtendedGamepad -> GameInput with snapshot mapping, keyboard/scripted merge, focus-loss/disconnect clearing, and unit + live GameController.framework smoke tests.

**@⁠claytonblythe** on GitHub · 2026-11-26 08:54 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/10#issuecomment-7187171218) Opened https://git.gtahub.st/github/LakshanSivakumar--Native-Victory-macOS/pulls/11 implementing `GCController` / `GCExtendedGamepad` -> `GameInput` with snapshot mapping, keyboard/scripted merge, focus-loss/disconnect clearing, and unit + live `GameController.framework` smoke tests.
This discussion has been locked. Commenting is limited to contributors.
No description provided.