Skip to content

Ensure Switch controller paradigm exists and recover Mac controllers after sleep - #87

Open
actuallyitsnathaniel wants to merge 2 commits into
ThatGuyMcd:mainfrom
actuallyitsnathaniel:controller-map-etiquette-and-mac-wake
Open

actuallyitsnathaniel wants to merge 2 commits into
ThatGuyMcd:mainfrom
actuallyitsnathaniel:controller-map-etiquette-and-mac-wake

Conversation

@actuallyitsnathaniel

Copy link
Copy Markdown
Contributor

What

  • Switch Pro / Joy-Con defaults now follow the controller face etiquette: printed A/B/X/Y match the binding tokens. SDL2 pins SDL_GAMECONTROLLER_USE_BUTTON_LABELS=1; SDL3's position-mode reports are remapped in the SDL3 input host before bindings see them. NSO N64 / GameCube pads stay on their existing label-oriented paths.

  • Also fixes dead input after closing a MacBook lid while paused: on wake we treat a frontmost app as input-capable when SDL's focus bit is stale, and force-reopen controller handles so pads come back in the same session without unplugging.

this is a non-issue. unplugging and re-plugging in a controller fixes this already.

Pattern checklist

  • First-party changes are in-place edits under runtime-recomp/, modding/ or scripts/ (no new patches/<name>/)
  • Third-party changes are *.patch files registered in patches/manifest.json (n/a)
  • Guest hooks only via guest-hooks/hooks.toml; symbols only via symbols/*.toml (n/a)
  • New settings, launcher pages and owned services are registered, and their contract docs are updated (n/a;
    docs/CONTROLLERS.md note only)
  • netplay/legacy_identity.hpp updated (reviewed by both owners) if simulation, wire or owned-service behaviour changed
    (n/a)
  • Tests added or updated; python scripts/check.py --suite guard passes locally (DKRControllerFaceEtiquette added)
  • Platforms considered: built/ran on macOS; Switch etiquette also applies wherever SDL2/SDL3 input runs. Windows / Linux
    / iOS / Android not rebuilt for this PR.

Risk

Low. Etiquette remap is limited to Switch Pro / Joy-Con families; Xbox/PS and NSO N64/GC are unchanged. Mac wake recovery only force-reopens pads and relaxes the focus gate while NSApp is active, so backgrounded windows still drop gameplay input. Capsule base_sha256 pins updated for the touched first-party files. Revert the commit to roll back.

    controller paradigm exists and recover Mac controllers after sleep
@actuallyitsnathaniel

Copy link
Copy Markdown
Contributor Author

reviewing failed checks rn

@swhitt swhitt left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Main moved to DRIFTED_BASES in check_pinned_bytes.py for evolving capsule bases, so the base_sha256 bumps here fail the pinned-bytes check once merged. Leave the manifest alone and add the touched files to DRIFTED_BASES instead. The manifest also got rewritten CRLF -> LF, which is the whole 12.7k-line diff - definitely fix that.

The body says the lid-sleep part is a non-issue since replugging fixes it. I'd drop that half and keep this to the face etiquette. The tidy-skip lintfix is also duplicated in #88, might be good as its own PR.

if ((flags & (SDL_WINDOW_MINIMIZED | SDL_WINDOW_HIDDEN)) != 0U) {
return false;
}
return dkr_macos_app_is_active();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[NSApp isActive] is true while a native file picker or other modal panel has key focus, so gameplay input leaks through while typing in it. This also runs from poll_input off the main thread.

}
// Close and reopen: after sleep GetAttached can stay true for dead HID
// handles, so a dirty-only refresh would keep the zombie pads.
for (ControllerRecord& record : g_controller_devices) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This drops and reopens every pad on each wake, even when they're fine. Do player slot assignments survive that?

const auto family = dkr::runtime::controllers::detect_controller_family(
device.name, SdlControllerTypeCode(device.gamepad));
if (dkr::runtime::controllers::uses_nintendo_face_etiquette(family)) {
dkr::runtime::controllers::apply_nintendo_face_etiquette(packet.buttons);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyone on SDL3 native with a Switch pad who already rebound buttons gets A/B and X/Y silently swapped after this. Is that intentional, or should saved bindings be migrated?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants