input(macos): DualShock 4 touchpad as View, prefer the controller used last #113

Manually merged
github merged 2 commits from github-bot/gh-113 into main 2026-11-26 17:21:09 +00:00 AGit
Owner

@⁠mimaslifetree on GitHub · 2026-11-26 16:50 UTC · original
mimaslifetree:ps4-controller → main · +243 −72 · 5 files · 2 commits · merged 2026-11-26 17:16 UTC

The Game Controller path from #10 already reads a DualShock 4, because GCDualShockGamepad is an extended gamepad. This PR fills in the PlayStation-specific parts and makes the read path testable without hardware.

Changes

  • Touchpad click is View. On a DualShock 4 or DualSense the touchpad click counts as View, alongside Share. It is read only when the profile responds to touchpadButton, so Xbox and MFi pads are unchanged.
  • Controller choice. GCController.current (the one used last) drives the pad. If it has no extended gamepad, the first connected one that has drives it.
  • Log line. Each change of controller is logged once at info level: controller: drives the pad, with vendor, category (e.g. DualShock 4) and touchpad. Testers can then confirm their pad was recognised.
  • Refactor. poll_controller is split into active_controller and snapshot_of.
  • Flaky test. keys_feed_the_keyboard_and_the_stand_in_pad now takes LIVE_TEST_LOCK on macOS. There the stand-in pad includes LIVE_PAD, which the live-controller test sets in parallel; it failed about 1 run in 4. CI runs on Windows, so it doesn't see this.
  • Docs. A README controller section with DS4 pairing steps, the ROADMAP status, and the controller path in docs/native-host.md.

Tests

  • New: window::tests::snapshot_reads_a_software_extended_gamepad reads a software gamepad made with +[GCController controllerWithExtendedGamepad] (elements set with setValue:) through the real Objective-C path.
  • New: gameinput::tests::playstation_touchpad_click_is_view.
  • cargo test --target x86_64-apple-darwin -p victory -- window:: passes 4/4.
  • cargo test -p victory-hle unit tests pass 123/123; the gameinput tests pass 10 reruns in a row.
  • cargo clippy --workspace --all-targets --target x86_64-pc-windows-gnullvm -- -D warnings is clean, and cargo xtask policy passes.

Not tested: a physical DualShock 4 in the game's menus. The mapping is verified only against the software gamepad. A tester run with a real pad is welcome.

**@⁠mimaslifetree** on GitHub · 2026-11-26 16:50 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/113) `mimaslifetree:ps4-controller` → `main` · +243 −72 · 5 files · 2 commits · merged 2026-11-26 17:16 UTC The Game Controller path from #10 already reads a DualShock 4, because `GCDualShockGamepad` is an extended gamepad. This PR fills in the PlayStation-specific parts and makes the read path testable without hardware. **Changes** - **Touchpad click is View.** On a DualShock 4 or DualSense the touchpad click counts as View, alongside Share. It is read only when the profile responds to `touchpadButton`, so Xbox and MFi pads are unchanged. - **Controller choice.** `GCController.current` (the one used last) drives the pad. If it has no extended gamepad, the first connected one that has drives it. - **Log line.** Each change of controller is logged once at info level: `controller: drives the pad`, with `vendor`, `category` (e.g. `DualShock 4`) and `touchpad`. Testers can then confirm their pad was recognised. - **Refactor.** `poll_controller` is split into `active_controller` and `snapshot_of`. - **Flaky test.** `keys_feed_the_keyboard_and_the_stand_in_pad` now takes `LIVE_TEST_LOCK` on macOS. There the stand-in pad includes `LIVE_PAD`, which the live-controller test sets in parallel; it failed about 1 run in 4. CI runs on Windows, so it doesn't see this. - **Docs.** A README controller section with DS4 pairing steps, the ROADMAP status, and the controller path in `docs/native-host.md`. **Tests** - New: `window::tests::snapshot_reads_a_software_extended_gamepad` reads a software gamepad made with `+[GCController controllerWithExtendedGamepad]` (elements set with `setValue:`) through the real Objective-C path. - New: `gameinput::tests::playstation_touchpad_click_is_view`. - `cargo test --target x86_64-apple-darwin -p victory -- window::` passes 4/4. - `cargo test -p victory-hle` unit tests pass 123/123; the `gameinput` tests pass 10 reruns in a row. - `cargo clippy --workspace --all-targets --target x86_64-pc-windows-gnullvm -- -D warnings` is clean, and `cargo xtask policy` passes. **Not tested:** a physical DualShock 4 in the game's menus. The mapping is verified only against the software gamepad. A tester run with a real pad is welcome.
The Game Controller path already reads a DualShock 4 (GCDualShockGamepad is
an extended gamepad). This rounds out PlayStation pads:

- The touchpad click of a DualShock 4 or DualSense is View, alongside Share
  (ControllerSnapshot::touchpad, read only when the profile has
  touchpadButton).
- With several controllers connected, GCController.current (the one used
  last) drives the pad, falling back to the first extended gamepad.
- Each change of controller is logged once (vendor, category such as
  "DualShock 4", touchpad), so testers can see their pad was recognised.
- poll_controller is split into active_controller and snapshot_of; a new
  window test reads a software gamepad
  (+[GCController controllerWithExtendedGamepad]) through the same path, so
  the read path is checked without hardware.
- keys_feed_the_keyboard_and_the_stand_in_pad now takes LIVE_TEST_LOCK on
  macOS: the stand-in pad carries LIVE_PAD there, which the live controller
  test sets in parallel (it failed about 1 run in 4).

Docs: README controller section with DS4 pairing, ROADMAP status, and the
controller path in docs/native-host.md.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 16:52:01 +00:00
github manually merged commit 182c14fafb into main 2026-11-26 17:21:09 +00:00
Author
Owner

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

Merged in 182c14f. The touchpad click as View and the controller selection are tested without hardware, and the LIVE_TEST_LOCK change fixes a flaky test too. Thanks!

**@⁠LakshanSivakumar** on GitHub · 2026-11-26 17:17 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/113#issuecomment-7198769921) Merged in 182c14f. The touchpad click as View and the controller selection are tested without hardware, and the LIVE_TEST_LOCK change fixes a flaky test too. Thanks!
This discussion has been locked. Commenting is limited to contributors.
No description provided.