feat(native-usb): add 32-frame HD gameplay rumble and USB flight diagnostics

Preserve native frequency/amplitude timelines for DualSense PCM output,
remove the unsupported 64-frame path, and retain compatibility rumble for
other controllers. Use the validated 300 MHz sampling phase and restrict
non-bondable Classic discovery autoconnect to previously paired peers.

Buffer native-hub UART stdout and release USB IRQs around port-reset
callbacks. Add observer liveness and pre-SETUP root-response observations
without changing recovery behavior. Cover transport and haptics boundaries.

Record the user-accepted 0.108 trial: controls remained responsive and
rumble felt fine. Instrumentation changes timing; the disconnect root
cause and long-term reliability remain unqualified.

Validation: 624 tests, 11 affected firmware/probe builds, and on-device
concurrent USB and HD-auto-start checks. Private captures, generated
images, and unrelated working-tree files are intentionally excluded.
This commit is contained in:
Joey Yakimowich-Payne 2026-09-19 17:03:46 -06:00
commit 80b788099b
46 changed files with 2873 additions and 412 deletions

View file

@ -7,11 +7,9 @@ from pathlib import Path
import pytest
@pytest.mark.parametrize("source", ("GAMEPAD", "DUALSENSE"))
@pytest.mark.parametrize("controller_count", (2, 4))
def test_native_gamepad_backend_native(
tmp_path: Path, source: str, controller_count: int
) -> None:
def compile_native_backend(
tmp_path: Path, source: str, controller_count: int, hd: bool = False
) -> tuple[Path, Path]:
root = Path(__file__).resolve().parents[1]
compiler = shutil.which("c++") or shutil.which("g++")
assert compiler is not None, "a host C++ compiler is required"
@ -28,6 +26,25 @@ def test_native_gamepad_backend_native(
firmware / "input" / "controller_macro_capture.cpp",
root / "bluepad32_config" / "parser" / "uni_switch2_haptics.c",
]
hd_flags = []
if hd:
hd_flags = [
"-DSWITCH_PICO_HAPTICS_EXPERIMENT=1",
"-DSWITCH_PICO_HD_RUMBLE=1",
"-DSWITCH_PICO_HAPTICS_EXPERIMENT_RAM=0",
"-DSWITCH_PICO_HD_PACKET_FRAMES=32",
"-DSWITCH_PICO_CYW43_PACKET_READ=1",
"-DSWITCH_PICO_HCI_CREDIT_BATCH=1",
"-DSWITCH_PICO_SYS_CLOCK_MHZ=300",
]
sources.extend(
[
firmware / "input" / "haptics_experiment.cpp",
firmware / "input" / "native_output_scheduler.cpp",
firmware / "input" / "switch_hd_rumble_synth.cpp",
firmware / "usb" / "switch" / "switch_haptics.cpp",
]
)
subprocess.run(
[
compiler,
@ -43,6 +60,7 @@ def test_native_gamepad_backend_native(
"-DSWITCH2_BRIDGE_FULL_INPUT=1",
f"-DSWITCH2_BRIDGE_{source}_INPUT=1",
f"-DPROBE_CONTROLLER_COUNT={controller_count}",
*hd_flags,
f"-I{root / 'tests' / 'bluepad32_native_stubs'}",
f"-I{firmware}",
f"-I{root / 'bluepad32_config'}",
@ -53,6 +71,15 @@ def test_native_gamepad_backend_native(
check=True,
cwd=root,
)
return root, executable
@pytest.mark.parametrize("source", ("GAMEPAD", "DUALSENSE"))
@pytest.mark.parametrize("controller_count", (2, 4))
def test_native_gamepad_backend_native(
tmp_path: Path, source: str, controller_count: int
) -> None:
root, executable = compile_native_backend(tmp_path, source, controller_count)
scenarios = [
"stable-logical-slot",
"cue-lifetime",
@ -96,3 +123,17 @@ def test_native_gamepad_backend_native(
)
for scenario in scenarios:
subprocess.run([str(executable), scenario], check=True, cwd=root)
def test_native_gamepad_hd_backend_native(tmp_path: Path) -> None:
root, executable = compile_native_backend(tmp_path, "GAMEPAD", 4, hd=True)
for scenario in (
"hd-second-pair-wii",
"hd-second-pair-other",
"hd-unselected-dualsense",
"hd-cues",
"hd-reselection",
"hd-delayed-cue",
"hd-admission-cancel",
):
subprocess.run([str(executable), scenario], check=True, cwd=root)